boolean supports(ProtocolVersion version) { return getCassandraVersion() == null || version.minCassandraVersion().compareTo(getCassandraVersion().nextStable()) <= 0; }
@Override public VersionNumber getCassandraVersion() { ResultSet result = executeWithSession(session -> session.execute("select release_version from system.local")); Row versionRow = result.one(); if (versionRow == null) { throw new PrestoException(CASSANDRA_VERSION_ERROR, "The cluster version is not available. " + "Please make sure that the Cassandra cluster is up and running, " + "and that the contact points are specified correctly."); } return VersionNumber.parse(versionRow.getString("release_version")); }
/** * @return The mapped cassandra version to the given dseVersion. If the DSE version can't be * derived the following logic is used: * <ol> * <li>If <= 3.X, use C* 1.2 * <li>If 4.X, use 2.1 for >= 4.7, 2.0 otherwise. * <li>Otherwise 3.0 * </ol> */ public static VersionNumber getCassandraVersion(VersionNumber dseVersion) { String cassandraVersion = dseToCassandraVersions.get(dseVersion.toString()); if (cassandraVersion != null) { return VersionNumber.parse(cassandraVersion); } else if (dseVersion.getMajor() <= 3) { return VersionNumber.parse("1.2"); } else if (dseVersion.getMajor() == 4) { if (dseVersion.getMinor() >= 7) { return VersionNumber.parse("2.1"); } else { return VersionNumber.parse("2.0"); } } else { // Fallback on 3.0 by default. return VersionNumber.parse("3.0"); } }
public VersionNumberAssert hasNextStable(String version) { assertThat(actual.nextStable()).isEqualTo(VersionNumber.parse(version)); return this; }
@Test(groups = "unit") public void should_treat_same_prerelease_equal() { VersionNumber version1 = VersionNumber.parse("3.0.15-SNAPSHOT"); VersionNumber version2 = VersionNumber.parse("3.0.15-SNAPSHOT"); assertThat(version1).isEqualTo(version2); assertThat(version1.hashCode()).isEqualTo(version2.hashCode()); }
if (getCassandraVersion().compareTo(PARTITION_FETCH_WITH_IN_PREDICATE_VERSION) > 0) { log.debug("Using IN predicate to fetch partitions."); rows = queryPartitionKeysWithInClauses(table, filterPrefixes);
/** * The next stable version, i.e. the version stripped of its pre-release labels and build * metadata. * * <p>This is mostly used during our development stage, where we test the driver against * pre-release versions of Cassandra like 2.1.0-rc7-SNAPSHOT, but need to compare to the stable * version 2.1.0 when testing for native protocol compatibility, etc. * * @return the next stable version. */ public VersionNumber nextStable() { return new VersionNumber(major, minor, patch, dsePatch, null, null); }
/** * Validates aggregates with DynamicCompositeType state types and an initcond value that is a hex * string representing the bytes for the type, i.e.: 0x80730003666f6f00806900040000002000' can be * appropriately parsed and generates an equivalent CQL string. * * @jira_ticket JAVA-1046 * @test_category metadata * @since 3.0.1 */ @Test(groups = "short") @CassandraVersion("3.4") public void should_parse_and_format_aggregate_with_composite_type_hex_initcond() { VersionNumber ver = ccm().getCassandraVersion(); if ((ver.getMinor() >= 1 && ver.getMinor() < 4)) { throw new SkipException("Requires 3.0.4+ or 3.4.X+"); } parse_and_format_aggregate_with_composite_type("ag1", "0x80730003666f6f00806900040000002000"); }
@BeforeTest void setUp() { col1 = new CassandraColumnHandle("cassandra", "partitionKey1", 1, CassandraType.BIGINT, null, true, false, false, false); col2 = new CassandraColumnHandle("cassandra", "clusteringKey1", 2, CassandraType.BIGINT, null, false, true, false, false); col3 = new CassandraColumnHandle("cassandra", "clusteringKey2", 3, CassandraType.BIGINT, null, false, true, false, false); col4 = new CassandraColumnHandle("cassandra", "clusteringKe3", 4, CassandraType.BIGINT, null, false, true, false, false); cassandraTable = new CassandraTable( new CassandraTableHandle("cassandra", "test", "records"), ImmutableList.of(col1, col2, col3, col4)); cassandraVersion = VersionNumber.parse("2.1.5"); }
/** * Validates aggregates with DynamicCompositeType state types and an initcond value that is a * literal, i.e.: 's@foo:i@32' can be appropriately parsed and generate a CQL string with the init * cond as a hex string, i.e.: 0x80730003666f6f00806900040000002000. * * @jira_ticket JAVA-1046 * @test_category metadata * @since 3.0.1 */ @Test(groups = "short") @CassandraVersion("2.2.0") public void should_parse_and_format_aggregate_with_composite_type_literal_initcond() { VersionNumber ver = ccm().getCassandraVersion(); if (ver.getMajor() == 3) { if ((ver.getMinor() >= 1 && ver.getMinor() < 4) || (ver.getMinor() == 0 && ver.getPatch() < 4)) { throw new SkipException("Requires C* 2.2.X, 3.0.4+ or 3.4.X+"); } } parse_and_format_aggregate_with_composite_type("ag0", "'s@foo:i@32'"); }
/** * @return The mapped cassandra version to the given dseVersion. If the DSE version can't be * derived the following logic is used: * <ol> * <li>If <= 3.X, use C* 1.2 * <li>If 4.X, use 2.1 for >= 4.7, 2.0 otherwise. * <li>Otherwise 3.0 * </ol> */ public static VersionNumber getCassandraVersion(VersionNumber dseVersion) { String cassandraVersion = dseToCassandraVersions.get(dseVersion.toString()); if (cassandraVersion != null) { return VersionNumber.parse(cassandraVersion); } else if (dseVersion.getMajor() <= 3) { return VersionNumber.parse("1.2"); } else if (dseVersion.getMajor() == 4) { if (dseVersion.getMinor() >= 7) { return VersionNumber.parse("2.1"); } else { return VersionNumber.parse("2.0"); } } else if (dseVersion.getMajor() == 6) { return VersionNumber.parse("4.0"); } else if (dseVersion.getMajor() == 5 && dseVersion.getMinor() > 0) { return VersionNumber.parse("3.10"); } else { // Fallback on 3.0 by default. return VersionNumber.parse("3.0"); } }
static SchemaParser forDseVersion(VersionNumber dseVersion) { if (dseVersion.getMajor() >= 5) return V3_PARSER; return V2_PARSER; }
public VersionNumberAssert hasNextStable(String version) { assertThat(actual.nextStable()).isEqualTo(VersionNumber.parse(version)); return this; }
private static void versionCheck( VersionNumber current, VersionNumber required, String skipString) { if (current == null) { throw new SkipException("Skipping test because provided version is null"); } else { if (current.compareTo(required) < 0) { throw new SkipException( String.format( "Version >= %s required, but found %s. Justification: %s", required, current, skipString)); } } } }
String build = bl == null || bl.isEmpty() ? null : bl.substring(1); // drop the initial '+' return new VersionNumber(major, minor, patch, dsePatch, preReleases, build); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid version number: " + version);
/** * Validates aggregates with DynamicCompositeType state types and an initcond value that is a hex * string representing the bytes for the type, i.e.: 0x80730003666f6f00806900040000002000' can be * appropriately parsed and generates an equivalent CQL string. * * @jira_ticket JAVA-1046 * @test_category metadata * @since 3.0.1 */ @Test(groups = "short") @CassandraVersion("3.4") public void should_parse_and_format_aggregate_with_composite_type_hex_initcond() { VersionNumber ver = ccm().getCassandraVersion(); if ((ver.getMinor() >= 1 && ver.getMinor() < 4)) { throw new SkipException("Requires 3.0.4+ or 3.4.X+"); } parse_and_format_aggregate_with_composite_type("ag1", "0x80730003666f6f00806900040000002000"); }