From 4effaa9b01ede2f0e13f9e14debc6bad595d7642 Mon Sep 17 00:00:00 2001 From: Jeremy Corbett Date: Wed, 10 Jul 2024 15:55:42 -0700 Subject: [PATCH] back to 3.2.5 base (#3) * Revert "Updates for ruby 3.0 (#1)" This reverts commit a134e1e698e85365faa3ac1a91b44b4e7239e877. * Revert "Fix a case sensitivity issue when fetching the clustering order" This reverts commit 71e70bfd068e202195db6fbb227acee68e2dc232. * Revert "Update docs.yaml to reflect recent work on docs" This reverts commit 5f41fa92aee6626f0178dbca2d3f2d5cfdd8f525. * Revert "changed 4.0+ to 4.0.x" This reverts commit aa6e17d0747dda1f17861a8bd46635bf87b86801. * Revert "readme and docs.yaml updates" This reverts commit 28cc9aa7ade6916a100cc16d4a919aa7131b4315. * Revert "DOC-4040 update to docs.yaml (#274)" This reverts commit c18f98e1b81e4595322219a836b4af790b81f7bd. * Revert "Add varchar to Cassandra::Types.text mapping (#270)" This reverts commit 2c9070cbb8f484da901bd0454a4c20478430615e. * Revert "Slight refactorig of prior commit. Main goal was to preserve ordering of hosts on the" This reverts commit 022906dcbb3d400f0c6c274317e3896439d73921. * Revert "Merge pull request #267 from abicky/fix-replication-strategies-simple" This reverts commit 42c435d9205a4620bfe18240e57a144de5e0a6f6. * Revert "Minor spec fixes" This reverts commit 765f9c9c5a8e617bbf11771de36956684f08e213. * Revert "Merge pull request #265 from EasyPost:log_in_protocol" This reverts commit e1b8dcb49a477d6a0165e4c942a0d66bea5c0071. * Revert "Quick testing fix; make check for enable_materialized_views YAML config more" This reverts commit 8fdcfd27ed07e5fd5f9ad7fe545b8f58d5253cfe. * Revert "RUBY-331: Migrate to Jenkins pipelines (#264)" This reverts commit 572dec030dbed56b3132292a0c980f6a2886f0a1. * Revert "Revert "Fix a case sensitivity issue when fetching the clustering order"" This reverts commit 23ce3b90ea8d4cc2cf70f23e8a61fdfc51e412a1. * Revert "Revert "Updates for ruby 3.0 (#1)"" This reverts commit 1b3f6ea7ff26ac8fe4c47d0e565c113c3412bc2f. * Version bump to 3.2.5.2 --- Jenkinsfile | 100 ------------------ README.md | 4 +- build.yaml.bak => build.yaml | 0 docs.yaml | 53 +++------- lib/cassandra/cluster/connector.rb | 2 - .../cluster/schema/cql_type_parser.rb | 1 - .../schema/replication_strategies/simple.rb | 6 +- .../protocol/cql_protocol_handler.rb | 8 +- lib/cassandra/version.rb | 2 +- .../replication_strategies/simple_spec.rb | 82 -------------- .../protocol/cql_protocol_handler_spec.rb | 15 +-- support/ccm.rb | 5 +- 12 files changed, 27 insertions(+), 251 deletions(-) delete mode 100644 Jenkinsfile rename build.yaml.bak => build.yaml (100%) delete mode 100644 spec/cassandra/cluster/schema/replication_strategies/simple_spec.rb diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 05a058585..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,100 +0,0 @@ -def initializeEnvironment() { - - env.DRIVER_DISPLAY_NAME = 'Cassandra Ruby Driver' - env.DRIVER_METRIC_TYPE = 'oss' - - 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}" - - sh label: 'Download Apache CassandraⓇ or DataStax Enterprise', script: '''#!/bin/bash -lex - . ${CCM_ENVIRONMENT_SHELL} ${CASSANDRA_VERSION} - ''' -} - -def installDependencies() { - sh label: 'Set Ruby env and update gems', script: '''#!/bin/bash -le - rbenv global ${RUBY_VERSION} - - ruby_bin_version=`ruby -v` - echo "Ruby binary version: ${ruby_bin_version}" - if [[ $ruby_bin_version == jruby* ]]; then - # Add '-java' to version as that is included in version name when using jruby - echo "JRuby detected, updating Gemfile.lock" - sed -i -r 's/cassandra-driver \\((.*)\\)/cassandra-driver (\\1-java)/' Gemfile.lock - fi - - bundle update --bundler - bundle --version - bundle install --without development docs - ''' -} - -def executeTests() { - sh label: 'Execute all tests', script: '''#!/bin/bash -le - # Load CCM environment variables - set -o allexport - . ${HOME}/environment.txt - set +o allexport - - bundle exec rake test - ''' -} - -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 - } - - environment { - CCM_ENVIRONMENT_SHELL = '/usr/local/bin/ccm_environment.sh' - } - - stages { - stage('Per-Commit') { - environment { - OS_VERSION = 'ubuntu/bionic64/ruby-driver' - } - - matrix { - axes { - axis { - name 'CASSANDRA_VERSION' - values '2.1', '3.11', '4.0' - } - axis { - name 'RUBY_VERSION' - values '2.3.6', '2.4.3', '2.7.0', 'jruby-9.1.15.0' - } - } - agent { - label "${OS_VERSION}" - } - - stages { - stage('Initialize-Environment') { - steps { - initializeEnvironment() - } - } - stage('Install-Dependencies') { - steps { - installDependencies() - } - } - stage('Execute-Tests') { - steps { - executeTests() - } - } - } - } - } - } -} diff --git a/README.md b/README.md index 47a2349e7..76072e0de 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ better compatibility and support for DataStax Enterprise. - Docs: http://docs.datastax.com/en/developer/ruby-driver - Jira: https://datastax-oss.atlassian.net/browse/RUBY - Mailing List: https://groups.google.com/a/lists.datastax.com/forum/#!forum/ruby-driver-user +- Slack: `#datastax-drivers` channel at https://academy.datastax.com/slack +- Twitter: Follow the latest news about DataStax Drivers - [@stamhankar999](http://twitter.com/stamhankar999), [@avalanche123](http://twitter.com/avalanche123), [@al3xandru](https://twitter.com/al3xandru) This driver is based on [the cql-rb gem](https://github.com/iconara/cql-rb) by [Theo Hultberg](https://github.com/iconara) and we added support for: @@ -36,7 +38,7 @@ This driver is based on [the cql-rb gem](https://github.com/iconara/cql-rb) by [ This driver works exclusively with the Cassandra Query Language v3 (CQL3) and Cassandra's native protocol. The current version works with: -* Apache Cassandra versions 2.1, 2.2, 3.0+, and 4.0.x +* Apache Cassandra versions 2.1, 2.2, and 3.x * DataStax Enterprise 4.8 and above. However, the [Ruby DSE driver](https://docs.datastax.com/en/developer/ruby-driver-dse/2.1/) provides more features and is recommended for use with DataStax Enterprise. * Ruby (MRI) 2.2, 2.3, 2.4 * JRuby 9k diff --git a/build.yaml.bak b/build.yaml similarity index 100% rename from build.yaml.bak rename to build.yaml diff --git a/docs.yaml b/docs.yaml index 59fb62bff..f48bfaa52 100644 --- a/docs.yaml +++ b/docs.yaml @@ -23,20 +23,18 @@ rewrites: - supplemental/: / - en/latest-ruby-driver/ruby-driver/whatsNew.html: en/developer/ruby-driver/latest - 'trunk/doc/native_protocol_v([12])\.spec': cassandra-2.2/doc/native_protocol_v\1.spec - - search: 'http://www.datastax.com/documentation/cql/3.1/webhelp/index.html' - replace: 'http://docs.datastax.com/en/cql/3.3/cql/cql_using/useAboutCQL.html' - - search: 'https://datastax.github.io/java-driver/features' - replace: 'https://datastax.github.io/java-driver/manual' - - search: 'http://dsdocs30_java' - replace: 'http://docs.datastax.com/en/developer/java-driver/3.0' - - search: 'http://www.datastax.com/documentation/cassandra/2.0' - replace: 'https://docs.datastax.com/en/archived/cassandra/2.0' - - search: 'http://www.datastax.com/documentation/cassandra/1.2' - replace: 'https://docs.datastax.com/en/archived/cassandra/1.2' - - search: 'http://www.datastax.com/documentation/cql/3.0' - replace: 'https://docs.datastax.com/en/archived/cql/3.0' - - search: 'http://cukes.info/' - replace: 'https://cucumber.io/' + - search: http://www.datastax.com/documentation/cql/3.1/webhelp/index.html + replace: http://docs.datastax.com/en/cql/3.3/cql/cql_using/useAboutCQL.html + - search: https://datastax.github.io/java-driver/features + replace: https://datastax.github.io/java-driver/manual + - search: http://dsdocs30_java + replace: http://docs.datastax.com/en/developer/java-driver/3.0 + - search: http://www.datastax.com/documentation/cassandra/2.0 + replace: https://docs.datastax.com/en/archived/cassandra/2.0 + - search: http://www.datastax.com/documentation/cassandra/1.2 + replace: https://docs.datastax.com/en/archived/cassandra/1.2 + - search: http://www.datastax.com/documentation/cql/3.0 + replace: https://docs.datastax.com/en/archived/cql/3.0 links: - title: Code href: https://github.com/datastax/ruby-driver/ @@ -52,7 +50,7 @@ links: href: https://github.com/datastax/ruby-driver/releases versions: - name: 3.2 - ref: 1e95ca94ffbba215b5bf2758a646a48d4f4eaa0f + ref: v3.2.4 - name: 3.1 ref: v3.1.0 - name: 3.0 @@ -67,28 +65,3 @@ versions: ref: 1763066e2f70db8889799aa0af4a8eb63ad9ab74 - name: 1.0 ref: 72bfc9609f94e904c0186b061a02404fb2c0d22e -checks: - external_links: - exclude: - - 'https://twitter.com/dsJavaDriver' - - 'https://twitter.com/datastaxeng' - - 'https://twitter.com/datastax' - - 'https://projectreactor.io' - - 'https://docs.datastax.com/en/drivers/java/4.[0-9]+/com/datastax/oss/driver/internal/' - - 'http://www.planetcassandra.org/blog/user-defined-functions-in-cassandra-3-0/' - - 'http://www.planetcassandra.org/making-the-change-from-thrift-to-cql/' - - 'https://academy.datastax.com/slack' - - 'https://community.datastax.com/index.html' - - 'https://micrometer.io/docs' - - 'http://datastax.github.io/java-driver/features/shaded_jar/' - - 'http://twitter.com/avalanche123' - - 'http://twitter.com/mfiguiere' - - 'http://twitter.com/stamhankar999' - - 'https://twitter.com/al3xandru' - - 'https://github.com/datastax/ruby-dse-driver.git' - - 'https://academy.datastax.com/demos/datastax-ruby-driver-load-balancing-policies' - internal_links: - exclude: - - 'netty_pipeline/' - - '../core/' - - '%5Bguava%20eviction%5D' diff --git a/lib/cassandra/cluster/connector.rb b/lib/cassandra/cluster/connector.rb index bcbf12b66..a813bd61e 100644 --- a/lib/cassandra/cluster/connector.rb +++ b/lib/cassandra/cluster/connector.rb @@ -126,9 +126,7 @@ def do_connect(host) @connection_options.nodelay? ? 1 : 0) Protocol::CqlProtocolHandler.new(connection, - host, @reactor, - @logger, @connection_options.protocol_version, @connection_options.compressor, @connection_options.heartbeat_interval, diff --git a/lib/cassandra/cluster/schema/cql_type_parser.rb b/lib/cassandra/cluster/schema/cql_type_parser.rb index a10f08af4..ce177cb59 100644 --- a/lib/cassandra/cluster/schema/cql_type_parser.rb +++ b/lib/cassandra/cluster/schema/cql_type_parser.rb @@ -42,7 +42,6 @@ def parse(string, types) def lookup_type(node, types) case node.name when 'text' then Cassandra::Types.text - when 'varchar' then Cassandra::Types.text when 'blob' then Cassandra::Types.blob when 'ascii' then Cassandra::Types.ascii when 'bigint' then Cassandra::Types.bigint diff --git a/lib/cassandra/cluster/schema/replication_strategies/simple.rb b/lib/cassandra/cluster/schema/replication_strategies/simple.rb index 4b2f7e5fe..15e6bdb8e 100644 --- a/lib/cassandra/cluster/schema/replication_strategies/simple.rb +++ b/lib/cassandra/cluster/schema/replication_strategies/simple.rb @@ -29,10 +29,10 @@ def replication_map(token_hosts, token_ring, replication_options) factor = size if size < factor replication_map = ::Hash.new - hosts_ring = token_ring.map { |t| token_hosts[t] } token_ring.each_with_index do |token, i| - candidates = hosts_ring.cycle(2 * size).drop(i).take(size).uniq - replication_map[token] = candidates.take(factor).freeze + replication_map[token] = factor.times.map do |j| + token_hosts[token_ring[(i + j) % size]] + end.freeze end replication_map diff --git a/lib/cassandra/protocol/cql_protocol_handler.rb b/lib/cassandra/protocol/cql_protocol_handler.rb index 113ef0f6e..59edadd00 100644 --- a/lib/cassandra/protocol/cql_protocol_handler.rb +++ b/lib/cassandra/protocol/cql_protocol_handler.rb @@ -41,9 +41,7 @@ class CqlProtocolHandler attr_reader :protocol_version def initialize(connection, - host, scheduler, - logger, protocol_version, compressor = nil, heartbeat_interval = 30, @@ -52,12 +50,10 @@ def initialize(connection, custom_type_handlers = {}) @protocol_version = protocol_version @connection = connection - @host = host @scheduler = scheduler @compressor = compressor @connection.on_data(&method(:receive_data)) @connection.on_closed(&method(:socket_closed)) - @logger = logger @streams = Array.new(requests_per_connection) {|i| i} @@ -418,8 +414,7 @@ def schedule_heartbeat end timer.on_value do - @logger.debug("sending heartbeat to #{@host}") - send_request(HEARTBEAT, nil, false).on_complete do + send_request(HEARTBEAT, nil, false).on_value do schedule_heartbeat end end @@ -437,7 +432,6 @@ def reschedule_termination end timer.on_value do - @logger.info("#{@host} has had no activity in the last #{@idle_timeout}s; marking as failed") @terminate = nil @connection.close(TERMINATED) end diff --git a/lib/cassandra/version.rb b/lib/cassandra/version.rb index 9fd98328c..80e96ed6d 100644 --- a/lib/cassandra/version.rb +++ b/lib/cassandra/version.rb @@ -22,6 +22,6 @@ module Cassandra # We publish our fork with a revision number appended to the upstream version. # # @return [String] the ART19 revision number - ART19_REVISION = '1'.freeze + ART19_REVISION = '2'.freeze VERSION = "3.2.5.#{ART19_REVISION}".freeze end diff --git a/spec/cassandra/cluster/schema/replication_strategies/simple_spec.rb b/spec/cassandra/cluster/schema/replication_strategies/simple_spec.rb deleted file mode 100644 index 90706f08e..000000000 --- a/spec/cassandra/cluster/schema/replication_strategies/simple_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -# encoding: utf-8 - -#-- -# Copyright DataStax, Inc. -# -# 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. -#++ - -require 'spec_helper' - -module Cassandra - class Cluster - class Schema - module ReplicationStrategies - describe(Simple) do - subject { Simple.new } - - describe('#replication_map') do - let(:hosts) { - [ - Host.new('127.0.0.1', 111, 'rack1', 'dc1'), - Host.new('127.0.0.2', 112, 'rack1', 'dc1'), - Host.new('127.0.0.3', 113, 'rack1', 'dc1'), - ] - } - - let(:token_hosts) { - { - -9000000000000000000 => hosts[0], - -8000000000000000000 => hosts[0], - -7000000000000000000 => hosts[1], - -6000000000000000000 => hosts[1], - -5000000000000000000 => hosts[2], - -4000000000000000000 => hosts[2], - -3000000000000000000 => hosts[0], - -2000000000000000000 => hosts[0], - -1000000000000000000 => hosts[1], - +0000000000000000000 => hosts[1], - +1000000000000000000 => hosts[2], - +2000000000000000000 => hosts[2], - } - } - - let(:token_ring) { - token_hosts.keys - } - - let(:replication_options) { - { - 'replication_factor' => 3, - } - } - - it do - replication_map = subject.replication_map(token_hosts, token_ring, replication_options) - expect(replication_map[token_ring[0]].map(&:ip)).to eq([ - '127.0.0.1', - '127.0.0.2', - '127.0.0.3', - ]) - expect(replication_map[token_ring[2]].map(&:ip)).to eq([ - '127.0.0.2', - '127.0.0.3', - '127.0.0.1', - ]) - end - end - end - end - end - end -end diff --git a/spec/cassandra/protocol/cql_protocol_handler_spec.rb b/spec/cassandra/protocol/cql_protocol_handler_spec.rb index 2a24474bc..16d4d12c5 100644 --- a/spec/cassandra/protocol/cql_protocol_handler_spec.rb +++ b/spec/cassandra/protocol/cql_protocol_handler_spec.rb @@ -22,14 +22,8 @@ module Cassandra module Protocol describe CqlProtocolHandler do - let :host do - 'example.com' - end - let :logger do - Cassandra::NullLogger.new - end let :protocol_handler do - described_class.new(connection, host, scheduler, logger, 1, nil, 30, 60, 36) + described_class.new(connection, scheduler, 1, nil, 30, 60, 36) end let :connection do @@ -58,8 +52,6 @@ module Protocol connection.stub(:on_connected) do |&h| connection.stub(:connected_listener).and_return(h) end - connection.stub(:host).and_return(host) - protocol_handler end @@ -95,6 +87,7 @@ module Protocol describe '#host' do it 'delegates to the connection' do + connection.stub(:host).and_return('example.com') protocol_handler.host.should == 'example.com' end end @@ -182,7 +175,7 @@ module Protocol context 'when a compressor is specified' do let :protocol_handler do - described_class.new(connection, host, scheduler, logger, 1, compressor) + described_class.new(connection, scheduler, 1, compressor) end let :compressor do @@ -222,7 +215,7 @@ module Protocol context 'when a protocol version is specified' do let :protocol_handler do - described_class.new(connection, host, scheduler, logger, 7) + described_class.new(connection, scheduler, 7) end it 'sets the protocol version in the header' do diff --git a/support/ccm.rb b/support/ccm.rb index ffb44d241..47ea1eedb 100644 --- a/support/ccm.rb +++ b/support/ccm.rb @@ -996,9 +996,8 @@ def create_cluster(name, version, datacenters, nodes_per_datacenter) config << 'memtable_flush_writers: 1' config << 'max_hints_delivery_threads: 1' - # Be more rigorous about our versioning here. - # enable_materialized_views flag was added in 3.0.16 (see CASSANDRA-13959) - if cassandra_version >= '3.0.16' and !dse + # If we're just dealing with C* 4.0 enable MV as well + if cassandra_version >= '3.0' and !dse config << 'enable_materialized_views: true' end