@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); } });
private UnsupportedProtocolVersionException unsupportedProtocolVersionException( ProtocolVersion triedVersion, ProtocolVersion serverProtocolVersion) { UnsupportedProtocolVersionException e = new UnsupportedProtocolVersionException(address, triedVersion, serverProtocolVersion); logger.debug(e.getMessage()); return e; }
Thread.currentThread().interrupt(); } catch (UnsupportedProtocolVersionException e) { logger.error(e.getMessage()); long nextDelay = schedule.nextDelayMs(); if (onUnsupportedProtocolVersionException(e, nextDelay)) { logger.error( "Retries against {} have been suspended. It won't be retried unless the node is restarted.", e.getHost()); currentAttempt.compareAndSet(handlerFuture, null);
/** @jira_ticket JAVA-1367 */ @Test(groups = "short") @CassandraVersion("3.8") public void should_fail_when_version_provided_and_too_low_3_8_plus() throws Exception { UnsupportedProtocolVersionException e = connectWithUnsupportedVersion(V1); assertThat(e.getUnsupportedVersion()).isEqualTo(V1); // post-CASSANDRA-11464: server replies with client's version assertThat(e.getServerVersion()).isEqualTo(V1); }
logger.error( "UnsupportedProtocolVersionException error while creating additional connection (error is: {})", e.getMessage()); return false; } catch (ClusterNameMismatchException e) {
@Override public UnsupportedProtocolVersionException copy() { return new UnsupportedProtocolVersionException( address, unsupportedVersion, serverVersion, this); } }
public UnsupportedProtocolVersionException( InetSocketAddress address, ProtocolVersion unsupportedVersion, ProtocolVersion serverVersion) { super(makeErrorMessage(address, unsupportedVersion, serverVersion)); this.address = address; this.unsupportedVersion = unsupportedVersion; this.serverVersion = serverVersion; }
/** @jira_ticket JAVA-1367 */ @Test(groups = "short") public void should_fail_when_version_provided_and_too_high() throws Exception { if (ccm().getCassandraVersion().compareTo(VersionNumber.parse("2.2")) >= 0) { throw new SkipException("Server supports protocol V4"); } UnsupportedProtocolVersionException e = connectWithUnsupportedVersion(V4); assertThat(e.getUnsupportedVersion()).isEqualTo(V4); // pre-CASSANDRA-11464: server replies with its own version assertThat(e.getServerVersion()).isEqualTo(protocolVersion); }
logger.debug("Ignoring host {}: {}", host, e.getMessage()); errors = logError(host, e, errors, iter); } catch (ClusterNameMismatchException e) {
@Override public UnsupportedProtocolVersionException copy() { return new UnsupportedProtocolVersionException(address, unsupportedVersion, serverVersion, this); }
public UnsupportedProtocolVersionException( InetSocketAddress address, ProtocolVersion unsupportedVersion, ProtocolVersion serverVersion, Throwable cause) { super(makeErrorMessage(address, unsupportedVersion, serverVersion), cause); this.address = address; this.unsupportedVersion = unsupportedVersion; this.serverVersion = serverVersion; }
private void negotiateProtocolVersionAndConnect() { boolean shouldNegotiate = (configuration.getProtocolOptions().initialProtocolVersion == null); while (true) { try { controlConnection.connect(); return; } catch (UnsupportedProtocolVersionException e) { if (!shouldNegotiate) { throw e; } // Do not trust version of server's response, as C* behavior in case of protocol // negotiation is not // properly documented, and varies over time (specially after CASSANDRA-11464). Instead, // always // retry at attempted version - 1, if such a version exists; and otherwise, stop and fail. ProtocolVersion attemptedVersion = e.getUnsupportedVersion(); ProtocolVersion retryVersion = attemptedVersion.getLowerSupported(); if (retryVersion == null) { throw e; } logger.info( "Cannot connect with protocol version {}, trying with {}", attemptedVersion, retryVersion); connectionFactory.protocolVersion = retryVersion; } } }
/** @jira_ticket JAVA-1367 */ @Test(groups = "short") @DseVersion("5.1.0") public void should_fail_when_version_provided_and_too_low() throws Exception { UnsupportedProtocolVersionException e = connectWithUnsupportedVersion(V1); assertThat(e.getUnsupportedVersion()).isEqualTo(V1); // post-CASSANDRA-11464: server replies with client's version assertThat(e.getServerVersion()).isEqualTo(V1); }
Thread.currentThread().interrupt(); } catch (UnsupportedProtocolVersionException e) { logger.error(e.getMessage()); long nextDelay = schedule.nextDelayMs(); if (onUnsupportedProtocolVersionException(e, nextDelay)) { reschedule(nextDelay); } else { logger.error("Retries against {} have been suspended. It won't be retried unless the node is restarted.", e.getHost()); currentAttempt.compareAndSet(handlerFuture, null);
private UnsupportedProtocolVersionException unsupportedProtocolVersionException(ProtocolVersion triedVersion, ProtocolVersion serverProtocolVersion) { UnsupportedProtocolVersionException e = new UnsupportedProtocolVersionException(address, triedVersion, serverProtocolVersion); logger.debug(e.getMessage()); return e; }
logger.error("UnsupportedProtocolVersionException error while creating additional connection (error is: {})", e.getMessage()); return false; } catch (ClusterNameMismatchException e) {
@Override public UnsupportedProtocolVersionException copy() { return new UnsupportedProtocolVersionException(address, unsupportedVersion, serverVersion, this); }
public UnsupportedProtocolVersionException(InetSocketAddress address, ProtocolVersion unsupportedVersion, ProtocolVersion serverVersion, Throwable cause) { super(makeErrorMessage(address, unsupportedVersion, serverVersion), cause); this.address = address; this.unsupportedVersion = unsupportedVersion; this.serverVersion = serverVersion; }
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
controlConnection.connect(); } catch (UnsupportedProtocolVersionException e) { logger.debug("Cannot connect with protocol {}, trying {}", e.getUnsupportedVersion(), e.getServerVersion()); connectionFactory.protocolVersion = e.getServerVersion(); try { controlConnection.connect();