negotiateProtocolVersionAndConnect(); loadBalancingPolicy().init(Cluster.this, contactPointHosts); speculativeExecutionPolicy().init(Cluster.this); configuration.getPolicies().getRetryPolicy().init(Cluster.this); reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers) tracker.onRegister(Cluster.this); for (Host.StateListener listener : listeners) listener.onRegister(Cluster.this); for (Host host : removedContactPointHosts) { loadBalancingPolicy().onRemove(host); for (Host.StateListener listener : listeners) listener.onRemove(host); loadBalancingPolicy().onDown(host); for (Host.StateListener listener : listeners) listener.onDown(host); startPeriodicReconnectionAttempt(host, true); configuration.getPoolingOptions().setProtocolVersion(protocolVersion()); logUnsupportedVersionProtocol(host, connectionFactory.protocolVersion); continue; if (!contactPointHosts.contains(host)) loadBalancingPolicy().onAdd(host); } catch (RuntimeException e) { initException = e; close(); throw e;
case TOPOLOGY_CHANGE: ProtocolEvent.TopologyChange tpc = (ProtocolEvent.TopologyChange) event; InetSocketAddress tpAddr = translateAddress(tpc.node.getAddress()); Host.statesLogger.debug("[{}] received event {}", tpAddr, tpc.change); switch (tpc.change) { case NEW_NODE: submitNodeRefresh(tpAddr, HostEvent.ADDED); break; case REMOVED_NODE: submitNodeRefresh(tpAddr, HostEvent.REMOVED); break; case MOVED_NODE: submitNodeListRefresh(); break; case STATUS_CHANGE: ProtocolEvent.StatusChange stc = (ProtocolEvent.StatusChange) event; InetSocketAddress stAddr = translateAddress(stc.node.getAddress()); Host.statesLogger.debug("[{}] received event {}", stAddr, stc.status); switch (stc.status) { case UP: submitNodeRefresh(stAddr, HostEvent.UP); break; case DOWN: submitNodeRefresh(stAddr, HostEvent.DOWN); break; case CREATED: case UPDATED:
@Override public void onFailure(Throwable t) { if (t instanceof UnsupportedProtocolVersionException) { cluster.manager.logUnsupportedVersionProtocol( host, ((UnsupportedProtocolVersionException) t).getUnsupportedVersion()); cluster.manager.triggerOnDown(host, false); } else if (t instanceof ClusterNameMismatchException) { ClusterNameMismatchException e = (ClusterNameMismatchException) t; cluster.manager.logClusterNameMismatch( host, e.expectedClusterName, e.actualClusterName); cluster.manager.triggerOnDown(host, false); } else { logger.warn("Error creating pool to " + host, t); // do not mark the host down, as there could be other connections to it // (e.g. the control connection, or another session pool). // The conviction policy will mark it down if it has no more active connections. } // propagate errors; for all other exceptions, consider the pool init failed // but allow the session init process to continue normally if (t instanceof Error) future.setException(t); else future.set(false); } });
loadBalancingPolicy().init(Cluster.this, contactPointHosts); speculativeExecutionPolicy().init(Cluster.this); configuration.getPolicies().getRetryPolicy().init(Cluster.this); reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers) listener.onRegister(Cluster.this); for (Host host : removedContactPointHosts) { loadBalancingPolicy().onRemove(host); for (Host.StateListener listener : listeners) listener.onRemove(host); loadBalancingPolicy().onDown(host); for (Host.StateListener listener : listeners) listener.onDown(host); startPeriodicReconnectionAttempt(host, true); configuration.getPoolingOptions().setProtocolVersion(protocolVersion()); logUnsupportedVersionProtocol(host, connectionFactory.protocolVersion); continue; loadBalancingPolicy().onAdd(host); close(); throw e;
loadBalancingPolicy().init(Cluster.this, contactPointHosts); speculativeExecutionPolicy().init(Cluster.this); configuration.getPolicies().getRetryPolicy().init(Cluster.this); reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers) listener.onRegister(Cluster.this); for (Host host : removedContactPointHosts) { loadBalancingPolicy().onRemove(host); for (Host.StateListener listener : listeners) listener.onRemove(host); loadBalancingPolicy().onDown(host); for (Host.StateListener listener : listeners) listener.onDown(host); startPeriodicReconnectionAttempt(host, true); configuration.getPoolingOptions().setProtocolVersion(protocolVersion()); logUnsupportedVersionProtocol(host, connectionFactory.protocolVersion); continue; loadBalancingPolicy().onAdd(host); close(); throw e;
case TOPOLOGY_CHANGE: ProtocolEvent.TopologyChange tpc = (ProtocolEvent.TopologyChange) event; InetSocketAddress tpAddr = translateAddress(tpc.node.getAddress()); Host.statesLogger.debug("[{}] received event {}", tpAddr, tpc.change); switch (tpc.change) { case NEW_NODE: submitNodeRefresh(tpAddr, HostEvent.ADDED); break; case REMOVED_NODE: submitNodeRefresh(tpAddr, HostEvent.REMOVED); break; case MOVED_NODE: submitNodeListRefresh(); break; case STATUS_CHANGE: ProtocolEvent.StatusChange stc = (ProtocolEvent.StatusChange) event; InetSocketAddress stAddr = translateAddress(stc.node.getAddress()); Host.statesLogger.debug("[{}] received event {}", stAddr, stc.status); switch (stc.status) { case UP: submitNodeRefresh(stAddr, HostEvent.UP); break; case DOWN: submitNodeRefresh(stAddr, HostEvent.DOWN); break; case CREATED: case UPDATED:
negotiateProtocolVersionAndConnect(); loadBalancingPolicy().init(Cluster.this, contactPointHosts); speculativeExecutionPolicy().init(Cluster.this); configuration.getPolicies().getRetryPolicy().init(Cluster.this); reconnectionPolicy().init(Cluster.this); configuration.getPolicies().getAddressTranslator().init(Cluster.this); for (LatencyTracker tracker : latencyTrackers) listener.onRegister(Cluster.this); for (Host host : removedContactPointHosts) { loadBalancingPolicy().onRemove(host); for (Host.StateListener listener : listeners) listener.onRemove(host); loadBalancingPolicy().onDown(host); for (Host.StateListener listener : listeners) listener.onDown(host); startPeriodicReconnectionAttempt(host, true); configuration.getPoolingOptions().setProtocolVersion(protocolVersion()); logUnsupportedVersionProtocol(host, connectionFactory.protocolVersion); continue; loadBalancingPolicy().onAdd(host); close();
case TOPOLOGY_CHANGE: ProtocolEvent.TopologyChange tpc = (ProtocolEvent.TopologyChange)event; InetSocketAddress tpAddr = translateAddress(tpc.node.getAddress()); switch (tpc.change) { case NEW_NODE: removeHost(metadata.getHost(tpAddr)); break; case MOVED_NODE: case STATUS_CHANGE: ProtocolEvent.StatusChange stc = (ProtocolEvent.StatusChange)event; InetSocketAddress stAddr = translateAddress(stc.node.getAddress()); switch (stc.status) { case UP: triggerOnDown(hostDown); break; case CREATED: if (scc.table.isEmpty()) submitSchemaRefresh(null, null); else submitSchemaRefresh(scc.keyspace, null); break; case DROPPED: if (scc.table.isEmpty()) submitSchemaRefresh(null, null); else
case TOPOLOGY_CHANGE: ProtocolEvent.TopologyChange tpc = (ProtocolEvent.TopologyChange) event; InetSocketAddress tpAddr = translateAddress(tpc.node.getAddress()); Host.statesLogger.debug("[{}] received event {}", tpAddr, tpc.change); switch (tpc.change) { case NEW_NODE: submitNodeRefresh(tpAddr, HostEvent.ADDED); break; case REMOVED_NODE: submitNodeRefresh(tpAddr, HostEvent.REMOVED); break; case MOVED_NODE: submitNodeListRefresh(); break; case STATUS_CHANGE: ProtocolEvent.StatusChange stc = (ProtocolEvent.StatusChange) event; InetSocketAddress stAddr = translateAddress(stc.node.getAddress()); Host.statesLogger.debug("[{}] received event {}", stAddr, stc.status); switch (stc.status) { case UP: submitNodeRefresh(stAddr, HostEvent.UP); break; case DOWN: submitNodeRefresh(stAddr, HostEvent.DOWN); break; case CREATED: case UPDATED:
logger.info(String.format("Asked to rebuild %s %s.%s but I don't know keyspace %s", targetType, targetKeyspace, targetName, targetKeyspace)); metadata.cluster.submitSchemaRefresh(null, null, null, null); } else { switch (targetType) {
logger.info(String.format("Asked to rebuild %s %s.%s but I don't know keyspace %s", targetType, targetKeyspace, targetName, targetKeyspace)); metadata.cluster.submitSchemaRefresh(null, null, null, null); } else { switch (targetType) {
cluster.submitSchemaRefresh(null, null); return;
logger.info(String.format("Asked to rebuild %s %s.%s but I don't know keyspace %s", targetType, targetKeyspace, targetName, targetKeyspace)); metadata.cluster.submitSchemaRefresh(null, null, null, null); } else { switch (targetType) {
synchronized void init() { if (isClosed()) throw new IllegalStateException("Can't use this Cluster instance because it was previously closed"); if (isInit) loadBalancingPolicy().init(Cluster.this, metadata.allHosts()); close(); throw e;
this.manager.init(); return this;
cluster.manager.triggerOnDown(pool.host, true);
schemaReady = submitSchemaRefresh(targetType, targetKeyspace, targetName, targetSignature);
this.manager.init(); return this;
schemaReady = submitSchemaRefresh(targetType, targetKeyspace, targetName, targetSignature);
this.manager.init(); return this;