question

amit82ocp_172818 avatar image
amit82ocp_172818 asked Erick Ramirez edited

How can I restrict an app user to only connect to specific nodes in a cluster?

I have 15 nodes cluster divided in three data centers (having 5 nodes each), lets say if i would like to decommission one site (remove all 5 nodes from that site) in that case how can i restrict application user to not to connect those nodes which i am going to decommission.

Note:- I am changing replication factor for all keyspaces which would be having only two site information however unable to understand how to restrict user to connect only two surviving sites.

It would be a great help if i can find any document which explain this connection settings for application users.

Regards,

Amit

cassandradriver
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered Erick Ramirez edited

@amit82ocp_172818 In your application, you would typically configure the driver with the contact points (seed nodes, if you like) and explicitly specify the local datacenter. This will cause the driver to compute a query plan which only contains nodes from the local datacenter.

To illustrate with an example, here is how contact points from the datacenter DC1 are configured in the Java driver v4.6:

CqlSession session = CqlSession.builder()
    .addContactPoint(new InetSocketAddress("10.1.2.3", 9042))
    .addContactPoint(new InetSocketAddress("10.1.2.4", 9042))
    .withLocalDatacenter("DC1")
    .build();

In this example, we are telling the driver that nodes 10.1.2.3 and 10.1.2.4 belong to the DC1 datacenter. When the driver computes a query plan, it will only ever include nodes in DC1 in the list of nodes to connect to.

Alternatively, you can also provide the contacts points to the driver in a configuration file like this:

datastax-java-driver {
  basic {
    contact-points = [ "10.1.2.3:9042", "10.1.2.4:9042" ]
    load-balancing-policy.local-datacenter = DC1
  }
}

For more information, see the Core driver and Load balancing pages of the Java Driver. For information about other drivers, see the Driver matrix page. Cheers!

1 comment Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

amit82ocp_172818 avatar image amit82ocp_172818 commented ·

Thanks for detailed information.

Amit

0 Likes 0 ·