java.lang.IllegalArgumentException: Null or empty data center specified for DC-aware policy

DataStax JIRA | Andy Tolbert | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    From the changes in [JAVA-451], it is now no longer possible from the outside to specify a 'null' localDC when creating a DCAwareRoundRobinPolicy and have it figured out the localDC based on contact points, however the [documentation states|http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/policies/DCAwareRoundRobinPolicy.html#DCAwareRoundRobinPolicy(java.lang.String)] that this functionality still works: {quote} localDc - the name of the local datacenter (as known by Cassandra). If this is null, the policy will default to the data-center of the first node connected to. {quote} Passing in a null localDC parameter emits the following error: {noformat} Exception in thread "main" java.lang.IllegalArgumentException: Null or empty data center specified for DC-aware policy at com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.<init>(DCAwareRoundRobinPolicy.java:176) at com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.<init>(DCAwareRoundRobinPolicy.java:138) {noformat} with the following code: {code} Cluster cluster = new Cluster.Builder() .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(null, 2)) .addContactPoint("127.0.0.1") .build(); {code} Additionally, A user could use the default Constructor for DCAwareRoundRobinPolicy to use the DC the contact points are in, but if they want to control the usedRemoteHostsPerDc / allowRemoteDCsForLocalConsistencyLevel options, they cannot. It seems like we should be able to support this, ([JAVA-652] will take care of this).

    DataStax JIRA | 2 years ago | Andy Tolbert
    java.lang.IllegalArgumentException: Null or empty data center specified for DC-aware policy
  2. 0

    From the changes in [JAVA-451], it is now no longer possible from the outside to specify a 'null' localDC when creating a DCAwareRoundRobinPolicy and have it figured out the localDC based on contact points, however the [documentation states|http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/policies/DCAwareRoundRobinPolicy.html#DCAwareRoundRobinPolicy(java.lang.String)] that this functionality still works: {quote} localDc - the name of the local datacenter (as known by Cassandra). If this is null, the policy will default to the data-center of the first node connected to. {quote} Passing in a null localDC parameter emits the following error: {noformat} Exception in thread "main" java.lang.IllegalArgumentException: Null or empty data center specified for DC-aware policy at com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.<init>(DCAwareRoundRobinPolicy.java:176) at com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.<init>(DCAwareRoundRobinPolicy.java:138) {noformat} with the following code: {code} Cluster cluster = new Cluster.Builder() .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(null, 2)) .addContactPoint("127.0.0.1") .build(); {code} Additionally, A user could use the default Constructor for DCAwareRoundRobinPolicy to use the DC the contact points are in, but if they want to control the usedRemoteHostsPerDc / allowRemoteDCsForLocalConsistencyLevel options, they cannot. It seems like we should be able to support this, ([JAVA-652] will take care of this).

    DataStax JIRA | 2 years ago | Andy Tolbert
    java.lang.IllegalArgumentException: Null or empty data center specified for DC-aware policy

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Null or empty data center specified for DC-aware policy

      at com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.<init>()
    2. DataStax Java Driver for Apache Cassandra - Core
      DCAwareRoundRobinPolicy.<init>
      1. com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.<init>(DCAwareRoundRobinPolicy.java:176)
      2. com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.<init>(DCAwareRoundRobinPolicy.java:138)
      2 frames