From 4ecff92404baccc848322a12921cf10af5e38e7b Mon Sep 17 00:00:00 2001 From: Stefan Miklosovic Date: Mon, 30 Oct 2023 21:54:55 +0100 Subject: [PATCH] Remove deprecated code in Cassandra 1.x and 2.x patch by Stefan Miklosovic; reviewed by Brandon Williams for CASSANDRA-18959 --- CHANGES.txt | 1 + NEWS.txt | 1 + .../org/apache/cassandra/auth/Permission.java | 7 ----- .../org/apache/cassandra/auth/Resources.java | 29 ++----------------- .../org/apache/cassandra/config/Config.java | 12 -------- .../cassandra/config/DatabaseDescriptor.java | 7 ----- .../locator/AbstractReplicationStrategy.java | 7 +++-- .../cassandra/locator/TokenMetadata.java | 21 -------------- .../cassandra/service/StorageService.java | 2 +- .../service/StorageServiceMBean.java | 16 +--------- .../org/apache/cassandra/tools/JMXTool.java | 3 +- .../org/apache/cassandra/tools/NodeTool.java | 2 -- .../tools/nodetool/CfHistograms.java | 29 ------------------- .../cassandra/tools/nodetool/CfStats.java | 29 ------------------- test/data/config/version=5.0-alpha1.yml | 3 -- .../simulator/cluster/OnInstanceRepair.java | 3 +- .../config/ConfigCompatibilityTest.java | 3 ++ .../cassandra/locator/SimpleStrategyTest.java | 3 +- .../service/LeaveAndBootstrapTest.java | 12 ++++---- .../apache/cassandra/service/MoveTest.java | 6 ++-- .../cassandra/tools/JMXCompatabilityTest.java | 24 ++++++++------- 21 files changed, 42 insertions(+), 178 deletions(-) delete mode 100644 src/java/org/apache/cassandra/tools/nodetool/CfHistograms.java delete mode 100644 src/java/org/apache/cassandra/tools/nodetool/CfStats.java diff --git a/CHANGES.txt b/CHANGES.txt index e87484c643..779d6f2d13 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 5.0-alpha2 + * Remove deprecated code in Cassandra 1.x and 2.x (CASSANDRA-18959) * ClientRequestSize metrics should not treat CONTAINS restrictions as being equality-based (CASSANDRA-18896) * Add support for vector search in SAI (CASSANDRA-18715) * Remove crc_check_chance from CompressionParams (CASSANDRA-18872) diff --git a/NEWS.txt b/NEWS.txt index a2731fcdc1..7a47bf0b45 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -231,6 +231,7 @@ Upgrading Deprecation ----------- + - Deprecated code in Cassandra 1.x and 2.x was removed. See CASSANDRA-18959 for more details. - In the JMX MBean `org.apache.cassandra.db:type=RepairService` (CASSANDRA-17668): - deprecate the getter/setter methods `getRepairSessionSpaceInMebibytes` and `setRepairSessionSpaceInMebibytes` in favor of `getRepairSessionSpaceInMiB` and `setRepairSessionSpaceInMiB` respectively diff --git a/src/java/org/apache/cassandra/auth/Permission.java b/src/java/org/apache/cassandra/auth/Permission.java index 20b781ae22..d6025a068f 100644 --- a/src/java/org/apache/cassandra/auth/Permission.java +++ b/src/java/org/apache/cassandra/auth/Permission.java @@ -31,13 +31,6 @@ import com.google.common.collect.Sets; */ public enum Permission { - /** @deprecated See CASSANDRA-4874 */ - @Deprecated(since = "1.2.0") - READ, - /** @deprecated See CASSANDRA-4874 */ - @Deprecated(since = "1.2.0") - WRITE, - // schema and role management // CREATE, ALTER and DROP permissions granted on an appropriate DataResource are required for // CREATE KEYSPACE and CREATE TABLE. diff --git a/src/java/org/apache/cassandra/auth/Resources.java b/src/java/org/apache/cassandra/auth/Resources.java index 8fa9ef3009..75353ee90c 100644 --- a/src/java/org/apache/cassandra/auth/Resources.java +++ b/src/java/org/apache/cassandra/auth/Resources.java @@ -20,8 +20,6 @@ package org.apache.cassandra.auth; import java.util.ArrayList; import java.util.List; -import org.apache.cassandra.utils.Hex; - public final class Resources { /** @@ -32,7 +30,7 @@ public final class Resources */ public static List chain(IResource resource) { - List chain = new ArrayList(); + List chain = new ArrayList<>(); while (true) { chain.add(resource); @@ -47,7 +45,7 @@ public final class Resources * Creates an IResource instance from its external name. * Resource implementation class is inferred by matching against the known IResource * impls' root level resources. - * @param name + * @param name external name to create IResource from * @return an IResource instance created from the name */ public static IResource fromName(String name) @@ -63,27 +61,4 @@ public final class Resources else throw new IllegalArgumentException(String.format("Name %s is not valid for any resource type", name)); } - - /** @deprecated See CASSANDRA-4874 */ - @Deprecated(since = "1.2.0") - public final static String ROOT = "cassandra"; - /** @deprecated See CASSANDRA-4874 */ - @Deprecated(since = "1.2.0") - public final static String KEYSPACES = "keyspaces"; - - /** @deprecated See CASSANDRA-4874 */ - @Deprecated(since = "1.2.0") - public static String toString(List resource) - { - StringBuilder buff = new StringBuilder(); - for (Object component : resource) - { - buff.append("/"); - if (component instanceof byte[]) - buff.append(Hex.bytesToHex((byte[])component)); - else - buff.append(component); - } - return buff.toString(); - } } diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java index 3670892c85..08f90e47cb 100644 --- a/src/java/org/apache/cassandra/config/Config.java +++ b/src/java/org/apache/cassandra/config/Config.java @@ -179,10 +179,6 @@ public class Config public int concurrent_materialized_view_writes = 32; public int available_processors = -1; - /** @deprecated See CASSANDRA-6504 */ - @Deprecated(since = "2.1") - public Integer concurrent_replicates = null; - public int memtable_flush_writers = 0; @Replaces(oldName = "memtable_heap_space_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE_INT, deprecated = true) public DataStorageSpec.IntMebibytesBound memtable_heap_space; @@ -297,10 +293,6 @@ public class Config @Replaces(oldName = "native_transport_receive_queue_capacity_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true) public DataStorageSpec.IntBytesBound native_transport_receive_queue_capacity = new DataStorageSpec.IntBytesBound("1MiB"); - /** @deprecated See CASSANDRA-5529 */ - @Deprecated(since = "1.2.6") - public Integer native_transport_max_negotiable_protocol_version = null; - /** * Max size of values in SSTables, in MebiBytes. * Default is the same as the native protocol frame limit: 256MiB. @@ -415,10 +407,6 @@ public class Config @Replaces(oldName = "cdc_free_space_check_interval_ms", converter = Converters.MILLIS_DURATION_INT, deprecated = true) public DurationSpec.IntMillisecondsBound cdc_free_space_check_interval = new DurationSpec.IntMillisecondsBound("250ms"); - /** @deprecated See CASSANDRA-3578 */ - @Deprecated(since = "2.1.3") - public int commitlog_periodic_queue_size = -1; - public String endpoint_snitch; public boolean dynamic_snitch = true; @Replaces(oldName = "dynamic_snitch_update_interval_in_ms", converter = Converters.MILLIS_DURATION_INT, deprecated = true) diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index f5d0bf70e5..ddf9c0d872 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -550,9 +550,6 @@ public class DatabaseDescriptor if (conf.concurrent_counter_writes < 2) throw new ConfigurationException("concurrent_counter_writes must be at least 2, but was " + conf.concurrent_counter_writes, false); - if (conf.concurrent_replicates != null) - logger.warn("concurrent_replicates has been deprecated and should be removed from cassandra.yaml"); - if (conf.networking_cache_size == null) conf.networking_cache_size = new DataStorageSpec.IntMebibytesBound(Math.min(128, (int) (Runtime.getRuntime().maxMemory() / (16 * 1048576)))); @@ -613,10 +610,6 @@ public class DatabaseDescriptor checkValidForByteConversion(conf.column_index_cache_size, "column_index_cache_size"); checkValidForByteConversion(conf.batch_size_warn_threshold, "batch_size_warn_threshold"); - if (conf.native_transport_max_negotiable_protocol_version != null) - logger.warn("The configuration option native_transport_max_negotiable_protocol_version has been deprecated " + - "and should be removed from cassandra.yaml as it has no longer has any effect."); - // if data dirs, commitlog dir, or saved caches dir are set in cassandra.yaml, use that. Otherwise, // use -Dcassandra.storagedir (set in cassandra-env.sh) as the parent dir for data/, commitlog/, and saved_caches/ if (conf.commitlog_directory == null) diff --git a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java index 44af98a6ea..2debc1adf9 100644 --- a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java +++ b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java @@ -22,6 +22,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; @@ -214,7 +215,7 @@ public abstract class AbstractReplicationStrategy for (Token token : metadata.sortedTokens()) { - Range range = metadata.getPrimaryRangeFor(token); + Range range = metadata.getPrimaryRangesFor(List.of(token)).iterator().next(); for (Replica replica : calculateNaturalReplicas(token, metadata)) { // LocalStrategy always returns (min, min] ranges for it's replicas, so we skip the check here @@ -231,7 +232,7 @@ public abstract class AbstractReplicationStrategy RangesAtEndpoint.Builder builder = RangesAtEndpoint.builder(endpoint); for (Token token : metadata.sortedTokens()) { - Range range = metadata.getPrimaryRangeFor(token); + Range range = metadata.getPrimaryRangesFor(List.of(token)).iterator().next(); Replica replica = calculateNaturalReplicas(token, metadata) .byEndpoint().get(endpoint); if (replica != null) @@ -251,7 +252,7 @@ public abstract class AbstractReplicationStrategy for (Token token : metadata.sortedTokens()) { - Range range = metadata.getPrimaryRangeFor(token); + Range range = metadata.getPrimaryRangesFor(List.of(token)).iterator().next(); for (Replica replica : calculateNaturalReplicas(token, metadata)) { // LocalStrategy always returns (min, min] ranges for it's replicas, so we skip the check here diff --git a/src/java/org/apache/cassandra/locator/TokenMetadata.java b/src/java/org/apache/cassandra/locator/TokenMetadata.java index 3399ecbcd3..151674a10d 100644 --- a/src/java/org/apache/cassandra/locator/TokenMetadata.java +++ b/src/java/org/apache/cassandra/locator/TokenMetadata.java @@ -349,13 +349,6 @@ public class TokenMetadata } } - /** @deprecated See CASSANDRA-4121 */ - @Deprecated(since = "1.2.0") - public void addBootstrapToken(Token token, InetAddressAndPort endpoint) - { - addBootstrapTokens(Collections.singleton(token), endpoint); - } - public void addBootstrapTokens(Collection tokens, InetAddressAndPort endpoint) { addBootstrapTokens(tokens, endpoint, null); @@ -612,13 +605,6 @@ public class TokenMetadata } } - /** @deprecated See CASSANDRA-4121 */ - @Deprecated(since = "1.2.0") - public Token getToken(InetAddressAndPort endpoint) - { - return getTokens(endpoint).iterator().next(); - } - public boolean isMember(InetAddressAndPort endpoint) { assert endpoint != null; @@ -794,13 +780,6 @@ public class TokenMetadata return ranges; } - /** @deprecated See CASSANDRA-4121 */ - @Deprecated(since = "1.2.0") - public Range getPrimaryRangeFor(Token right) - { - return getPrimaryRangesFor(Arrays.asList(right)).iterator().next(); - } - public ArrayList sortedTokens() { return sortedTokens; diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 352e841cae..79a80d6f4d 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -5520,7 +5520,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE } return String.format("Removing token (%s). Waiting for replication confirmation from [%s].", - tokenMetadata.getToken(removingNode), + tokenMetadata.getTokens(removingNode).iterator().next(), StringUtils.join(toFormat, ",")); } diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java b/src/java/org/apache/cassandra/service/StorageServiceMBean.java index 1de796c6bd..4ca8194164 100644 --- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java +++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java @@ -210,13 +210,6 @@ public interface StorageServiceMBean extends NotificationEmitter /** Retrieve this hosts unique ID */ public String getLocalHostId(); - /** - * {@link StorageServiceMBean#getEndpointToHostId} - * @deprecated See CASSANDRA-10382 - */ - @Deprecated(since = "2.1.10") - public Map getHostIdMap(); - /** * Retrieve the mapping of endpoint to host ID. * @deprecated See CASSANDRA-7544 @@ -411,15 +404,8 @@ public interface StorageServiceMBean extends NotificationEmitter * If tableNames array is empty, all CFs are scrubbed. * * Scrubbed CFs will be snapshotted first, if disableSnapshot is false - * @deprecated See CASSANDRA-9406 + * @deprecated See CASSANDRA-11179 */ - @Deprecated(since = "2.2.0") - default int scrub(boolean disableSnapshot, boolean skipCorrupted, String keyspaceName, String... tableNames) throws IOException, ExecutionException, InterruptedException - { - return scrub(disableSnapshot, skipCorrupted, true, keyspaceName, tableNames); - } - - /** @deprecated See CASSANDRA-11179 */ @Deprecated(since = "3.5") default int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, String keyspaceName, String... tableNames) throws IOException, ExecutionException, InterruptedException { diff --git a/src/java/org/apache/cassandra/tools/JMXTool.java b/src/java/org/apache/cassandra/tools/JMXTool.java index dcc9f6a3ea..c3e7981c5a 100644 --- a/src/java/org/apache/cassandra/tools/JMXTool.java +++ b/src/java/org/apache/cassandra/tools/JMXTool.java @@ -302,7 +302,8 @@ public class JMXTool DiffResult operations = diff(leftInfo.operationSet(), rightInfo.operationSet(), operation -> { for (CliPattern p : excludeOperations) { - if (p.pattern.matcher(operation.name).matches()) + if (p.pattern.matcher(operation.name).matches() || + p.pattern.matcher(operation.toString().replaceAll(" +", "")).matches()) return false; } return true; diff --git a/src/java/org/apache/cassandra/tools/NodeTool.java b/src/java/org/apache/cassandra/tools/NodeTool.java index 9c4d7858fd..a630e66deb 100644 --- a/src/java/org/apache/cassandra/tools/NodeTool.java +++ b/src/java/org/apache/cassandra/tools/NodeTool.java @@ -96,8 +96,6 @@ public class NodeTool List> commands = newArrayList( Assassinate.class, CassHelp.class, - CfHistograms.class, - CfStats.class, CIDRFilteringStats.class, Cleanup.class, ClearSnapshot.class, diff --git a/src/java/org/apache/cassandra/tools/nodetool/CfHistograms.java b/src/java/org/apache/cassandra/tools/nodetool/CfHistograms.java deleted file mode 100644 index 0a8dd44588..0000000000 --- a/src/java/org/apache/cassandra/tools/nodetool/CfHistograms.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ -package org.apache.cassandra.tools.nodetool; - -import io.airlift.airline.Command; - -/** - * @deprecated use TableHistograms - */ -@Command(name = "cfhistograms", hidden = true, description = "Print statistic histograms for a given column family") -@Deprecated(since = "2.2.0") -public class CfHistograms extends TableHistograms -{ -} diff --git a/src/java/org/apache/cassandra/tools/nodetool/CfStats.java b/src/java/org/apache/cassandra/tools/nodetool/CfStats.java deleted file mode 100644 index d76b39d5bd..0000000000 --- a/src/java/org/apache/cassandra/tools/nodetool/CfStats.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ -package org.apache.cassandra.tools.nodetool; - -import io.airlift.airline.Command; - -/** - * @deprecated use TableStats - */ -@Command(name = "cfstats", hidden = true, description = "Print statistics on tables") -@Deprecated(since = "2.2.0") -public class CfStats extends TableStats -{ -} diff --git a/test/data/config/version=5.0-alpha1.yml b/test/data/config/version=5.0-alpha1.yml index 21630a19d2..01a5f90ea6 100644 --- a/test/data/config/version=5.0-alpha1.yml +++ b/test/data/config/version=5.0-alpha1.yml @@ -206,7 +206,6 @@ zero_ttl_on_twcs_enabled: "java.lang.Boolean" cdc_free_space_check_interval: "org.apache.cassandra.config.DurationSpec.IntMillisecondsBound" roles_cache_max_entries: "java.lang.Integer" allow_filtering_enabled: "java.lang.Boolean" -native_transport_max_negotiable_protocol_version: "java.lang.Integer" columns_per_table_fail_threshold: "java.lang.Integer" start_native_transport: "java.lang.Boolean" ssl_storage_port: "java.lang.Integer" @@ -344,7 +343,6 @@ authenticator: internode_socket_receive_buffer_size: "org.apache.cassandra.config.DataStorageSpec.IntBytesBound" allow_insecure_udfs: "java.lang.Boolean" internode_application_receive_queue_capacity: "org.apache.cassandra.config.DataStorageSpec.IntBytesBound" -concurrent_replicates: "java.lang.Integer" user_defined_functions_enabled: "java.lang.Boolean" user_defined_functions_threads_enabled: "java.lang.Boolean" streaming_slow_events_log_timeout: "org.apache.cassandra.config.DurationSpec.IntSecondsBound" @@ -441,7 +439,6 @@ hints_compression: class_name: "java.lang.String" parameters: "java.util.Map" native_transport_max_auth_threads: "java.lang.Integer" -commitlog_periodic_queue_size: "java.lang.Integer" force_new_prepared_statement_behaviour: "java.lang.Boolean" back_pressure_enabled: "java.lang.Boolean" materialized_views_per_table_warn_threshold: "java.lang.Integer" diff --git a/test/simulator/main/org/apache/cassandra/simulator/cluster/OnInstanceRepair.java b/test/simulator/main/org/apache/cassandra/simulator/cluster/OnInstanceRepair.java index 9da7317fdd..8344a65db7 100644 --- a/test/simulator/main/org/apache/cassandra/simulator/cluster/OnInstanceRepair.java +++ b/test/simulator/main/org/apache/cassandra/simulator/cluster/OnInstanceRepair.java @@ -20,6 +20,7 @@ package org.apache.cassandra.simulator.cluster; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Map; import org.apache.cassandra.db.Keyspace; @@ -87,7 +88,7 @@ class OnInstanceRepair extends ClusterAction Keyspace keyspace = Keyspace.open(keyspaceName); TokenMetadata metadata = StorageService.instance.getTokenMetadata().cloneOnlyTokenMap(); invokeRepair(keyspaceName, repairPaxos, repairOnlyPaxos, - () -> primaryRangeOnly ? Collections.singletonList(metadata.getPrimaryRangeFor(currentToken())) + () -> primaryRangeOnly ? Collections.singletonList(metadata.getPrimaryRangesFor(List.of(currentToken())).iterator().next()) : keyspace.getReplicationStrategy().getAddressReplicas(metadata).get(getBroadcastAddressAndPort()).asList(Replica::range), primaryRangeOnly, force, listener); } diff --git a/test/unit/org/apache/cassandra/config/ConfigCompatibilityTest.java b/test/unit/org/apache/cassandra/config/ConfigCompatibilityTest.java index 51e0b0ceda..e6e714daaa 100644 --- a/test/unit/org/apache/cassandra/config/ConfigCompatibilityTest.java +++ b/test/unit/org/apache/cassandra/config/ConfigCompatibilityTest.java @@ -91,6 +91,9 @@ public class ConfigCompatibilityTest private static final Set REMOVED_IN_50 = ImmutableSet.builder() .add("commitlog_sync_batch_window_in_ms") + .add("native_transport_max_negotiable_protocol_version") + .add("concurrent_replicates") + .add("commitlog_periodic_queue_size") .build(); private static final Set ALLOW_LIST = Sets.union(REMOVED_IN_40, REMOVED_IN_50); diff --git a/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java b/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java index a4cbcf4385..0204b22d70 100644 --- a/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java +++ b/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java @@ -19,6 +19,7 @@ package org.apache.cassandra.locator; import java.net.UnknownHostException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -211,7 +212,7 @@ public class SimpleStrategyTest // bootstrap at the end of the ring Token bsToken = new BigIntegerToken(String.valueOf(210)); InetAddressAndPort bootstrapEndpoint = InetAddressAndPort.getByName("127.0.0.11"); - tmd.addBootstrapToken(bsToken, bootstrapEndpoint); + tmd.addBootstrapTokens(Collections.singleton(bsToken), bootstrapEndpoint); AbstractReplicationStrategy strategy = null; for (String keyspaceName : Schema.instance.distributedKeyspaces().names()) diff --git a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java index dc022beb71..5d4f681e5c 100644 --- a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java +++ b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java @@ -529,10 +529,10 @@ public class LeaveAndBootstrapTest assertTrue(tmd.isMember(hosts.get(2))); assertFalse(tmd.isLeaving(hosts.get(2))); - assertEquals(keyTokens.get(3), tmd.getToken(hosts.get(2))); + assertEquals(keyTokens.get(3), tmd.getTokens(hosts.get(2)).iterator().next()); assertTrue(tmd.isMember(hosts.get(3))); assertFalse(tmd.isLeaving(hosts.get(3))); - assertEquals(keyTokens.get(2), tmd.getToken(hosts.get(3))); + assertEquals(keyTokens.get(2), tmd.getTokens(hosts.get(3)).iterator().next()); assertTrue(tmd.getBootstrapTokens().isEmpty()); } @@ -559,14 +559,14 @@ public class LeaveAndBootstrapTest ss.onChange(hosts.get(2), ApplicationState.STATUS, valueFactory.leaving(Collections.singleton(endpointTokens.get(2)))); assertTrue(tmd.isLeaving(hosts.get(2))); - assertEquals(endpointTokens.get(2), tmd.getToken(hosts.get(2))); + assertEquals(endpointTokens.get(2), tmd.getTokens(hosts.get(2)).iterator().next()); // back to normal Gossiper.instance.injectApplicationState(hosts.get(2), ApplicationState.TOKENS, valueFactory.tokens(Collections.singleton(keyTokens.get(2)))); ss.onChange(hosts.get(2), ApplicationState.STATUS, valueFactory.normal(Collections.singleton(keyTokens.get(2)))); assertTrue(tmd.getSizeOfLeavingEndpoints() == 0); - assertEquals(keyTokens.get(2), tmd.getToken(hosts.get(2))); + assertEquals(keyTokens.get(2), tmd.getTokens(hosts.get(2)).iterator().next()); // node 3 goes through leave and left and then jumps to normal at its new token ss.onChange(hosts.get(2), ApplicationState.STATUS, valueFactory.leaving(Collections.singleton(keyTokens.get(2)))); @@ -577,7 +577,7 @@ public class LeaveAndBootstrapTest assertTrue(tmd.getBootstrapTokens().isEmpty()); assertTrue(tmd.getSizeOfLeavingEndpoints() == 0); - assertEquals(keyTokens.get(4), tmd.getToken(hosts.get(2))); + assertEquals(keyTokens.get(4), tmd.getTokens(hosts.get(2)).iterator().next()); } @Test @@ -602,7 +602,7 @@ public class LeaveAndBootstrapTest Gossiper.instance.injectApplicationState(hosts.get(2), ApplicationState.TOKENS, valueFactory.tokens(Collections.singleton(keyTokens.get(0)))); ss.onChange(hosts.get(2), ApplicationState.STATUS, valueFactory.leaving(Collections.singleton(keyTokens.get(0)))); - assertEquals(keyTokens.get(0), tmd.getToken(hosts.get(2))); + assertEquals(keyTokens.get(0), tmd.getTokens(hosts.get(2)).iterator().next()); assertTrue(tmd.isLeaving(hosts.get(2))); assertNull(tmd.getEndpoint(endpointTokens.get(2))); diff --git a/test/unit/org/apache/cassandra/service/MoveTest.java b/test/unit/org/apache/cassandra/service/MoveTest.java index 57b91b9812..a642ff3377 100644 --- a/test/unit/org/apache/cassandra/service/MoveTest.java +++ b/test/unit/org/apache/cassandra/service/MoveTest.java @@ -967,14 +967,14 @@ public class MoveTest ss.onChange(hosts.get(2), ApplicationState.STATUS, valueFactory.moving(newToken)); assertTrue(tmd.isMoving(hosts.get(2))); - assertEquals(endpointTokens.get(2), tmd.getToken(hosts.get(2))); + assertEquals(endpointTokens.get(2), tmd.getTokens(hosts.get(2)).iterator().next()); // back to normal Gossiper.instance.injectApplicationState(hosts.get(2), ApplicationState.TOKENS, valueFactory.tokens(Collections.singleton(newToken))); ss.onChange(hosts.get(2), ApplicationState.STATUS, valueFactory.normal(Collections.singleton(newToken))); assertTrue(tmd.getSizeOfMovingEndpoints() == 0); - assertEquals(newToken, tmd.getToken(hosts.get(2))); + assertEquals(newToken, tmd.getTokens(hosts.get(2)).iterator().next()); newToken = positionToken(8); // node 2 goes through leave and left and then jumps to normal at its new token @@ -984,7 +984,7 @@ public class MoveTest assertTrue(tmd.getBootstrapTokens().isEmpty()); assertTrue(tmd.getSizeOfMovingEndpoints() == 0); - assertEquals(newToken, tmd.getToken(hosts.get(2))); + assertEquals(newToken, tmd.getTokens(hosts.get(2)).iterator().next()); } private static Collection makeAddrs(String... hosts) throws UnknownHostException diff --git a/test/unit/org/apache/cassandra/tools/JMXCompatabilityTest.java b/test/unit/org/apache/cassandra/tools/JMXCompatabilityTest.java index ee98545716..d4cdfae827 100644 --- a/test/unit/org/apache/cassandra/tools/JMXCompatabilityTest.java +++ b/test/unit/org/apache/cassandra/tools/JMXCompatabilityTest.java @@ -89,13 +89,13 @@ public class JMXCompatabilityTest extends CQLTester GCInspector.register(); CassandraDaemon.registerNativeAccess(); - String name = KEYSPACE + "." + createTable("CREATE TABLE %s (pk int PRIMARY KEY)"); + String name = KEYSPACE + '.' + createTable("CREATE TABLE %s (pk int PRIMARY KEY)"); // use net to register everything like storage proxy executeNet(ProtocolVersion.CURRENT, new SimpleStatement("INSERT INTO " + name + " (pk) VALUES (?)", 42)); executeNet(ProtocolVersion.CURRENT, new SimpleStatement("SELECT * FROM " + name + " WHERE pk=?", 42)); - String script = "tools/bin/jmxtool dump -f yaml --url service:jmx:rmi:///jndi/rmi://" + jmxHost + ":" + jmxPort + "/jmxrmi > " + TMP.getRoot().getAbsolutePath() + "/out.yaml"; + String script = "tools/bin/jmxtool dump -f yaml --url service:jmx:rmi:///jndi/rmi://" + jmxHost + ':' + jmxPort + "/jmxrmi > " + TMP.getRoot().getAbsolutePath() + "/out.yaml"; ToolRunner.invoke(ENV, "bash", "-c", script).assertOnCleanExit(); CREATED_TABLE = true; } @@ -119,14 +119,16 @@ public class JMXCompatabilityTest extends CQLTester ".*keyspace=system,(scope|table|columnfamily)=hints.*", ".*keyspace=system,(scope|table|columnfamily)=batchlog.*"); List excludeAttributes = newArrayList("RPCServerRunning", // removed in CASSANDRA-11115 - "MaxNativeProtocolVersion"); + "MaxNativeProtocolVersion", + "HostIdMap"); // removed in CASSANDRA-18959 List excludeOperations = newArrayList("startRPCServer", "stopRPCServer", // removed in CASSANDRA-11115 // nodetool apis that were changed, "decommission", // -> decommission(boolean) "forceRepairAsync", // -> repairAsync "forceRepairRangeAsync", // -> repairAsync "beginLocalSampling", // -> beginLocalSampling(p1: java.lang.String, p2: int, p3: int): void - "finishLocalSampling" // -> finishLocalSampling(p1: java.lang.String, p2: int): java.util.List + "finishLocalSampling", // -> finishLocalSampling(p1: java.lang.String, p2: int): java.util.List + "scrub\\(p1:boolean,p2:boolean,p3:java.lang.String,p4:java.lang.String\\[\\]\\):int" // removed in CASSANDRA-18959 ); if (BtiFormat.isSelected()) @@ -157,14 +159,16 @@ public class JMXCompatabilityTest extends CQLTester ); List excludeAttributes = newArrayList("RPCServerRunning", // removed in CASSANDRA-11115 "MaxNativeProtocolVersion", - "StreamingSocketTimeout"); + "StreamingSocketTimeout", + "HostIdMap"); // removed in CASSANDRA-18959; List excludeOperations = newArrayList("startRPCServer", "stopRPCServer", // removed in CASSANDRA-11115 // nodetool apis that were changed, "decommission", // -> decommission(boolean) "forceRepairAsync", // -> repairAsync "forceRepairRangeAsync", // -> repairAsync "beginLocalSampling", // -> beginLocalSampling(p1: java.lang.String, p2: int, p3: int): void - "finishLocalSampling" // -> finishLocalSampling(p1: java.lang.String, p2: int): java.util.List + "finishLocalSampling", // -> finishLocalSampling(p1: java.lang.String, p2: int): java.util.List + "scrub\\(p1:boolean,p2:boolean,p3:java.lang.String,p4:java.lang.String\\[\\]\\):int" // removed in CASSANDRA-18959 ); if (BtiFormat.isSelected()) @@ -181,8 +185,8 @@ public class JMXCompatabilityTest extends CQLTester { List excludeObjects = newArrayList("org.apache.cassandra.metrics:type=BufferPool,name=(Misses|Size)" // removed in CASSANDRA-18313 ); - List excludeAttributes = newArrayList(); - List excludeOperations = newArrayList(); + List excludeAttributes = newArrayList("HostIdMap"); // removed in CASSANDRA-18959 + List excludeOperations = newArrayList("scrub\\(p1:boolean,p2:boolean,p3:java.lang.String,p4:java.lang.String\\[\\]\\):int"); // removed in CASSANDRA-18959 if (BtiFormat.isSelected()) { @@ -198,8 +202,8 @@ public class JMXCompatabilityTest extends CQLTester { List excludeObjects = newArrayList("org.apache.cassandra.metrics:type=BufferPool,name=(Misses|Size)" // removed in CASSANDRA-18313 ); - List excludeAttributes = newArrayList(); - List excludeOperations = newArrayList(); + List excludeAttributes = newArrayList("HostIdMap"); // removed in CASSANDRA-18959 + List excludeOperations = newArrayList("scrub\\(p1:boolean,p2:boolean,p3:java.lang.String,p4:java.lang.String\\[\\]\\):int"); // removed in CASSANDRA-18959 if (BtiFormat.isSelected()) {