diff --git a/CHANGES.txt b/CHANGES.txt index db336e5961..f8933fbc7d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -48,6 +48,7 @@ Merged from 2.2: * Add new types to Stress (CASSANDRA-9556) * Add property to allow listening on broadcast interface (CASSANDRA-9748) Merged from 2.1: + * Sane default (200Mbps) for inter-DC streaming througput (CASSANDRA-9708) * Match cassandra-loader options in COPY FROM (CASSANDRA-9303) * Fix binding to any address in CqlBulkRecordWriter (CASSANDRA-9309) * cqlsh fails to decode utf-8 characters for text typed columns (CASSANDRA-10875) diff --git a/NEWS.txt b/NEWS.txt index 3d468b6cdc..20ab20231d 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -182,6 +182,13 @@ Operations -Dcassandra.ignore_dc=true. - Reloading the configuration file of GossipingPropertyFileSnitch has been disabled. +Upgrading +--------- + - The default for the inter-DC stream throughput setting + (inter_dc_stream_throughput_outbound_megabits_per_sec in cassandra.yaml) is + the same than the one for intra-DC one (200Mbps) instead of being unlimited. + Having it unlimited was never intended and was a bug. + New features ------------ - Time windows in DTCS are now limited to 1 day by default to be able to diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml index a8a90baf31..779575ce45 100644 --- a/conf/cassandra.yaml +++ b/conf/cassandra.yaml @@ -704,7 +704,8 @@ sstable_preemptive_open_interval_in_mb: 50 # this setting allows users to throttle inter dc stream throughput in addition # to throttling all network stream traffic as configured with # stream_throughput_outbound_megabits_per_sec -# inter_dc_stream_throughput_outbound_megabits_per_sec: +# When unset, the default is 200 Mbps or 25 MB/s +# inter_dc_stream_throughput_outbound_megabits_per_sec: 200 # How long the coordinator should wait for read operations to complete read_request_timeout_in_ms: 5000 diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java index 54cb0897bd..9277df902e 100644 --- a/src/java/org/apache/cassandra/config/Config.java +++ b/src/java/org/apache/cassandra/config/Config.java @@ -156,7 +156,7 @@ public class Config public Integer max_streaming_retries = 3; public volatile Integer stream_throughput_outbound_megabits_per_sec = 200; - public volatile Integer inter_dc_stream_throughput_outbound_megabits_per_sec = 0; + public volatile Integer inter_dc_stream_throughput_outbound_megabits_per_sec = 200; public String[] data_file_directories = new String[0]; diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index b74caed791..78c45db71e 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -1148,6 +1148,18 @@ public class StorageService extends NotificationBroadcasterSupport implements IE return DatabaseDescriptor.getStreamThroughputOutboundMegabitsPerSec(); } + public void setInterDCStreamThroughputMbPerSec(int value) + { + DatabaseDescriptor.setInterDCStreamThroughputOutboundMegabitsPerSec(value); + logger.info("setinterdcstreamthroughput: throttle set to {}", value); + } + + public int getInterDCStreamThroughputMbPerSec() + { + return DatabaseDescriptor.getInterDCStreamThroughputOutboundMegabitsPerSec(); + } + + public int getCompactionThroughputMbPerSec() { return DatabaseDescriptor.getCompactionThroughputMbPerSec(); diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java b/src/java/org/apache/cassandra/service/StorageServiceMBean.java index eef34c08ea..4e2f632a00 100644 --- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java +++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java @@ -486,6 +486,9 @@ public interface StorageServiceMBean extends NotificationEmitter public void setStreamThroughputMbPerSec(int value); public int getStreamThroughputMbPerSec(); + public void setInterDCStreamThroughputMbPerSec(int value); + public int getInterDCStreamThroughputMbPerSec(); + public int getCompactionThroughputMbPerSec(); public void setCompactionThroughputMbPerSec(int value); diff --git a/src/java/org/apache/cassandra/tools/BulkLoader.java b/src/java/org/apache/cassandra/tools/BulkLoader.java index 2b94a68768..3e32f66c27 100644 --- a/src/java/org/apache/cassandra/tools/BulkLoader.java +++ b/src/java/org/apache/cassandra/tools/BulkLoader.java @@ -56,6 +56,7 @@ public class BulkLoader private static final String PASSWD_OPTION = "password"; private static final String AUTH_PROVIDER_OPTION = "auth-provider"; private static final String THROTTLE_MBITS = "throttle"; + private static final String INTER_DC_THROTTLE_MBITS = "inter-dc-throttle"; /* client encryption options */ private static final String SSL_TRUSTSTORE = "truststore"; @@ -87,6 +88,7 @@ public class BulkLoader handler, options.connectionsPerHost); DatabaseDescriptor.setStreamThroughputOutboundMegabitsPerSec(options.throttle); + DatabaseDescriptor.setInterDCStreamThroughputOutboundMegabitsPerSec(options.interDcThrottle); StreamResultFuture future = null; ProgressIndicator indicator = new ProgressIndicator(); @@ -313,6 +315,7 @@ public class BulkLoader public String authProviderName; public AuthProvider authProvider; public int throttle = 0; + public int interDcThrottle = 0; public int storagePort; public int sslStoragePort; public EncryptionOptions encOptions = new EncryptionOptions.ClientEncryptionOptions(); @@ -443,6 +446,7 @@ public class BulkLoader opts.storagePort = config.storage_port; opts.sslStoragePort = config.ssl_storage_port; opts.throttle = config.stream_throughput_outbound_megabits_per_sec; + opts.interDcThrottle = config.inter_dc_stream_throughput_outbound_megabits_per_sec; opts.encOptions = config.client_encryption_options; opts.serverEncOptions = config.server_encryption_options; @@ -451,6 +455,11 @@ public class BulkLoader opts.throttle = Integer.parseInt(cmd.getOptionValue(THROTTLE_MBITS)); } + if (cmd.hasOption(INTER_DC_THROTTLE_MBITS)) + { + opts.interDcThrottle = Integer.parseInt(cmd.getOptionValue(INTER_DC_THROTTLE_MBITS)); + } + if (cmd.hasOption(SSL_TRUSTSTORE)) { opts.encOptions.truststore = cmd.getOptionValue(SSL_TRUSTSTORE); @@ -577,6 +586,7 @@ public class BulkLoader options.addOption("d", INITIAL_HOST_ADDRESS_OPTION, "initial hosts", "Required. try to connect to these hosts (comma separated) initially for ring information"); options.addOption("p", NATIVE_PORT_OPTION, "rpc port", "port used for native connection (default 9042)"); options.addOption("t", THROTTLE_MBITS, "throttle", "throttle speed in Mbits (default unlimited)"); + options.addOption("idct", INTER_DC_THROTTLE_MBITS, "inter-dc-throttle", "inter-datacenter throttle speed in Mbits (default unlimited)"); options.addOption("u", USER_OPTION, "username", "username for cassandra authentication"); options.addOption("pw", PASSWD_OPTION, "password", "password for cassandra authentication"); options.addOption("ap", AUTH_PROVIDER_OPTION, "auth provider", "custom AuthProvider class name for cassandra authentication"); @@ -604,7 +614,7 @@ public class BulkLoader "you will need to have the files Standard1-g-1-Data.db and Standard1-g-1-Index.db into a directory /path/to/Keyspace1/Standard1/."; String footer = System.lineSeparator() + "You can provide cassandra.yaml file with -f command line option to set up streaming throughput, client and server encryption options. " + - "Only stream_throughput_outbound_megabits_per_sec, server_encryption_options and client_encryption_options are read from yaml. " + + "Only stream_throughput_outbound_megabits_per_sec, inter_dc_stream_throughput_outbound_megabits_per_sec, server_encryption_options and client_encryption_options are read from yaml. " + "You can override options read from cassandra.yaml with corresponding command line options."; new HelpFormatter().printHelp(usage, header, options, footer); } diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java index 6f1c75311c..291eeedd4f 100644 --- a/src/java/org/apache/cassandra/tools/NodeProbe.java +++ b/src/java/org/apache/cassandra/tools/NodeProbe.java @@ -962,7 +962,15 @@ public class NodeProbe implements AutoCloseable return ssProxy.getStreamThroughputMbPerSec(); } - public double getTraceProbability() {return ssProxy.getTraceProbability();} + public int getInterDCStreamThroughput() + { + return ssProxy.getInterDCStreamThroughputMbPerSec(); + } + + public double getTraceProbability() + { + return ssProxy.getTraceProbability(); + } public int getExceptionCount() { @@ -1004,6 +1012,11 @@ public class NodeProbe implements AutoCloseable ssProxy.setStreamThroughputMbPerSec(value); } + public void setInterDCStreamThroughput(int value) + { + ssProxy.setInterDCStreamThroughputMbPerSec(value); + } + public void setTraceProbability(double value) { ssProxy.setTraceProbability(value); diff --git a/src/java/org/apache/cassandra/tools/NodeTool.java b/src/java/org/apache/cassandra/tools/NodeTool.java index 9728356bc9..8e9345031d 100644 --- a/src/java/org/apache/cassandra/tools/NodeTool.java +++ b/src/java/org/apache/cassandra/tools/NodeTool.java @@ -81,6 +81,7 @@ public class NodeTool GetCompactionThroughput.class, GetStreamThroughput.class, GetTraceProbability.class, + GetInterDCStreamThroughput.class, GetEndpoints.class, GetSSTables.class, GossipInfo.class, @@ -103,6 +104,7 @@ public class NodeTool SetCompactionThreshold.class, SetCompactionThroughput.class, SetStreamThroughput.class, + SetInterDCStreamThroughput.class, SetTraceProbability.class, Snapshot.class, ListSnapshots.class, diff --git a/src/java/org/apache/cassandra/tools/nodetool/GetInterDCStreamThroughput.java b/src/java/org/apache/cassandra/tools/nodetool/GetInterDCStreamThroughput.java new file mode 100644 index 0000000000..4c354c03ff --- /dev/null +++ b/src/java/org/apache/cassandra/tools/nodetool/GetInterDCStreamThroughput.java @@ -0,0 +1,33 @@ +/* + * 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.command.Command; + +import org.apache.cassandra.tools.NodeProbe; +import org.apache.cassandra.tools.NodeTool.NodeToolCmd; + +@Command(name = "getinterdcstreamthroughput", description = "Print the Mb/s throughput cap for inter-datacenter streaming in the system") +public class GetInterDCStreamThroughput extends NodeToolCmd +{ + @Override + public void execute(NodeProbe probe) + { + System.out.println("Current inter-datacenter stream throughput: " + probe.getInterDCStreamThroughput() + " Mb/s"); + } +} diff --git a/src/java/org/apache/cassandra/tools/nodetool/SetInterDCStreamThroughput.java b/src/java/org/apache/cassandra/tools/nodetool/SetInterDCStreamThroughput.java new file mode 100644 index 0000000000..41ce43a648 --- /dev/null +++ b/src/java/org/apache/cassandra/tools/nodetool/SetInterDCStreamThroughput.java @@ -0,0 +1,37 @@ +/* + * 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.command.Arguments; +import io.airlift.command.Command; + +import org.apache.cassandra.tools.NodeProbe; +import org.apache.cassandra.tools.NodeTool.NodeToolCmd; + +@Command(name = "setinterdcstreamthroughput", description = "Set the Mb/s throughput cap for inter-datacenter streaming in the system, or 0 to disable throttling") +public class SetInterDCStreamThroughput extends NodeToolCmd +{ + @Arguments(title = "inter_dc_stream_throughput", usage = "", description = "Value in Mb, 0 to disable throttling", required = true) + private Integer interDCStreamThroughput = null; + + @Override + public void execute(NodeProbe probe) + { + probe.setInterDCStreamThroughput(interDCStreamThroughput); + } +}