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; } } }
ProtocolVersion usedVersion = ccm().getProtocolVersion(); while (version != usedVersion && version != null) { version = version.getLowerSupported(); expectedNumberOfCalls++;
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; } } }
ProtocolVersion usedVersion = ccm().getProtocolVersion(); while (version != usedVersion && version != null) { version = version.getLowerSupported(); expectedNumberOfCalls++;
while (ProtocolFeature.KEYSPACE_ON_QUERY.isSupportedBy(protocolVersion)) { protocolVersion = protocolVersion.getLowerSupported();
@Test(groups = "short", expectedExceptions = InvalidQueryException.class) public void should_not_use_keyspace_if_set_and_protocol_does_not_support() { ProtocolVersion protocolVersion = cluster().getConfiguration().getProtocolOptions().getProtocolVersion(); while (ProtocolFeature.KEYSPACE_ON_QUERY.isSupportedBy(protocolVersion)) { // Downgrade until we hit a protocol version that doesn't support keyspace on query. protocolVersion = protocolVersion.getLowerSupported(); } Cluster cluster = createClusterBuilderNoDebouncing() .addContactPointsWithPorts(getContactPointsWithPorts()) .withNettyOptions(TestUtils.nonQuietClusterCloseOptions) .withProtocolVersion(protocolVersion) .build(); queryWithKeyspaceOnStatement(cluster, keyspace); }
@Test(groups = "short", expectedExceptions = InvalidQueryException.class) public void should_not_use_keyspace_if_set_and_protocol_does_not_support() { ProtocolVersion protocolVersion = cluster().getConfiguration().getProtocolOptions().getProtocolVersion(); while (ProtocolFeature.KEYSPACE_ON_QUERY.isSupportedBy(protocolVersion)) { // Downgrade until we hit a protocol version that doesn't support keyspace on query. protocolVersion = protocolVersion.getLowerSupported(); } Cluster cluster = createClusterBuilderNoDebouncing() .addContactPointsWithPorts(getContactPointsWithPorts()) .withNettyOptions(TestUtils.nonQuietClusterCloseOptions) .withProtocolVersion(protocolVersion) .build(); insertWithKeyspaceOnStatement(cluster, keyspace); }