This is an automated email from the ASF dual-hosted git repository. frankgh pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra-sidecar.git
The following commit(s) were added to refs/heads/trunk by this push: new 971941ca Fixes updating traffic shaping options throws IllegalStateException (#130) 971941ca is described below commit 971941cac0ca62d03503509b92d035624388ffba Author: Francisco Guerrero <fran...@apache.org> AuthorDate: Tue Aug 6 15:06:30 2024 -0700 Fixes updating traffic shaping options throws IllegalStateException (#130) Patch by Francisco Guerrero; Reviewed by Saranya Krishnakumar, Arjun Ashok, Yifan Cai for CASSANDRASC-140 --- CHANGES.txt | 1 + .../cassandra/sidecar/server/ServerVerticle.java | 31 +++++- .../cassandra/sidecar/server/ServerTest.java | 29 +++++- .../sidecar_single_instance_default_port.yaml | 106 +++++++++++++++++++++ 4 files changed, 165 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b2464df3..9b62fa86 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 1.0.0 ----- + * Updating traffic shaping options throws IllegalStateException (CASSANDRASC-140) * Add restore job progress endpoint and consistency check on restore ranges (CASSANDRASC-132) * Upgrade asciidoctor plugin to version 3.3.2 (CASSANDRASC-139) * Bump AWS SDK version to 2.26.12 (CASSANDRASC-137) diff --git a/src/main/java/org/apache/cassandra/sidecar/server/ServerVerticle.java b/src/main/java/org/apache/cassandra/sidecar/server/ServerVerticle.java index 54ca7041..53221149 100644 --- a/src/main/java/org/apache/cassandra/sidecar/server/ServerVerticle.java +++ b/src/main/java/org/apache/cassandra/sidecar/server/ServerVerticle.java @@ -127,7 +127,36 @@ public class ServerVerticle extends AbstractVerticle { throw new IllegalStateException("No servers are running"); } - deployedServers.forEach(server -> server.updateTrafficShapingOptions(options)); + deployedServers.forEach(server -> { + try + { + server.updateTrafficShapingOptions(options); + } + catch (IllegalStateException ex) + { + // Sidecar always configures the traffic shaping option; such IllegalStateException is thrown due + // to a vert.x bug. + // See following comment for details + if (ex.getMessage() != null + && ex.getMessage().contains("Unable to update traffic shaping options because the server was not configured to use traffic shaping during startup")) + { + // TODO: we need to rollback this change once vert.x fixes this problem + // Swallowing the exception here is okay for now until we get a proper fix in vert.x. + // The way vert.x works is by creating a main io.vertx.core.net.impl.TCPServerBase + // object per host/port combination. Child handlers will inherit the main's + // io.netty.handler.traffic.GlobalTrafficShapingHandler since this configuration is a + // global configuration for a given host/port. + // As long as we are able to set the traffic shaping changes to the main server + // these changes will take effect on the child servers as well. A child server + // is created when there are multiple verticles configured. + LOGGER.warn("Unable to update traffic shaping options for server={}", server, ex); + } + else + { + throw ex; + } + } + }); } /** diff --git a/src/test/java/org/apache/cassandra/sidecar/server/ServerTest.java b/src/test/java/org/apache/cassandra/sidecar/server/ServerTest.java index 8e1b023b..2c9c3cc3 100644 --- a/src/test/java/org/apache/cassandra/sidecar/server/ServerTest.java +++ b/src/test/java/org/apache/cassandra/sidecar/server/ServerTest.java @@ -19,6 +19,7 @@ package org.apache.cassandra.sidecar.server; import java.nio.file.Path; +import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -45,6 +46,7 @@ import static org.apache.cassandra.sidecar.utils.TestMetricUtils.registry; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatNoException; /** * Unit tests for {@link Server} lifecycle @@ -67,9 +69,20 @@ class ServerTest } @AfterEach - void clear() + void tearDown() { registry().removeMatching((name, metric) -> true); + if (server != null) + { + try + { + server.close().toCompletionStage().toCompletableFuture().get(30, TimeUnit.SECONDS); + } + catch (Exception ex) + { + LOGGER.error("Unable to close server after 30 seconds", ex); + } + } } @Test @@ -181,6 +194,20 @@ class ServerTest }); } + @Test + @DisplayName("Updating traffic shaping options with non-zero listen port should succeed") + void updateTrafficShapingOptionsWithNonZeroListenPort() + { + configureServer("config/sidecar_single_instance_default_port.yaml"); + + assertThatNoException().isThrownBy(() -> { + server.start().toCompletionStage().toCompletableFuture().get(30, TimeUnit.SECONDS); + TrafficShapingOptions update = new TrafficShapingOptions() + .setOutboundGlobalBandwidth(100 * 1024 * 1024); + server.updateTrafficShapingOptions(update); + }); + } + @Test @DisplayName("Update should fail with null options") void updatingTrafficShapingOptionsWithNull(VertxTestContext context) diff --git a/src/test/resources/config/sidecar_single_instance_default_port.yaml b/src/test/resources/config/sidecar_single_instance_default_port.yaml new file mode 100644 index 00000000..4f00ff9a --- /dev/null +++ b/src/test/resources/config/sidecar_single_instance_default_port.yaml @@ -0,0 +1,106 @@ +# +# Cassandra SideCar configuration file +# +cassandra: + host: localhost + port: 9042 + username: cassandra + password: cassandra + data_dirs: + - /ccm/test/node1/data0 + - /ccm/test/node1/data1 + staging_dir: /ccm/test/node1/sstable-staging + jmx_host: 127.0.0.1 + jmx_port: 7199 + jmx_role: controlRole + jmx_role_password: controlPassword + jmx_ssl_enabled: true + +sidecar: + host: 0.0.0.0 + port: 9043 + request_idle_timeout_millis: 300000 # this field expects integer value + request_timeout_millis: 300000 + tcp_keep_alive: false + accept_backlog: 1024 + server_verticle_instances: 2 + throttle: + stream_requests_per_sec: 5000 + timeout_sec: 10 + traffic_shaping: + inbound_global_bandwidth_bps: 500 + outbound_global_bandwidth_bps: 1500 + peak_outbound_global_bandwidth_bps: 2000 + max_delay_to_wait_millis: 2500 + check_interval_for_stats_millis: 3000 + sstable_upload: + concurrent_upload_limit: 80 + min_free_space_percent: 10 + # file_permissions: "rw-r--r--" # when not specified, the default file permissions are owner read & write, group & others read + allowable_time_skew_in_minutes: 60 + sstable_import: + poll_interval_millis: 100 + cache: + expire_after_access_millis: 7200000 # 2 hours + maximum_size: 10000 + sstable_snapshot: + snapshot_list_cache: + expire_after_access_millis: 350 + maximum_size: 450 + worker_pools: + service: + name: "sidecar-worker-pool" + size: 20 + max_execution_time_millis: 60000 # 60 seconds + internal: + name: "sidecar-internal-worker-pool" + size: 20 + max_execution_time_millis: 900000 # 15 minutes + jmx: + max_retries: 42 + retry_delay_millis: 1234 + schema: + is_enabled: false + keyspace: sidecar_internal + replication_strategy: SimpleStrategy + replication_factor: 1 + +# +# Enable SSL configuration (Disabled by default) +# +# ssl: +# enabled: true +# use_openssl: true +# handshake_timeout_sec: 10 +# client_auth: NONE # valid options are NONE, REQUEST, REQUIRED +# accepted_protocols: +# - TLSv1.2 +# - TLSv1.3 +# cipher_suites: [] +# keystore: +# type: PKCS12 +# path: "path/to/keystore.p12" +# password: password +# check_interval_sec: 300 +# truststore: +# path: "path/to/truststore.p12" +# password: password + + +healthcheck: + initial_delay_millis: 100 + poll_freq_millis: 30000 + +cassandra_input_validation: + forbidden_keyspaces: + - system_schema + - system_traces + - system_distributed + - system + - system_auth + - system_views + - system_virtual_schema + allowed_chars_for_directory: "[a-zA-Z][a-zA-Z0-9_]{0,47}" + allowed_chars_for_quoted_name: "[a-zA-Z_0-9]{1,48}" + allowed_chars_for_component_name: "[a-zA-Z0-9_-]+(.db|.cql|.json|.crc32|TOC.txt)" + allowed_chars_for_restricted_component_name: "[a-zA-Z0-9_-]+(.db|TOC.txt)" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org