private void printHosts(Iterator<Host> hostIterator) { StringBuilder sb = new StringBuilder(); while (hostIterator.hasNext()) { sb.append(hostIterator.next().toString()).append(" "); } System.out.println(sb.toString()); }
localDc = dc; } else if (!dc.equals(localDc)) notInLocalDC.add(String.format("%s (%s)", host.toString(), dc));
void startPeriodicReconnectionAttempt(final Host host, final boolean isHostAddition) { new AbstractReconnectionHandler( host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(),
host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(),
private String stringify(ConcurrentMap<String, Host> hosts) { StringBuilder sb = new StringBuilder(); String delimiter = ""; for (String key : hosts.keySet()) { Host host = hosts.get(key); if (host != null) { sb.append(delimiter) .append(host.toString()) .append(" (dc=") .append(host.getDatacenter()) .append(" up=") .append(host.isUp()) .append(")"); delimiter = "\n"; } } return sb.toString(); }
private String stringify(ConcurrentMap<String, Host> hosts) { StringBuilder sb = new StringBuilder(); String delimiter = ""; for (String key : hosts.keySet()) { Host host = hosts.get(key); if (host != null) { sb.append(delimiter) .append(host.toString()) .append(" (dc=") .append(host.getDatacenter()) .append(" up=") .append(host.isUp()) .append(")"); delimiter = "\n"; } } return sb.toString(); }
private String stringify(ConcurrentMap<String, Host> hosts) { StringBuilder sb = new StringBuilder(); String delimiter = ""; for (String key : hosts.keySet()) { Host host = hosts.get(key); if (host != null) { sb.append(delimiter) .append(host.toString()) .append(" (dc=") .append(host.getDatacenter()) .append(" up=") .append(host.isUp()) .append(")"); delimiter = "\n"; } } return sb.toString(); }
@Override public void init(Cluster cluster, Collection<Host> hosts) { if (localDc != UNSET) logger.info("Using provided data-center name '{}' for DCAwareRoundRobinPolicy", localDc); this.configuration = cluster.getConfiguration(); ArrayList<String> notInLocalDC = new ArrayList<String>(); for (Host host : hosts) { String dc = dc(host); // If the localDC was in "auto-discover" mode and it's the first host for which we have a DC, use it. if (localDc == UNSET && dc != UNSET) { logger.info("Using data-center name '{}' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)", dc); localDc = dc; } else if (!dc.equals(localDc)) notInLocalDC.add(String.format("%s (%s)", host.toString(), dc)); CopyOnWriteArrayList<Host> prev = perDcLiveHosts.get(dc); if (prev == null) perDcLiveHosts.put(dc, new CopyOnWriteArrayList<Host>(Collections.singletonList(host))); else prev.addIfAbsent(host); } if (notInLocalDC.size() > 0) { String nonLocalHosts = Joiner.on(",").join(notInLocalDC); logger.warn("Some contact points don't match local data center. Local DC = {}. Non-conforming contact points: {}", localDc, nonLocalHosts); } this.index.set(new Random().nextInt(Math.max(hosts.size(), 1))); }
@Override public void init(Cluster cluster, Collection<Host> hosts) { if (localDc != UNSET) logger.info("Using provided data-center name '{}' for DCAwareRoundRobinPolicy", localDc); this.configuration = cluster.getConfiguration(); ArrayList<String> notInLocalDC = new ArrayList<String>(); for (Host host : hosts) { String dc = dc(host); // If the localDC was in "auto-discover" mode and it's the first host for which we have a DC, use it. if (localDc == UNSET && dc != UNSET) { logger.info("Using data-center name '{}' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)", dc); localDc = dc; } else if (!dc.equals(localDc)) notInLocalDC.add(String.format("%s (%s)", host.toString(), dc)); CopyOnWriteArrayList<Host> prev = perDcLiveHosts.get(dc); if (prev == null) perDcLiveHosts.put(dc, new CopyOnWriteArrayList<Host>(Collections.singletonList(host))); else prev.addIfAbsent(host); } if (notInLocalDC.size() > 0) { String nonLocalHosts = Joiner.on(",").join(notInLocalDC); logger.warn("Some contact points don't match local data center. Local DC = {}. Non-conforming contact points: {}", localDc, nonLocalHosts); } this.index.set(new Random().nextInt(Math.max(hosts.size(), 1))); }
@Override public void init(Cluster cluster, Collection<Host> hosts) { if (localDc != UNSET) logger.info("Using provided data-center name '{}' for DCAwareRoundRobinPolicy", localDc); this.configuration = cluster.getConfiguration(); ArrayList<String> notInLocalDC = new ArrayList<String>(); for (Host host : hosts) { String dc = dc(host); // If the localDC was in "auto-discover" mode and it's the first host for which we have a DC, use it. if (localDc == UNSET && dc != UNSET) { logger.info("Using data-center name '{}' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)", dc); localDc = dc; } else if (!dc.equals(localDc)) notInLocalDC.add(String.format("%s (%s)", host.toString(), dc)); CopyOnWriteArrayList<Host> prev = perDcLiveHosts.get(dc); if (prev == null) perDcLiveHosts.put(dc, new CopyOnWriteArrayList<Host>(Collections.singletonList(host))); else prev.addIfAbsent(host); } if (notInLocalDC.size() > 0) { String nonLocalHosts = Joiner.on(",").join(notInLocalDC); logger.warn("Some contact points don't match local data center. Local DC = {}. Non-conforming contact points: {}", localDc, nonLocalHosts); } this.index.set(new Random().nextInt(Math.max(hosts.size(), 1))); }
notInLocalDC.add(String.format("%s (%s)", host.toString(), dc));
private ResultSet createPositiveResultSet(String hostName) { ExecutionInfo executionInfo = mock(ExecutionInfo.class); Host host = mock(Host.class); when(host.toString()).thenReturn(hostName); when(executionInfo.getQueriedHost()).thenReturn(host); ResultSet resultSet = mock(ResultSet.class); when(resultSet.getExecutionInfo()).thenReturn(executionInfo); return resultSet; } }
void startPeriodicReconnectionAttempt(final Host host, final boolean isHostAddition) { new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt) {
void startPeriodicReconnectionAttempt(final Host host, final boolean isHostAddition) { new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt) {
void startPeriodicReconnectionAttempt(final Host host, final boolean isHostAddition) { new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt) {
new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt, 0) {
new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt, 0) {
new AbstractReconnectionHandler(host.toString(), reconnectionExecutor, reconnectionPolicy().newSchedule(), host.reconnectionAttempt, 0) {