Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple clusters capability. The api interface has changed because all apis now need an atom identifying the connection. #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Changelog:

##### v3.2.4

- Fix a critical memory issue discovered by running the VM in debug mode.

##### v3.2.3

- Add Trevis CI (Thanks to Gonçalo Tomás)
Expand Down
30 changes: 16 additions & 14 deletions benchmarks/benchmark.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@
]},

{erlcass, [
{keyspace, <<"load_test_erlcass">>},
{cluster_options,[
{contact_points, <<"172.17.3.129">>},
{latency_aware_routing, true},
{token_aware_routing, true},
{number_threads_io, 8},
{queue_size_io, 128000},
{core_connections_host, 5},
{max_connections_host, 5},
{tcp_nodelay, true},
{tcp_keepalive, {true, 60}},
{connect_timeout, 5000},
{request_timeout, 20000},
{retry_policy, {default, true}}
{clusters, [
{erlcass_conn, [
{keyspace, <<"load_test_erlcass">>},
{contact_points, <<"127.0.0.1">>},
{latency_aware_routing, true},
{token_aware_routing, true},
{number_threads_io, 8},
{queue_size_io, 128000},
{core_connections_host, 5},
{max_connections_host, 5},
{tcp_nodelay, true},
{tcp_keepalive, {true, 60}},
{connect_timeout, 5000},
{request_timeout, 20000},
{retry_policy, {default, true}}
]}
]}
]}
].
14 changes: 5 additions & 9 deletions c_src/erlcass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ atoms ATOMS;
void open_resources(ErlNifEnv* env, cassandra_data* data)
{
ErlNifResourceFlags flags = static_cast<ErlNifResourceFlags>(ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER);

data->resCassCluster = enif_open_resource_type(env, NULL, "enif_cass_cluster", nif_cass_cluster_free, flags, NULL);
data->resCassSession = enif_open_resource_type(env, NULL, "enif_cass_session", nif_cass_session_free, flags, NULL);
data->resCassPrepared = enif_open_resource_type(env, NULL, "enif_cass_prepared", nif_cass_prepared_free, flags, NULL);
data->resCassStatement = enif_open_resource_type(env, NULL, "enif_cass_statement", nif_cass_statement_free, flags, NULL);
Expand Down Expand Up @@ -120,7 +122,6 @@ int on_nif_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
ATOMS.atomClusterSettingRetryPolicyFallthrough = make_atom(env, erlcass::kAtomClusterSettingRetryPolicyFallthrough);

cassandra_data* data = static_cast<cassandra_data*>(enif_alloc(sizeof(cassandra_data)));
data->cluster = NULL;
data->uuid_gen = cass_uuid_gen_new();
data->defaultConsistencyLevel = CASS_CONSISTENCY_LOCAL_QUORUM;

Expand All @@ -134,9 +135,6 @@ void on_nif_unload(ErlNifEnv* env, void* priv_data)
{
cassandra_data* data = static_cast<cassandra_data*>(priv_data);

if(data->cluster)
cass_cluster_free(data->cluster);

if(data->uuid_gen)
cass_uuid_gen_free(data->uuid_gen);

Expand All @@ -148,12 +146,10 @@ int on_nif_upgrade(ErlNifEnv* env, void** priv, void** old_priv, ERL_NIF_TERM in
cassandra_data* old_data = static_cast<cassandra_data*>(*old_priv);

cassandra_data* data = static_cast<cassandra_data*>(enif_alloc(sizeof(cassandra_data)));
data->cluster = old_data->cluster;
data->uuid_gen = old_data->uuid_gen;
data->defaultConsistencyLevel = old_data->defaultConsistencyLevel;
open_resources(env, data);

old_data->cluster = NULL;
old_data->uuid_gen = NULL;
*priv = data;

Expand All @@ -165,16 +161,16 @@ static ErlNifFunc nif_funcs[] =
//CassCluster

{"cass_cluster_create", 0, nif_cass_cluster_create},
{"cass_cluster_release", 0, nif_cass_cluster_release},
{"cass_cluster_release", 1, nif_cass_cluster_release},
{"cass_log_set_callback", 1, nif_cass_log_set_callback},
{"cass_log_set_level", 1, nif_cass_log_set_level},
{"cass_cluster_set_options", 1, nif_cass_cluster_set_options},
{"cass_cluster_set_options", 2, nif_cass_cluster_set_options},

//CassSession

{"cass_session_new", 0, nif_cass_session_new},
{"cass_session_connect", 2, nif_cass_session_connect},
{"cass_session_connect", 3, nif_cass_session_connect},
{"cass_session_connect", 4, nif_cass_session_connect},
{"cass_session_close", 2, nif_cass_session_close},
{"cass_session_prepare", 4, nif_cass_session_prepare},

Expand Down
2 changes: 1 addition & 1 deletion c_src/erlcass.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ struct atoms

struct cassandra_data
{
CassCluster* cluster;
CassUuidGen* uuid_gen;
ErlNifPid log_pid;

CassConsistency defaultConsistencyLevel;
ErlNifResourceType* resCassCluster;
ErlNifResourceType* resCassSession;
ErlNifResourceType* resCassPrepared;
ErlNifResourceType* resCassStatement;
Expand Down
Loading