@Test public void testDistance() throws UnknownHostException{ int i=0; for(Host host:hosts){ policy.onUp(host); if(i<=2){ assertEquals(policy.distance(host),HostDistance.LOCAL); }else{ assertTrue(policy.distance(host).equals(HostDistance.REMOTE) || policy.distance(host).equals(HostDistance.IGNORED)); } i++; } }
public HostDistance distance(Host host) { String dc = dc(host); if(!switchBackCanNeverHappen){ triggerBackSwitchIfNecessary(); } if (isLocal(dc)) { return HostDistance.LOCAL; } if(dc(host).equals(localDc) || dc(host).equals(backupDc)) return HostDistance.REMOTE; return HostDistance.IGNORED; }
DCAwareFailoverRoundRobinPolicy implements LoadBalancingPolicy,
		CloseableLoadBalancingPolicy { public HostDistance distance(Host host) { String dc = dc(host); if(!switchBackCanNeverHappen){ triggerBackSwitchIfNecessary(); } if (isLocal(dc)) { return HostDistance.LOCAL; } if(dc(host).equals(localDc) || dc(host).equals(backupDc)) return HostDistance.REMOTE; return HostDistance.IGNORED; } }
DCAwareFailoverRoundRobinPolicy implements LoadBalancingPolicy,
		CloseableLoadBalancingPolicy { public HostDistance distance(Host host) { String dc = dc(host); if(!switchBackCanNeverHappen){ triggerBackSwitchIfNecessary(); } if (isLocal(dc)) { return HostDistance.LOCAL; } if(dc(host).equals(localDc) || dc(host).equals(backupDc)) return HostDistance.REMOTE; return HostDistance.IGNORED; } DCAwareFailoverRoundRobinPolicy(String localDc, String backupDc,
			int hostDownSwitchThreshold);  DCAwareFailoverRoundRobinPolicy(String localDc, String backupDc,
			int hostDownSwitchThreshold, float switchBackDelayFactor,
			int noSwitchBackDowntimeDelay); }
DCAwareFailoverRoundRobinPolicy implements LoadBalancingPolicy,
		CloseableLoadBalancingPolicy { public HostDistance distance(Host host) { String dc = dc(host); if(!switchBackCanNeverHappen){ triggerBackSwitchIfNecessary(); } if (isLocal(dc)) { return HostDistance.LOCAL; } if(dc(host).equals(localDc) || dc(host).equals(backupDc)) return HostDistance.REMOTE; return HostDistance.IGNORED; } DCAwareFailoverRoundRobinPolicy(String localDc, String backupDc,
			int hostDownSwitchThreshold);  DCAwareFailoverRoundRobinPolicy(String localDc, String backupDc,
			int hostDownSwitchThreshold, float switchBackDelayFactor,
			int noSwitchBackDowntimeDelay); static Builder builder(); void init(Cluster cluster, Collection<Host> hosts); HostDistance distance(Host host); Iterator<Host> newQueryPlan(String loggedKeyspace,
			final Statement statement); void onUp(Host host); void onSuspected(Host host); void onDown(Host host); void onAdd(Host host); void onRemove(Host host); void close(); void triggerBackSwitchIfNecessary(); }
DCAwareFailoverRoundRobinPolicy implements LoadBalancingPolicy,
		CloseableLoadBalancingPolicy { public HostDistance distance(Host host) { String dc = dc(host); if(!switchBackCanNeverHappen){ triggerBackSwitchIfNecessary(); } if (isLocal(dc)) { return HostDistance.LOCAL; } if(dc(host).equals(localDc) || dc(host).equals(backupDc)) return HostDistance.REMOTE; return HostDistance.IGNORED; } DCAwareFailoverRoundRobinPolicy(String localDc, String backupDc,
			int hostDownSwitchThreshold);  DCAwareFailoverRoundRobinPolicy(String localDc, String backupDc,
			int hostDownSwitchThreshold, float switchBackDelayFactor,
			int noSwitchBackDowntimeDelay); static Builder builder(); void init(Cluster cluster, Collection<Host> hosts); HostDistance distance(Host host); Iterator<Host> newQueryPlan(String loggedKeyspace,
			final Statement statement); void onUp(Host host); void onSuspected(Host host); void onDown(Host host); void onAdd(Host host); void onRemove(Host host); void close(); void triggerBackSwitchIfNecessary();  }