@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 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") @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); }
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
/** @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); }
/** @jira_ticket JAVA-1367 */ @Test(groups = "short") public void should_fail_when_beta_allowed_and_too_high() throws Exception { if (ccm().getCassandraVersion().compareTo(VersionNumber.parse("3.10")) >= 0) { throw new SkipException("Server supports protocol protocol V5 beta"); } UnsupportedProtocolVersionException e = connectWithUnsupportedBetaVersion(); assertThat(e.getUnsupportedVersion()).isEqualTo(V5); }
@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); } future.set(false); } });
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; } } }
@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); } future.set(false); } });
@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); } future.set(false); } });
/** @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); }
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); return; } catch (ClusterNameMismatchException e) {
controlConnection.connect(); } catch (UnsupportedProtocolVersionException e) { logger.debug("Cannot connect with protocol {}, trying {}", e.getUnsupportedVersion(), e.getServerVersion());
controlConnection.connect(); } catch (UnsupportedProtocolVersionException e) { logger.debug("Cannot connect with protocol {}, trying {}", e.getUnsupportedVersion(), e.getServerVersion());