diff --git a/.travis.yml b/.travis.yml
index 489a813b9f1..1ea0a30844e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
language: java
+dist: trusty
jdk:
-- openjdk6
-- oraclejdk7
+- openjdk7
- oraclejdk8
sudo: false
before_install:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a4358fe89ee..703c5fa05b5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,5 +1,44 @@
+
+
# Contributing guidelines
+## Code formatting
+
+We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). See
+https://github.com/google/google-java-format for IDE plugins. The rules are not configurable.
+
+The build will fail if the code is not formatted. To format all files from the command line, run:
+
+```
+mvn fmt:format
+```
+
+Some aspects are not covered by the formatter:
+
+* braces must be used with `if`, `else`, `for`, `do` and `while` statements, even when the body is
+ empty or contains only a single statement.
+
+Also, if your IDE sorts import statements automatically, make sure it follows the same order as the
+formatter: all static imports in ASCII sort order, followed by a blank line, followed by all regular
+imports in ASCII sort order. In addition, please avoid using wildcard imports.
+
## Working on an issue
Before starting to work on something, please comment in JIRA or ask on the mailing list
diff --git a/Jenkinsfile-asf b/Jenkinsfile-asf
new file mode 100644
index 00000000000..2bc42bea379
--- /dev/null
+++ b/Jenkinsfile-asf
@@ -0,0 +1,78 @@
+#!groovy
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+pipeline {
+ agent {
+ label 'cassandra-small'
+ }
+
+ triggers {
+ // schedules only run against release branches (i.e. 3.x, 4.x, 4.5.x, etc.)
+ cron(branchPatternCron().matcher(env.BRANCH_NAME).matches() ? "@weekly" : "")
+ }
+
+ stages {
+ stage('Matrix') {
+ matrix {
+ axes {
+ axis {
+ name 'TEST_JAVA_VERSION'
+ values 'openjdk@1.8.0-292', 'openjdk@1.11.0-9'
+ }
+ axis {
+ name 'SERVER_VERSION'
+ values '2.1', '3.0', '3.11', '4.0'
+ }
+ }
+ stages {
+ stage('Tests') {
+ agent {
+ label 'cassandra-medium'
+ }
+ steps {
+ script {
+ executeTests()
+ junit testResults: '**/target/surefire-reports/TEST-*.xml', allowEmptyResults: true
+ junit testResults: '**/target/failsafe-reports/TEST-*.xml', allowEmptyResults: true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+def executeTests() {
+ sh """
+ container_id=\$(docker run -td -e TEST_JAVA_VERSION=${TEST_JAVA_VERSION} -e SERVER_VERSION=${SERVER_VERSION} -v \$(pwd):/home/docker/cassandra-java-driver apache.jfrog.io/cassan-docker/apache/cassandra-java-driver-testing-ubuntu2204 'sleep 2h')
+ docker exec --user root \$container_id bash -c \"sudo bash /home/docker/cassandra-java-driver/ci/create-user.sh docker \$(id -u) \$(id -g) /home/docker/cassandra-java-driver\"
+ docker exec --user docker \$container_id './cassandra-java-driver/ci/run-tests.sh'
+ ( nohup docker stop \$container_id >/dev/null 2>/dev/null & )
+ """
+}
+
+// branch pattern for cron
+// should match 3.x, 4.x, 4.5.x, etc
+def branchPatternCron() {
+ ~"((\\d+(\\.[\\dx]+)+))"
+}
+
diff --git a/Jenkinsfile-datastax b/Jenkinsfile-datastax
new file mode 100644
index 00000000000..21bd9721f7f
--- /dev/null
+++ b/Jenkinsfile-datastax
@@ -0,0 +1,569 @@
+#!groovy
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def initializeEnvironment() {
+ env.DRIVER_DISPLAY_NAME = 'CassandraⓇ Java Driver 3.x'
+ env.DRIVER_METRIC_TYPE = 'oss'
+ if (env.GIT_URL.contains('riptano/java-driver')) {
+ env.DRIVER_DISPLAY_NAME = 'private ' + env.DRIVER_DISPLAY_NAME
+ env.DRIVER_METRIC_TYPE = 'oss-private'
+ } else if (env.GIT_URL.contains('java-dse-driver')) {
+ env.DRIVER_DISPLAY_NAME = 'DSE Java Driver 1.x'
+ env.DRIVER_METRIC_TYPE = 'dse'
+ }
+
+ env.GIT_SHA = "${env.GIT_COMMIT.take(7)}"
+ env.GITHUB_PROJECT_URL = "https://${GIT_URL.replaceFirst(/(git@|http:\/\/|https:\/\/)/, '').replace(':', '/').replace('.git', '')}"
+ env.GITHUB_BRANCH_URL = "${GITHUB_PROJECT_URL}/tree/${env.BRANCH_NAME}"
+ env.GITHUB_COMMIT_URL = "${GITHUB_PROJECT_URL}/commit/${env.GIT_COMMIT}"
+
+ env.MAVEN_HOME = "${env.HOME}/.mvn/apache-maven-3.2.5"
+ env.PATH = "${env.MAVEN_HOME}/bin:${env.PATH}"
+ env.JAVA_HOME = sh(label: 'Get JAVA_HOME',script: '''#!/bin/bash -le
+ . ${JABBA_SHELL}
+ jabba which ${JABBA_VERSION}''', returnStdout: true).trim()
+ env.JAVA8_HOME = sh(label: 'Get JAVA8_HOME',script: '''#!/bin/bash -le
+ . ${JABBA_SHELL}
+ jabba which 1.8''', returnStdout: true).trim()
+
+ sh label: 'Download Apache CassandraⓇ',script: '''#!/bin/bash -le
+ . ${JABBA_SHELL}
+ jabba use ${JABBA_VERSION}
+ . ${CCM_ENVIRONMENT_SHELL} ${SERVER_VERSION}
+ '''
+
+ sh label: 'Display Java and environment information',script: '''#!/bin/bash -le
+ # Load CCM environment variables
+ set -o allexport
+ . ${HOME}/environment.txt
+ set +o allexport
+
+ . ${JABBA_SHELL}
+ jabba use ${JABBA_VERSION}
+
+ java -version
+ mvn -v
+ printenv | sort
+ '''
+}
+
+def buildDriver(jabbaVersion) {
+ def buildDriverScript = '''#!/bin/bash -le
+
+ . ${JABBA_SHELL}
+ jabba use '''+jabbaVersion+'''
+
+ echo "Building with Java version '''+jabbaVersion+'''"
+
+ mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true
+ '''
+ sh label: 'Build driver', script: buildDriverScript
+}
+
+def executeTests() {
+ sh label: 'Execute tests', script: '''#!/bin/bash -le
+ # Load CCM environment variables
+ set -o allexport
+ . ${HOME}/environment.txt
+ set +o allexport
+
+ . ${JABBA_SHELL}
+ jabba use ${JABBA_VERSION}
+
+ printenv | sort
+
+ mvn -B -V verify \
+ -fail-never -P${TEST_PROFILE} \
+ -Dcom.datastax.driver.TEST_BASE_NODE_WAIT=120 \
+ -Dcom.datastax.driver.NEW_NODE_DELAY_SECONDS=100 \
+ -Dcassandra.version=${CCM_CASSANDRA_VERSION} \
+ -Ddse=${CCM_IS_DSE} \
+ -Dccm.java.home=${CCM_JAVA_HOME} \
+ -Dccm.path=${CCM_JAVA_HOME}/bin \
+ -Dccm.maxNumberOfNodes=3 \
+ -DfailIfNoTests=false \
+ -Dmaven.test.failure.ignore=true \
+ -Dmaven.javadoc.skip=true \
+ -Dproxy.path=${HOME}/proxy
+
+ # run isolated tests
+ mvn -B -V verify \
+ -fail-never -Pisolated \
+ -Dcom.datastax.driver.TEST_BASE_NODE_WAIT=120 \
+ -Dcom.datastax.driver.NEW_NODE_DELAY_SECONDS=100 \
+ -Dcassandra.version=${CCM_CASSANDRA_VERSION} \
+ -Ddse=${CCM_IS_DSE} \
+ -Dccm.java.home=${CCM_JAVA_HOME} \
+ -Dccm.path=${CCM_JAVA_HOME}/bin \
+ -Dccm.maxNumberOfNodes=3 \
+ -DfailIfNoTests=false \
+ -Dmaven.test.failure.ignore=true \
+ -Dmaven.javadoc.skip=true
+ '''
+}
+
+def executeCodeCoverage() {
+ jacoco(
+ execPattern: '**/target/jacoco.exec',
+ classPattern: '**/classes',
+ sourcePattern: '**/src/main/java'
+ )
+}
+
+def notifySlack(status = 'started') {
+ // Notify Slack channel for every build except adhoc executions
+ if (params.ADHOC_BUILD_TYPE != 'BUILD-AND-EXECUTE-TESTS') {
+ // Set the global pipeline scoped environment (this is above each matrix)
+ env.BUILD_STATED_SLACK_NOTIFIED = 'true'
+
+ def buildType = 'Commit'
+ if (params.CI_SCHEDULE != 'DO-NOT-CHANGE-THIS-SELECTION') {
+ buildType = "${params.CI_SCHEDULE.toLowerCase().capitalize()}"
+ }
+
+ def color = 'good' // Green
+ if (status.equalsIgnoreCase('aborted')) {
+ color = '808080' // Grey
+ } else if (status.equalsIgnoreCase('unstable')) {
+ color = 'warning' // Orange
+ } else if (status.equalsIgnoreCase('failed')) {
+ color = 'danger' // Red
+ }
+
+ def message = """Build ${status} for ${env.DRIVER_DISPLAY_NAME} [${buildType}]
+<${env.GITHUB_BRANCH_URL}|${env.BRANCH_NAME}> - <${env.RUN_DISPLAY_URL}|#${env.BUILD_NUMBER}> - <${env.GITHUB_COMMIT_URL}|${env.GIT_SHA}>"""
+ if (!status.equalsIgnoreCase('Started')) {
+ message += """
+${status} after ${currentBuild.durationString - ' and counting'}"""
+ }
+
+ slackSend color: "${color}",
+ channel: "#java-driver-dev-bots",
+ message: "${message}"
+ }
+}
+
+def describePerCommitStage() {
+ script {
+ currentBuild.displayName = "Per-Commit build"
+ currentBuild.description = 'Per-Commit build and testing of development Apache CassandraⓇ against Oracle JDK 8'
+ }
+}
+
+def describeAdhocAndScheduledTestingStage() {
+ script {
+ if (params.CI_SCHEDULE == 'DO-NOT-CHANGE-THIS-SELECTION') {
+ // Ad-hoc build
+ currentBuild.displayName = "Adhoc testing"
+ currentBuild.description = "Testing ${params.ADHOC_BUILD_AND_EXECUTE_TESTS_SERVER_VERSION} against JDK version ${params.ADHOC_BUILD_AND_EXECUTE_TESTS_JABBA_VERSION}"
+ } else {
+ // Scheduled build
+ currentBuild.displayName = "${params.CI_SCHEDULE.toLowerCase().replaceAll('_', ' ').capitalize()} schedule"
+ currentBuild.description = "Testing server versions [${params.CI_SCHEDULE_SERVER_VERSIONS}] against JDK version ${params.CI_SCHEDULE_JABBA_VERSION}"
+ }
+ }
+}
+
+// branch pattern for cron
+// should match 3.x, 4.x, 4.5.x, etc
+def branchPatternCron() {
+ ~"((\\d+(\\.[\\dx]+)+))"
+}
+
+pipeline {
+ agent none
+
+ // Global pipeline timeout
+ options {
+ timeout(time: 10, unit: 'HOURS')
+ buildDiscarder(logRotator(artifactNumToKeepStr: '10', // Keep only the last 10 artifacts
+ numToKeepStr: '50')) // Keep only the last 50 build records
+ }
+
+ parameters {
+ choice(
+ name: 'ADHOC_BUILD_TYPE',
+ choices: ['BUILD', 'BUILD-AND-EXECUTE-TESTS'],
+ description: '''
Perform a adhoc build operation
+
+
+
+
+ | Choice |
+ Description |
+
+
+ | BUILD |
+ Performs a Per-Commit build |
+
+
+ | BUILD-AND-EXECUTE-TESTS |
+ Performs a build and executes the integration and unit tests |
+
+
''')
+ choice(
+ name: 'ADHOC_BUILD_AND_EXECUTE_TESTS_SERVER_VERSION',
+ choices: ['2.1', // Legacy Apache CassandraⓇ
+ '2.2', // Legacy Apache CassandraⓇ
+ '3.0', // Previous Apache CassandraⓇ
+ '3.11', // Current Apache CassandraⓇ
+ '4.0', // Development Apache CassandraⓇ
+ 'dse-5.1', // Legacy DataStax Enterprise
+ 'dse-6.0', // Previous DataStax Enterprise
+ 'dse-6.7', // Previous DataStax Enterprise
+ 'dse-6.8.0', // Current DataStax Enterprise
+ 'ALL'],
+ description: '''Apache Cassandra® or DataStax Enterprise server version to use for adhoc BUILD-AND-EXECUTE-TESTS builds
+
+
+
+
+ | Choice |
+ Description |
+
+
+ | 2.1 |
+ Apache Cassandra® v2.1.x |
+
+
+ | 2.2 |
+ Apache Cassandra® v2.2.x |
+
+
+ | 3.0 |
+ Apache Cassandra® v3.0.x |
+
+
+ | 3.11 |
+ Apache Cassandra® v3.11.x |
+
+
+ | 4.0 |
+ Apache Cassandra® v4.x (CURRENTLY UNDER DEVELOPMENT) |
+
+
+ | dse-5.1 |
+ DataStax Enterprise v5.1.x |
+
+
+ | dse-6.0 |
+ DataStax Enterprise v6.0.x |
+
+
+ | dse-6.7 |
+ DataStax Enterprise v6.7.x |
+
+
+ | dse-6.8.0 |
+ DataStax Enterprise v6.8.0 |
+
+
''')
+ choice(
+ name: 'ADHOC_BUILD_AND_EXECUTE_TESTS_JABBA_VERSION',
+ choices: ['zulu@1.6', // Zulu JDK 1.6
+ 'zulu@1.7', // Zulu JDK 1.7
+ '1.8', // Oracle JDK version 1.8 (current default)
+ 'openjdk@1.11'], // OpenJDK version 11
+ description: '''JDK version to use for TESTING when running adhoc BUILD-AND-EXECUTE-TESTS builds. All builds will use JDK8 for building the driver
+
+
+
+
+ | Choice |
+ Description |
+
+
+ | zulu@1.6 |
+ Zulu JDK version 1.6 |
+
+
+ | zulu@1.7 |
+ Zulu JDK version 1.7 |
+
+
+ | 1.8 |
+ Oracle JDK version 1.8 (Used for compiling regardless of choice) |
+
+
+ | openjdk@1.11 |
+ OpenJDK version 11 |
+
+
''')
+ choice(
+ name: 'ADHOC_BUILD_AND_EXECUTE_TESTS_TEST_PROFILE',
+ choices: ['short', 'long'],
+ description: 'Test profile to execute during test phase of the build')
+ choice(
+ name: 'CI_SCHEDULE',
+ choices: ['DO-NOT-CHANGE-THIS-SELECTION', 'WEEKNIGHTS', 'WEEKENDS', 'MONTHLY'],
+ description: 'CI testing schedule to execute periodically scheduled builds and tests of the driver (DO NOT CHANGE THIS SELECTION)')
+ string(
+ name: 'CI_SCHEDULE_SERVER_VERSIONS',
+ defaultValue: 'DO-NOT-CHANGE-THIS-SELECTION',
+ description: 'CI testing server version(s) to utilize for scheduled test runs of the driver (DO NOT CHANGE THIS SELECTION)')
+ string(
+ name: 'CI_SCHEDULE_JABBA_VERSION',
+ defaultValue: 'DO-NOT-CHANGE-THIS-SELECTION',
+ description: 'CI testing JDK version(s) to utilize for scheduled test runs of the driver (DO NOT CHANGE THIS SELECTION)')
+ string(
+ name: 'CI_SCHEDULE_TEST_PROFILE',
+ defaultValue: 'DO-NOT-CHANGE-THIS-SELECTION',
+ description: 'CI testing profile to execute (DO NOT CHANGE THIS SELECTION)')
+ }
+
+ triggers {
+ // schedules only run against release branches (i.e. 3.x, 4.x, 4.5.x, etc.)
+ parameterizedCron(branchPatternCron().matcher(env.BRANCH_NAME).matches() ? """
+ # Every weeknight (Monday - Friday) around 3:00 AM
+ ### JDK8 tests against 2.1, 3.0, 3.11 and 4.0
+ H 3 * * 1-5 %CI_SCHEDULE=WEEKNIGHTS;CI_SCHEDULE_SERVER_VERSIONS=2.1 3.0 3.11 4.0;CI_SCHEDULE_JABBA_VERSION=1.8;CI_SCHEDULE_TEST_PROFILE=long
+ # Every weekend (Sunday) around 2:00 PM
+ ### JDK11 tests against 2.1, 3.0, 3.11 and 4.0
+ H 14 * * 0 %CI_SCHEDULE=WEEKENDS;CI_SCHEDULE_SERVER_VERSIONS=2.1 3.0 3.11 4.0;CI_SCHEDULE_JABBA_VERSION=openjdk@1.11;CI_SCHEDULE_TEST_PROFILE=long
+ """ : "")
+ }
+
+ environment {
+ OS_VERSION = 'ubuntu/bionic64/java-driver'
+ JABBA_SHELL = '/usr/lib/jabba/jabba.sh'
+ CCM_ENVIRONMENT_SHELL = '/usr/local/bin/ccm_environment.sh'
+ }
+
+ stages {
+ stage ('Per-Commit') {
+ options {
+ timeout(time: 2, unit: 'HOURS')
+ }
+ when {
+ beforeAgent true
+ allOf {
+ expression { params.ADHOC_BUILD_TYPE == 'BUILD' }
+ expression { params.CI_SCHEDULE == 'DO-NOT-CHANGE-THIS-SELECTION' }
+ expression { params.CI_SCHEDULE_SERVER_VERSIONS == 'DO-NOT-CHANGE-THIS-SELECTION' }
+ expression { params.CI_SCHEDULE_JABBA_VERSION == 'DO-NOT-CHANGE-THIS-SELECTION' }
+ expression { params.CI_SCHEDULE_TEST_PROFILE == 'DO-NOT-CHANGE-THIS-SELECTION' }
+ not { buildingTag() }
+ }
+ }
+
+ matrix {
+ axes {
+ axis {
+ name 'SERVER_VERSION'
+ values '3.11', // Current Apache CassandraⓇ
+ '4.0' // Development Apache CassandraⓇ
+ }
+ }
+
+ agent {
+ label "${OS_VERSION}"
+ }
+ environment {
+ // Per-commit builds are only going to run against JDK8
+ JABBA_VERSION = '1.8'
+ TEST_PROFILE = 'short'
+ }
+
+ stages {
+ stage('Initialize-Environment') {
+ steps {
+ initializeEnvironment()
+ script {
+ if (env.BUILD_STATED_SLACK_NOTIFIED != 'true') {
+ notifySlack()
+ }
+ }
+ }
+ }
+ stage('Describe-Build') {
+ steps {
+ describePerCommitStage()
+ }
+ }
+ stage('Build-Driver') {
+ steps {
+ buildDriver('1.8')
+ }
+ }
+ stage('Execute-Tests') {
+ steps {
+ catchError {
+ // Use the matrix JDK for testing
+ executeTests()
+ }
+ }
+ post {
+ always {
+ /*
+ * Empty results are possible
+ *
+ * - Build failures during mvn verify may exist so report may not be available
+ */
+ junit testResults: '**/target/surefire-reports/TEST-*.xml', allowEmptyResults: true
+ junit testResults: '**/target/failsafe-reports/TEST-*.xml', allowEmptyResults: true
+ }
+ }
+ }
+ stage('Execute-Code-Coverage') {
+ // Ensure the code coverage is run only once per-commit
+ when { environment name: 'SERVER_VERSION', value: '4.0' }
+ steps {
+ executeCodeCoverage()
+ }
+ }
+ }
+ }
+ post {
+ aborted {
+ notifySlack('aborted')
+ }
+ success {
+ notifySlack('completed')
+ }
+ unstable {
+ notifySlack('unstable')
+ }
+ failure {
+ notifySlack('FAILED')
+ }
+ }
+ }
+
+ stage('Adhoc-And-Scheduled-Testing') {
+ when {
+ beforeAgent true
+ allOf {
+ expression { (params.ADHOC_BUILD_TYPE == 'BUILD' && params.CI_SCHEDULE != 'DO-NOT-CHANGE-THIS-SELECTION') ||
+ params.ADHOC_BUILD_TYPE == 'BUILD-AND-EXECUTE-TESTS' }
+ not { buildingTag() }
+ anyOf {
+ expression { params.ADHOC_BUILD_TYPE == 'BUILD-AND-EXECUTE-TESTS' }
+ allOf {
+ expression { params.ADHOC_BUILD_TYPE == 'BUILD' }
+ expression { params.CI_SCHEDULE != 'DO-NOT-CHANGE-THIS-SELECTION' }
+ expression { params.CI_SCHEDULE_SERVER_VERSIONS != 'DO-NOT-CHANGE-THIS-SELECTION' }
+ }
+ }
+ }
+ }
+
+ environment {
+ SERVER_VERSIONS = "${params.CI_SCHEDULE_SERVER_VERSIONS == 'DO-NOT-CHANGE-THIS-SELECTION' ? params.ADHOC_BUILD_AND_EXECUTE_TESTS_SERVER_VERSION : params.CI_SCHEDULE_SERVER_VERSIONS}"
+ JABBA_VERSION = "${params.CI_SCHEDULE_JABBA_VERSION == 'DO-NOT-CHANGE-THIS-SELECTION' ? params.ADHOC_BUILD_AND_EXECUTE_TESTS_JABBA_VERSION : params.CI_SCHEDULE_JABBA_VERSION}"
+ TEST_PROFILE = "${params.CI_SCHEDULE_TEST_PROFILE == 'DO-NOT-CHANGE-THIS-SELECTION' ? params.ADHOC_BUILD_AND_EXECUTE_TESTS_TEST_PROFILE : params.CI_SCHEDULE_TEST_PROFILE}"
+ }
+
+ matrix {
+ axes {
+ axis {
+ name 'SERVER_VERSION'
+ values '2.1', // Legacy Apache CassandraⓇ
+ '3.0', // Previous Apache CassandraⓇ
+ '3.11', // Current Apache CassandraⓇ
+ '4.0', // Development Apache CassandraⓇ
+ 'dse-5.1', // Legacy DataStax Enterprise
+ 'dse-6.0', // Previous DataStax Enterprise
+ 'dse-6.7', // Previous DataStax Enterprise
+ 'dse-6.8.0' // Current DataStax Enterprise
+ }
+ }
+ when {
+ beforeAgent true
+ allOf {
+ expression { return env.SERVER_VERSIONS.split(' ').any { it =~ /(ALL|${env.SERVER_VERSION})/ } }
+ }
+ }
+ agent {
+ label "${env.OS_VERSION}"
+ }
+
+ stages {
+ stage('Initialize-Environment') {
+ steps {
+ initializeEnvironment()
+ script {
+ if (env.BUILD_STATED_SLACK_NOTIFIED != 'true') {
+ notifySlack()
+ }
+ }
+ }
+ }
+ stage('Describe-Build') {
+ steps {
+ describeAdhocAndScheduledTestingStage()
+ }
+ }
+ stage('Build-Driver') {
+ steps {
+ // Jabba default should be a JDK8 for now
+ buildDriver('1.8')
+ }
+ }
+ stage('Execute-Tests') {
+ steps {
+ catchError {
+ // Use the matrix JDK for testing
+ executeTests()
+ }
+ }
+ post {
+ always {
+ /*
+ * Empty results are possible
+ *
+ * - Build failures during mvn verify may exist so report may not be available
+ * - With boolean parameters to skip tests a failsafe report may not be available
+ */
+ junit testResults: '**/target/surefire-reports/TEST-*.xml', allowEmptyResults: true
+ junit testResults: '**/target/failsafe-reports/TEST-*.xml', allowEmptyResults: true
+ }
+ }
+ }
+ stage('Execute-Code-Coverage') {
+ // Ensure the code coverage is run only once per-commit
+ when {
+ allOf {
+ environment name: 'SERVER_VERSION', value: '4.0'
+ environment name: 'JABBA_VERSION', value: '1.8'
+ }
+ }
+ steps {
+ executeCodeCoverage()
+ }
+ }
+ }
+ }
+ post {
+ aborted {
+ notifySlack('aborted')
+ }
+ success {
+ notifySlack('completed')
+ }
+ unstable {
+ notifySlack('unstable')
+ }
+ failure {
+ notifySlack('FAILED')
+ }
+ }
+ }
+ }
+}
diff --git a/LICENSE b/LICENSE
index d6456956733..38f06999ef6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -200,3 +200,10 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
+Apache Cassandra Java Driver bundles code and files from the following projects:
+
+Protocol Buffers
+Copyright 2008 Google Inc.
+This product includes software developed as part of the Protocol Buffers project ( https://developers.google.com/protocol-buffers/ ).
+see driver-core/src/main/java/com/datastax/driver/core/VIntCoding.java
diff --git a/LICENSE_binary b/LICENSE_binary
new file mode 100644
index 00000000000..5232779c907
--- /dev/null
+++ b/LICENSE_binary
@@ -0,0 +1,229 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+Apache Cassandra Java Driver bundles code and files from the following projects:
+
+Protocol Buffers
+Copyright 2008 Google Inc.
+This product includes software developed as part of the Protocol Buffers project ( https://developers.google.com/protocol-buffers/ ).
+see driver-core/src/main/java/com/datastax/driver/core/VIntCoding.java
+
+This product bundles Java Native Runtime - POSIX 3.1.15,
+which is available under the Eclipse Public License version 2.0.
+see licenses/jnr-posix.txt
+
+This product bundles jnr-x86asm 1.0.2,
+which is available under the MIT License.
+see licenses/jnr-x86asm.txt
+
+This product bundles ASM 9.2: a very small and fast Java bytecode manipulation framework,
+which is available under the 3-Clause BSD License.
+see licenses/asm.txt
+
+This product bundles HdrHistogram 2.1.12: A High Dynamic Range (HDR) Histogram,
+which is available under the 2-Clause BSD License.
+see licenses/HdrHistogram.txt
+
+This product bundles The Simple Logging Facade for Java (SLF4J) API 1.7.26,
+which is available under the MIT License.
+see licenses/slf4j-api.txt
diff --git a/NOTICE.txt b/NOTICE.txt
new file mode 100644
index 00000000000..8e27ae3e52f
--- /dev/null
+++ b/NOTICE.txt
@@ -0,0 +1,5 @@
+Apache Cassandra Java Driver
+Copyright 2012- The Apache Software Foundation
+
+This product includes software developed at The Apache Software
+Foundation (http://www.apache.org/).
diff --git a/NOTICE_binary.txt b/NOTICE_binary.txt
new file mode 100644
index 00000000000..c60d8ceb245
--- /dev/null
+++ b/NOTICE_binary.txt
@@ -0,0 +1,249 @@
+Apache Cassandra Java Driver
+Copyright 2012- The Apache Software Foundation
+
+This product includes software developed at The Apache Software
+Foundation (http://www.apache.org/).
+
+This compiled product also includes Apache-licensed dependencies
+that contain the following NOTICE information:
+
+==================================================================
+io.netty:netty-handler NOTICE.txt
+==================================================================
+This product contains the extensions to Java Collections Framework which has
+been derived from the works by JSR-166 EG, Doug Lea, and Jason T. Greene:
+
+ * LICENSE:
+ * license/LICENSE.jsr166y.txt (Public Domain)
+ * HOMEPAGE:
+ * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/
+ * http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbosscache/experimental/jsr166/
+
+This product contains a modified version of Robert Harder's Public Domain
+Base64 Encoder and Decoder, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.base64.txt (Public Domain)
+ * HOMEPAGE:
+ * http://iharder.sourceforge.net/current/java/base64/
+
+This product contains a modified portion of 'Webbit', an event based
+WebSocket and HTTP server, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.webbit.txt (BSD License)
+ * HOMEPAGE:
+ * https://github.com/joewalnes/webbit
+
+This product contains a modified portion of 'SLF4J', a simple logging
+facade for Java, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.slf4j.txt (MIT License)
+ * HOMEPAGE:
+ * https://www.slf4j.org/
+
+This product contains a modified portion of 'Apache Harmony', an open source
+Java SE, which can be obtained at:
+
+ * NOTICE:
+ * license/NOTICE.harmony.txt
+ * LICENSE:
+ * license/LICENSE.harmony.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://archive.apache.org/dist/harmony/
+
+This product contains a modified portion of 'jbzip2', a Java bzip2 compression
+and decompression library written by Matthew J. Francis. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jbzip2.txt (MIT License)
+ * HOMEPAGE:
+ * https://code.google.com/p/jbzip2/
+
+This product contains a modified portion of 'libdivsufsort', a C API library to construct
+the suffix array and the Burrows-Wheeler transformed string for any input string of
+a constant-size alphabet written by Yuta Mori. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.libdivsufsort.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/y-256/libdivsufsort
+
+This product contains a modified portion of Nitsan Wakart's 'JCTools', Java Concurrency Tools for the JVM,
+ which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jctools.txt (ASL2 License)
+ * HOMEPAGE:
+ * https://github.com/JCTools/JCTools
+
+This product optionally depends on 'JZlib', a re-implementation of zlib in
+pure Java, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jzlib.txt (BSD style License)
+ * HOMEPAGE:
+ * http://www.jcraft.com/jzlib/
+
+This product optionally depends on 'Compress-LZF', a Java library for encoding and
+decoding data in LZF format, written by Tatu Saloranta. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.compress-lzf.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/ning/compress
+
+This product optionally depends on 'lz4', a LZ4 Java compression
+and decompression library written by Adrien Grand. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.lz4.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jpountz/lz4-java
+
+This product optionally depends on 'lzma-java', a LZMA Java compression
+and decompression library, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.lzma-java.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jponge/lzma-java
+
+This product optionally depends on 'zstd-jni', a zstd-jni Java compression
+and decompression library, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.zstd-jni.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/luben/zstd-jni
+
+This product contains a modified portion of 'jfastlz', a Java port of FastLZ compression
+and decompression library written by William Kinney. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jfastlz.txt (MIT License)
+ * HOMEPAGE:
+ * https://code.google.com/p/jfastlz/
+
+This product contains a modified portion of and optionally depends on 'Protocol Buffers', Google's data
+interchange format, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.protobuf.txt (New BSD License)
+ * HOMEPAGE:
+ * https://github.com/google/protobuf
+
+This product optionally depends on 'Bouncy Castle Crypto APIs' to generate
+a temporary self-signed X.509 certificate when the JVM does not provide the
+equivalent functionality. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.bouncycastle.txt (MIT License)
+ * HOMEPAGE:
+ * https://www.bouncycastle.org/
+
+This product optionally depends on 'Snappy', a compression library produced
+by Google Inc, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.snappy.txt (New BSD License)
+ * HOMEPAGE:
+ * https://github.com/google/snappy
+
+This product optionally depends on 'JBoss Marshalling', an alternative Java
+serialization API, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jboss-marshalling.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jboss-remoting/jboss-marshalling
+
+This product optionally depends on 'Caliper', Google's micro-
+benchmarking framework, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.caliper.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/google/caliper
+
+This product optionally depends on 'Apache Commons Logging', a logging
+framework, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.commons-logging.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://commons.apache.org/logging/
+
+This product optionally depends on 'Apache Log4J', a logging framework, which
+can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.log4j.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://logging.apache.org/log4j/
+
+This product optionally depends on 'Aalto XML', an ultra-high performance
+non-blocking XML processor, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.aalto-xml.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://wiki.fasterxml.com/AaltoHome
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Twitter. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.hpack.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/twitter/hpack
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Cory Benfield. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.hyper-hpack.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/python-hyper/hpack/
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Tatsuhiro Tsujikawa. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.nghttp2-hpack.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/nghttp2/nghttp2/
+
+This product contains a modified portion of 'Apache Commons Lang', a Java library
+provides utilities for the java.lang API, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.commons-lang.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://commons.apache.org/proper/commons-lang/
+
+
+This product contains the Maven wrapper scripts from 'Maven Wrapper', that provides an easy way to ensure a user has everything necessary to run the Maven build.
+
+ * LICENSE:
+ * license/LICENSE.mvn-wrapper.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/takari/maven-wrapper
+
+This product contains the dnsinfo.h header file, that provides a way to retrieve the system DNS configuration on MacOS.
+This private header is also used by Apple's open source
+ mDNSResponder (https://opensource.apple.com/tarballs/mDNSResponder/).
+
+ * LICENSE:
+ * license/LICENSE.dnsinfo.txt (Apple Public Source License 2.0)
+ * HOMEPAGE:
+ * https://www.opensource.apple.com/source/configd/configd-453.19/dnsinfo/dnsinfo.h
+
+This product optionally depends on 'Brotli4j', Brotli compression and
+decompression for Java., which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.brotli4j.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/hyperxpro/Brotli4j
diff --git a/README.md b/README.md
index 25b0d4754d7..a56816e0767 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,21 @@
-# Datastax Java Driver for Apache Cassandra
+# Java Driver for Apache Cassandra®
-[](https://travis-ci.org/datastax/java-driver)
+:warning: The java-driver has recently been donated by Datastax to The Apache Software Foundation and the Apache Cassandra project. Bear with us as we move assets and coordinates.
+
+[](https://opensource.org/licenses/Apache-2.0)
+[](https://maven-badges.herokuapp.com/maven-central/org.apache.cassandra/cassandra-driver-core)
*If you're reading this on github.com, please note that this is the readme
for the development version and that some features described here might
-not yet have been released. You can find the documentation for latest
-version through [Java driver
-docs](http://datastax.github.io/java-driver/) or via the release tags,
-[e.g.
-3.3.0](https://github.com/datastax/java-driver/tree/3.3.0).*
+not yet have been released. You can find the documentation for the latest
+version through the [Java Driver
+docs](http://docs.datastax.com/en/developer/java-driver/3.11/index.html) or via the release tags,
+[e.g. 3.12.1](https://github.com/apache/cassandra-java-driver/tree/3.12.1).*
A modern, [feature-rich](manual/) and highly tunable Java client
-library for Apache Cassandra (1.2+) and DataStax Enterprise (3.1+) using
-exclusively Cassandra's binary protocol and Cassandra Query Language v3.
+library for Apache Cassandra (2.1+) and using exclusively Cassandra's binary protocol
+and Cassandra Query Language v3. _Use the [DataStax Enterprise Java Driver][dse-driver]
+for better compatibility and support for DataStax Enterprise._
**Features:**
@@ -37,38 +40,32 @@ The driver contains the following modules:
- driver-core: the core layer.
- driver-mapping: the object mapper.
-- driver-extras: optional features for the Java driver.
+- driver-extras: optional features for the Java Driver.
- driver-examples: example applications using the other modules which are
only meant for demonstration purposes.
- driver-tests: tests for the java-driver.
**Useful links:**
-- JIRA (bug tracking): https://datastax-oss.atlassian.net/browse/JAVA
-- MAILING LIST: https://groups.google.com/a/lists.datastax.com/forum/#!forum/java-driver-user
-- IRC: #datastax-drivers on [irc.freenode.net](http://freenode.net)
-- TWITTER: [@dsJavaDriver](https://twitter.com/dsJavaDriver) tweets Java
- driver releases and important announcements (low frequency).
- [@DataStaxEng](https://twitter.com/datastaxeng) has more news including
- other drivers, Cassandra, and DSE.
-- DOCS: the [manual](http://docs.datastax.com/en/developer/java-driver/3.2/manual/) has quick
+- JIRA (bug tracking): https://issues.apache.org/jira/projects/CASSJAVA
+- MAILING LIST: https://cassandra.apache.org/_/community.html#discussions
+- DOCS: the [manual](http://docs.datastax.com/en/developer/java-driver/3.11/manual/) has quick
start material and technical details about the driver and its features.
-- API: http://www.datastax.com/drivers/java/3.2
+- API: https://docs.datastax.com/en/drivers/java/3.11
+- GITHUB REPOSITORY: https://github.com/apache/cassandra-java-driver
- [changelog](changelog/)
-- [binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.3.0.tar.gz)
-
-**Feeback requested:** help us focus our efforts, provide your input on the [Platform and Runtime Survey](http://goo.gl/forms/qwUE6qnL7U) (we kept it short).
## Getting the driver
The last release of the driver is available on Maven Central. You can install
-it in your application using the following Maven dependency:
+it in your application using the following Maven dependency (_if
+using DataStax Enterprise, install the [DataStax Enterprise Java Driver][dse-driver] instead_):
```xml
- com.datastax.cassandra
+ org.apache.cassandra
cassandra-driver-core
- 3.3.0
+ 3.12.1
```
@@ -76,9 +73,9 @@ Note that the object mapper is published as a separate artifact:
```xml
- com.datastax.cassandra
+ org.apache.cassandra
cassandra-driver-mapping
- 3.3.0
+ 3.12.1
```
@@ -86,9 +83,9 @@ The 'extras' module is also published as a separate artifact:
```xml
- com.datastax.cassandra
+ org.apache.cassandra
cassandra-driver-extras
- 3.3.0
+ 3.12.1
```
@@ -97,25 +94,25 @@ We also provide a [shaded JAR](manual/shaded_jar/)
to avoid the explicit dependency to Netty.
If you can't use a dependency management tool, a
-[binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.3.0.tar.gz)
+[binary tarball](https://cassandra.apache.org/_/download.html)
is available for download.
## Compatibility
-The Java client driver 3.3.0 ([branch 3.x](https://github.com/datastax/java-driver/tree/3.x)) is compatible with Apache
-Cassandra 1.2, 2.0, 2.1, 2.2 and 3.0 (see [this page](http://datastax.github.io/java-driver/manual/native_protocol) for
+The Java client driver 3.12.1 ([branch 3.x](https://github.com/apache/cassandra-java-driver/tree/3.x)) is compatible with Apache
+Cassandra 2.1, 2.2 and 3.0+ (see [this page](http://docs.datastax.com/en/developer/java-driver/3.11/manual/native_protocol/) for
the most up-to-date compatibility information).
UDT and tuple support is available only when using Apache Cassandra 2.1 or higher (see [CQL improvements in Cassandra 2.1](http://www.datastax.com/dev/blog/cql-in-2-1)).
Other features are available only when using Apache Cassandra 2.0 or higher (e.g. result set paging,
-[BatchStatement](https://github.com/datastax/java-driver/blob/3.x/driver-core/src/main/java/com/datastax/driver/core/BatchStatement.java),
+[BatchStatement](https://github.com/apache/cassandra-java-driver/blob/3.x/driver-core/src/main/java/com/datastax/driver/core/BatchStatement.java),
[lightweight transactions](http://www.datastax.com/documentation/cql/3.1/cql/cql_using/use_ltweight_transaction_t.html)
-- see [What's new in Cassandra 2.0](http://www.datastax.com/documentation/cassandra/2.0/cassandra/features/features_key_c.html)).
Trying to use these with a cluster running Cassandra 1.2 will result in
-an [UnsupportedFeatureException](https://github.com/datastax/java-driver/blob/3.x/driver-core/src/main/java/com/datastax/driver/core/exceptions/UnsupportedFeatureException.java) being thrown.
+an [UnsupportedFeatureException](https://github.com/apache/cassandra-java-driver/blob/3.x/driver-core/src/main/java/com/datastax/driver/core/exceptions/UnsupportedFeatureException.java) being thrown.
-__Note__: DataStax products do not support big-endian systems.
+The java driver supports Java JDK versions 6 and above.
## Upgrading from previous versions
@@ -123,23 +120,11 @@ If you are upgrading from a previous version of the driver, be sure to have a lo
the [upgrade guide](/upgrade_guide/).
-### Troubleshooting
-
-If you are having issues connecting to the cluster (seeing `NoHostAvailableConnection` exceptions) please check the
-[connection requirements](https://github.com/datastax/java-driver/wiki/Connection-requirements).
-
-
-## License
-Copyright 2012-2015, DataStax
+----
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
+Apache Cassandra, Apache, Tomcat, Lucene, Solr, Hadoop, Spark, TinkerPop, and Cassandra are
+trademarks of the [Apache Software Foundation](http://www.apache.org/) or its subsidiaries in
+Canada, the United States and/or other countries.
-http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+Binary artifacts of this product bundle Java Native Runtime libraries, which is available under the Eclipse Public License version 2.0.
diff --git a/build.yaml b/build.yaml
deleted file mode 100644
index 956c97fe3b2..00000000000
--- a/build.yaml
+++ /dev/null
@@ -1,84 +0,0 @@
-schedules:
- commit:
- # Run short suite on commit with enough C* versions to get full protocol version coverage.
- schedule: per_commit
- matrix:
- exclude:
- # Exclude all java 7 builds
- - java: oraclejdk7
- # Exclude java6 with all versions except latest
- - java: openjdk6
- cassandra: ['1.2', '2.0', '2.1', '2.2', '3.0']
- env_vars: |
- TEST_GROUP="short"
- disable_commit_status: true
- nightly:
- # Run full suite nightly on change for all primary branches if they have changes.
- schedule: nightly
- branches:
- # regex matches primary branch format (2.1, 3.x, 3.0.x, 3.1.x, etc).
- include: ["/\\d+(\\.[\\dx]+)+/"]
- env_vars: |
- TEST_GROUP="long"
- disable_commit_status: true
- adhoc:
- # Adhoc job for non-primary braches that doesn't have a schedule but may be used to run all configs.
- schedule: adhoc
- branches:
- # regex matches primary branch format (2.1, 3.x, 3.0.x, 3.1.x, etc).
- exclude: ["/\\d+(\\.[\\dx]+)+/"]
- env_vars: |
- TEST_GROUP="long"
- disable_commit_status: true
-java:
- - openjdk6
- - oraclejdk7
- - oraclejdk8
-os:
- - ubuntu/trusty64/m3.large
-cassandra:
- - '1.2'
- - '2.0'
- - '2.1'
- - '2.2'
- - '3.0'
- - '3.10'
-build:
- - script: |
- . /usr/local/bin/jdk_switcher.sh
- jdk_switcher use oraclejdk8
- export MAVEN_HOME=/home/jenkins/.mvn/apache-maven-3.2.5
- export PATH=$MAVEN_HOME/bin:$PATH
- mvn -B -V install -DskipTests
- - script: |
- . /usr/local/bin/jdk_switcher.sh
- jdk_switcher use $JAVA_VERSION
- - type: maven
- version: 3.2.5
- goals: verify --fail-never -P$TEST_GROUP
- properties: |
- com.datastax.driver.TEST_BASE_NODE_WAIT=120
- com.datastax.driver.NEW_NODE_DELAY_SECONDS=100
- cassandra.version=$CCM_CASSANDRA_VERSION
- ccm.java.home=$CCM_JAVA_HOME
- ccm.path=$CCM_JAVA_HOME/bin
- ccm.maxNumberOfNodes=3
- failIfNoTests=false
- maven.test.failure.ignore=true
- maven.javadoc.skip=true
- - type: maven
- version: 3.2.5
- goals: verify --fail-never -Pisolated
- properties: |
- com.datastax.driver.TEST_BASE_NODE_WAIT=120
- com.datastax.driver.NEW_NODE_DELAY_SECONDS=100
- cassandra.version=$CCM_CASSANDRA_VERSION
- ccm.java.home=$CCM_JAVA_HOME
- ccm.path=$CCM_JAVA_HOME/bin
- ccm.maxNumberOfNodes=3
- failIfNoTests=false
- maven.test.failure.ignore=true
- maven.javadoc.skip=true
- - xunit:
- - "**/target/surefire-reports/TEST-*.xml"
- - "**/target/failsafe-reports/TEST-*.xml"
diff --git a/changelog/README.md b/changelog/README.md
index 3320ae0f026..c8c12cffdbf 100644
--- a/changelog/README.md
+++ b/changelog/README.md
@@ -1,5 +1,257 @@
+
+
## Changelog
+
+
+## 3.12.1
+- [improvement] CASSJAVA-55: Remove setting "Host" header for metadata requests.
+- [bug] JAVA-3125: Match broadcast RPC for control connection and Astra events
+
+## 3.12.0
+- [improvement] CASSANDRA-18971: Switch all archs to netty-tcnative-boringssl-static
+- [improvement] CASSJAVA-58: Update 3.x DRIVER_NAME to match 4.x Java driver
+
+## 3.11.5
+- [improvement] JAVA-3114: Shade io.dropwizard.metrics:metrics-core in shaded driver
+- [improvement] JAVA-3115: SchemaChangeListener#onKeyspaceChanged can fire when keyspace has not changed if using SimpleStrategy replication
+
+## 3.11.4
+- [improvement] JAVA-3079: Upgrade Netty to 4.1.94, 3.x edition
+- [improvement] JAVA-3082: Fix maven build for Apple-silicon
+- [improvement] PR 1671: Fix LatencyAwarePolicy scale docstring
+
+## 3.11.3
+- [improvement] JAVA-3023: Upgrade Netty to 4.1.77, 3.x edition
+
+
+## 3.11.2
+- [improvement] JAVA-3008: Upgrade Netty to 4.1.75, 3.x edition
+- [improvement] JAVA-2984: Upgrade Jackson to resolve high-priority CVEs
+
+
+## 3.11.1
+- [bug] JAVA-2967: Support native transport peer information for DSE 6.8.
+- [bug] JAVA-2976: Support missing protocol v5 error codes CAS_WRITE_UNKNOWN, CDC_WRITE_FAILURE.
+
+
+## 3.11.0
+
+- [improvement] JAVA-2705: Remove protocol v5 beta status, add v6-beta.
+- [bug] JAVA-2923: Detect and use Guava's new HostAndPort.getHost method.
+- [bug] JAVA-2922: Switch to modern framing format inside a channel handler.
+- [bug] JAVA-2924: Consider protocol version unsupported when server requires USE_BETA flag for it.
+
+
+## 3.10.2
+
+- [bug] JAVA-2860: Avoid NPE if channel initialization crashes.
+
+
+## 3.10.1
+
+- [bug] JAVA-2857: Fix NPE when built statements without parameters are logged at TRACE level.
+- [bug] JAVA-2843: Successfully parse DSE table schema in OSS driver.
+
+
+## 3.10.0
+
+- [improvement] JAVA-2676: Don't reschedule flusher after empty runs.
+- [new feature] JAVA-2772: Support new protocol v5 message format.
+
+
+## 3.9.0
+
+- [bug] JAVA-2627: Avoid logging error message including stack trace in request handler.
+- [new feature] JAVA-2706: Add now_in_seconds to protocol v5 query messages.
+- [improvement] JAVA-2730: Add support for Cassandra® 4.0 table options
+- [improvement] JAVA-2702: Transient Replication Support for Cassandra® 4.0
+
+
+## 3.8.0
+
+- [new feature] JAVA-2356: Support for DataStax Cloud API.
+- [improvement] JAVA-2483: Allow to provide secure bundle via URL.
+- [improvement] JAVA-2499: Allow to read the secure bundle from an InputStream.
+- [improvement] JAVA-2457: Detect CaaS and change default consistency.
+- [improvement] JAVA-2485: Add errors for Cloud misconfiguration.
+- [documentation] JAVA-2504: Migrate Cloud "getting started" page to driver manual.
+- [improvement] JAVA-2516: Enable hostname validation with Cloud
+- [bug] JAVA-2515: NEW_NODE and REMOVED_NODE events should trigger ADDED and REMOVED.
+
+
+### 3.7.2
+
+- [bug] JAVA-2249: Stop stripping trailing zeros in ByteOrderedTokens.
+- [bug] JAVA-1492: Don't immediately reuse busy connections for another request.
+- [bug] JAVA-2198: Handle UDTs with names that clash with collection types.
+- [bug] JAVA-2204: Avoid memory leak when client holds onto a stale TableMetadata instance.
+
+
+### 3.7.1
+
+- [bug] JAVA-2174: Metadata.needsQuote should accept empty strings.
+- [bug] JAVA-2193: Fix flaky tests in WarningsTest.
+
+
+### 3.7.0
+
+- [improvement] JAVA-2025: Include exception message in Abstract\*Codec.accepts(null).
+- [improvement] JAVA-1980: Use covariant return types in RemoteEndpointAwareJdkSSLOptions.Builder methods.
+- [documentation] JAVA-2062: Document frozen collection preference with Mapper.
+- [bug] JAVA-2071: Fix NPE in ArrayBackedRow.toString().
+- [bug] JAVA-2070: Call onRemove instead of onDown when rack and/or DC information changes for a host.
+- [improvement] JAVA-1256: Log parameters of BuiltStatement in QueryLogger.
+- [documentation] JAVA-2074: Document preference for LZ4 over Snappy.
+- [bug] JAVA-1612: Include netty-common jar in binary tarball.
+- [improvement] JAVA-2003: Simplify CBUtil internal API to improve performance.
+- [improvement] JAVA-2002: Reimplement TypeCodec.accepts to improve performance.
+- [documentation] JAVA-2041: Deprecate cross-DC failover in DCAwareRoundRobinPolicy.
+- [documentation] JAVA-1159: Document workaround for using tuple with udt field in Mapper.
+- [documentation] JAVA-1964: Complete remaining "Coming Soon" sections in docs.
+- [improvement] JAVA-1950: Log server side warnings returned from a query.
+- [improvement] JAVA-2123: Allow to use QueryBuilder for building queries against Materialized Views.
+- [bug] JAVA-2082: Avoid race condition during cluster close and schema refresh.
+
+
+### 3.6.0
+
+- [improvement] JAVA-1394: Add request-queue-depth metric.
+- [improvement] JAVA-1857: Add Statement.setHost.
+- [bug] JAVA-1920: Use nanosecond precision in LocalTimeCodec#format().
+- [bug] JAVA-1794: Driver tries to create a connection array of size -1.
+- [new feature] JAVA-1899: Support virtual tables.
+- [bug] JAVA-1908: TableMetadata.asCQLQuery does not add table option 'memtable_flush_period_in_ms' in the generated query.
+- [bug] JAVA-1924: StatementWrapper setters should return the wrapping statement.
+- [new feature] JAVA-1532: Add Codec support for Java 8's LocalDateTime and ZoneId.
+- [improvement] JAVA-1786: Use Google code formatter.
+- [bug] JAVA-1871: Change LOCAL\_SERIAL.isDCLocal() to return true.
+- [documentation] JAVA-1902: Clarify unavailable & request error in DefaultRetryPolicy javadoc.
+- [new feature] JAVA-1903: Add WhiteListPolicy.ofHosts.
+- [bug] JAVA-1928: Fix GuavaCompatibility for Guava 26.
+- [bug] JAVA-1935: Add null check in QueryConsistencyException.getHost.
+- [improvement] JAVA-1771: Send driver name and version in STARTUP message.
+- [improvement] JAVA-1388: Add dynamic port discovery for system.peers\_v2.
+- [documentation] JAVA-1810: Note which setters are not propagated to PreparedStatement.
+- [bug] JAVA-1944: Surface Read and WriteFailureException to RetryPolicy.
+- [bug] JAVA-1211: Fix NPE in cluster close when cluster init fails.
+- [bug] JAVA-1220: Fail fast on cluster init if previous init failed.
+- [bug] JAVA-1929: Preempt session execute queries if session was closed.
+
+Merged from 3.5.x:
+
+- [bug] JAVA-1872: Retain table's views when processing table update.
+
+
+### 3.5.0
+
+- [improvement] JAVA-1448: TokenAwarePolicy should respect child policy ordering.
+- [bug] JAVA-1751: Include defaultTimestamp length in encodedSize for protocol version >= 3.
+- [bug] JAVA-1770: Fix message size when using Custom Payload.
+- [documentation] JAVA-1760: Add metrics documentation.
+- [improvement] JAVA-1765: Update dependencies to latest patch versions.
+- [improvement] JAVA-1752: Deprecate DowngradingConsistencyRetryPolicy.
+- [improvement] JAVA-1735: Log driver version on first use.
+- [documentation] JAVA-1380: Add FAQ entry for errors arising from incompatibilities.
+- [improvement] JAVA-1748: Support IS NOT NULL and != in query builder.
+- [documentation] JAVA-1740: Mention C*2.2/3.0 incompatibilities in paging state manual.
+- [improvement] JAVA-1725: Add a getNodeCount method to CCMAccess for easier automation.
+- [new feature] JAVA-708: Add means to measure request sizes.
+- [documentation] JAVA-1788: Add example for enabling host name verification to SSL docs.
+- [improvement] JAVA-1791: Revert "JAVA-1677: Warn if auth is configured on the client but not the server."
+- [bug] JAVA-1789: Account for flags in Prepare encodedSize.
+- [bug] JAVA-1797: Use jnr-ffi version required by jnr-posix.
+
+
+### 3.4.0
+
+- [improvement] JAVA-1671: Remove unnecessary test on prepared statement metadata.
+- [bug] JAVA-1694: Upgrade to jackson-databind 2.7.9.2 to address CVE-2015-15095.
+- [documentation] JAVA-1685: Clarify recommendation on preparing SELECT *.
+- [improvement] JAVA-1679: Improve error message on batch log write timeout.
+- [improvement] JAVA-1672: Remove schema agreement check when repreparing on up.
+- [improvement] JAVA-1677: Warn if auth is configured on the client but not the server.
+- [new feature] JAVA-1651: Add NO_COMPACT startup option.
+- [improvement] JAVA-1683: Add metrics to track writes to nodes.
+- [new feature] JAVA-1229: Allow specifying the keyspace for individual queries.
+- [improvement] JAVA-1682: Provide a way to record latencies for cancelled speculative executions.
+- [improvement] JAVA-1717: Add metrics to latency-aware policy.
+- [improvement] JAVA-1675: Remove dates from copyright headers.
+
+Merged from 3.3.x:
+
+- [bug] JAVA-1555: Include VIEW and CDC in WriteType.
+- [bug] JAVA-1599: exportAsString improvements (sort, format, clustering order)
+- [improvement] JAVA-1587: Deterministic ordering of columns used in Mapper#saveQuery
+- [improvement] JAVA-1500: Add a metric to report number of in-flight requests.
+- [bug] JAVA-1438: QueryBuilder check for empty orderings.
+- [improvement] JAVA-1490: Allow zero delay for speculative executions.
+- [documentation] JAVA-1607: Add FAQ entry for netty-transport-native-epoll.
+- [bug] JAVA-1630: Fix Metadata.addIfAbsent.
+- [improvement] JAVA-1619: Update QueryBuilder methods to support Iterable input.
+- [improvement] JAVA-1527: Expose host_id and schema_version on Host metadata.
+- [new feature] JAVA-1377: Add support for TWCS in SchemaBuilder.
+- [improvement] JAVA-1631: Publish a sources jar for driver-core-tests.
+- [improvement] JAVA-1632: Add a withIpPrefix(String) method to CCMBridge.Builder.
+- [bug] JAVA-1639: VersionNumber does not fullfill equals/hashcode contract.
+- [bug] JAVA-1613: Fix broken shaded Netty detection in NettyUtil.
+- [bug] JAVA-1666: Fix keyspace export when a UDT has case-sensitive field names.
+- [improvement] JAVA-1196: Include hash of result set metadata in prepared statement id.
+- [improvement] JAVA-1670: Support user-provided JMX ports for CCMBridge.
+- [improvement] JAVA-1661: Avoid String.toLowerCase if possible in Metadata.
+- [improvement] JAVA-1659: Expose low-level flusher tuning options.
+- [improvement] JAVA-1660: Support netty-transport-native-epoll in OSGi container.
+
+
+### 3.3.2
+
+- [bug] JAVA-1666: Fix keyspace export when a UDT has case-sensitive field names.
+- [improvement] JAVA-1196: Include hash of result set metadata in prepared statement id.
+- [improvement] JAVA-1670: Support user-provided JMX ports for CCMBridge.
+- [improvement] JAVA-1661: Avoid String.toLowerCase if possible in Metadata.
+- [improvement] JAVA-1659: Expose low-level flusher tuning options.
+- [improvement] JAVA-1660: Support netty-transport-native-epoll in OSGi container.
+
+
+### 3.3.1
+
+- [bug] JAVA-1555: Include VIEW and CDC in WriteType.
+- [bug] JAVA-1599: exportAsString improvements (sort, format, clustering order)
+- [improvement] JAVA-1587: Deterministic ordering of columns used in Mapper#saveQuery
+- [improvement] JAVA-1500: Add a metric to report number of in-flight requests.
+- [bug] JAVA-1438: QueryBuilder check for empty orderings.
+- [improvement] JAVA-1490: Allow zero delay for speculative executions.
+- [documentation] JAVA-1607: Add FAQ entry for netty-transport-native-epoll.
+- [bug] JAVA-1630: Fix Metadata.addIfAbsent.
+- [improvement] JAVA-1619: Update QueryBuilder methods to support Iterable input.
+- [improvement] JAVA-1527: Expose host_id and schema_version on Host metadata.
+- [new feature] JAVA-1377: Add support for TWCS in SchemaBuilder.
+- [improvement] JAVA-1631: Publish a sources jar for driver-core-tests.
+- [improvement] JAVA-1632: Add a withIpPrefix(String) method to CCMBridge.Builder.
+- [bug] JAVA-1639: VersionNumber does not fullfill equals/hashcode contract.
+- [bug] JAVA-1613: Fix broken shaded Netty detection in NettyUtil.
+
+
### 3.3.0
- [bug] JAVA-1469: Update LoggingRetryPolicy to deal with SLF4J-353.
diff --git a/ci/appveyor.ps1 b/ci/appveyor.ps1
index bc1d95b69f7..c0db375e05c 100644
--- a/ci/appveyor.ps1
+++ b/ci/appveyor.ps1
@@ -1,3 +1,22 @@
+<#
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied. See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+ #>
+
Add-Type -AssemblyName System.IO.Compression.FileSystem
$dep_dir="C:\Users\appveyor\deps"
diff --git a/ci/appveyor.yml b/ci/appveyor.yml
index 81dd5b01958..bd621defb76 100644
--- a/ci/appveyor.yml
+++ b/ci/appveyor.yml
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
environment:
test_profile: default
matrix:
diff --git a/ci/create-user.sh b/ci/create-user.sh
new file mode 100644
index 00000000000..fb193df9a00
--- /dev/null
+++ b/ci/create-user.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+################################
+#
+# Prep
+#
+################################
+
+if [ "$1" == "-h" ]; then
+ echo "$0 [-h] "
+ echo " this script is used internally by other scripts in the same directory to create a user with the running host user's same uid and gid"
+ exit 1
+fi
+
+# arguments
+username=$1
+uid=$2
+gid=$3
+BUILD_HOME=$4
+
+################################
+#
+# Main
+#
+################################
+
+# disable git directory ownership checks
+su ${username} -c "git config --global safe.directory '*'"
+
+if grep "^ID=" /etc/os-release | grep -q 'debian\|ubuntu' ; then
+ deluser docker
+ adduser --quiet --disabled-login --no-create-home --uid $uid --gecos ${username} ${username}
+ groupmod --non-unique -g $gid $username
+ gpasswd -a ${username} sudo >/dev/null
+else
+ adduser --no-create-home --uid $uid ${username}
+fi
+
+# sudo priviledges
+echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username}
+chmod 0440 /etc/sudoers.d/${username}
+
+# proper permissions
+chown -R ${username}:${username} /home/docker
+chmod og+wx ${BUILD_HOME}
\ No newline at end of file
diff --git a/ci/run-tests.sh b/ci/run-tests.sh
new file mode 100755
index 00000000000..b1bf201442b
--- /dev/null
+++ b/ci/run-tests.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+
+. ~/env.txt
+printenv | sort
+cd $(dirname "$(readlink -f "$0")")/..
+mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true
+jabba use ${TEST_JAVA_VERSION}
+printenv | sort
+mvn -B -V verify -T 1 -Dcassandra.version=${SERVER_VERSION} -Ddse=false -Dmaven.test.failure.ignore=true -Dmaven.javadoc.skip=true;
diff --git a/ci/uploadtests.ps1 b/ci/uploadtests.ps1
index cf88b16229c..aaf7279ed46 100644
--- a/ci/uploadtests.ps1
+++ b/ci/uploadtests.ps1
@@ -1,3 +1,22 @@
+<#
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied. See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+ #>
+
$testResults=Get-ChildItem TEST-TestSuite.xml -Recurse
Write-Host "Uploading test results."
diff --git a/clirr-ignores.xml b/clirr-ignores.xml
index 5b59573cc25..271bd6f7773 100644
--- a/clirr-ignores.xml
+++ b/clirr-ignores.xml
@@ -1,3 +1,23 @@
+
+
+
com/datastax/driver/core/FrameCompressor$LZ4Compressor
False positive, the enclosing class is package-private so this was never exposed
+
+ 7005
+ com/datastax/driver/core/querybuilder/QueryBuilder
+
+ *
+ *
+ Relaxed parameters from List to Iterable for in, lt, lte, eq, gt, and gte
+
+
+ 7005
+ com/datastax/driver/core/exceptions/AlreadyExistsException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/AuthenticationException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/BootstrappingException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/BusyConnectionException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/BusyPoolException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 6001
+ com/datastax/driver/core/exceptions/ConnectionException
+ address
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/ConnectionException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7012
+ com/datastax/driver/core/exceptions/CoordinatorException
+ com.datastax.driver.core.EndPoint getEndPoint()
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/FunctionExecutionException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/InvalidConfigurationInQueryException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/InvalidQueryException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/OperationTimedOutException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/OperationTimedOutException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/OverloadedException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/ProtocolError
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/QueryConsistencyException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/ReadFailureException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/ReadTimeoutException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/ServerError
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/SyntaxError
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/TransportException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/TruncateException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/UnauthorizedException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/UnavailableException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/UnpreparedException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/UnsupportedProtocolVersionException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/WriteFailureException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
+
+ 7005
+ com/datastax/driver/core/exceptions/WriteTimeoutException
+ *java.net.InetSocketAddress*
+ *com.datastax.driver.core.EndPoint*
+ JAVA-2355: Abstract connection information into new EndPoint type for sni support
+
diff --git a/docs.yaml b/docs.yaml
index 8b47643224b..4b30dcd5813 100644
--- a/docs.yaml
+++ b/docs.yaml
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
title: Java Driver for Apache Cassandra
summary: High performance Java client for Apache Cassandra
homepage: http://datastax.github.io/java-driver/
@@ -33,7 +50,7 @@ sections:
files: 'faq/**/*.md'
links:
- title: Code
- href: https://github.com/datastax/java-driver/
+ href: https://github.com/apache/cassandra-java-driver/
- title: Docs
href: http://docs.datastax.com/en/developer/java-driver/
- title: Issues
@@ -54,7 +71,7 @@ versions:
- name: '3.3'
ref: '3.3.0'
- name: '4.0-alpha'
- ref: '4.0.0-alpha1'
+ ref: '9f0edeb'
- name: '3.2'
ref: '3.2_docfixes'
- name: '3.1'
diff --git a/doxyfile b/doxyfile
index 414bdbd7ec4..d64c6fe1d82 100644
--- a/doxyfile
+++ b/doxyfile
@@ -1,10 +1,30 @@
+
+
+
# Doxyfile 1.8.10
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
-PROJECT_NAME = "DataStax Java Driver"
+PROJECT_NAME = "Java Driver"
PROJECT_NUMBER =
PROJECT_BRIEF =
PROJECT_LOGO =
@@ -333,4 +353,4 @@ MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
\ No newline at end of file
+DOT_CLEANUP = YES
diff --git a/driver-core/pom.xml b/driver-core/pom.xml
index 0cb71e8ef08..45aff62c17d 100644
--- a/driver-core/pom.xml
+++ b/driver-core/pom.xml
@@ -1,12 +1,14 @@
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-test-sources
+
+ test-jar-no-fork
+
+
+
+
org.apache.felix
maven-bundle-plugin
@@ -216,7 +250,7 @@
${project.build.outputDirectory}/META-INF
-
+
@@ -234,8 +268,9 @@
JNR does not provide OSGi bundles, so exclude it; the driver can live without it
Explicitly import javax.security.cert because it's required by Netty, but Netty has been explicitly excluded
-->
-
+
com.datastax.shaded.*
+ com.datastax.shaded.metrics;*
@@ -249,6 +284,7 @@
io.netty:*
+ io.dropwizard.metrics:metrics-core
io.netty:netty-transport-native-epoll
@@ -259,6 +295,10 @@
io.netty
com.datastax.shaded.netty
+
+ com.codahale.metrics
+ com.datastax.shaded.metrics
+
@@ -275,6 +315,8 @@
META-INF/maven/io.netty/netty-handler/pom.xml
META-INF/maven/io.netty/netty-transport/pom.properties
META-INF/maven/io.netty/netty-transport/pom.xml
+ META-INF/maven/io.dropwizard.metrics/metrics-core/pom.properties
+ META-INF/maven/io.dropwizard.metrics/metrics-core/pom.xml
diff --git a/driver-core/src/main/java/com/datastax/driver/core/AbstractAddressableByIndexData.java b/driver-core/src/main/java/com/datastax/driver/core/AbstractAddressableByIndexData.java
index 3cc9fb75592..689b41d0b25 100644
--- a/driver-core/src/main/java/com/datastax/driver/core/AbstractAddressableByIndexData.java
+++ b/driver-core/src/main/java/com/datastax/driver/core/AbstractAddressableByIndexData.java
@@ -1,11 +1,13 @@
/*
- * Copyright (C) 2012-2017 DataStax Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,281 +19,275 @@
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.reflect.TypeToken;
-
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.ByteBuffer;
-import java.util.*;
-
-abstract class AbstractAddressableByIndexData> extends AbstractGettableByIndexData implements SettableByIndexData {
-
- final ByteBuffer[] values;
-
- protected AbstractAddressableByIndexData(ProtocolVersion protocolVersion, int size) {
- super(protocolVersion);
- this.values = new ByteBuffer[size];
- }
-
- @SuppressWarnings("unchecked")
- protected T setValue(int i, ByteBuffer value) {
- values[i] = value;
- return (T) this;
- }
-
- @Override
- protected ByteBuffer getValue(int i) {
- return values[i];
- }
-
- @Override
- public T setBool(int i, boolean v) {
- TypeCodec codec = codecFor(i, Boolean.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveBooleanCodec)
- bb = ((TypeCodec.PrimitiveBooleanCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setByte(int i, byte v) {
- TypeCodec codec = codecFor(i, Byte.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveByteCodec)
- bb = ((TypeCodec.PrimitiveByteCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setShort(int i, short v) {
- TypeCodec codec = codecFor(i, Short.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveShortCodec)
- bb = ((TypeCodec.PrimitiveShortCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setInt(int i, int v) {
- TypeCodec codec = codecFor(i, Integer.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveIntCodec)
- bb = ((TypeCodec.PrimitiveIntCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setLong(int i, long v) {
- TypeCodec codec = codecFor(i, Long.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveLongCodec)
- bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setTimestamp(int i, Date v) {
- return setValue(i, codecFor(i, Date.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setDate(int i, LocalDate v) {
- return setValue(i, codecFor(i, LocalDate.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setTime(int i, long v) {
- TypeCodec codec = codecFor(i, Long.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveLongCodec)
- bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setFloat(int i, float v) {
- TypeCodec codec = codecFor(i, Float.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveFloatCodec)
- bb = ((TypeCodec.PrimitiveFloatCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setDouble(int i, double v) {
- TypeCodec codec = codecFor(i, Double.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveDoubleCodec)
- bb = ((TypeCodec.PrimitiveDoubleCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setString(int i, String v) {
- return setValue(i, codecFor(i, String.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setBytes(int i, ByteBuffer v) {
- return setValue(i, codecFor(i, ByteBuffer.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setBytesUnsafe(int i, ByteBuffer v) {
- return setValue(i, v == null ? null : v.duplicate());
- }
-
- @Override
- public T setVarint(int i, BigInteger v) {
- return setValue(i, codecFor(i, BigInteger.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setDecimal(int i, BigDecimal v) {
- return setValue(i, codecFor(i, BigDecimal.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setUUID(int i, UUID v) {
- return setValue(i, codecFor(i, UUID.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setInet(int i, InetAddress v) {
- return setValue(i, codecFor(i, InetAddress.class).serialize(v, protocolVersion));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T setList(int i, List v) {
- return setValue(i, codecFor(i).serialize(v, protocolVersion));
- }
-
- @Override
- public T setList(int i, List v, Class elementsClass) {
- return setValue(i, codecFor(i, TypeTokens.listOf(elementsClass)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setList(int i, List v, TypeToken elementsType) {
- return setValue(i, codecFor(i, TypeTokens.listOf(elementsType)).serialize(v, protocolVersion));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T setMap(int i, Map v) {
- return setValue(i, codecFor(i).serialize(v, protocolVersion));
- }
-
- @Override
- public T setMap(int i, Map v, Class keysClass, Class valuesClass) {
- return setValue(i, codecFor(i, TypeTokens.mapOf(keysClass, valuesClass)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setMap(int i, Map v, TypeToken keysType, TypeToken valuesType) {
- return setValue(i, codecFor(i, TypeTokens.mapOf(keysType, valuesType)).serialize(v, protocolVersion));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T setSet(int i, Set v) {
- return setValue(i, codecFor(i).serialize(v, protocolVersion));
- }
-
- @Override
- public T setSet(int i, Set v, Class elementsClass) {
- return setValue(i, codecFor(i, TypeTokens.setOf(elementsClass)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setSet(int i, Set v, TypeToken elementsType) {
- return setValue(i, codecFor(i, TypeTokens.setOf(elementsType)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setUDTValue(int i, UDTValue v) {
- return setValue(i, codecFor(i, UDTValue.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setTupleValue(int i, TupleValue v) {
- return setValue(i, codecFor(i, TupleValue.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T set(int i, V v, Class targetClass) {
- return set(i, v, codecFor(i, targetClass));
- }
-
- @Override
- public T set(int i, V v, TypeToken targetType) {
- return set(i, v, codecFor(i, targetType));
- }
-
- @Override
- public T set(int i, V v, TypeCodec codec) {
- checkType(i, codec.getCqlType().getName());
- return setValue(i, codec.serialize(v, protocolVersion));
- }
-
- @Override
- public T setToNull(int i) {
- return setValue(i, null);
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof AbstractAddressableByIndexData))
- return false;
-
- AbstractAddressableByIndexData> that = (AbstractAddressableByIndexData>) o;
- if (values.length != that.values.length)
- return false;
-
- if (this.protocolVersion != that.protocolVersion)
- return false;
-
- // Deserializing each value is slightly inefficient, but comparing
- // the bytes could in theory be wrong (for varint for instance, 2 values
- // can have different binary representation but be the same value due to
- // leading zeros). So we don't take any risk.
- for (int i = 0; i < values.length; i++) {
- DataType thisType = getType(i);
- DataType thatType = that.getType(i);
- if (!thisType.equals(thatType))
- return false;
-
- Object thisValue = this.codecFor(i).deserialize(this.values[i], this.protocolVersion);
- Object thatValue = that.codecFor(i).deserialize(that.values[i], that.protocolVersion);
- if (!MoreObjects.equal(thisValue, thatValue))
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- // Same as equals
- int hash = 31;
- for (int i = 0; i < values.length; i++)
- hash += values[i] == null ? 1 : codecFor(i).deserialize(values[i], protocolVersion).hashCode();
- return hash;
- }
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+abstract class AbstractAddressableByIndexData>
+ extends AbstractGettableByIndexData implements SettableByIndexData {
+
+ final ByteBuffer[] values;
+
+ protected AbstractAddressableByIndexData(ProtocolVersion protocolVersion, int size) {
+ super(protocolVersion);
+ this.values = new ByteBuffer[size];
+ }
+
+ @SuppressWarnings("unchecked")
+ protected T setValue(int i, ByteBuffer value) {
+ values[i] = value;
+ return (T) this;
+ }
+
+ @Override
+ protected ByteBuffer getValue(int i) {
+ return values[i];
+ }
+
+ @Override
+ public T setBool(int i, boolean v) {
+ TypeCodec codec = codecFor(i, Boolean.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveBooleanCodec)
+ bb = ((TypeCodec.PrimitiveBooleanCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setByte(int i, byte v) {
+ TypeCodec codec = codecFor(i, Byte.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveByteCodec)
+ bb = ((TypeCodec.PrimitiveByteCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setShort(int i, short v) {
+ TypeCodec codec = codecFor(i, Short.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveShortCodec)
+ bb = ((TypeCodec.PrimitiveShortCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setInt(int i, int v) {
+ TypeCodec codec = codecFor(i, Integer.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveIntCodec)
+ bb = ((TypeCodec.PrimitiveIntCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setLong(int i, long v) {
+ TypeCodec codec = codecFor(i, Long.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveLongCodec)
+ bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setTimestamp(int i, Date v) {
+ return setValue(i, codecFor(i, Date.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setDate(int i, LocalDate v) {
+ return setValue(i, codecFor(i, LocalDate.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setTime(int i, long v) {
+ TypeCodec codec = codecFor(i, Long.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveLongCodec)
+ bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setFloat(int i, float v) {
+ TypeCodec codec = codecFor(i, Float.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveFloatCodec)
+ bb = ((TypeCodec.PrimitiveFloatCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setDouble(int i, double v) {
+ TypeCodec codec = codecFor(i, Double.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveDoubleCodec)
+ bb = ((TypeCodec.PrimitiveDoubleCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setString(int i, String v) {
+ return setValue(i, codecFor(i, String.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setBytes(int i, ByteBuffer v) {
+ return setValue(i, codecFor(i, ByteBuffer.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setBytesUnsafe(int i, ByteBuffer v) {
+ return setValue(i, v == null ? null : v.duplicate());
+ }
+
+ @Override
+ public T setVarint(int i, BigInteger v) {
+ return setValue(i, codecFor(i, BigInteger.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setDecimal(int i, BigDecimal v) {
+ return setValue(i, codecFor(i, BigDecimal.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setUUID(int i, UUID v) {
+ return setValue(i, codecFor(i, UUID.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setInet(int i, InetAddress v) {
+ return setValue(i, codecFor(i, InetAddress.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T setList(int i, List v) {
+ return setValue(i, codecFor(i).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setList(int i, List v, Class elementsClass) {
+ return setValue(i, codecFor(i, TypeTokens.listOf(elementsClass)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setList(int i, List v, TypeToken elementsType) {
+ return setValue(i, codecFor(i, TypeTokens.listOf(elementsType)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T setMap(int i, Map v) {
+ return setValue(i, codecFor(i).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setMap(int i, Map v, Class keysClass, Class valuesClass) {
+ return setValue(
+ i, codecFor(i, TypeTokens.mapOf(keysClass, valuesClass)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setMap(int i, Map v, TypeToken keysType, TypeToken valuesType) {
+ return setValue(
+ i, codecFor(i, TypeTokens.mapOf(keysType, valuesType)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T setSet(int i, Set v) {
+ return setValue(i, codecFor(i).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setSet(int i, Set v, Class elementsClass) {
+ return setValue(i, codecFor(i, TypeTokens.setOf(elementsClass)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setSet(int i, Set v, TypeToken elementsType) {
+ return setValue(i, codecFor(i, TypeTokens.setOf(elementsType)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setUDTValue(int i, UDTValue v) {
+ return setValue(i, codecFor(i, UDTValue.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setTupleValue(int i, TupleValue v) {
+ return setValue(i, codecFor(i, TupleValue.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T set(int i, V v, Class targetClass) {
+ return set(i, v, codecFor(i, targetClass));
+ }
+
+ @Override
+ public T set(int i, V v, TypeToken targetType) {
+ return set(i, v, codecFor(i, targetType));
+ }
+
+ @Override
+ public T set(int i, V v, TypeCodec codec) {
+ checkType(i, codec.getCqlType().getName());
+ return setValue(i, codec.serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setToNull(int i) {
+ return setValue(i, null);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof AbstractAddressableByIndexData)) return false;
+
+ AbstractAddressableByIndexData> that = (AbstractAddressableByIndexData>) o;
+ if (values.length != that.values.length) return false;
+
+ if (this.protocolVersion != that.protocolVersion) return false;
+
+ // Deserializing each value is slightly inefficient, but comparing
+ // the bytes could in theory be wrong (for varint for instance, 2 values
+ // can have different binary representation but be the same value due to
+ // leading zeros). So we don't take any risk.
+ for (int i = 0; i < values.length; i++) {
+ DataType thisType = getType(i);
+ DataType thatType = that.getType(i);
+ if (!thisType.equals(thatType)) return false;
+
+ Object thisValue = this.codecFor(i).deserialize(this.values[i], this.protocolVersion);
+ Object thatValue = that.codecFor(i).deserialize(that.values[i], that.protocolVersion);
+ if (!MoreObjects.equal(thisValue, thatValue)) return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ // Same as equals
+ int hash = 31;
+ for (int i = 0; i < values.length; i++)
+ hash +=
+ values[i] == null ? 1 : codecFor(i).deserialize(values[i], protocolVersion).hashCode();
+ return hash;
+ }
}
diff --git a/driver-core/src/main/java/com/datastax/driver/core/AbstractData.java b/driver-core/src/main/java/com/datastax/driver/core/AbstractData.java
index bbb349c5b6a..8de0ad00037 100644
--- a/driver-core/src/main/java/com/datastax/driver/core/AbstractData.java
+++ b/driver-core/src/main/java/com/datastax/driver/core/AbstractData.java
@@ -1,11 +1,13 @@
/*
- * Copyright (C) 2012-2017 DataStax Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,576 +19,572 @@
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.reflect.TypeToken;
-
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.ByteBuffer;
-import java.util.*;
-
-// We don't want to expose this one: it's less useful externally and it's a bit ugly to expose anyway (but it's convenient).
-abstract class AbstractData> extends AbstractGettableData implements SettableData {
-
- final T wrapped;
- final ByteBuffer[] values;
-
- // Ugly, we could probably clean that: it is currently needed however because we sometimes
- // want wrapped to be 'this' (UDTValue), and sometimes some other object (in BoundStatement).
- @SuppressWarnings("unchecked")
- protected AbstractData(ProtocolVersion protocolVersion, int size) {
- super(protocolVersion);
- this.wrapped = (T) this;
- this.values = new ByteBuffer[size];
- }
-
- protected AbstractData(ProtocolVersion protocolVersion, T wrapped, int size) {
- this(protocolVersion, wrapped, new ByteBuffer[size]);
- }
-
- protected AbstractData(ProtocolVersion protocolVersion, T wrapped, ByteBuffer[] values) {
- super(protocolVersion);
- this.wrapped = wrapped;
- this.values = values;
- }
-
- protected abstract int[] getAllIndexesOf(String name);
-
- protected T setValue(int i, ByteBuffer value) {
- values[i] = value;
- return wrapped;
- }
-
- @Override
- protected ByteBuffer getValue(int i) {
- return values[i];
- }
-
- @Override
- protected int getIndexOf(String name) {
- return getAllIndexesOf(name)[0];
- }
-
- @Override
- public T setBool(int i, boolean v) {
- TypeCodec codec = codecFor(i, Boolean.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveBooleanCodec)
- bb = ((TypeCodec.PrimitiveBooleanCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setBool(String name, boolean v) {
- for (int i : getAllIndexesOf(name)) {
- setBool(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setByte(int i, byte v) {
- TypeCodec codec = codecFor(i, Byte.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveByteCodec)
- bb = ((TypeCodec.PrimitiveByteCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setByte(String name, byte v) {
- for (int i : getAllIndexesOf(name)) {
- setByte(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setShort(int i, short v) {
- TypeCodec codec = codecFor(i, Short.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveShortCodec)
- bb = ((TypeCodec.PrimitiveShortCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setShort(String name, short v) {
- for (int i : getAllIndexesOf(name)) {
- setShort(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setInt(int i, int v) {
- TypeCodec codec = codecFor(i, Integer.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveIntCodec)
- bb = ((TypeCodec.PrimitiveIntCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setInt(String name, int v) {
- for (int i : getAllIndexesOf(name)) {
- setInt(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setLong(int i, long v) {
- TypeCodec codec = codecFor(i, Long.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveLongCodec)
- bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setLong(String name, long v) {
- for (int i : getAllIndexesOf(name)) {
- setLong(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setTimestamp(int i, Date v) {
- return setValue(i, codecFor(i, Date.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setTimestamp(String name, Date v) {
- for (int i : getAllIndexesOf(name)) {
- setTimestamp(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setDate(int i, LocalDate v) {
- return setValue(i, codecFor(i, LocalDate.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setDate(String name, LocalDate v) {
- for (int i : getAllIndexesOf(name)) {
- setDate(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setTime(int i, long v) {
- TypeCodec codec = codecFor(i, Long.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveLongCodec)
- bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setTime(String name, long v) {
- for (int i : getAllIndexesOf(name)) {
- setTime(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setFloat(int i, float v) {
- TypeCodec codec = codecFor(i, Float.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveFloatCodec)
- bb = ((TypeCodec.PrimitiveFloatCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setFloat(String name, float v) {
- for (int i : getAllIndexesOf(name)) {
- setFloat(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setDouble(int i, double v) {
- TypeCodec codec = codecFor(i, Double.class);
- ByteBuffer bb;
- if (codec instanceof TypeCodec.PrimitiveDoubleCodec)
- bb = ((TypeCodec.PrimitiveDoubleCodec) codec).serializeNoBoxing(v, protocolVersion);
- else
- bb = codec.serialize(v, protocolVersion);
- return setValue(i, bb);
- }
-
- @Override
- public T setDouble(String name, double v) {
- for (int i : getAllIndexesOf(name)) {
- setDouble(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setString(int i, String v) {
- return setValue(i, codecFor(i, String.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setString(String name, String v) {
- for (int i : getAllIndexesOf(name)) {
- setString(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setBytes(int i, ByteBuffer v) {
- return setValue(i, codecFor(i, ByteBuffer.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setBytes(String name, ByteBuffer v) {
- for (int i : getAllIndexesOf(name)) {
- setBytes(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setBytesUnsafe(int i, ByteBuffer v) {
- return setValue(i, v == null ? null : v.duplicate());
- }
-
- @Override
- public T setBytesUnsafe(String name, ByteBuffer v) {
- ByteBuffer value = v == null ? null : v.duplicate();
- for (int i : getAllIndexesOf(name)) {
- setValue(i, value);
- }
- return wrapped;
- }
-
- @Override
- public T setVarint(int i, BigInteger v) {
- return setValue(i, codecFor(i, BigInteger.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setVarint(String name, BigInteger v) {
- for (int i : getAllIndexesOf(name)) {
- setVarint(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setDecimal(int i, BigDecimal v) {
- return setValue(i, codecFor(i, BigDecimal.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setDecimal(String name, BigDecimal v) {
- for (int i : getAllIndexesOf(name)) {
- setDecimal(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setUUID(int i, UUID v) {
- return setValue(i, codecFor(i, UUID.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setUUID(String name, UUID v) {
- for (int i : getAllIndexesOf(name)) {
- setUUID(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setInet(int i, InetAddress v) {
- return setValue(i, codecFor(i, InetAddress.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setInet(String name, InetAddress v) {
- for (int i : getAllIndexesOf(name)) {
- setInet(i, v);
- }
- return wrapped;
- }
-
- // setToken is package-private because we only want to expose it in BoundStatement
- T setToken(int i, Token v) {
- if (v == null)
- throw new NullPointerException(String.format("Cannot set a null token for column %s", getName(i)));
- checkType(i, v.getType().getName());
- // Bypass CodecRegistry when serializing tokens
- return setValue(i, v.serialize(protocolVersion));
- }
-
- T setToken(String name, Token v) {
- for (int i : getAllIndexesOf(name)) {
- setToken(i, v);
- }
- return wrapped;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T setList(int i, List v) {
- return setValue(i, codecFor(i).serialize(v, protocolVersion));
- }
-
- @Override
- public T setList(int i, List v, Class elementsClass) {
- return setValue(i, codecFor(i, TypeTokens.listOf(elementsClass)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setList(int i, List v, TypeToken elementsType) {
- return setValue(i, codecFor(i, TypeTokens.listOf(elementsType)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setList(String name, List v) {
- for (int i : getAllIndexesOf(name)) {
- setList(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setList(String name, List v, Class elementsClass) {
- for (int i : getAllIndexesOf(name)) {
- setList(i, v, elementsClass);
- }
- return wrapped;
- }
-
- @Override
- public T setList(String name, List v, TypeToken elementsType) {
- for (int i : getAllIndexesOf(name)) {
- setList(i, v, elementsType);
- }
- return wrapped;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public T setMap(int i, Map v) {
- return setValue(i, codecFor(i).serialize(v, protocolVersion));
- }
-
- @Override
- public T setMap(int i, Map v, Class keysClass, Class valuesClass) {
- return setValue(i, codecFor(i, TypeTokens.mapOf(keysClass, valuesClass)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setMap(int i, Map v, TypeToken keysType, TypeToken valuesType) {
- return setValue(i, codecFor(i, TypeTokens.mapOf(keysType, valuesType)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setMap(String name, Map v) {
- for (int i : getAllIndexesOf(name)) {
- setMap(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setMap(String name, Map v, Class keysClass, Class valuesClass) {
- for (int i : getAllIndexesOf(name)) {
- setMap(i, v, keysClass, valuesClass);
- }
- return wrapped;
- }
-
- @Override
- public T setMap(String name, Map v, TypeToken keysType, TypeToken valuesType) {
- for (int i : getAllIndexesOf(name)) {
- setMap(i, v, keysType, valuesType);
- }
- return wrapped;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T setSet(int i, Set v) {
- return setValue(i, codecFor(i).serialize(v, protocolVersion));
- }
-
- @Override
- public T setSet(int i, Set v, Class elementsClass) {
- return setValue(i, codecFor(i, TypeTokens.setOf(elementsClass)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setSet(int i, Set v, TypeToken elementsType) {
- return setValue(i, codecFor(i, TypeTokens.setOf(elementsType)).serialize(v, protocolVersion));
- }
-
- @Override
- public T setSet(String name, Set v) {
- for (int i : getAllIndexesOf(name)) {
- setSet(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setSet(String name, Set v, Class elementsClass) {
- for (int i : getAllIndexesOf(name)) {
- setSet(i, v, elementsClass);
- }
- return wrapped;
- }
-
- @Override
- public T setSet(String name, Set v, TypeToken elementsType) {
- for (int i : getAllIndexesOf(name)) {
- setSet(i, v, elementsType);
- }
- return wrapped;
- }
-
- @Override
- public T setUDTValue(int i, UDTValue v) {
- return setValue(i, codecFor(i, UDTValue.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setUDTValue(String name, UDTValue v) {
- for (int i : getAllIndexesOf(name)) {
- setUDTValue(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T setTupleValue(int i, TupleValue v) {
- return setValue(i, codecFor(i, TupleValue.class).serialize(v, protocolVersion));
- }
-
- @Override
- public T setTupleValue(String name, TupleValue v) {
- for (int i : getAllIndexesOf(name)) {
- setTupleValue(i, v);
- }
- return wrapped;
- }
-
- @Override
- public T set(int i, V v, Class targetClass) {
- return set(i, v, codecFor(i, targetClass));
- }
-
- @Override
- public T set(String name, V v, Class targetClass) {
- for (int i : getAllIndexesOf(name)) {
- set(i, v, targetClass);
- }
- return wrapped;
- }
-
- @Override
- public T set(int i, V v, TypeToken targetType) {
- return set(i, v, codecFor(i, targetType));
- }
-
- @Override
- public T set(String name, V v, TypeToken targetType) {
- for (int i : getAllIndexesOf(name)) {
- set(i, v, targetType);
- }
- return wrapped;
- }
-
- @Override
- public T set(int i, V v, TypeCodec codec) {
- checkType(i, codec.getCqlType().getName());
- return setValue(i, codec.serialize(v, protocolVersion));
- }
-
- @Override
- public T set(String name, V v, TypeCodec codec) {
- for (int i : getAllIndexesOf(name)) {
- set(i, v, codec);
- }
- return wrapped;
- }
-
- @Override
- public T setToNull(int i) {
- return setValue(i, null);
- }
-
- @Override
- public T setToNull(String name) {
- for (int i : getAllIndexesOf(name)) {
- setToNull(i);
- }
- return wrapped;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof AbstractData))
- return false;
-
- AbstractData> that = (AbstractData>) o;
- if (values.length != that.values.length)
- return false;
-
- if (this.protocolVersion != that.protocolVersion)
- return false;
-
- // Deserializing each value is slightly inefficient, but comparing
- // the bytes could in theory be wrong (for varint for instance, 2 values
- // can have different binary representation but be the same value due to
- // leading zeros). So we don't take any risk.
- for (int i = 0; i < values.length; i++) {
- DataType thisType = getType(i);
- DataType thatType = that.getType(i);
- if (!thisType.equals(thatType))
- return false;
-
- Object thisValue = this.codecFor(i).deserialize(this.values[i], this.protocolVersion);
- Object thatValue = that.codecFor(i).deserialize(that.values[i], that.protocolVersion);
- if (!MoreObjects.equal(thisValue, thatValue))
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- // Same as equals
- int hash = 31;
- for (int i = 0; i < values.length; i++)
- hash += values[i] == null ? 1 : codecFor(i).deserialize(values[i], protocolVersion).hashCode();
- return hash;
- }
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+// We don't want to expose this one: it's less useful externally and it's a bit ugly to expose
+// anyway (but it's convenient).
+abstract class AbstractData> extends AbstractGettableData
+ implements SettableData {
+
+ final T wrapped;
+ final ByteBuffer[] values;
+
+ // Ugly, we could probably clean that: it is currently needed however because we sometimes
+ // want wrapped to be 'this' (UDTValue), and sometimes some other object (in BoundStatement).
+ @SuppressWarnings("unchecked")
+ protected AbstractData(ProtocolVersion protocolVersion, int size) {
+ super(protocolVersion);
+ this.wrapped = (T) this;
+ this.values = new ByteBuffer[size];
+ }
+
+ protected AbstractData(ProtocolVersion protocolVersion, T wrapped, int size) {
+ this(protocolVersion, wrapped, new ByteBuffer[size]);
+ }
+
+ protected AbstractData(ProtocolVersion protocolVersion, T wrapped, ByteBuffer[] values) {
+ super(protocolVersion);
+ this.wrapped = wrapped;
+ this.values = values;
+ }
+
+ protected abstract int[] getAllIndexesOf(String name);
+
+ protected T setValue(int i, ByteBuffer value) {
+ values[i] = value;
+ return wrapped;
+ }
+
+ @Override
+ protected ByteBuffer getValue(int i) {
+ return values[i];
+ }
+
+ @Override
+ protected int getIndexOf(String name) {
+ return getAllIndexesOf(name)[0];
+ }
+
+ @Override
+ public T setBool(int i, boolean v) {
+ TypeCodec codec = codecFor(i, Boolean.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveBooleanCodec)
+ bb = ((TypeCodec.PrimitiveBooleanCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setBool(String name, boolean v) {
+ for (int i : getAllIndexesOf(name)) {
+ setBool(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setByte(int i, byte v) {
+ TypeCodec codec = codecFor(i, Byte.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveByteCodec)
+ bb = ((TypeCodec.PrimitiveByteCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setByte(String name, byte v) {
+ for (int i : getAllIndexesOf(name)) {
+ setByte(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setShort(int i, short v) {
+ TypeCodec codec = codecFor(i, Short.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveShortCodec)
+ bb = ((TypeCodec.PrimitiveShortCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setShort(String name, short v) {
+ for (int i : getAllIndexesOf(name)) {
+ setShort(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setInt(int i, int v) {
+ TypeCodec codec = codecFor(i, Integer.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveIntCodec)
+ bb = ((TypeCodec.PrimitiveIntCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setInt(String name, int v) {
+ for (int i : getAllIndexesOf(name)) {
+ setInt(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setLong(int i, long v) {
+ TypeCodec codec = codecFor(i, Long.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveLongCodec)
+ bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setLong(String name, long v) {
+ for (int i : getAllIndexesOf(name)) {
+ setLong(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setTimestamp(int i, Date v) {
+ return setValue(i, codecFor(i, Date.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setTimestamp(String name, Date v) {
+ for (int i : getAllIndexesOf(name)) {
+ setTimestamp(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setDate(int i, LocalDate v) {
+ return setValue(i, codecFor(i, LocalDate.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setDate(String name, LocalDate v) {
+ for (int i : getAllIndexesOf(name)) {
+ setDate(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setTime(int i, long v) {
+ TypeCodec codec = codecFor(i, Long.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveLongCodec)
+ bb = ((TypeCodec.PrimitiveLongCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setTime(String name, long v) {
+ for (int i : getAllIndexesOf(name)) {
+ setTime(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setFloat(int i, float v) {
+ TypeCodec codec = codecFor(i, Float.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveFloatCodec)
+ bb = ((TypeCodec.PrimitiveFloatCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setFloat(String name, float v) {
+ for (int i : getAllIndexesOf(name)) {
+ setFloat(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setDouble(int i, double v) {
+ TypeCodec codec = codecFor(i, Double.class);
+ ByteBuffer bb;
+ if (codec instanceof TypeCodec.PrimitiveDoubleCodec)
+ bb = ((TypeCodec.PrimitiveDoubleCodec) codec).serializeNoBoxing(v, protocolVersion);
+ else bb = codec.serialize(v, protocolVersion);
+ return setValue(i, bb);
+ }
+
+ @Override
+ public T setDouble(String name, double v) {
+ for (int i : getAllIndexesOf(name)) {
+ setDouble(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setString(int i, String v) {
+ return setValue(i, codecFor(i, String.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setString(String name, String v) {
+ for (int i : getAllIndexesOf(name)) {
+ setString(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setBytes(int i, ByteBuffer v) {
+ return setValue(i, codecFor(i, ByteBuffer.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setBytes(String name, ByteBuffer v) {
+ for (int i : getAllIndexesOf(name)) {
+ setBytes(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setBytesUnsafe(int i, ByteBuffer v) {
+ return setValue(i, v == null ? null : v.duplicate());
+ }
+
+ @Override
+ public T setBytesUnsafe(String name, ByteBuffer v) {
+ ByteBuffer value = v == null ? null : v.duplicate();
+ for (int i : getAllIndexesOf(name)) {
+ setValue(i, value);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setVarint(int i, BigInteger v) {
+ return setValue(i, codecFor(i, BigInteger.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setVarint(String name, BigInteger v) {
+ for (int i : getAllIndexesOf(name)) {
+ setVarint(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setDecimal(int i, BigDecimal v) {
+ return setValue(i, codecFor(i, BigDecimal.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setDecimal(String name, BigDecimal v) {
+ for (int i : getAllIndexesOf(name)) {
+ setDecimal(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setUUID(int i, UUID v) {
+ return setValue(i, codecFor(i, UUID.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setUUID(String name, UUID v) {
+ for (int i : getAllIndexesOf(name)) {
+ setUUID(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setInet(int i, InetAddress v) {
+ return setValue(i, codecFor(i, InetAddress.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setInet(String name, InetAddress v) {
+ for (int i : getAllIndexesOf(name)) {
+ setInet(i, v);
+ }
+ return wrapped;
+ }
+
+ // setToken is package-private because we only want to expose it in BoundStatement
+ T setToken(int i, Token v) {
+ if (v == null)
+ throw new NullPointerException(
+ String.format("Cannot set a null token for column %s", getName(i)));
+ checkType(i, v.getType().getName());
+ // Bypass CodecRegistry when serializing tokens
+ return setValue(i, v.serialize(protocolVersion));
+ }
+
+ T setToken(String name, Token v) {
+ for (int i : getAllIndexesOf(name)) {
+ setToken(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T setList(int i, List v) {
+ return setValue(i, codecFor(i).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setList(int i, List v, Class elementsClass) {
+ return setValue(i, codecFor(i, TypeTokens.listOf(elementsClass)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setList(int i, List v, TypeToken elementsType) {
+ return setValue(i, codecFor(i, TypeTokens.listOf(elementsType)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setList(String name, List v) {
+ for (int i : getAllIndexesOf(name)) {
+ setList(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setList(String name, List v, Class elementsClass) {
+ for (int i : getAllIndexesOf(name)) {
+ setList(i, v, elementsClass);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setList(String name, List v, TypeToken elementsType) {
+ for (int i : getAllIndexesOf(name)) {
+ setList(i, v, elementsType);
+ }
+ return wrapped;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T setMap(int i, Map v) {
+ return setValue(i, codecFor(i).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setMap(int i, Map v, Class keysClass, Class valuesClass) {
+ return setValue(
+ i, codecFor(i, TypeTokens.mapOf(keysClass, valuesClass)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setMap(int i, Map v, TypeToken keysType, TypeToken valuesType) {
+ return setValue(
+ i, codecFor(i, TypeTokens.mapOf(keysType, valuesType)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setMap(String name, Map v) {
+ for (int i : getAllIndexesOf(name)) {
+ setMap(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setMap(String name, Map v, Class keysClass, Class valuesClass) {
+ for (int i : getAllIndexesOf(name)) {
+ setMap(i, v, keysClass, valuesClass);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setMap(String name, Map v, TypeToken keysType, TypeToken valuesType) {
+ for (int i : getAllIndexesOf(name)) {
+ setMap(i, v, keysType, valuesType);
+ }
+ return wrapped;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T setSet(int i, Set v) {
+ return setValue(i, codecFor(i).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setSet(int i, Set v, Class elementsClass) {
+ return setValue(i, codecFor(i, TypeTokens.setOf(elementsClass)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setSet(int i, Set v, TypeToken elementsType) {
+ return setValue(i, codecFor(i, TypeTokens.setOf(elementsType)).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setSet(String name, Set v) {
+ for (int i : getAllIndexesOf(name)) {
+ setSet(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setSet(String name, Set v, Class elementsClass) {
+ for (int i : getAllIndexesOf(name)) {
+ setSet(i, v, elementsClass);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setSet(String name, Set v, TypeToken elementsType) {
+ for (int i : getAllIndexesOf(name)) {
+ setSet(i, v, elementsType);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setUDTValue(int i, UDTValue v) {
+ return setValue(i, codecFor(i, UDTValue.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setUDTValue(String name, UDTValue v) {
+ for (int i : getAllIndexesOf(name)) {
+ setUDTValue(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setTupleValue(int i, TupleValue v) {
+ return setValue(i, codecFor(i, TupleValue.class).serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T setTupleValue(String name, TupleValue v) {
+ for (int i : getAllIndexesOf(name)) {
+ setTupleValue(i, v);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T set(int i, V v, Class targetClass) {
+ return set(i, v, codecFor(i, targetClass));
+ }
+
+ @Override
+ public T set(String name, V v, Class targetClass) {
+ for (int i : getAllIndexesOf(name)) {
+ set(i, v, targetClass);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T set(int i, V v, TypeToken targetType) {
+ return set(i, v, codecFor(i, targetType));
+ }
+
+ @Override
+ public T set(String name, V v, TypeToken targetType) {
+ for (int i : getAllIndexesOf(name)) {
+ set(i, v, targetType);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T set(int i, V v, TypeCodec codec) {
+ checkType(i, codec.getCqlType().getName());
+ return setValue(i, codec.serialize(v, protocolVersion));
+ }
+
+ @Override
+ public T set(String name, V v, TypeCodec codec) {
+ for (int i : getAllIndexesOf(name)) {
+ set(i, v, codec);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public T setToNull(int i) {
+ return setValue(i, null);
+ }
+
+ @Override
+ public T setToNull(String name) {
+ for (int i : getAllIndexesOf(name)) {
+ setToNull(i);
+ }
+ return wrapped;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof AbstractData)) return false;
+
+ AbstractData> that = (AbstractData>) o;
+ if (values.length != that.values.length) return false;
+
+ if (this.protocolVersion != that.protocolVersion) return false;
+
+ // Deserializing each value is slightly inefficient, but comparing
+ // the bytes could in theory be wrong (for varint for instance, 2 values
+ // can have different binary representation but be the same value due to
+ // leading zeros). So we don't take any risk.
+ for (int i = 0; i < values.length; i++) {
+ DataType thisType = getType(i);
+ DataType thatType = that.getType(i);
+ if (!thisType.equals(thatType)) return false;
+
+ Object thisValue = this.codecFor(i).deserialize(this.values[i], this.protocolVersion);
+ Object thatValue = that.codecFor(i).deserialize(that.values[i], that.protocolVersion);
+ if (!MoreObjects.equal(thisValue, thatValue)) return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ // Same as equals
+ int hash = 31;
+ for (int i = 0; i < values.length; i++)
+ hash +=
+ values[i] == null ? 1 : codecFor(i).deserialize(values[i], protocolVersion).hashCode();
+ return hash;
+ }
}
diff --git a/driver-core/src/main/java/com/datastax/driver/core/AbstractGettableByIndexData.java b/driver-core/src/main/java/com/datastax/driver/core/AbstractGettableByIndexData.java
index d1b19741c19..389aeea33e7 100644
--- a/driver-core/src/main/java/com/datastax/driver/core/AbstractGettableByIndexData.java
+++ b/driver-core/src/main/java/com/datastax/driver/core/AbstractGettableByIndexData.java
@@ -1,11 +1,13 @@
/*
- * Copyright (C) 2012-2017 DataStax Inc.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,369 +19,310 @@
import com.datastax.driver.core.exceptions.InvalidTypeException;
import com.google.common.reflect.TypeToken;
-
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.ByteBuffer;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
abstract class AbstractGettableByIndexData implements GettableByIndexData {
- protected final ProtocolVersion protocolVersion;
-
- protected AbstractGettableByIndexData(ProtocolVersion protocolVersion) {
- this.protocolVersion = protocolVersion;
- }
-
- /**
- * Returns the type for the value at index {@code i}.
- *
- * @param i the index of the type to fetch.
- * @return the type of the value at index {@code i}.
- * @throws IndexOutOfBoundsException if {@code i} is not a valid index.
- */
- protected abstract DataType getType(int i);
-
- /**
- * Returns the name corresponding to the value at index {@code i}.
- *
- * @param i the index of the name to fetch.
- * @return the name corresponding to the value at index {@code i}.
- * @throws IndexOutOfBoundsException if {@code i} is not a valid index.
- */
- protected abstract String getName(int i);
-
- /**
- * Returns the value at index {@code i}.
- *
- * @param i the index to fetch.
- * @return the value at index {@code i}.
- * @throws IndexOutOfBoundsException if {@code i} is not a valid index.
- */
- protected abstract ByteBuffer getValue(int i);
-
- protected abstract CodecRegistry getCodecRegistry();
-
- protected TypeCodec codecFor(int i) {
- return getCodecRegistry().codecFor(getType(i));
- }
-
- protected TypeCodec codecFor(int i, Class javaClass) {
- return getCodecRegistry().codecFor(getType(i), javaClass);
- }
-
- protected TypeCodec codecFor(int i, TypeToken javaType) {
- return getCodecRegistry().codecFor(getType(i), javaType);
- }
-
- protected TypeCodec codecFor(int i, T value) {
- return getCodecRegistry().codecFor(getType(i), value);
- }
-
- protected void checkType(int i, DataType.Name actual) {
- DataType.Name expected = getType(i).getName();
- if (!actual.isCompatibleWith(expected))
- throw new InvalidTypeException(String.format("Value %s is of type %s, not %s", getName(i), expected, actual));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isNull(int i) {
- return getValue(i) == null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getBool(int i) {
- ByteBuffer value = getValue(i);
- TypeCodec codec = codecFor(i, Boolean.class);
- if (codec instanceof TypeCodec.PrimitiveBooleanCodec)
- return ((TypeCodec.PrimitiveBooleanCodec) codec).deserializeNoBoxing(value, protocolVersion);
- else
- return codec.deserialize(value, protocolVersion);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public byte getByte(int i) {
- ByteBuffer value = getValue(i);
- TypeCodec codec = codecFor(i, Byte.class);
- if (codec instanceof TypeCodec.PrimitiveByteCodec)
- return ((TypeCodec.PrimitiveByteCodec) codec).deserializeNoBoxing(value, protocolVersion);
- else
- return codec.deserialize(value, protocolVersion);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public short getShort(int i) {
- ByteBuffer value = getValue(i);
- TypeCodec codec = codecFor(i, Short.class);
- if (codec instanceof TypeCodec.PrimitiveShortCodec)
- return ((TypeCodec.PrimitiveShortCodec) codec).deserializeNoBoxing(value, protocolVersion);
- else
- return codec.deserialize(value, protocolVersion);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getInt(int i) {
- ByteBuffer value = getValue(i);
- TypeCodec codec = codecFor(i, Integer.class);
- if (codec instanceof TypeCodec.PrimitiveIntCodec)
- return ((TypeCodec.PrimitiveIntCodec) codec).deserializeNoBoxing(value, protocolVersion);
- else
- return codec.deserialize(value, protocolVersion);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getLong(int i) {
- ByteBuffer value = getValue(i);
- TypeCodec