Skip to content
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
5 changes: 5 additions & 0 deletions driver-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public interface DriverConfigReporter {
*
* <p><b>Implementations must not throw:</b> a failure to build the report must be swallowed (and
* logged) rather than propagated, so that a diagnostic aid can never break cluster
* initialization.
* initialization. For the same reason they must return {@code null} rather than a report that
* exceeds {@code DefaultDriverConfigReporter.MAX_DRIVER_CONFIG_LENGTH}: {@code STARTUP} option
* values carry an unchecked 16-bit length prefix, so an oversized one corrupts the frame instead
* of merely being useless.
*
* @return the report to send under the {@code DRIVER_CONFIG} startup option, or {@code null} to
* send nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static Builder builder() {

private final int usedHostsPerRemoteDc;
private final boolean dontHopForLocalCL;
private final boolean localDcExplicit;

private volatile Configuration configuration;

Expand All @@ -90,6 +91,40 @@ private DCAwareRoundRobinPolicy(
this.localDc = localDc == null ? UNSET : localDc;
this.usedHostsPerRemoteDc = usedHostsPerRemoteDc;
this.dontHopForLocalCL = !allowRemoteDCsForLocalConsistencyLevel;
this.localDcExplicit = !Strings.isNullOrEmpty(localDc);
}

/**
* The datacenter this policy considers local, or {@code null} if it has neither been configured
* explicitly nor inferred yet. When {@link #isLocalDcExplicit()} is {@code false}, this is the
* datacenter inferred from the first contacted node, which is only available once the policy has
* been initialized.
*
* @return the local datacenter name, or {@code null}.
*/
public String getLocalDc() {
String dc = localDc;
return Strings.isNullOrEmpty(dc) ? null : dc;
}

/**
* Whether the local datacenter was configured explicitly (as opposed to being inferred from the
* first contacted node).
*
* @return {@code true} if the local datacenter was set explicitly.
*/
public boolean isLocalDcExplicit() {
return localDcExplicit;
}

/**
* The number of hosts per remote datacenter that this policy considers for failover (0 means no
* remote failover).
*
* @return the number of used hosts per remote datacenter.
*/
public int getUsedHostsPerRemoteDc() {
return usedHostsPerRemoteDc;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;

public class PagingOptimizingLoadBalancingPolicy implements LoadBalancingPolicy {
public class PagingOptimizingLoadBalancingPolicy implements ChainableLoadBalancingPolicy {
private final LoadBalancingPolicy wrapped;
private volatile CopyOnWriteArrayList<Host> hosts;

public PagingOptimizingLoadBalancingPolicy(LoadBalancingPolicy loadBalancingPolicy) {
wrapped = loadBalancingPolicy;
}

@Override
public LoadBalancingPolicy getChildPolicy() {
return wrapped;
}

@Override
public void init(Cluster cluster, Collection<Host> hosts) {
this.hosts = new CopyOnWriteArrayList<Host>(hosts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public static Builder builder() {

private final int usedHostsPerRemoteDc;
private final boolean dontHopForLocalCL;
private final boolean localDcExplicit;
private final boolean localRackExplicit;

private volatile Configuration configuration;

Expand All @@ -109,6 +111,62 @@ public RackAwareRoundRobinPolicy(
this.localRack = localRack == null ? UNSET : localRack;
this.usedHostsPerRemoteDc = usedHostsPerRemoteDc;
this.dontHopForLocalCL = !allowRemoteDCsForLocalConsistencyLevel;
this.localDcExplicit = !Strings.isNullOrEmpty(localDc);
this.localRackExplicit = !Strings.isNullOrEmpty(localRack);
}

/**
* The datacenter this policy considers local, or {@code null} if it has neither been configured
* explicitly nor inferred yet. When {@link #isLocalDcExplicit()} is {@code false}, this is the
* datacenter inferred from the first contacted node, which is only available once the policy has
* been initialized.
*
* @return the local datacenter name, or {@code null}.
*/
public String getLocalDc() {
String dc = localDc;
return Strings.isNullOrEmpty(dc) ? null : dc;
}

/**
* The rack this policy considers local, or {@code null} if it has neither been configured
* explicitly nor inferred yet.
*
* @return the local rack name, or {@code null}.
*/
public String getLocalRack() {
String rack = localRack;
return Strings.isNullOrEmpty(rack) ? null : rack;
}

/**
* Whether the local datacenter was configured explicitly (as opposed to being inferred from the
* first contacted node).
*
* @return {@code true} if the local datacenter was set explicitly.
*/
public boolean isLocalDcExplicit() {
return localDcExplicit;
}

/**
* Whether the local rack was configured explicitly (as opposed to being inferred from the first
* contacted node).
*
* @return {@code true} if the local rack was set explicitly.
*/
public boolean isLocalRackExplicit() {
return localRackExplicit;
}

/**
* The number of hosts per remote datacenter that this policy considers for failover (0 means no
* remote failover).
*
* @return the number of used hosts per remote datacenter.
*/
public int getUsedHostsPerRemoteDc() {
return usedHostsPerRemoteDc;
}

@Override
Expand Down
Loading
Loading