You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/03/19 16:08:09 UTC
[cassandra] 01/03: Allow sstableloader to use SSL on the native
port.
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 1a14c3ac483ce3a118b3f8acfdd3d26d3c5a0241
Author: Brandon Williams <br...@apache.org>
AuthorDate: Thu Mar 19 10:43:45 2020 -0500
Allow sstableloader to use SSL on the native port.
Patch by Ian Cleasby, reviewed by brandonwilliams for CASSANDRA-14904
---
CHANGES.txt | 2 +
.../org/apache/cassandra/tools/LoaderOptions.java | 16 ++++--
test/conf/unit-test-conf/test-native-port.yaml | 61 ++++++++++++++++++++++
.../apache/cassandra/tools/LoaderOptionsTest.java | 47 +++++++++++++++++
4 files changed, 122 insertions(+), 4 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 6a1cf93..508ae19 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -34,6 +34,8 @@
* Make native_transport_max_concurrent_requests_in_bytes updatable (CASSANDRA-15519)
* Cleanup and improvements to IndexInfo/ColumnIndex (CASSANDRA-15469)
* Potential Overflow in DatabaseDescriptor Functions That Convert Between KB/MB & Bytes (CASSANDRA-15470)
+Merged from 3.11:
+ * Allow sstableloader to use SSL on the native port (CASSANDRA-14904)
Merged from 3.0:
* Run evictFromMembership in GossipStage (CASSANDRA-15592)
Merged from 2.2:
diff --git a/src/java/org/apache/cassandra/tools/LoaderOptions.java b/src/java/org/apache/cassandra/tools/LoaderOptions.java
index 9acf8a5..1801941 100644
--- a/src/java/org/apache/cassandra/tools/LoaderOptions.java
+++ b/src/java/org/apache/cassandra/tools/LoaderOptions.java
@@ -386,10 +386,6 @@ public class LoaderOptions
config.inter_dc_stream_throughput_outbound_megabits_per_sec = 0;
}
- if (cmd.hasOption(NATIVE_PORT_OPTION))
- nativePort = Integer.parseInt(cmd.getOptionValue(NATIVE_PORT_OPTION));
- else
- nativePort = config.native_transport_port;
if (cmd.hasOption(INITIAL_HOST_ADDRESS_OPTION))
{
@@ -462,6 +458,18 @@ public class LoaderOptions
clientEncOptions = clientEncOptions.withEnabled(true);
}
+ if (cmd.hasOption(NATIVE_PORT_OPTION))
+ {
+ nativePort = Integer.parseInt(cmd.getOptionValue(NATIVE_PORT_OPTION));
+ }
+ else
+ {
+ if (config.native_transport_port_ssl != null && (config.client_encryption_options.enabled || clientEncOptions.enabled))
+ nativePort = config.native_transport_port_ssl;
+ else
+ nativePort = config.native_transport_port;
+ }
+
if (cmd.hasOption(SSL_TRUSTSTORE))
{
clientEncOptions = clientEncOptions.withTrustStore(cmd.getOptionValue(SSL_TRUSTSTORE));
diff --git a/test/conf/unit-test-conf/test-native-port.yaml b/test/conf/unit-test-conf/test-native-port.yaml
new file mode 100644
index 0000000..b46525f
--- /dev/null
+++ b/test/conf/unit-test-conf/test-native-port.yaml
@@ -0,0 +1,61 @@
+#
+# Warning!
+# Consider the effects on 'o.a.c.i.s.LegacySSTableTest' before changing schemas in this file.
+#
+cluster_name: Test Cluster
+# memtable_allocation_type: heap_buffers
+memtable_allocation_type: offheap_objects
+commitlog_sync: batch
+commitlog_sync_batch_window_in_ms: 1.0
+commitlog_segment_size_in_mb: 5
+commitlog_directory: build/test/cassandra/commitlog
+# commitlog_compression:
+# - class_name: LZ4Compressor
+cdc_raw_directory: build/test/cassandra/cdc_raw
+cdc_enabled: false
+hints_directory: build/test/cassandra/hints
+partitioner: org.apache.cassandra.dht.ByteOrderedPartitioner
+listen_address: 127.0.0.1
+storage_port: 7010
+ssl_storage_port: 7011
+start_native_transport: true
+native_transport_port_ssl: 9142
+column_index_size_in_kb: 4
+saved_caches_directory: build/test/cassandra/saved_caches
+data_file_directories:
+- build/test/cassandra/data
+disk_access_mode: mmap
+seed_provider:
+- class_name: org.apache.cassandra.locator.SimpleSeedProvider
+ parameters:
+ - seeds: "127.0.0.1:7010"
+endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch
+dynamic_snitch: true
+server_encryption_options:
+ internode_encryption: none
+ keystore: conf/.keystore
+ keystore_password: cassandra
+ truststore: conf/.truststore
+ truststore_password: cassandra
+incremental_backups: true
+concurrent_compactors: 4
+compaction_throughput_mb_per_sec: 0
+row_cache_class_name: org.apache.cassandra.cache.OHCProvider
+row_cache_size_in_mb: 16
+enable_user_defined_functions: true
+enable_scripted_user_defined_functions: true
+prepared_statements_cache_size_mb: 1
+corrupted_tombstone_strategy: exception
+stream_entire_sstables: true
+stream_throughput_outbound_megabits_per_sec: 200000000
+
+client_encryption_options:
+ enabled: true
+ # If enabled and optional is set to true encrypted and unencrypted connections are handled.
+ optional: false
+ keystore: conf/cassandra_ssl_test.keystore
+ keystore_password: cassandra
+ # require_client_auth: false
+ # Set trustore and truststore_password if require_client_auth is true
+ truststore: conf/cassandra_ssl_test.truststore
+ truststore_password: cassandra
diff --git a/test/unit/org/apache/cassandra/tools/LoaderOptionsTest.java b/test/unit/org/apache/cassandra/tools/LoaderOptionsTest.java
new file mode 100644
index 0000000..67258ad
--- /dev/null
+++ b/test/unit/org/apache/cassandra/tools/LoaderOptionsTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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;
+import java.io.File;
+import java.nio.file.Paths;
+import org.junit.Test;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+
+import static org.apache.cassandra.tools.ToolsTester.sstableDirName;
+import static org.junit.Assert.*;
+
+// LoaderOptionsTester for custom configuration
+public class LoaderOptionsTest
+{
+ @Test
+ public void testNativePort() throws Exception {
+ //Default Cassandra config
+ File config = Paths.get(".", "test", "conf", "cassandra.yaml").normalize().toFile();
+ String[] args = {"-d", "127.9.9.1", "-f", config.getAbsolutePath(), sstableDirName("legacy_sstables", "legacy_ma_simple")};
+ LoaderOptions options = LoaderOptions.builder().parseArgs(args).build();
+ assertEquals(9042, options.nativePort);
+
+
+ // SSL Enabled Cassandra config
+ config = Paths.get(".", "test", "conf", "unit-test-conf/test-native-port.yaml").normalize().toFile();
+ String[] args2 = {"-d", "127.9.9.1", "-f", config.getAbsolutePath(), sstableDirName("legacy_sstables", "legacy_ma_simple")};
+ options = LoaderOptions.builder().parseArgs(args2).build();
+ assertEquals(9142, options.nativePort);
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org