Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I use for localDataCenter in Cassandra-Driver 4.x

When I was using cassandra-driver version 3.x everything worked fine. Now that I have upgraded I get the following message...

Error: ArgumentError: 'localDataCenter' is not defined in Client options and also was not specified in constructor. At least one is required.

My client declaration looks like this...

const client = new Client({
        contactPoints: this.servers,
        keyspace: "keyspace",
        authProvider,
        sslOptions,
        pooling: {
            coreConnectionsPerHost: {
                [distance.local]: 1,
                [distance.remote]: 1
            }
        },
        // TODO: Needed because in spite of the documentation provided by DataStax the default value is not 0
        socketOptions: {
            readTimeout: 0
        }
});

What should I use for the localDataCenter property?

like image 604
JGleason Avatar asked Mar 03 '23 01:03

JGleason


2 Answers

To find your datacenter name, check in your node's cassandra-rackdc.properties file:

$ cat cassandra-rackdc.properties
dc=HoldYourFire
rack=force10

Or, run a nodetool status:

$ bin/nodetool status
Datacenter: HoldYourFire
========================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns    Host ID                               Rack
UN  172.0.0.1  575.64 KiB  16           ?       5c5cfc93-2e61-472e-b69b-a4fc40f94876  force10
UN  172.0.0.2  575.64 KiB  16           ?       4f040fef-5a6c-4be1-ba13-c9edbeaff6e1  force10
UN  172.0.0.3  575.64 KiB  16           ?       96626294-0ea1-4775-a08e-45661dc84cfa  force10

If you have multiple data centers, you should pick the same one that your application is deployed in.

like image 192
Aaron Avatar answered Mar 05 '23 14:03

Aaron


Since v4.0 localDataCenter is now a required Client option When using DCAwareRoundRobinPolicy, which is used by default, a local data center must now be provided to the Client options parameter as localDataCenter. This is necessary to prevent routing requests to nodes in remote data centers.

Refer upgrade guide here.

like image 30
GAK Avatar answered Mar 05 '23 15:03

GAK