boolean supports(ProtocolVersion version) { return getCassandraVersion() == null || version.minCassandraVersion().compareTo(getCassandraVersion().nextStable()) <= 0; }
if (host == null || host.getCassandraVersion() == null) { cassandraVersion = cluster.protocolVersion().minCassandraVersion(); logger.warn( cassandraVersion); } else { cassandraVersion = host.getCassandraVersion();
@Override public void onTestContextInitialized() { ProtocolVersion protocolVersion = ccm().getProtocolVersion(); samples = PrimitiveTypeSamples.samples(protocolVersion); tables = allTables(); Host host = cluster().getMetadata().getAllHosts().iterator().next(); cassandraVersion = host.getCassandraVersion().nextStable(); List<String> statements = Lists.newArrayList(); for (TestTable table : tables) { if (cassandraVersion.compareTo(table.minCassandraVersion) < 0) logger.debug( "Skipping table because it uses a feature not supported by Cassandra {}: {}", cassandraVersion, table.createStatement); else statements.add(table.createStatement); } execute(statements); }
boolean isSupportedBy(Host host) { return host.getCassandraVersion() == null || isSupportedBy(host.getCassandraVersion()); }
boolean isSupportedBy(Host host) { return host.getCassandraVersion() == null || isSupportedBy(host.getCassandraVersion()); }
private boolean supportsProtocolV2(Host newHost) { return newHost.getCassandraVersion() == null || newHost.getCassandraVersion().getMajor() >= 2; }
boolean supports(ProtocolVersion version) { return getCassandraVersion() == null || version.minCassandraVersion().compareTo(getCassandraVersion().nextStable()) <= 0; }
static KeyspaceMetadata getKeyspaceMetadata(Session session, String keyspace) { Cluster cluster = session.getCluster(); com.datastax.driver.core.Metadata metadata = cluster.getMetadata(); for (Host host : metadata.getAllHosts()) { checkState( 0 >= VersionNumber.parse("3.11.3").compareTo(host.getCassandraVersion()), "Host %s is running Cassandra %s, but minimum version is 3.11.3", host.getHostId(), host.getCassandraVersion()); } return metadata.getKeyspace(keyspace); }
static void refreshSchema(Connection connection, SchemaElement targetType, String targetKeyspace, String targetName, List<String> targetSignature, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException { Host host = cluster.metadata.getHost(connection.address); // Neither host, nor it's version should be null. But instead of dying if there is a race or something, we can kind of try to infer // a Cassandra version from the protocol version (this is not full proof, we can have the protocol 1 against C* 2.0+, but it's worth // a shot, and since we log in this case, it should be relatively easy to debug when if this ever fail). VersionNumber cassandraVersion; if (host == null || host.getCassandraVersion() == null) { cassandraVersion = cluster.protocolVersion().minCassandraVersion(); logger.warn("Cannot find Cassandra version for host {} to parse the schema, using {} based on protocol version in use. " + "If parsing the schema fails, this could be the cause", connection.address, cassandraVersion); } else { cassandraVersion = host.getCassandraVersion(); } SchemaParser.forVersion(cassandraVersion) .refresh(cluster.getCluster(), targetType, targetKeyspace, targetName, targetSignature, connection, cassandraVersion); }
static void refreshSchema(Connection connection, SchemaElement targetType, String targetKeyspace, String targetName, List<String> targetSignature, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException { Host host = cluster.metadata.getHost(connection.address); // Neither host, nor it's version should be null. But instead of dying if there is a race or something, we can kind of try to infer // a Cassandra version from the protocol version (this is not full proof, we can have the protocol 1 against C* 2.0+, but it's worth // a shot, and since we log in this case, it should be relatively easy to debug when if this ever fail). VersionNumber cassandraVersion; if (host == null || host.getCassandraVersion() == null) { cassandraVersion = cluster.protocolVersion().minCassandraVersion(); logger.warn("Cannot find Cassandra version for host {} to parse the schema, using {} based on protocol version in use. " + "If parsing the schema fails, this could be the cause", connection.address, cassandraVersion); } else { cassandraVersion = host.getCassandraVersion(); } SchemaParser.forVersion(cassandraVersion) .refresh(cluster.getCluster(), targetType, targetKeyspace, targetName, targetSignature, connection, cassandraVersion); }
@Test(groups = "short") public void should_parse_table_options() { VersionNumber version = TestUtils.findHost(cluster(), 1).getCassandraVersion();
Host firstHost = hosts.next(); CassandraConnection.DB_MAJOR_VERSION = firstHost.getCassandraVersion().getMajor(); CassandraConnection.DB_MINOR_VERSION = firstHost.getCassandraVersion().getMinor(); CassandraConnection.DB_REVISION = firstHost.getCassandraVersion().getPatch();
QueryTrace queryTrace = executionInfo.getQueryTrace(); execInfo.append("\n exeuction info: queried-host=[address=").append(qh.getAddress()). append(", version=").append(qh.getCassandraVersion()). append(", dc=").append(qh.getDatacenter()). append(", rac=").append(qh.getRack()).
static void refreshSchema(Connection connection, SchemaElement targetType, String targetKeyspace, String targetName, List<String> targetSignature, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException { Host host = cluster.metadata.getHost(connection.address); // Neither host, nor it's version should be null. But instead of dying if there is a race or something, we can kind of try to infer // a Cassandra version from the protocol version (this is not full proof, we can have the protocol 1 against C* 2.0+, but it's worth // a shot, and since we log in this case, it should be relatively easy to debug when if this ever fail). VersionNumber cassandraVersion; if (host == null || host.getCassandraVersion() == null) { cassandraVersion = cluster.protocolVersion().minCassandraVersion(); logger.warn("Cannot find Cassandra version for host {} to parse the schema, using {} based on protocol version in use. " + "If parsing the schema fails, this could be the cause", connection.address, cassandraVersion); } else { cassandraVersion = host.getCassandraVersion(); } SchemaParser.forVersion(cassandraVersion) .refresh(cluster.getCluster(), targetType, targetKeyspace, targetName, targetSignature, connection, cassandraVersion); if (targetType == null || targetType == KEYSPACE || targetType == TABLE) { // Refresh the entire partition map because one keyspace or table change may trigger // re-balancing for the entire cluster. refreshPartitionMap(connection, cluster); } // Other change types do not affect the partition map so nothing to do. }
public CassandraConnectionImpl(CassandraManagedConnectionFactory config) { this.config = config; Cluster.Builder builder = Cluster.builder().addContactPoint(config.getAddress()); if (this.config.getUsername() != null) { builder.withCredentials(this.config.getUsername(), this.config.getPassword()); } if (this.config.getPort() != null) { builder.withPort(this.config.getPort()); } this.cluster = builder.build(); this.metadata = cluster.getMetadata(); this.session = cluster.connect(config.getKeyspace()); Set<Host> allHosts = cluster.getMetadata().getAllHosts(); if (!allHosts.isEmpty()) { Host host = allHosts.iterator().next(); this.version = host.getCassandraVersion(); } }
public CassandraConnectionImpl(CassandraManagedConnectionFactory config) { this.config = config; Cluster.Builder builder = Cluster.builder().addContactPoint(config.getAddress()); if (this.config.getUsername() != null) { builder.withCredentials(this.config.getUsername(), this.config.getPassword()); } if (this.config.getPort() != null) { builder.withPort(this.config.getPort()); } this.cluster = builder.build(); this.metadata = cluster.getMetadata(); this.session = cluster.connect(config.getKeyspace()); Set<Host> allHosts = cluster.getMetadata().getAllHosts(); if (!allHosts.isEmpty()) { Host host = allHosts.iterator().next(); this.version = host.getCassandraVersion(); } }
@Override public void onTestContextInitialized() { ProtocolVersion protocolVersion = ccm().getProtocolVersion(); samples = PrimitiveTypeSamples.samples(protocolVersion); tables = allTables(); Host host = cluster().getMetadata().getAllHosts().iterator().next(); cassandraVersion = host.getCassandraVersion().nextStable(); List<String> statements = Lists.newArrayList(); for (TestTable table : tables) { if (cassandraVersion.compareTo(table.minCassandraVersion) < 0) logger.debug( "Skipping table because it uses a feature not supported by Cassandra {}: {}", cassandraVersion, table.createStatement); else statements.add(table.createStatement); } execute(statements); }
if (host == null || host.getCassandraVersion() == null) { cassandraVersion = cluster.protocolVersion() == 1 ? VersionNumber.parse("1.2.0") : VersionNumber.parse("2.0.0"); logger.warn("Cannot find Cassandra version for host {} to parse the schema, using {} based on protocol version in use. " + "If parsing the schema fails, this could be the cause", connection.address, cassandraVersion); } else { cassandraVersion = host.getCassandraVersion();
LOGGER.debug("Host [{}]:\n\n\tDC: [{}]\n\tRack: [{}]\n\tVersion: [{}]\n\tDistance: [{}]\n\tUp?: [{}]\n", clusterHost.getAddress(), clusterHost.getDatacenter(), clusterHost.getRack(), clusterHost.getCassandraVersion(), loadBalancingPolicy.distance(clusterHost), clusterHost.isUp()));
@Test(groups = "short") public void should_parse_table_options() { VersionNumber version = TestUtils.findHost(cluster(), 1).getCassandraVersion();