You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2025/05/13 20:09:49 UTC
(cassandra-analytics) branch trunk updated: CASSANALYTICS-30: Add Sidecar Client (#108)
This is an automated email from the ASF dual-hosted git repository.
bernardobotella pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-analytics.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6440af98 CASSANALYTICS-30: Add Sidecar Client (#108)
6440af98 is described below
commit 6440af987e75e4221b627754a929ea4d9d770cb3
Author: Bernardo Botella <bb...@users.noreply.github.com>
AuthorDate: Tue May 13 13:09:45 2025 -0700
CASSANALYTICS-30: Add Sidecar Client (#108)
Patch by Bernardo Botella; reviewed by Yifan Cai, Francisco Guerrero for CASSANALYTICS-30
---
CHANGES.txt | 1 +
LICENSE.txt | 6 +
analytics-sidecar-client-common/build.gradle | 60 +
.../cassandra/sidecar/client/SidecarInstance.java | 35 +
.../sidecar/client/SidecarInstanceImpl.java | 104 ++
.../cassandra/sidecar/common/ApiEndpointsV1.java | 148 ++
.../sidecar/common/DataObjectBuilder.java | 56 +
.../sidecar/common/data/ConsistencyConfig.java | 56 +
.../sidecar/common/data/ConsistencyLevel.java | 58 +
.../common/data/ConsistencyVerificationResult.java | 38 +
.../sidecar/common/data/OperationalJobStatus.java | 48 +
.../sidecar/common/data/RestoreJobConstants.java | 67 +
.../common/data/RestoreJobProgressFetchPolicy.java | 68 +
.../sidecar/common/data/RestoreJobSecrets.java | 96 +
.../sidecar/common/data/RestoreJobStatus.java | 64 +
.../sidecar/common/data/SSTableImportOptions.java | 129 ++
.../sidecar/common/data/StorageCredentials.java | 168 ++
.../sidecar/common/exceptions/RangeException.java | 30 +
.../common/http/SidecarHttpHeaderNames.java | 38 +
.../common/http/SidecarHttpResponseStatus.java | 48 +
.../common/request/AbortRestoreJobRequest.java | 66 +
.../common/request/AllServicesConfigRequest.java | 43 +
.../common/request/CassandraJmxHealthRequest.java | 46 +
.../request/CassandraNativeHealthRequest.java | 60 +
.../request/CleanSSTableUploadSessionRequest.java | 44 +
.../common/request/ClearSnapshotRequest.java | 49 +
.../request/ConnectedClientStatsRequest.java | 47 +
.../common/request/CreateRestoreJobRequest.java | 64 +
.../request/CreateRestoreJobSliceRequest.java | 67 +
.../common/request/CreateSnapshotRequest.java | 54 +
.../common/request/DeleteServiceConfigRequest.java | 43 +
.../common/request/GossipHealthRequest.java | 46 +
.../sidecar/common/request/GossipInfoRequest.java | 46 +
.../common/request/ImportSSTableRequest.java | 211 +++
.../sidecar/common/request/JsonRequest.java | 60 +
.../common/request/JsonResponseBytesDecoder.java | 51 +
.../common/request/ListCdcSegmentsRequest.java | 31 +-
.../common/request/ListOperationalJobsRequest.java | 46 +
.../common/request/ListSnapshotFilesRequest.java | 54 +
.../common/request/NodeDecommissionRequest.java | 46 +
.../common/request/NodeSettingsRequest.java | 46 +
.../common/request/OperationalJobRequest.java | 50 +
.../common/request/ReportSchemaRequest.java | 41 +
.../cassandra/sidecar/common/request/Request.java | 108 ++
.../common/request/ResponseBytesDecoder.java | 37 +
.../common/request/RestoreJobProgressRequest.java | 51 +
.../common/request/RestoreJobSummaryRequest.java | 57 +
.../sidecar/common/request/RingRequest.java | 56 +
.../common/request/SSTableComponentRequest.java | 103 ++
.../sidecar/common/request/SchemaRequest.java | 56 +
.../cassandra/sidecar/common/request/Service.java | 41 +
.../common/request/SidecarHealthRequest.java | 46 +
.../sidecar/common/request/SnapshotRequest.java | 69 +
.../common/request/StreamCdcSegmentRequest.java | 54 +
.../sidecar/common/request/StreamStatsRequest.java | 45 +
.../sidecar/common/request/TableStatsRequest.java | 56 +
.../sidecar/common/request/TimeSkewRequest.java | 46 +
.../common/request/TokenRangeReplicasRequest.java | 44 +
.../common/request/UpdateRestoreJobRequest.java | 68 +
.../common/request/UpdateServiceConfigRequest.java | 49 +
.../common/request/UploadSSTableRequest.java | 101 ++
.../sidecar/common/request/UploadableRequest.java | 30 +
.../data/AbortRestoreJobRequestPayload.java | 74 +
.../request/data/AllServicesConfigPayload.java | 117 ++
.../data/CreateRestoreJobRequestPayload.java | 278 +++
.../request/data/CreateSliceRequestPayload.java | 209 +++
.../sidecar/common/request/data/Digest.java | 42 +
.../sidecar/common/request/data/MD5Digest.java | 68 +
.../data/RestoreJobProgressRequestParams.java | 51 +
.../data/UpdateCdcServiceConfigPayload.java | 64 +
.../data/UpdateRestoreJobRequestPayload.java | 202 +++
.../common/request/data/XXHash32Digest.java | 110 ++
.../response/ConnectedClientStatsResponse.java | 75 +
.../common/response/GossipInfoResponse.java | 323 ++++
.../sidecar/common/response/HealthResponse.java | 63 +
.../common/response/ListCdcSegmentsResponse.java | 90 +
.../response/ListOperationalJobsResponse.java | 51 +
.../common/response/ListSnapshotFilesResponse.java | 152 ++
.../sidecar/common/response/NodeSettings.java | 296 ++++
.../common/response/OperationalJobResponse.java | 89 +
.../sidecar/common/response/RingResponse.java | 47 +
.../common/response/SSTableImportResponse.java | 79 +
.../common/response/SSTableUploadResponse.java | 77 +
.../sidecar/common/response/SchemaResponse.java | 74 +
.../common/response/StreamStatsResponse.java | 60 +
.../common/response/TableStatsResponse.java | 100 ++
.../sidecar/common/response/TimeSkewResponse.java | 41 +
.../response/TokenRangeReplicasResponse.java | 267 +++
.../common/response/data/CdcSegmentInfo.java | 72 +
.../response/data/ClientConnectionEntry.java | 166 ++
.../data/CreateRestoreJobResponsePayload.java | 60 +
.../data/RestoreJobProgressResponsePayload.java | 221 +++
.../data/RestoreJobSummaryResponsePayload.java | 109 ++
.../common/response/data/RestoreRangeJson.java | 99 ++
.../sidecar/common/response/data/RingEntry.java | 404 +++++
.../common/response/data/StreamsProgressStats.java | 122 ++
.../cassandra/sidecar/common/utils/HttpRange.java | 195 +++
.../sidecar/common/utils/Preconditions.java | 91 +
.../sidecar/common/utils/StringUtils.java | 49 +
.../cassandra/sidecar/common/utils/TimeUtils.java | 56 +
.../data/RestoreJobProgressFetchPolicyTest.java | 61 +
.../sidecar/common/data/RestoreJobStatusTest.java | 43 +
.../common/http/SidecarHttpResponseStatusTest.java | 38 +
.../CreateRestoreJobRequestPayloadTest.java | 230 +++
.../request/CreateSliceRequestPayloadTest.java | 110 ++
.../request/RestoreJobProgressRequestTest.java | 43 +
.../UpdateRestoreJobRequestPayloadTest.java | 93 +
.../data/AbortRestoreJobRequestPayloadTest.java | 72 +
.../common/response/GossipInfoResponseTest.java | 53 +
.../response/ListCdcSegmentsResponseTest.java | 67 +
.../sidecar/common/response/RingResponseTest.java | 71 +
.../sidecar/common/utils/HttpRangeTest.java | 177 ++
.../sidecar/common/utils/TimeUtilsTest.java | 62 +
.../sidecar/foundation/RestoreJobSecretsGen.java | 61 +
analytics-sidecar-client/build.gradle | 88 +
.../cassandra/sidecar/client/HttpClient.java | 54 +
.../cassandra/sidecar/client/HttpClientConfig.java | 398 +++++
.../cassandra/sidecar/client/HttpResponse.java | 70 +
.../cassandra/sidecar/client/HttpResponseImpl.java | 153 ++
.../cassandra/sidecar/client/RequestContext.java | 647 +++++++
.../cassandra/sidecar/client/RequestExecutor.java | 377 ++++
.../cassandra/sidecar/client/SidecarClient.java | 859 +++++++++
.../client/SidecarClientBlobRestoreExtension.java | 134 ++
.../sidecar/client/SidecarClientConfig.java | 53 +
.../sidecar/client/SidecarClientConfigImpl.java | 189 ++
.../sidecar/client/SidecarInstancesProvider.java | 33 +
.../client/SimpleSidecarInstancesProvider.java | 53 +
.../cassandra/sidecar/client/StreamBuffer.java | 123 ++
.../cassandra/sidecar/client/StreamConsumer.java | 46 +
.../exception/ResourceNotFoundException.java | 37 +
.../exception/RetriesExhaustedException.java | 82 +
.../exception/UnexpectedStatusCodeException.java | 53 +
.../sidecar/client/retry/BasicRetryPolicy.java | 321 ++++
.../client/retry/CreateRestoreJobRetryPolicy.java | 62 +
.../retry/ExponentialBackoffRetryPolicy.java | 124 ++
.../client/retry/IgnoreConflictRetryPolicy.java | 74 +
.../sidecar/client/retry/NoRetryPolicy.java | 59 +
.../client/retry/OncePerInstanceRetryPolicy.java | 90 +
.../sidecar/client/retry/RetryAction.java | 33 +
.../sidecar/client/retry/RetryPolicy.java | 78 +
.../retry/RunnableOnStatusCodeRetryPolicy.java | 77 +
.../client/selection/InstanceSelectionPolicy.java | 28 +
.../selection/OrderedInstanceSelectionPolicy.java | 56 +
.../selection/RandomInstanceSelectionPolicy.java | 61 +
.../selection/SingleInstanceSelectionPolicy.java | 73 +
.../HttpClientConfigTest.java | 154 ++
.../SidecarClientConfigTest.java | 73 +
.../SidecarInstanceImplTest.java | 31 +
.../SidecarInstanceTest.java | 91 +
.../SimpleSidecarInstancesProviderTest.java | 67 +
.../StreamBufferTest.java | 101 ++
.../request/JsonRequestTest.java | 47 +
.../request/JsonResponseBytesDecoderTest.java | 60 +
.../retry/BasicRetryPolicyTest.java | 330 ++++
.../retry/ExponentialBackoffRetryPolicyTest.java | 144 ++
.../retry/IgnoreConflictRetryPolicyTest.java | 112 ++
.../retry/NoRetryPolicyTest.java | 102 ++
.../retry/RunnableOnStatusCodeRetryPolicyTest.java | 97 ++
.../OrderedInstanceSelectionPolicyTest.java | 79 +
.../RandomInstanceSelectionPolicyTest.java | 72 +
.../SingleInstanceSelectionPolicyTest.java | 56 +
.../sidecar/client/SidecarClientTest.java | 1833 ++++++++++++++++++++
.../sidecar/client/request/BaseRequestTest.java | 88 +
.../request/FullSchemaRequestTestParameters.java | 56 +
.../request/GossipInfoRequestTestParameters.java | 72 +
.../ListSnapshotFilesRequestTestParameters.java | 108 ++
.../request/NodeSettingsRequestTestParameters.java | 56 +
.../client/request/RequestExecutorTest.java | 247 +++
.../client/request/RequestTestParameters.java | 42 +
.../RingRequestForKeyspaceTestParameters.java | 77 +
.../client/request/RingRequestTestParameters.java | 82 +
.../request/SchemaRequestTestParameters.java | 99 ++
.../request/TimeSkewRequestTestParameters.java | 56 +
.../resources/sstables/nb-1-big-TOC.txt | 8 +
analytics-sidecar-vertx-client-shaded/build.gradle | 130 ++
.../cassandra/sidecar/client/test/LibraryTest.java | 39 +
analytics-sidecar-vertx-client/build.gradle | 87 +
.../client/SidecarClientVertxRequestExecutor.java | 47 +
.../sidecar/client/StreamConsumerWriteStream.java | 94 +
.../cassandra/sidecar/client/VertxHttpClient.java | 373 ++++
.../sidecar/client/VertxRequestExecutor.java | 74 +
.../sidecar/client/VertxStreamBuffer.java | 87 +
.../client/StreamConsumerWriteStreamTest.java | 62 +
.../sidecar/client/VertxSidecarClientTest.java | 58 +
.../sidecar/client/VertxStreamBufferTest.java | 96 +
.../client/request/BaseVertxRequestTest.java | 62 +
build.gradle | 49 +
cassandra-analytics-core/build.gradle | 3 +-
cassandra-analytics-sidecar-client/build.gradle | 3 +-
config/checkstyle/suppressions.xml | 2 +
gradle.properties | 6 +-
profiles/scala-2.12-spark-3-jdk-11.gradle | 3 -
profiles/scala-2.13-spark-3-jdk-11.gradle | 3 -
settings.gradle | 9 +
194 files changed, 19960 insertions(+), 22 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 04181cc7..f35c4971 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
1.0.0
+ * Add Sidecar Client (CASSANALYTICS-30)
* Add support for vnodes (CASSANALYTICS-50)
* Add CDC Kafka and Avro codecs module to translate CDC mutations into Avro format for publication over Kafka (CASSANALYTICS-9)
* Bump Cassandra version to 4.0.17 and integrate with CQLSSTableWriter notification (CASSANALYTICS-5)
diff --git a/LICENSE.txt b/LICENSE.txt
index a2dca24c..1d1f05f9 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -223,3 +223,9 @@
This product bundles a file (CommitLogSegmentReader.java) from Apache
Cassandra, copyright The Apache Cassandra Authors, which is available
under an Apache License version 2.
+
+ This product bundles some modules (analitycs-sidecar-client,
+ analytics-sidecar-client-common, analytics-sidecar-vertx-client-shaded,
+ analytics-sidecar-vertx-client) from Apache Cassandra Sidecar,
+ copyright The Apache Cassandra Authors, which is available under an
+ Apache License version 2.
diff --git a/analytics-sidecar-client-common/build.gradle b/analytics-sidecar-client-common/build.gradle
new file mode 100644
index 00000000..7a8d4e78
--- /dev/null
+++ b/analytics-sidecar-client-common/build.gradle
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+
+import java.nio.file.Paths
+
+plugins {
+ id 'java-library'
+ id "java-test-fixtures"
+ id 'idea'
+ id 'maven-publish'
+}
+
+sourceCompatibility = 1.8
+
+test {
+ useJUnitPlatform()
+ maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
+ reports {
+ junitXml.setRequired(true)
+ def destDir = Paths.get(rootProject.rootDir.absolutePath, "build", "test-results", "client-common").toFile()
+ println("Destination directory for client-common tests: ${destDir}")
+ junitXml.getOutputLocation().set(destDir)
+ html.setRequired(true)
+ html.getOutputLocation().set(destDir)
+ }
+}
+
+dependencies {
+ compileOnly(group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jApiVersion}")
+ compileOnly(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${project.jacksonVersion}")
+ compileOnly(group: 'org.jetbrains', name: 'annotations', version: '23.0.0')
+ compileOnly(group: 'io.netty', name: 'netty-codec-http', version: "${project.nettyVersion}")
+ compileOnly(group: 'com.google.guava', name: 'guava', version: "${project.guavaVersion}")
+
+ testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${project.jacksonVersion}")
+ testImplementation("com.google.guava:guava:${project.guavaVersion}")
+ testImplementation('org.mockito:mockito-inline:4.10.0')
+ testImplementation("org.assertj:assertj-core:3.24.2")
+ testImplementation("org.junit.jupiter:junit-jupiter-api:${project.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-params:${project.junitVersion}")
+ testImplementation(group: 'io.netty', name: 'netty-codec-http', version: "${project.nettyVersion}")
+ testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}")
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/client/SidecarInstance.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/client/SidecarInstance.java
new file mode 100644
index 00000000..1d2d1482
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/client/SidecarInstance.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sidecar.client;
+
+/**
+ * Holds information about the Cassandra Sidecar Instance host and port
+ */
+public interface SidecarInstance
+{
+ /**
+ * @return the port where the Cassandra Sidecar instance is listening
+ */
+ int port();
+
+ /**
+ * @return the hostname where the Cassandra Sidecar instance is running
+ */
+ String hostname();
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/client/SidecarInstanceImpl.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/client/SidecarInstanceImpl.java
new file mode 100644
index 00000000..751218b1
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/client/SidecarInstanceImpl.java
@@ -0,0 +1,104 @@
+/*
+ * 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.sidecar.client;
+
+import java.util.Objects;
+
+/**
+ * A simple implementation of the {@link SidecarInstance} interface
+ */
+public class SidecarInstanceImpl implements SidecarInstance
+{
+ protected int port;
+ protected String hostname;
+
+ /**
+ * Constructs a new Sidecar instance with the given {@code port} and {@code hostname}
+ *
+ * @param hostname the host name where Sidecar is running
+ * @param port the port where Sidecar is running
+ */
+ public SidecarInstanceImpl(String hostname, int port)
+ {
+ if (port < 1 || port > 65535)
+ {
+ throw new IllegalArgumentException(String.format("Invalid port number for the Sidecar service: %d",
+ port));
+ }
+ this.port = port;
+ this.hostname = Objects.requireNonNull(hostname, "The Sidecar hostname must be non-null");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int port()
+ {
+ return port;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String hostname()
+ {
+ return hostname;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ SidecarInstanceImpl that = (SidecarInstanceImpl) o;
+ return port == that.port && Objects.equals(hostname, that.hostname);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(port, hostname);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "SidecarInstanceImpl{" +
+ "port=" + port +
+ ", hostname='" + hostname + '\'' +
+ '}';
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/ApiEndpointsV1.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/ApiEndpointsV1.java
new file mode 100644
index 00000000..4be4c4a8
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/ApiEndpointsV1.java
@@ -0,0 +1,148 @@
+/*
+ * 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.sidecar.common;
+
+/**
+ * A constants container class for API endpoints of version 1.
+ */
+public final class ApiEndpointsV1
+{
+ public static final String API = "/api";
+ public static final String API_V1 = API + "/v1";
+ public static final String API_V1_ALL_ROUTES = API_V1 + "/.*";
+
+ public static final String HEALTH = "/__health";
+ public static final String CASSANDRA = "/cassandra";
+
+ public static final String NATIVE = "/native";
+ public static final String JMX = "/jmx";
+ public static final String KEYSPACE = "keyspace";
+ public static final String TABLE = "table";
+ public static final String KEYSPACE_PATH_PARAM = ":" + KEYSPACE;
+ public static final String TABLE_PATH_PARAM = ":" + TABLE;
+ public static final String SNAPSHOT_PATH_PARAM = ":snapshot";
+ public static final String COMPONENT_PATH_PARAM = ":component";
+ public static final String INDEX_PATH_PARAM = ":index";
+ public static final String UPLOAD_ID_PATH_PARAM = ":uploadId";
+ public static final String JOB_ID_PATH_PARAM = ":jobId";
+
+ public static final String OPERATIONAL_JOB_ID_PATH_PARAM = ":operationId";
+
+ public static final String PER_KEYSPACE = "/keyspaces/" + KEYSPACE_PATH_PARAM;
+ public static final String PER_TABLE = "/tables/" + TABLE_PATH_PARAM;
+ public static final String PER_SNAPSHOT = "/snapshots/" + SNAPSHOT_PATH_PARAM;
+ public static final String PER_COMPONENT = "/components/" + COMPONENT_PATH_PARAM;
+ public static final String PER_SECONDARY_INDEX_COMPONENT = "/components/" + INDEX_PATH_PARAM
+ + "/" + COMPONENT_PATH_PARAM;
+ public static final String PER_UPLOAD = "/uploads/" + UPLOAD_ID_PATH_PARAM;
+
+ public static final String HEALTH_ROUTE = API_V1 + HEALTH;
+
+ /**
+ * @deprecated in favor of {@link #CASSANDRA_NATIVE_HEALTH_ROUTE}
+ */
+ @Deprecated
+ public static final String CASSANDRA_HEALTH_ROUTE = API_V1 + CASSANDRA + HEALTH;
+ public static final String CASSANDRA_NATIVE_HEALTH_ROUTE = API_V1 + CASSANDRA + NATIVE + HEALTH;
+ public static final String CASSANDRA_JMX_HEALTH_ROUTE = API_V1 + CASSANDRA + JMX + HEALTH;
+
+ @Deprecated // NOTE: Uses singular forms of "keyspace" and "table"
+ public static final String DEPRECATED_SNAPSHOTS_ROUTE = API_V1 + "/keyspace/" + KEYSPACE_PATH_PARAM +
+ "/table/" + TABLE_PATH_PARAM +
+ PER_SNAPSHOT;
+ @Deprecated
+ public static final String DEPRECATED_COMPONENTS_ROUTE = DEPRECATED_SNAPSHOTS_ROUTE +
+ "/component/" + COMPONENT_PATH_PARAM;
+
+ // Replaces DEPRECATED_SNAPSHOT_ROUTE
+ public static final String SNAPSHOTS_ROUTE = API_V1 + PER_KEYSPACE + PER_TABLE + PER_SNAPSHOT;
+ // Replaces DEPRECATED_COMPONENTS_ROUTE
+ public static final String COMPONENTS_ROUTE = SNAPSHOTS_ROUTE + PER_COMPONENT;
+ public static final String COMPONENTS_WITH_SECONDARY_INDEX_ROUTE_SUPPORT = SNAPSHOTS_ROUTE
+ + PER_SECONDARY_INDEX_COMPONENT;
+
+ @Deprecated
+ public static final String DEPRECATED_ALL_KEYSPACES_SCHEMA_ROUTE = API_V1 + "/schema/keyspaces";
+ @Deprecated
+ public static final String DEPRECATED_KEYSPACE_SCHEMA_ROUTE = API_V1 + "/schema" + PER_KEYSPACE;
+
+ // Replaces DEPRECATED_ALL_KEYSPACES_SCHEMA_ROUTE
+ public static final String ALL_KEYSPACES_SCHEMA_ROUTE = API_V1 + CASSANDRA + "/schema";
+
+ // Replaces DEPRECATED_KEYSPACE_SCHEMA_ROUTE
+ public static final String KEYSPACE_SCHEMA_ROUTE = API_V1 + PER_KEYSPACE + "/schema";
+ public static final String NODE_SETTINGS_ROUTE = API_V1 + CASSANDRA + "/settings";
+
+ public static final String RING_ROUTE = API_V1 + CASSANDRA + "/ring";
+ public static final String RING_WITH_KEYSPACE_ROUTE = RING_ROUTE + PER_KEYSPACE;
+
+ public static final String SSTABLE_UPLOAD_ROUTE = API_V1 + PER_UPLOAD + PER_KEYSPACE + PER_TABLE + PER_COMPONENT;
+ public static final String SSTABLE_IMPORT_ROUTE = API_V1 + PER_UPLOAD + PER_KEYSPACE + PER_TABLE + "/import";
+ public static final String SSTABLE_CLEANUP_ROUTE = API_V1 + PER_UPLOAD;
+
+ public static final String GOSSIP_INFO_ROUTE = API_V1 + CASSANDRA + "/gossip";
+ public static final String GOSSIP_HEALTH_ROUTE = GOSSIP_INFO_ROUTE + HEALTH;
+ public static final String TIME_SKEW_ROUTE = API_V1 + "/time-skew";
+
+ public static final String KEYSPACE_TOKEN_MAPPING_ROUTE = API_V1 + PER_KEYSPACE + "/token-range-replicas";
+
+ // Blob Transport Extension
+ public static final String RESTORE_JOBS = "/restore-jobs";
+ public static final String SLICES = "/slices";
+ public static final String ABORT = "/abort";
+ public static final String PROGRESS = "/progress";
+ public static final String FETCH_POLICY_QUERY_PARAM = "fetch-policy";
+ public static final String PER_RESTORE_JOB = RESTORE_JOBS + "/" + JOB_ID_PATH_PARAM;
+ public static final String CREATE_RESTORE_JOB_ROUTE = API_V1 + PER_KEYSPACE + PER_TABLE + RESTORE_JOBS;
+ public static final String RESTORE_JOB_ROUTE = API_V1 + PER_KEYSPACE + PER_TABLE + PER_RESTORE_JOB;
+ public static final String RESTORE_JOB_SLICES_ROUTE = RESTORE_JOB_ROUTE + SLICES;
+ public static final String ABORT_RESTORE_JOB_ROUTE = RESTORE_JOB_ROUTE + ABORT;
+ public static final String RESTORE_JOB_PROGRESS_ROUTE = RESTORE_JOB_ROUTE + PROGRESS;
+
+ // CDC APIs
+ public static final String CDC_PATH = "/cdc";
+ public static final String SEGMENT_PATH_PARAM = ":segment";
+ public static final String LIST_CDC_SEGMENTS_ROUTE = API_V1 + CDC_PATH + "/segments";
+ public static final String STREAM_CDC_SEGMENTS_ROUTE = LIST_CDC_SEGMENTS_ROUTE + "/" + SEGMENT_PATH_PARAM;
+
+ // Schema Reporting
+ private static final String REPORT_SCHEMA = "/datahub/schemas";
+ public static final String REPORT_SCHEMA_ROUTE = API_V1 + REPORT_SCHEMA;
+
+ public static final String SERVICES_PATH = "/services";
+ public static final String SERVICE_PARAM = ":service";
+ public static final String CONFIG = "/config";
+ public static final String SERVICE_CONFIG_ROUTE = API_V1 + SERVICES_PATH + "/" + SERVICE_PARAM + CONFIG;
+ public static final String SERVICES_CONFIG_ROUTE = API_V1 + SERVICES_PATH;
+
+ public static final String CONNECTED_CLIENT_STATS_ROUTE = API_V1 + CASSANDRA + "/stats/connected-clients";
+
+ private static final String OPERATIONAL_JOBS = "/operational-jobs";
+ private static final String PER_OPERATIONAL_JOB = OPERATIONAL_JOBS + '/' + OPERATIONAL_JOB_ID_PATH_PARAM;
+ public static final String LIST_OPERATIONAL_JOBS_ROUTE = API_V1 + CASSANDRA + OPERATIONAL_JOBS;
+ public static final String OPERATIONAL_JOB_ROUTE = API_V1 + CASSANDRA + PER_OPERATIONAL_JOB;
+ public static final String NODE_DECOMMISSION_ROUTE = API_V1 + CASSANDRA + "/operations/decommission";
+ public static final String STREAM_STATS_ROUTE = API_V1 + CASSANDRA + "/stats/streams";
+ public static final String TABLE_STATS_ROUTE = API_V1 + CASSANDRA + PER_KEYSPACE + PER_TABLE + "/stats";
+
+ private ApiEndpointsV1()
+ {
+ throw new IllegalStateException(getClass() + " is a constants container and shall not be instantiated");
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/DataObjectBuilder.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/DataObjectBuilder.java
new file mode 100644
index 00000000..e04724d9
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/DataObjectBuilder.java
@@ -0,0 +1,56 @@
+/*
+ * 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.sidecar.common;
+
+import java.util.function.Consumer;
+
+/**
+ * Interface to build data objects
+ *
+ * @param <T> type of builder
+ * @param <R> type of result from build
+ */
+public interface DataObjectBuilder<T extends DataObjectBuilder<?, ?>, R>
+{
+ /**
+ * Self typing
+ *
+ * @return type of implementor class
+ */
+ T self();
+
+ /**
+ * Build into data object of type R
+ *
+ * @return data object type
+ */
+ R build();
+
+ /**
+ * Updates a field in the builder
+ *
+ * @param updater function to mutate fields
+ * @return builder itself for chained invocation
+ */
+ default T update(Consumer<? super T> updater)
+ {
+ updater.accept(self());
+ return self();
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyConfig.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyConfig.java
new file mode 100644
index 00000000..85025145
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyConfig.java
@@ -0,0 +1,56 @@
+/*
+ * 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.sidecar.common.data;
+
+import org.apache.cassandra.sidecar.common.utils.Preconditions;
+import org.apache.cassandra.sidecar.common.utils.StringUtils;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Consistency config to group the related values, i.e. consistency level and local datacenter name.
+ * Note that both fields are nullable
+ */
+public class ConsistencyConfig
+{
+ @Nullable
+ public final ConsistencyLevel consistencyLevel;
+ @Nullable
+ public final String localDatacenter;
+
+ /**
+ * Create {@link ConsistencyConfig} from the string literals
+ *
+ * @param consistencyLevelString nullable string to resolve to {@link ConsistencyLevel}
+ * @param localDatacenter nullable string; required to be not empty when the resolved consistency level is localDcOnly
+ * @return {@link ConsistencyConfig} instance
+ */
+ public static ConsistencyConfig parseString(@Nullable String consistencyLevelString, @Nullable String localDatacenter)
+ {
+ return new ConsistencyConfig(ConsistencyLevel.fromString(consistencyLevelString), localDatacenter);
+ }
+
+ private ConsistencyConfig(@Nullable ConsistencyLevel consistencyLevel, @Nullable String localDatacenter)
+ {
+ Preconditions.checkArgument(consistencyLevel == null || !consistencyLevel.isLocalDcOnly || StringUtils.isNotEmpty(localDatacenter),
+ "localDatacenter cannot be empty for consistency level: " + consistencyLevel);
+
+ this.consistencyLevel = consistencyLevel;
+ this.localDatacenter = localDatacenter;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyLevel.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyLevel.java
new file mode 100644
index 00000000..d64fbde9
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyLevel.java
@@ -0,0 +1,58 @@
+/*
+ * 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.sidecar.common.data;
+
+import java.util.Locale;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Consistency level for read/write operations
+ * Note: not supporting all consistency level in Cassandra on purpose
+ */
+public enum ConsistencyLevel
+{
+ ONE,
+ TWO,
+ LOCAL_ONE(true),
+ LOCAL_QUORUM(true),
+ EACH_QUORUM,
+ QUORUM,
+ ALL;
+
+ public final boolean isLocalDcOnly;
+
+ ConsistencyLevel()
+ {
+ this(false);
+ }
+
+ ConsistencyLevel(boolean isLocalDcOnly)
+ {
+ this.isLocalDcOnly = isLocalDcOnly;
+ }
+
+ /**
+ * Try to get the enum value based on the input name.
+ * @param name string literal of the enum name
+ * @return enum, or null if the input is null
+ */
+ public static @Nullable ConsistencyLevel fromString(@Nullable String name)
+ {
+ return name == null ? null : valueOf(name.toUpperCase(Locale.ROOT));
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyVerificationResult.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyVerificationResult.java
new file mode 100644
index 00000000..6abecab0
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/ConsistencyVerificationResult.java
@@ -0,0 +1,38 @@
+/*
+ * 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.sidecar.common.data;
+
+/**
+ * Verification result
+ */
+public enum ConsistencyVerificationResult
+{
+ /**
+ * the passed replicas have satisfied the consistency level
+ */
+ SATISFIED,
+ /**
+ * no conclusion can be made yet
+ */
+ PENDING,
+ /**
+ * the failed replicas have failed the consistency level
+ */
+ FAILED,
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/OperationalJobStatus.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/OperationalJobStatus.java
new file mode 100644
index 00000000..6a2d0600
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/OperationalJobStatus.java
@@ -0,0 +1,48 @@
+/*
+ * 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.sidecar.common.data;
+
+/**
+ * Encapsulates the states of the job lifecycle.
+ * Operational jobs are the ones running on Cassandra, e.g. decommission, etc.
+ */
+public enum OperationalJobStatus
+{
+ /**
+ * The operational job is created
+ */
+ CREATED,
+ /**
+ * The operational job is running on Cassandra
+ */
+ RUNNING,
+ /**
+ * The operational job succeeds
+ */
+ SUCCEEDED,
+ /**
+ * The operational job fails
+ */
+ FAILED;
+
+ public boolean isCompleted()
+ {
+ return this == SUCCEEDED || this == FAILED;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobConstants.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobConstants.java
new file mode 100644
index 00000000..b6028800
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobConstants.java
@@ -0,0 +1,67 @@
+/*
+ * 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.sidecar.common.data;
+
+/**
+ * Holds restore job API requests related constants.
+ */
+public class RestoreJobConstants
+{
+ public static final String JOB_ID = "jobId";
+ public static final String JOB_AGENT = "jobAgent";
+ public static final String JOB_STATUS = "status";
+ public static final String JOB_SECRETS = "secrets";
+ public static final String JOB_EXPIRE_AT = "expireAt";
+ public static final String JOB_SLICE_COUNT = "sliceCount";
+ public static final String JOB_IMPORT_OPTIONS = "importOptions";
+ public static final String JOB_CREATED_AT = "createdAt";
+ public static final String JOB_KEYSPACE = "keyspace";
+ public static final String JOB_TABLE = "table";
+ public static final String JOB_CONSISTENCY_LEVEL = "consistencyLevel";
+ public static final String JOB_OPERATION_REASON = "reason";
+ public static final String JOB_LOCAL_DATA_CENTER = "localDatacenter";
+ public static final String SLICE_ID = "sliceId";
+ public static final String BUCKET_ID = "bucketId";
+ public static final String SLICE_START_TOKEN = "startToken";
+ public static final String SLICE_END_TOKEN = "endToken";
+ public static final String SLICE_STORAGE_BUCKET = "storageBucket";
+ public static final String SLICE_STORAGE_KEY = "storageKey";
+ public static final String SLICE_CHECKSUM = "sliceChecksum";
+ public static final String SLICE_UNCOMPRESSED_SIZE = "sliceUncompressedSize";
+ public static final String SLICE_COMPRESSED_SIZE = "sliceCompressedSize";
+ public static final String SECRET_READ_CREDENTIALS = "readCredentials";
+ public static final String SECRET_WRITE_CREDENTIALS = "writeCredentials";
+ public static final String CREDENTIALS_ACCESS_KEY_ID = "accessKeyId";
+ public static final String CREDENTIALS_SECRET_ACCESS_KEY = "secretAccessKey";
+ public static final String CREDENTIALS_SESSION_TOKEN = "sessionToken";
+ public static final String CREDENTIALS_REGION = "region";
+
+ // -- restore job status fields
+ public static final String JOB_PROGRESS_MESSAGE = "message";
+ public static final String JOB_PROGRESS_STATUS = "status";
+ public static final String JOB_PROGRESS_SUMMARY = "summary";
+ public static final String JOB_PROGRESS_FAILED_RANGES = "failedRanges";
+ public static final String JOB_PROGRESS_ABORTED_RANGES = "abortedRanges";
+ public static final String JOB_PROGRESS_PENDING_RANGES = "pendingRanges";
+ public static final String JOB_PROGRESS_SUCCEEDED_RANGES = "succeededRanges";
+
+ private RestoreJobConstants()
+ {
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobProgressFetchPolicy.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobProgressFetchPolicy.java
new file mode 100644
index 00000000..50ce6644
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobProgressFetchPolicy.java
@@ -0,0 +1,68 @@
+/*
+ * 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.sidecar.common.data;
+
+import java.util.Locale;
+
+/**
+ * Defines fetch policies for restore job progress endpoint. See individual fetch policy for details.
+ */
+public enum RestoreJobProgressFetchPolicy
+{
+ /**
+ * Check the progress on all slices/ranges until encountering the first failed. Only the first failed range is collected.
+ * <p>
+ * A job is succeeded, if the query with this fetch policy returns empty response, meaning no failed and no unsatisfied slices/ranges.
+ */
+ FIRST_FAILED,
+
+ /**
+ * Gathers all failed and pending/unsatisfied slices/ranges. The policy is used to retrieve the slices/ranges
+ * failed to import with the specified consistency level _when a job has failed_
+ * <p>
+ * A pending/unsatisfied range means sidecar instances are still working on importing
+ *
+ */
+ ALL_FAILED_AND_PENDING,
+
+ /**
+ * Gather the progress of every slice/range in the job.
+ * The fetch policy is mostly used for debugging.
+ */
+ ALL;
+
+ @Override
+ public String toString()
+ {
+ return name().toLowerCase(Locale.ROOT);
+ }
+
+ /**
+ * @return {@link RestoreJobProgressFetchPolicy} from string
+ */
+ public static RestoreJobProgressFetchPolicy fromString(String name)
+ {
+ try
+ {
+ return valueOf(name.toUpperCase(Locale.ROOT));
+ }
+ catch (IllegalArgumentException unknownEnum)
+ {
+ throw new IllegalArgumentException("No RestoreJobProgressFetchPolicy found for " + name);
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobSecrets.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobSecrets.java
new file mode 100644
index 00000000..e9a80ab9
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobSecrets.java
@@ -0,0 +1,96 @@
+/*
+ * 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.sidecar.common.data;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SECRET_READ_CREDENTIALS;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SECRET_WRITE_CREDENTIALS;
+
+/**
+ * Holds both read and write credentials needed for talk to S3
+ */
+public class RestoreJobSecrets
+{
+ private final StorageCredentials writeCredentials;
+ private final StorageCredentials readCredentials;
+
+ @JsonCreator
+ public RestoreJobSecrets(@JsonProperty(SECRET_READ_CREDENTIALS) StorageCredentials readCredentials,
+ @JsonProperty(SECRET_WRITE_CREDENTIALS) StorageCredentials writeCredentials)
+ {
+ Objects.requireNonNull(readCredentials, "Read credentials must be supplied");
+ Objects.requireNonNull(writeCredentials, "Write credentials must be supplied");
+ this.readCredentials = readCredentials;
+ this.writeCredentials = writeCredentials;
+ }
+
+ /**
+ * @return credentials that have write permission
+ */
+ @JsonProperty(SECRET_WRITE_CREDENTIALS)
+ public StorageCredentials writeCredentials()
+ {
+ return writeCredentials;
+ }
+
+ /**
+ * @return credentials that have read permission
+ */
+ @JsonProperty(SECRET_READ_CREDENTIALS)
+ public StorageCredentials readCredentials()
+ {
+ return readCredentials;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format("RestoreJobSecrets{%s=%s, %s=%s}",
+ SECRET_WRITE_CREDENTIALS, writeCredentials,
+ SECRET_READ_CREDENTIALS, readCredentials);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+
+ if (!(obj instanceof RestoreJobSecrets))
+ {
+ return false;
+ }
+
+ RestoreJobSecrets that = (RestoreJobSecrets) obj;
+ return Objects.equals(this.readCredentials, that.readCredentials)
+ && Objects.equals(this.writeCredentials, that.writeCredentials);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(writeCredentials, readCredentials);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobStatus.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobStatus.java
new file mode 100644
index 00000000..9074ccb5
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/RestoreJobStatus.java
@@ -0,0 +1,64 @@
+/*
+ * 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.sidecar.common.data;
+
+/**
+ * Holds all possible restore job statuses
+ */
+public enum RestoreJobStatus
+{
+ /**
+ * The external controller creates the RestoreJob
+ */
+ CREATED,
+ /**
+ * The external controller updates the status of the RestoreJob to STAGE_READY.
+ * It indicates that all relevant slices of the RestoreJob have been uploaded and ready to be consumed.
+ */
+ STAGE_READY,
+ /**
+ * All relevant slices are staged and the staged data satisfies the consistency requirement of the RestoreJob.
+ * The external controller updates the status of the RestoreJob to STAGED.
+ */
+ STAGED,
+ /**
+ * The external controller updates the status of the RestoreJob to IMPORT_READY
+ * It indicates that all staged data now are ready to be imported into Cassandra.
+ */
+ IMPORT_READY,
+ /**
+ * @deprecated replaced by {@link #ABORTED}
+ */
+ FAILED,
+ /**
+ * The external controller aborts the RestoreJob due to some failure, e.g. consistency not satisfied, timeout, etc.
+ * The RestoreJob can also be aborted by Sidecar, if and only if, the external controller fails to renew the lease for certain long duration.
+ * Such RestoreJobs are aborted due to expiry.
+ */
+ ABORTED,
+ /**
+ * The external controller marks the RestoreJob as succeeded.
+ */
+ SUCCEEDED;
+
+ public boolean isFinal()
+ {
+ return this == FAILED || this == ABORTED || this == SUCCEEDED;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/SSTableImportOptions.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/SSTableImportOptions.java
new file mode 100644
index 00000000..60b6a492
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/SSTableImportOptions.java
@@ -0,0 +1,129 @@
+/*
+ * 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.sidecar.common.data;
+
+import java.util.HashMap;
+
+/**
+ * Options for Cassandra import nodetool command. It is like properties.
+ * Supports Json serialization and deserialization.
+ */
+public class SSTableImportOptions extends HashMap<String, String>
+{
+ private static final String RESET_LEVEL = "resetLevel";
+ private static final String CLEAR_REPAIRED = "clearRepaired";
+ private static final String VERIFY_SSTABLES = "verifySSTables";
+ private static final String VERIFY_TOKENS = "verifyTokens";
+ private static final String INVALIDATE_CACHES = "invalidateCaches";
+ private static final String EXTENDED_VERIFY = "extendedVerify";
+ private static final String COPY_DATA = "copyData";
+
+ public static SSTableImportOptions defaults()
+ {
+ return new SSTableImportOptions();
+ }
+
+ private SSTableImportOptions()
+ {
+ put(RESET_LEVEL, Boolean.toString(true));
+ put(CLEAR_REPAIRED, Boolean.toString(true));
+ put(VERIFY_SSTABLES, Boolean.toString(true));
+ put(VERIFY_TOKENS, Boolean.toString(true));
+ put(INVALIDATE_CACHES, Boolean.toString(true));
+ put(EXTENDED_VERIFY, Boolean.toString(true));
+ put(COPY_DATA, Boolean.toString(false)); // note: the default is false
+ }
+
+ public SSTableImportOptions resetLevel(boolean enabled)
+ {
+ put(RESET_LEVEL, Boolean.toString(enabled));
+ return this;
+ }
+
+ public boolean resetLevel()
+ {
+ return Boolean.parseBoolean(get(RESET_LEVEL));
+ }
+
+ public SSTableImportOptions clearRepaired(boolean enabled)
+ {
+ put(CLEAR_REPAIRED, Boolean.toString(enabled));
+ return this;
+ }
+
+ public boolean clearRepaired()
+ {
+ return Boolean.parseBoolean(get(CLEAR_REPAIRED));
+ }
+
+ public SSTableImportOptions verifySSTables(boolean enabled)
+ {
+ put(VERIFY_SSTABLES, Boolean.toString(enabled));
+ return this;
+ }
+
+ public boolean verifySSTables()
+ {
+ return Boolean.parseBoolean(get(VERIFY_SSTABLES));
+ }
+
+ public SSTableImportOptions verifyTokens(boolean enabled)
+ {
+ put(VERIFY_TOKENS, Boolean.toString(enabled));
+ return this;
+ }
+
+ public boolean verifyTokens()
+ {
+ return Boolean.parseBoolean(get(VERIFY_TOKENS));
+ }
+
+ public SSTableImportOptions invalidateCaches(boolean enabled)
+ {
+ put(INVALIDATE_CACHES, Boolean.toString(enabled));
+ return this;
+ }
+
+ public boolean invalidateCaches()
+ {
+ return Boolean.parseBoolean(get(INVALIDATE_CACHES));
+ }
+
+ public SSTableImportOptions extendedVerify(boolean enabled)
+ {
+ put(EXTENDED_VERIFY, Boolean.toString(enabled));
+ return this;
+ }
+
+ public boolean extendedVerify()
+ {
+ return Boolean.parseBoolean(get(EXTENDED_VERIFY));
+ }
+
+ public SSTableImportOptions copyData(boolean enabled)
+ {
+ put(COPY_DATA, Boolean.toString(enabled));
+ return this;
+ }
+
+ public boolean copyData()
+ {
+ return Boolean.parseBoolean(get(COPY_DATA));
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/StorageCredentials.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/StorageCredentials.java
new file mode 100644
index 00000000..3cce29dd
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/data/StorageCredentials.java
@@ -0,0 +1,168 @@
+/*
+ * 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.sidecar.common.data;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.CREDENTIALS_ACCESS_KEY_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.CREDENTIALS_REGION;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.CREDENTIALS_SECRET_ACCESS_KEY;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.CREDENTIALS_SESSION_TOKEN;
+
+/**
+ * Used for storing credential details needed for either reading/writing to S3
+ */
+public class StorageCredentials
+{
+ private final String accessKeyId;
+ private final String secretAccessKey;
+ private final String sessionToken;
+ private final String region;
+
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+ @JsonCreator
+ public StorageCredentials(@JsonProperty(CREDENTIALS_ACCESS_KEY_ID) String accessKeyId,
+ @JsonProperty(CREDENTIALS_SECRET_ACCESS_KEY) String secretAccessKey,
+ @JsonProperty(CREDENTIALS_SESSION_TOKEN) String sessionToken,
+ @JsonProperty(CREDENTIALS_REGION) String region)
+ {
+ Objects.requireNonNull(accessKeyId, "accessKeyId must be supplied");
+ Objects.requireNonNull(secretAccessKey, "secretAccessKey must be supplied");
+ Objects.requireNonNull(sessionToken, "sessionToken must be supplied");
+ Objects.requireNonNull(region, "region must be supplied");
+ this.accessKeyId = accessKeyId;
+ this.secretAccessKey = secretAccessKey;
+ this.sessionToken = sessionToken;
+ this.region = region;
+ }
+
+ @JsonProperty(CREDENTIALS_ACCESS_KEY_ID)
+ public String accessKeyId()
+ {
+ return accessKeyId;
+ }
+
+ @JsonProperty(CREDENTIALS_SECRET_ACCESS_KEY)
+ public String secretAccessKey()
+ {
+ return secretAccessKey;
+ }
+
+ @JsonProperty(CREDENTIALS_SESSION_TOKEN)
+ public String sessionToken()
+ {
+ return sessionToken;
+ }
+
+ @JsonProperty(CREDENTIALS_REGION)
+ public String region()
+ {
+ return region;
+ }
+
+ /**
+ * @return secrets string with redacted values
+ */
+ @Override
+ public String toString()
+ {
+ return String.format("StorageCredentials{%s=%s, %s=%s, %s=%s, %s=%s}",
+ CREDENTIALS_ACCESS_KEY_ID, accessKeyId,
+ CREDENTIALS_SECRET_ACCESS_KEY, "redacted",
+ CREDENTIALS_SESSION_TOKEN, "redacted",
+ CREDENTIALS_REGION, region);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+
+ if (!(obj instanceof StorageCredentials))
+ {
+ return false;
+ }
+
+ StorageCredentials that = (StorageCredentials) obj;
+ return Objects.equals(this.accessKeyId, that.accessKeyId)
+ && Objects.equals(this.secretAccessKey, that.secretAccessKey)
+ && Objects.equals(this.sessionToken, that.sessionToken)
+ && Objects.equals(this.region, that.region);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(accessKeyId, secretAccessKey, sessionToken, region);
+ }
+
+ /**
+ * Builds the RestoreJobSecrets
+ */
+ public static class Builder
+ {
+ private String accessKeyId;
+ private String secretAccessKey;
+ private String sessionToken;
+ private String region;
+
+ private Builder()
+ {
+ }
+
+ public Builder accessKeyId(String accessKeyId)
+ {
+ this.accessKeyId = accessKeyId;
+ return this;
+ }
+
+ public Builder secretAccessKey(String secretAccessKey)
+ {
+ this.secretAccessKey = secretAccessKey;
+ return this;
+ }
+
+ public Builder sessionToken(String sessionToken)
+ {
+ this.sessionToken = sessionToken;
+ return this;
+ }
+
+ public Builder region(String region)
+ {
+ this.region = region;
+ return this;
+ }
+
+ public StorageCredentials build()
+ {
+ return new StorageCredentials(accessKeyId, secretAccessKey, sessionToken, region);
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/exceptions/RangeException.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/exceptions/RangeException.java
new file mode 100644
index 00000000..6ab43f8e
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/exceptions/RangeException.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sidecar.common.exceptions;
+
+/**
+ * Custom exception
+ */
+public class RangeException extends RuntimeException
+{
+ public RangeException(String message)
+ {
+ super(message);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/http/SidecarHttpHeaderNames.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/http/SidecarHttpHeaderNames.java
new file mode 100644
index 00000000..8a87b32b
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/http/SidecarHttpHeaderNames.java
@@ -0,0 +1,38 @@
+/*
+ * 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.sidecar.common.http;
+
+/**
+ * Custom header names for sidecar
+ */
+public final class SidecarHttpHeaderNames
+{
+ /**
+ * {@code "cassandra-content-xxhash32"}
+ */
+ public static final String CONTENT_XXHASH32 = "cassandra-content-xxhash32";
+ /**
+ * {@code "cassandra-content-xxhash32-seed"}
+ */
+ public static final String CONTENT_XXHASH32_SEED = "cassandra-content-xxhash32-seed";
+
+ private SidecarHttpHeaderNames()
+ {
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/http/SidecarHttpResponseStatus.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/http/SidecarHttpResponseStatus.java
new file mode 100644
index 00000000..3524daaf
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/http/SidecarHttpResponseStatus.java
@@ -0,0 +1,48 @@
+/*
+ * 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.sidecar.common.http;
+
+import io.netty.handler.codec.http.HttpResponseStatus;
+
+/**
+ * Non-standard HTTP response status codes used in Sidecar
+ */
+public class SidecarHttpResponseStatus extends HttpResponseStatus
+{
+ /**
+ * 455 INVALID CHECKSUM
+ */
+ public static final HttpResponseStatus CHECKSUM_MISMATCH = newStatus(455, "Checksum Mismatch");
+
+ /**
+ * Creates a new instance with the specified {@code code} and its {@code reasonPhrase}.
+ *
+ * @param code the HTTP status code
+ * @param reasonPhrase the HTTP status reason
+ */
+ public SidecarHttpResponseStatus(int code, String reasonPhrase)
+ {
+ super(code, reasonPhrase);
+ }
+
+ private static HttpResponseStatus newStatus(int statusCode, String reasonPhrase)
+ {
+ return new SidecarHttpResponseStatus(statusCode, reasonPhrase);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/AbortRestoreJobRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/AbortRestoreJobRequest.java
new file mode 100644
index 00000000..88fe8351
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/AbortRestoreJobRequest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.UUID;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.AbortRestoreJobRequestPayload;
+
+/**
+ * Represents a request to abort a restore job
+ */
+public class AbortRestoreJobRequest extends Request
+{
+ private final AbortRestoreJobRequestPayload requestPayload;
+
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param table the table name in Cassandra
+ * @param jobId a unique identifier for the job
+ */
+ public AbortRestoreJobRequest(String keyspace, String table, UUID jobId, AbortRestoreJobRequestPayload payload)
+ {
+ super(requestURI(keyspace, table, jobId));
+ this.requestPayload = payload;
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.POST;
+ }
+
+ @Override
+ public Object requestBody()
+ {
+ return requestPayload;
+ }
+
+ static String requestURI(String keyspace, String table, UUID jobId)
+ {
+ return ApiEndpointsV1.ABORT_RESTORE_JOB_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, table)
+ .replaceAll(ApiEndpointsV1.JOB_ID_PATH_PARAM, jobId.toString());
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/AllServicesConfigRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/AllServicesConfigRequest.java
new file mode 100644
index 00000000..c257319d
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/AllServicesConfigRequest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.AllServicesConfigPayload;
+
+/**
+ * Represents a request for getting configurations for services from "configs" table inside
+ * sidecar internal keyspace.
+ */
+public class AllServicesConfigRequest extends JsonRequest<AllServicesConfigPayload>
+{
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled.
+ */
+ public AllServicesConfigRequest()
+ {
+ super(ApiEndpointsV1.SERVICES_CONFIG_ROUTE);
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CassandraJmxHealthRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CassandraJmxHealthRequest.java
new file mode 100644
index 00000000..fc87ecff
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CassandraJmxHealthRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.HealthResponse;
+
+/**
+ * Represents a request to retrieve the connectivity health checks performed against the Cassandra JMX protocol
+ */
+public class CassandraJmxHealthRequest extends JsonRequest<HealthResponse>
+{
+ /**
+ * Constructs a request to retrieve the Cassandra JMX health
+ */
+ public CassandraJmxHealthRequest()
+ {
+ super(ApiEndpointsV1.CASSANDRA_JMX_HEALTH_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CassandraNativeHealthRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CassandraNativeHealthRequest.java
new file mode 100644
index 00000000..085bcc8c
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CassandraNativeHealthRequest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.HealthResponse;
+
+/**
+ * Represents a request to retrieve the connectivity health checks performed against the Cassandra native protocol
+ */
+public class CassandraNativeHealthRequest extends JsonRequest<HealthResponse>
+{
+ /**
+ * Constructs a request to retrieve the Cassandra native health
+ */
+ public CassandraNativeHealthRequest()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a request to retrieve the Cassandra native health
+ *
+ * @param useDeprecatedHealthEndpoint {@code true} if using the deprecated endpoint, {@code false} to use
+ * the new endpoint
+ */
+ @SuppressWarnings("deprecation")
+ public CassandraNativeHealthRequest(boolean useDeprecatedHealthEndpoint)
+ {
+ super(useDeprecatedHealthEndpoint
+ ? ApiEndpointsV1.CASSANDRA_HEALTH_ROUTE
+ : ApiEndpointsV1.CASSANDRA_NATIVE_HEALTH_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CleanSSTableUploadSessionRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CleanSSTableUploadSessionRequest.java
new file mode 100644
index 00000000..d1533aca
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CleanSSTableUploadSessionRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+
+/**
+ * Represents a request to clean up the SSTable upload session
+ */
+public class CleanSSTableUploadSessionRequest extends Request
+{
+ /**
+ * Constructs a request with the provided {@code requestURI}
+ *
+ * @param uploadId the unique identifier for the upload
+ */
+ public CleanSSTableUploadSessionRequest(String uploadId)
+ {
+ super(ApiEndpointsV1.SSTABLE_CLEANUP_ROUTE.replaceAll(ApiEndpointsV1.UPLOAD_ID_PATH_PARAM, uploadId));
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.DELETE;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ClearSnapshotRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ClearSnapshotRequest.java
new file mode 100644
index 00000000..000d6c73
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ClearSnapshotRequest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+
+/**
+ * Represents a request to clear a snapshot
+ */
+public class ClearSnapshotRequest extends SnapshotRequest<Void>
+{
+ /**
+ * Constructs a new request to clear a snapshot with name {@code snapshotName} for the given {@code keyspace}
+ * and {@code table}.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param table the table name in Cassandra
+ * @param snapshotName the name of the snapshot
+ */
+ public ClearSnapshotRequest(String keyspace, String table, String snapshotName)
+ {
+ super(keyspace, table, snapshotName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.DELETE;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ConnectedClientStatsRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ConnectedClientStatsRequest.java
new file mode 100644
index 00000000..7d8d7b98
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ConnectedClientStatsRequest.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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.ConnectedClientStatsResponse;
+
+/**
+ * Represents a request get the stats related to the clients connected to the node
+ */
+public class ConnectedClientStatsRequest extends JsonRequest<ConnectedClientStatsResponse>
+{
+ /**
+ * Constructs a request to retrieve the Cassandra node stats connected clients information
+ */
+ public ConnectedClientStatsRequest()
+ {
+ super(ApiEndpointsV1.CONNECTED_CLIENT_STATS_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobRequest.java
new file mode 100644
index 00000000..07fc8570
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobRequest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.CreateRestoreJobRequestPayload;
+import org.apache.cassandra.sidecar.common.response.data.CreateRestoreJobResponsePayload;
+
+/**
+ * Represents a request to create a restore job
+ */
+public class CreateRestoreJobRequest extends JsonRequest<CreateRestoreJobResponsePayload>
+{
+ private final CreateRestoreJobRequestPayload requestPayload;
+
+ /**
+ * Constructs a decodable request with the provided parameters
+ *
+ * @param keyspace name of the keyspace in the cluster
+ * @param table name of the table in the cluster
+ * @param requestPayload request payload
+ */
+ public CreateRestoreJobRequest(String keyspace, String table, CreateRestoreJobRequestPayload requestPayload)
+ {
+ super(requestURI(keyspace, table));
+ this.requestPayload = requestPayload;
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.POST;
+ }
+
+ @Override
+ public Object requestBody()
+ {
+ return requestPayload;
+ }
+
+ static String requestURI(String keyspace, String table)
+ {
+ return ApiEndpointsV1.CREATE_RESTORE_JOB_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, table);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobSliceRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobSliceRequest.java
new file mode 100644
index 00000000..8b330e6c
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobSliceRequest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.UUID;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.CreateSliceRequestPayload;
+
+/**
+ * Represents a request to create a restore job slice
+ */
+public class CreateRestoreJobSliceRequest extends Request
+{
+ private final CreateSliceRequestPayload payload;
+
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}
+ *
+ * @param keyspace name of the keyspace in the cluster
+ * @param table name of the table in the cluster
+ * @param jobId job ID of the restore job to create slice
+ * @param payload request payload
+ */
+ public CreateRestoreJobSliceRequest(String keyspace, String table, UUID jobId, CreateSliceRequestPayload payload)
+ {
+ super(requestURI(keyspace, table, jobId));
+ this.payload = payload;
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.POST;
+ }
+
+ @Override
+ public Object requestBody()
+ {
+ return payload;
+ }
+
+ static String requestURI(String keyspace, String table, UUID jobId)
+ {
+ return ApiEndpointsV1.RESTORE_JOB_SLICES_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, table)
+ .replaceAll(ApiEndpointsV1.JOB_ID_PATH_PARAM, jobId.toString());
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateSnapshotRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateSnapshotRequest.java
new file mode 100644
index 00000000..addccabc
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CreateSnapshotRequest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Represents a request to create a snapshot
+ */
+public class CreateSnapshotRequest extends SnapshotRequest<Void>
+{
+ /**
+ * Constructs a new request to create a snapshot with name {@code snapshotName} for the given {@code keyspace}
+ * and {@code table}.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param table the table name in Cassandra
+ * @param snapshotName the name of the snapshot
+ * @param snapshotTTL an optional time to live option for the snapshot (available since Cassandra 4.1+)
+ * The TTL option must specify the units, for example 2d represents a TTL for 2 days;
+ * 1h represents a TTL of 1 hour, etc. Valid units are {@code d}, {@code h}, {@code s},
+ * {@code ms}, {@code us}, {@code µs}, {@code ns}, and {@code m}.
+ */
+ public CreateSnapshotRequest(String keyspace, String table, String snapshotName, @Nullable String snapshotTTL)
+ {
+ super(keyspace, table, snapshotName, false, snapshotTTL);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.PUT;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/DeleteServiceConfigRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/DeleteServiceConfigRequest.java
new file mode 100644
index 00000000..f627d355
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/DeleteServiceConfigRequest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+
+/**
+ * Represents a request for deleting configurations for a service from "configs" table inside
+ * sidecar internal keyspace.
+ */
+public class DeleteServiceConfigRequest extends Request
+{
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled.
+ */
+ public DeleteServiceConfigRequest(Service service)
+ {
+ super(ApiEndpointsV1.SERVICE_CONFIG_ROUTE.replaceAll(ApiEndpointsV1.SERVICE_PARAM, service.serviceName));
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.DELETE;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/GossipHealthRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/GossipHealthRequest.java
new file mode 100644
index 00000000..9235d2ee
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/GossipHealthRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.HealthResponse;
+
+/**
+ * Request to get gossip health
+ */
+public class GossipHealthRequest extends JsonRequest<HealthResponse>
+{
+ /**
+ * Constructs a request to GET gossip health
+ */
+ public GossipHealthRequest()
+ {
+ super(ApiEndpointsV1.GOSSIP_HEALTH_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/GossipInfoRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/GossipInfoRequest.java
new file mode 100644
index 00000000..4947a8f0
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/GossipInfoRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.GossipInfoResponse;
+
+/**
+ * Represents a request to retrieve the Cassandra gossip information
+ */
+public class GossipInfoRequest extends JsonRequest<GossipInfoResponse>
+{
+ /**
+ * Constructs a request to retrieve the Cassandra gossip information
+ */
+ public GossipInfoRequest()
+ {
+ super(ApiEndpointsV1.GOSSIP_INFO_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ImportSSTableRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ImportSSTableRequest.java
new file mode 100644
index 00000000..7633b944
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ImportSSTableRequest.java
@@ -0,0 +1,211 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.SSTableImportResponse;
+
+/**
+ * Represents a request to import SSTable components previously uploaded for an upload identifier
+ */
+public class ImportSSTableRequest extends JsonRequest<SSTableImportResponse>
+{
+ /**
+ * Constructs a decodable request with the provided {@code requestURI}
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param tableName the table name in Cassandra
+ * @param uploadId an identifier for the upload
+ * @param importOptions additional options for the import process
+ */
+ public ImportSSTableRequest(String keyspace, String tableName, String uploadId, ImportOptions importOptions)
+ {
+ super(requestURI(keyspace, tableName, uploadId, importOptions));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.PUT;
+ }
+
+ /**
+ * Options for the SSTable import
+ */
+ public static class ImportOptions
+ {
+ private Boolean resetLevel;
+ private Boolean clearRepaired;
+ private Boolean verifySSTables;
+ private Boolean verifyTokens;
+ private Boolean invalidateCaches;
+ private Boolean extendedVerify;
+ private Boolean copyData;
+
+ public ImportOptions()
+ {
+ }
+
+ /**
+ * Sets the {@code resetLevel} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param resetLevel the {@code resetLevel} to set
+ * @return a reference to this Builder
+ */
+ public ImportOptions resetLevel(boolean resetLevel)
+ {
+ this.resetLevel = resetLevel;
+ return this;
+ }
+
+ /**
+ * Sets the {@code clearRepaired} and returns a reference to this ImportOptions enabling method chaining.
+ *
+ * @param clearRepaired the {@code clearRepaired} to set
+ * @return a reference to this ImportOptions
+ */
+ public ImportOptions clearRepaired(boolean clearRepaired)
+ {
+ this.clearRepaired = clearRepaired;
+ return this;
+ }
+
+ /**
+ * Sets the {@code verifySSTables} and returns a reference to this ImportOptions enabling method chaining.
+ *
+ * @param verifySSTables the {@code verifySSTables} to set
+ * @return a reference to this ImportOptions
+ */
+ public ImportOptions verifySSTables(boolean verifySSTables)
+ {
+ this.verifySSTables = verifySSTables;
+ return this;
+ }
+
+ /**
+ * Sets the {@code verifyTokens} and returns a reference to this ImportOptions enabling method chaining.
+ *
+ * @param verifyTokens the {@code verifyTokens} to set
+ * @return a reference to this ImportOptions
+ */
+ public ImportOptions verifyTokens(boolean verifyTokens)
+ {
+ this.verifyTokens = verifyTokens;
+ return this;
+ }
+
+ /**
+ * Sets the {@code invalidateCaches} and returns a reference to this ImportOptions enabling method chaining.
+ *
+ * @param invalidateCaches the {@code invalidateCaches} to set
+ * @return a reference to this ImportOptions
+ */
+ public ImportOptions invalidateCaches(boolean invalidateCaches)
+ {
+ this.invalidateCaches = invalidateCaches;
+ return this;
+ }
+
+ /**
+ * Sets the {@code extendedVerify} and returns a reference to this ImportOptions enabling method chaining.
+ *
+ * @param extendedVerify the {@code extendedVerify} to set
+ * @return a reference to this ImportOptions
+ */
+ public ImportOptions extendedVerify(boolean extendedVerify)
+ {
+ this.extendedVerify = extendedVerify;
+ return this;
+ }
+
+ /**
+ * Sets the {@code copyData} and returns a reference to this ImportOptions enabling method chaining.
+ *
+ * @param copyData the {@code copyData} to set
+ * @return a reference to this ImportOptions
+ */
+ public ImportOptions copyData(boolean copyData)
+ {
+ this.copyData = copyData;
+ return this;
+ }
+ }
+
+ static String requestURI(String keyspace, String tableName, String uploadId, ImportOptions importOptions)
+ {
+ String requestUri = ApiEndpointsV1.SSTABLE_IMPORT_ROUTE
+ .replaceAll(ApiEndpointsV1.UPLOAD_ID_PATH_PARAM, uploadId)
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, tableName);
+
+ List<String> options = selectedOptions(importOptions);
+
+ if (options.isEmpty())
+ {
+ return requestUri;
+ }
+
+ return requestUri + options.stream()
+ .collect(Collectors.joining("&", "?", ""));
+ }
+
+ private static List<String> selectedOptions(ImportOptions importOptions)
+ {
+ List<String> options = new ArrayList<>();
+
+ if (importOptions.resetLevel != null)
+ {
+ options.add("resetLevel=" + importOptions.resetLevel);
+ }
+ if (importOptions.clearRepaired != null)
+ {
+ options.add("clearRepaired=" + importOptions.clearRepaired);
+ }
+ if (importOptions.verifySSTables != null)
+ {
+ options.add("verifySSTables=" + importOptions.verifySSTables);
+ }
+ if (importOptions.verifyTokens != null)
+ {
+ options.add("verifyTokens=" + importOptions.verifyTokens);
+ }
+ if (importOptions.invalidateCaches != null)
+ {
+ options.add("invalidateCaches=" + importOptions.invalidateCaches);
+ }
+ if (importOptions.extendedVerify != null)
+ {
+ options.add("extendedVerify=" + importOptions.extendedVerify);
+ }
+ if (importOptions.copyData != null)
+ {
+ options.add("copyData=" + importOptions.copyData);
+ }
+
+ return options;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/JsonRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/JsonRequest.java
new file mode 100644
index 00000000..7f99c8ce
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/JsonRequest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.lang.reflect.ParameterizedType;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Json request that returns json response
+ *
+ * @param <T> response type
+ */
+public abstract class JsonRequest<T> extends Request
+{
+ private final JsonResponseBytesDecoder<T> responseDecoder;
+
+ /**
+ * Constructs a decodable request with the provided {@code requestURI}
+ *
+ * @param requestURI the URI of the request
+ */
+ protected JsonRequest(String requestURI)
+ {
+ super(requestURI);
+ Class<T> type = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
+ this.responseDecoder = new JsonResponseBytesDecoder<>(type);
+ }
+
+ @Override
+ public ResponseBytesDecoder<T> responseBytesDecoder()
+ {
+ return responseDecoder;
+ }
+
+ @Override
+ public Map<String, String> headers()
+ {
+ Map<String, String> headers = new HashMap<>(super.headers());
+ headers.put("content-type", "application/json");
+ return Collections.unmodifiableMap(headers);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/JsonResponseBytesDecoder.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/JsonResponseBytesDecoder.java
new file mode 100644
index 00000000..20929641
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/JsonResponseBytesDecoder.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * Decoder for json response body bytes
+ * @param <T> expected java type
+ */
+public class JsonResponseBytesDecoder<T> implements ResponseBytesDecoder<T>
+{
+ private static final ObjectMapper MAPPER = new ObjectMapper()
+ // ignore all the properties that are not declared
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ private final Class<T> type;
+
+ public JsonResponseBytesDecoder(Class<T> type)
+ {
+ this.type = type;
+ }
+
+ @Override
+ public T decode(byte[] bytes) throws IOException
+ {
+ if (bytes == null)
+ {
+ return null;
+ }
+ return MAPPER.readValue(bytes, type);
+ }
+}
diff --git a/profiles/scala-2.13-spark-3-jdk-11.gradle b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListCdcSegmentsRequest.java
similarity index 57%
copy from profiles/scala-2.13-spark-3-jdk-11.gradle
copy to analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListCdcSegmentsRequest.java
index 31cf55e4..90331d98 100644
--- a/profiles/scala-2.13-spark-3-jdk-11.gradle
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListCdcSegmentsRequest.java
@@ -16,16 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.cassandra.sidecar.common.request;
-ext {
- jacksonVersion="2.12.7"
- jacksonScalaModuleVersion="2.12.7"
- scalaMajorVersion="2.13"
- scalaVersion="2.13.10"
- sparkGroupId="org.apache.spark"
- sparkMajorVersion="3"
- sparkVersion="3.2.2"
- sidecarClientGroup="org.apache.cassandra"
- sidecarClientName="sidecar-vertx-client-all"
- sidecarVersion="${sidecarClientVersion}"
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.ListCdcSegmentsResponse;
+
+/**
+ * Represents a request for listing commit log files on an instance
+ */
+public class ListCdcSegmentsRequest extends JsonRequest<ListCdcSegmentsResponse>
+{
+ public ListCdcSegmentsRequest()
+ {
+ super(ApiEndpointsV1.LIST_CDC_SEGMENTS_ROUTE);
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListOperationalJobsRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListOperationalJobsRequest.java
new file mode 100644
index 00000000..b472bd70
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListOperationalJobsRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.ListOperationalJobsResponse;
+
+/**
+ * Represents a request to retrieve the list of async operational jobs
+ */
+public class ListOperationalJobsRequest extends JsonRequest<ListOperationalJobsResponse>
+{
+ /**
+ * Constructs a request to retrieve the list of running operational jobs
+ */
+ public ListOperationalJobsRequest()
+ {
+ super(ApiEndpointsV1.LIST_OPERATIONAL_JOBS_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListSnapshotFilesRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListSnapshotFilesRequest.java
new file mode 100644
index 00000000..0c5d527a
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListSnapshotFilesRequest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.response.ListSnapshotFilesResponse;
+
+/**
+ * Represents a request to list the files for a Cassandra snapshot
+ */
+public class ListSnapshotFilesRequest extends SnapshotRequest<ListSnapshotFilesResponse>
+{
+ /**
+ * Constructs a request to list the Cassandra snapshot for the given {@code snapshotName} in the {@code keyspace}
+ * and {@code table}, specifying whether secondary index files should be included as part of the response.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param table the table name in Cassandra
+ * @param snapshotName the name of the snapshot
+ * @param includeSecondaryIndexFiles whether to include secondary index files
+ */
+ public ListSnapshotFilesRequest(String keyspace,
+ String table,
+ String snapshotName,
+ boolean includeSecondaryIndexFiles)
+ {
+ super(keyspace, table, snapshotName, includeSecondaryIndexFiles, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/NodeDecommissionRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/NodeDecommissionRequest.java
new file mode 100644
index 00000000..48269f28
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/NodeDecommissionRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.OperationalJobResponse;
+
+/**
+ * Represents a request to execute node decommission operation
+ */
+public class NodeDecommissionRequest extends JsonRequest<OperationalJobResponse>
+{
+ /**
+ * Constructs a request to execute a node decommission operation
+ */
+ public NodeDecommissionRequest()
+ {
+ super(ApiEndpointsV1.NODE_DECOMMISSION_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.PUT;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/NodeSettingsRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/NodeSettingsRequest.java
new file mode 100644
index 00000000..b73e99a0
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/NodeSettingsRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.NodeSettings;
+
+/**
+ * Represents a request to retrieve the node settings
+ */
+public class NodeSettingsRequest extends JsonRequest<NodeSettings>
+{
+ /**
+ * Constructs a request to retrieve the node settings
+ */
+ public NodeSettingsRequest()
+ {
+ super(ApiEndpointsV1.NODE_SETTINGS_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/OperationalJobRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/OperationalJobRequest.java
new file mode 100644
index 00000000..402c7d86
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/OperationalJobRequest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.UUID;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.OperationalJobResponse;
+
+/**
+ * Represents a request to retrieve the status of a async operational job
+ */
+public class OperationalJobRequest extends JsonRequest<OperationalJobResponse>
+{
+
+ /**
+ * Constructs a request to retrieve status for a specified operational job
+ */
+ public OperationalJobRequest(UUID jobId)
+ {
+ super(ApiEndpointsV1.OPERATIONAL_JOB_ROUTE
+ .replaceAll(ApiEndpointsV1.OPERATIONAL_JOB_ID_PATH_PARAM, jobId.toString()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ReportSchemaRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ReportSchemaRequest.java
new file mode 100644
index 00000000..91b5a7fc
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ReportSchemaRequest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.HealthResponse;
+
+/**
+ * A request to trigger an immediate, synchronous schema conversion
+ * and report regardless of the periodic task schedule or status
+ */
+public class ReportSchemaRequest extends JsonRequest<HealthResponse>
+{
+ public ReportSchemaRequest()
+ {
+ super(ApiEndpointsV1.REPORT_SCHEMA_ROUTE);
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.PUT;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/Request.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/Request.java
new file mode 100644
index 00000000..cb33db24
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/Request.java
@@ -0,0 +1,108 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import io.netty.handler.codec.http.HttpHeaderNames;
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.utils.HttpRange;
+
+/**
+ * An abstract class representing a request for Sidecar
+ */
+public abstract class Request
+{
+ protected final String requestURI;
+
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled.
+ *
+ * @param requestURI the URI of the request
+ */
+ protected Request(String requestURI)
+ {
+ this.requestURI = requestURI;
+ }
+
+ /**
+ * @return a map of headers for the request
+ */
+ public Map<String, String> headers()
+ {
+ HttpRange range = range();
+ if (range == null)
+ {
+ return Collections.emptyMap();
+ }
+ Map<String, String> headers = new HashMap<>();
+ headers.put(HttpHeaderNames.RANGE.toString(), range.toString());
+ return Collections.unmodifiableMap(headers);
+ }
+
+ /**
+ * @return the range for the HTTP request
+ */
+ protected HttpRange range()
+ {
+ return null;
+ }
+
+ /**
+ * @return the HTTP method to be used for the request
+ */
+ public abstract HttpMethod method();
+
+ /**
+ * @return the URI for the request
+ */
+ public String requestURI()
+ {
+ return requestURI;
+ }
+
+ /**
+ * @return the request body. Returns null, when there is no request body.
+ */
+ public Object requestBody()
+ {
+ return null;
+ }
+
+ /**
+ * @return the response bytes decoder if configured, or null
+ */
+ public ResponseBytesDecoder<?> responseBytesDecoder()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName() + "{" +
+ "requestURI='" + requestURI + '\'' +
+ '}';
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ResponseBytesDecoder.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ResponseBytesDecoder.java
new file mode 100644
index 00000000..72154647
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ResponseBytesDecoder.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.sidecar.common.request;
+
+import java.io.IOException;
+
+/**
+ * Decode response bytes into given java type {@code <T>}
+ * @param <T> expected java type
+ */
+public interface ResponseBytesDecoder<T>
+{
+ /**
+ * Decodes the provided {@code bytes} to an instance of the type {@code <T>}
+ *
+ * @param bytes the raw bytes of the response
+ * @return the decoded instance for the given {@code bytes}, or null for null input
+ * @throws IOException when the decoder is unable to decode successfully
+ */
+ T decode(byte[] bytes) throws IOException;
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RestoreJobProgressRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RestoreJobProgressRequest.java
new file mode 100644
index 00000000..c377b3a6
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RestoreJobProgressRequest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.RestoreJobProgressRequestParams;
+import org.apache.cassandra.sidecar.common.response.data.RestoreJobProgressResponsePayload;
+
+/**
+ * Represents a request to retrieve the status of a restore job
+ */
+public class RestoreJobProgressRequest extends JsonRequest<RestoreJobProgressResponsePayload>
+{
+ /**
+ * Constructs a decodable request with the provided {@code requestURI}
+ */
+ public RestoreJobProgressRequest(RestoreJobProgressRequestParams requestParams)
+ {
+ super(requestURI(requestParams));
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+
+ static String requestURI(RestoreJobProgressRequestParams requestParams)
+ {
+ String base = ApiEndpointsV1.RESTORE_JOB_PROGRESS_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, requestParams.keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, requestParams.table)
+ .replaceAll(ApiEndpointsV1.JOB_ID_PATH_PARAM, requestParams.jobId.toString());
+ return base + "?" + ApiEndpointsV1.FETCH_POLICY_QUERY_PARAM + "=" + requestParams.fetchPolicy.toString();
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RestoreJobSummaryRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RestoreJobSummaryRequest.java
new file mode 100644
index 00000000..b8318723
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RestoreJobSummaryRequest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.UUID;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.data.RestoreJobSummaryResponsePayload;
+
+/**
+ * Represents a request to retrieve the summary of a restore job
+ */
+public class RestoreJobSummaryRequest extends JsonRequest<RestoreJobSummaryResponsePayload>
+{
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param table the table name in Cassandra
+ * @param jobId a unique identifier for the job
+ */
+ public RestoreJobSummaryRequest(String keyspace, String table, UUID jobId)
+ {
+ super(requestURI(keyspace, table, jobId));
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+
+ static String requestURI(String keyspace, String table, UUID jobId)
+ {
+ return ApiEndpointsV1.RESTORE_JOB_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, table)
+ .replaceAll(ApiEndpointsV1.JOB_ID_PATH_PARAM, jobId.toString());
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RingRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RingRequest.java
new file mode 100644
index 00000000..c87dcacb
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/RingRequest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.RingResponse;
+
+/**
+ * Represents a request to retrieve the Cassandra ring information
+ */
+public class RingRequest extends JsonRequest<RingResponse>
+{
+ /**
+ * Constructs a request to retrieve the Cassandra ring information
+ */
+ public RingRequest()
+ {
+ super(ApiEndpointsV1.RING_ROUTE);
+ }
+
+ /**
+ * Constructs a request to retrieve the Cassandra ring information for the given {@code keyspace}
+ *
+ * @param keyspace the keyspace in Cassandra
+ */
+ public RingRequest(String keyspace)
+ {
+ super(ApiEndpointsV1.RING_WITH_KEYSPACE_ROUTE.replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SSTableComponentRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SSTableComponentRequest.java
new file mode 100644
index 00000000..82b83774
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SSTableComponentRequest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.ListSnapshotFilesResponse;
+import org.apache.cassandra.sidecar.common.utils.HttpRange;
+
+/**
+ * Represents a request to stream an SSTable component
+ */
+public class SSTableComponentRequest extends Request
+{
+ private final HttpRange range;
+
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param tableName the table name in Cassandra
+ * @param snapshotName the name of the snapshot
+ * @param componentName the name of the SSTable component
+ * @param range the HTTP range for the request
+ */
+ public SSTableComponentRequest(String keyspace,
+ String tableName,
+ String snapshotName,
+ String componentName,
+ HttpRange range)
+ {
+ super(requestURI(keyspace, tableName, snapshotName, componentName));
+ this.range = range;
+ }
+
+ /**
+ * Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled.
+ *
+ * @param fileInfo contains information about the file to stream
+ * @param range the HTTP range for the request
+ */
+ public SSTableComponentRequest(ListSnapshotFilesResponse.FileInfo fileInfo, HttpRange range)
+ {
+ super(fileInfo.componentDownloadUrl());
+ this.range = range;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected HttpRange range()
+ {
+ return range;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "SSTableComponentRequest{" +
+ "range=" + range +
+ ", requestURI='" + requestURI + '\'' +
+ '}';
+ }
+
+ static String requestURI(String keyspace, String table, String snapshot, String component)
+ {
+ return ApiEndpointsV1.COMPONENTS_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, table)
+ .replaceAll(ApiEndpointsV1.SNAPSHOT_PATH_PARAM, snapshot)
+ .replaceAll(ApiEndpointsV1.COMPONENT_PATH_PARAM, component);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SchemaRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SchemaRequest.java
new file mode 100644
index 00000000..c19ffac0
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SchemaRequest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.SchemaResponse;
+
+/**
+ * Represents a request to retrieve the schema
+ */
+public class SchemaRequest extends JsonRequest<SchemaResponse>
+{
+ /**
+ * Constructs a request to retrieve the full Cassandra schema
+ */
+ public SchemaRequest()
+ {
+ super(ApiEndpointsV1.ALL_KEYSPACES_SCHEMA_ROUTE);
+ }
+
+ /**
+ * Constructs a request to retrieve the schema for the given {@code keyspace}
+ *
+ * @param keyspace the keyspace in Cassandra
+ */
+ public SchemaRequest(String keyspace)
+ {
+ super(ApiEndpointsV1.KEYSPACE_SCHEMA_ROUTE.replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/Service.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/Service.java
new file mode 100644
index 00000000..1b0d69c4
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/Service.java
@@ -0,0 +1,41 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.Locale;
+
+/**
+ * "configs" table inside internal sidecar keyspace stores configs for Kafka and CDC. ServiceConfig identifies
+ * the service of the configs.
+ */
+public enum Service
+{
+ KAFKA,
+ CDC;
+ public final String serviceName;
+
+ Service()
+ {
+ this.serviceName = this.toString().toLowerCase(Locale.ENGLISH);
+ }
+
+ public static Service withName(String serviceName)
+ {
+ return valueOf(serviceName.toUpperCase(Locale.ENGLISH));
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SidecarHealthRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SidecarHealthRequest.java
new file mode 100644
index 00000000..c25afa65
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SidecarHealthRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.HealthResponse;
+
+/**
+ * Represents a request to retrieve the Sidecar health
+ */
+public class SidecarHealthRequest extends JsonRequest<HealthResponse>
+{
+ /**
+ * Constructs a request to retrieve the Sidecar health
+ */
+ public SidecarHealthRequest()
+ {
+ super(ApiEndpointsV1.HEALTH_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SnapshotRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SnapshotRequest.java
new file mode 100644
index 00000000..4068ce1e
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/SnapshotRequest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.sidecar.common.request;
+
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * An abstract class that access the {@link ApiEndpointsV1#SNAPSHOTS_ROUTE}
+ *
+ * @param <T> the type of the decodable request
+ */
+abstract class SnapshotRequest<T> extends JsonRequest<T>
+{
+ SnapshotRequest(String keyspace, String table, String snapshotName)
+ {
+ super(requestURI(keyspace, table, snapshotName, false, null));
+ }
+
+ SnapshotRequest(String keyspace, String table, String snapshotName, boolean includeSecondaryIndexFiles,
+ @Nullable String snapshotTTL)
+ {
+ super(requestURI(keyspace, table, snapshotName, includeSecondaryIndexFiles, snapshotTTL));
+ }
+
+ static String requestURI(String keyspace, String tableName, String snapshotName,
+ boolean includeSecondaryIndexFiles, @Nullable String snapshotTTL)
+ {
+ String requestUri = ApiEndpointsV1.SNAPSHOTS_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, tableName)
+ .replaceAll(ApiEndpointsV1.SNAPSHOT_PATH_PARAM, snapshotName);
+
+ if (!includeSecondaryIndexFiles && snapshotTTL == null)
+ {
+ return requestUri;
+ }
+
+ requestUri = requestUri + '?';
+
+ if (includeSecondaryIndexFiles)
+ {
+ requestUri = requestUri + "includeSecondaryIndexFiles=true";
+ }
+
+ if (snapshotTTL != null)
+ {
+ requestUri = requestUri + "ttl=" + snapshotTTL;
+ }
+
+ return requestUri;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/StreamCdcSegmentRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/StreamCdcSegmentRequest.java
new file mode 100644
index 00000000..fe1ac54b
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/StreamCdcSegmentRequest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.utils.HttpRange;
+
+/**
+ * Represents a request to stream CDC segments(commit logs) on an instance.
+ */
+public class StreamCdcSegmentRequest extends Request
+{
+ private final HttpRange range;
+
+ public StreamCdcSegmentRequest(String segment, HttpRange range)
+ {
+ super(requestURI(segment));
+ this.range = range;
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+
+ @Override
+ protected HttpRange range()
+ {
+ return range;
+ }
+
+ private static String requestURI(String segment)
+ {
+ return ApiEndpointsV1.STREAM_CDC_SEGMENTS_ROUTE.replaceAll(ApiEndpointsV1.SEGMENT_PATH_PARAM, segment);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/StreamStatsRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/StreamStatsRequest.java
new file mode 100644
index 00000000..2640f85d
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/StreamStatsRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.StreamStatsResponse;
+
+/**
+ * Class response for the StreamsStats API
+ */
+public class StreamStatsRequest extends JsonRequest<StreamStatsResponse>
+{
+ /**
+ * Constructs a request to retrieve the Cassandra node streaming stats information
+ */
+ public StreamStatsRequest()
+ {
+ super(ApiEndpointsV1.STREAM_STATS_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TableStatsRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TableStatsRequest.java
new file mode 100644
index 00000000..8c4633a0
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TableStatsRequest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.TableStatsResponse;
+
+/**
+ * Represents a request get the stats related to the clients connected to the node
+ */
+public class TableStatsRequest extends JsonRequest<TableStatsResponse>
+{
+ /**
+ * Constructs a request to retrieve the Cassandra node table stats information
+ * @param keyspace name of the keyspace in the cluster
+ * @param table name of the table in the cluster
+ */
+ public TableStatsRequest(String keyspace, String table)
+ {
+ super(requestURI(keyspace, table));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+
+ static String requestURI(String keyspace, String table)
+ {
+ return ApiEndpointsV1.TABLE_STATS_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, table);
+ }
+
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TimeSkewRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TimeSkewRequest.java
new file mode 100644
index 00000000..277ffb42
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TimeSkewRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.TimeSkewResponse;
+
+/**
+ * Represents a request to retrieve information from the time skew endpoint
+ */
+public class TimeSkewRequest extends JsonRequest<TimeSkewResponse>
+{
+ /**
+ * Constructs a new request to retrieve information from the time skew endpoint
+ */
+ public TimeSkewRequest()
+ {
+ super(ApiEndpointsV1.TIME_SKEW_ROUTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TokenRangeReplicasRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TokenRangeReplicasRequest.java
new file mode 100644
index 00000000..3d141760
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/TokenRangeReplicasRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.response.TokenRangeReplicasResponse;
+
+/**
+ * Represents a request to retrieve information from the token-range replicas endpoint
+ */
+public class TokenRangeReplicasRequest extends JsonRequest<TokenRangeReplicasResponse>
+{
+ /**
+ * Constructs a new request to retrieve information by keyspace from token-range replicas endpoint
+ * @param keyspace the keyspace for which the token range replicas will be retrieved.
+ */
+ public TokenRangeReplicasRequest(String keyspace)
+ {
+ super(ApiEndpointsV1.KEYSPACE_TOKEN_MAPPING_ROUTE.replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace));
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.GET;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UpdateRestoreJobRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UpdateRestoreJobRequest.java
new file mode 100644
index 00000000..122308c2
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UpdateRestoreJobRequest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.UUID;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.UpdateRestoreJobRequestPayload;
+
+/**
+ * Represents a request to update a restore job
+ */
+public class UpdateRestoreJobRequest extends Request
+{
+ private final UpdateRestoreJobRequestPayload requestPayload;
+
+ /**
+ * Constructs a Sidecar request with the given parameters.
+ *
+ * @param keyspace name of the keyspace in the cluster
+ * @param table name of the table in the cluster
+ * @param jobId a unique identifier for the job
+ * @param requestPayload request payload
+ */
+ public UpdateRestoreJobRequest(String keyspace, String table, UUID jobId,
+ UpdateRestoreJobRequestPayload requestPayload)
+ {
+ super(requestURI(keyspace, table, jobId));
+ this.requestPayload = requestPayload;
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.PATCH;
+ }
+
+ @Override
+ public Object requestBody()
+ {
+ return requestPayload;
+ }
+
+ static String requestURI(String keyspace, String table, UUID jobId)
+ {
+ return ApiEndpointsV1.RESTORE_JOB_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, table)
+ .replaceAll(ApiEndpointsV1.JOB_ID_PATH_PARAM, jobId.toString());
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UpdateServiceConfigRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UpdateServiceConfigRequest.java
new file mode 100644
index 00000000..cbb38cc2
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UpdateServiceConfigRequest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.sidecar.common.request;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.UpdateCdcServiceConfigPayload;
+
+/**
+ * Request class for updating the config of a given service.
+ * Ex: updating kafka configs or updating cdc configs
+ */
+public class UpdateServiceConfigRequest extends JsonRequest<UpdateCdcServiceConfigPayload>
+{
+ final UpdateCdcServiceConfigPayload payload;
+
+ public UpdateServiceConfigRequest(Service service, UpdateCdcServiceConfigPayload payload)
+ {
+ super(ApiEndpointsV1.SERVICE_CONFIG_ROUTE.replaceAll(ApiEndpointsV1.SERVICE_PARAM, service.serviceName));
+ this.payload = payload;
+ }
+
+ @Override
+ public Object requestBody()
+ {
+ return this.payload;
+ }
+
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.PUT;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UploadSSTableRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UploadSSTableRequest.java
new file mode 100644
index 00000000..45dda39a
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UploadSSTableRequest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import io.netty.handler.codec.http.HttpMethod;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+import org.apache.cassandra.sidecar.common.request.data.Digest;
+
+/**
+ * Represents a request to upload an SSTable component
+ */
+public class UploadSSTableRequest extends Request implements UploadableRequest
+{
+ private final Digest digest;
+ private final String filename;
+
+ /**
+ * Constructs a request with the provided {@code requestURI}
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param table the table name in Cassandra
+ * @param uploadId an identifier for the upload
+ * @param component SSTable component being uploaded
+ * @param digest digest value to check integrity of SSTable component uploaded
+ * @param filename the path to the file to be uploaded
+ */
+ public UploadSSTableRequest(String keyspace, String table, String uploadId, String component,
+ Digest digest, String filename)
+ {
+ super(requestURI(keyspace, table, uploadId, component));
+ this.digest = digest;
+ this.filename = Objects.requireNonNull(filename, "the filename is must be non-null");
+
+ if (!Files.exists(Paths.get(filename)))
+ {
+ throw new IllegalArgumentException("File '" + filename + "' does not exist");
+ }
+ }
+
+ @Override
+ public String filename()
+ {
+ return filename;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, String> headers()
+ {
+ if (digest == null)
+ {
+ return super.headers();
+ }
+ Map<String, String> headers = new HashMap<>(super.headers());
+ headers.putAll(digest.headers());
+ return Collections.unmodifiableMap(headers);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpMethod method()
+ {
+ return HttpMethod.PUT;
+ }
+
+ static String requestURI(String keyspace, String tableName, String uploadId, String component)
+ {
+ return ApiEndpointsV1.SSTABLE_UPLOAD_ROUTE
+ .replaceAll(ApiEndpointsV1.UPLOAD_ID_PATH_PARAM, uploadId)
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, tableName)
+ .replaceAll(ApiEndpointsV1.COMPONENT_PATH_PARAM, component);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UploadableRequest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UploadableRequest.java
new file mode 100644
index 00000000..cb4a1657
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/UploadableRequest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sidecar.common.request;
+
+/**
+ * A request that will upload the provided file to the service
+ */
+public interface UploadableRequest
+{
+ /**
+ * @return the path to the file to be uploaded
+ */
+ String filename();
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/AbortRestoreJobRequestPayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/AbortRestoreJobRequestPayload.java
new file mode 100644
index 00000000..664451aa
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/AbortRestoreJobRequestPayload.java
@@ -0,0 +1,74 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.regex.Pattern;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.utils.Preconditions;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_OPERATION_REASON;
+
+/**
+ * Request payload for aborting a restore job.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AbortRestoreJobRequestPayload
+{
+ private static final Pattern ALPHANUMERIC_BLANK_ONLY = Pattern.compile("^[a-zA-Z0-9 ]*$");
+ private final String reason;
+
+ @JsonCreator
+ public AbortRestoreJobRequestPayload(@Nullable @JsonProperty(JOB_OPERATION_REASON) String reason)
+ {
+ this.reason = validateContent(reason);
+ }
+
+ /**
+ * @return the reason to abort the job
+ */
+ @JsonProperty(JOB_OPERATION_REASON)
+ public String reason()
+ {
+ return reason;
+ }
+
+ /**
+ * As reason string is logged and persisted, the validation is performed to avoid any malicious behavior
+ * @param reason client-sent string content
+ * @return the same string if content is good
+ */
+ private String validateContent(String reason)
+ {
+ if (reason == null)
+ {
+ return null;
+ }
+
+ Preconditions.checkArgument(reason.length() <= 1024, "Reason string is too long");
+ Preconditions.checkArgument(ALPHANUMERIC_BLANK_ONLY.matcher(reason).matches(),
+ "Reason string cannot contain non-alphanumeric-blank characters");
+ return reason;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/AllServicesConfigPayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/AllServicesConfigPayload.java
new file mode 100644
index 00000000..d7331271
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/AllServicesConfigPayload.java
@@ -0,0 +1,117 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * A class representing a response for the GetServicesConfig api "/api/v1/services" which contains
+ * configurations for all the services in the "configs" table.
+ */
+public class AllServicesConfigPayload
+{
+ public final List<Service> services;
+
+ @JsonCreator
+ public AllServicesConfigPayload(@JsonProperty("services") List<Service> services)
+ {
+ this.services = services;
+ }
+
+ @JsonProperty("services")
+ public List<Service> services()
+ {
+ return services;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ AllServicesConfigPayload that = (AllServicesConfigPayload) o;
+ return Objects.equals(services, that.services);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(services);
+ }
+
+ /**
+ * POJO class that represent config for a given service in "configs" table in sidecar
+ * internal keyspace
+ */
+ public static class Service
+ {
+ public final String service;
+ public final Map<String, String> config;
+
+ @JsonCreator
+ public Service(@JsonProperty("service") String service,
+ @JsonProperty("config") Map<String, String> config)
+ {
+ this.service = service;
+ this.config = config;
+ }
+
+ @JsonProperty("service")
+ public String service()
+ {
+ return service;
+ }
+
+ @JsonProperty("config")
+ public Map<String, String> config()
+ {
+ return config;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ Service service1 = (Service) o;
+ return Objects.equals(service, service1.service) && Objects.equals(config, service1.config);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(service, config);
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CreateRestoreJobRequestPayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CreateRestoreJobRequestPayload.java
new file mode 100644
index 00000000..9799d6ea
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CreateRestoreJobRequestPayload.java
@@ -0,0 +1,278 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.Date;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.function.Consumer;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.DataObjectBuilder;
+import org.apache.cassandra.sidecar.common.data.ConsistencyConfig;
+import org.apache.cassandra.sidecar.common.data.ConsistencyLevel;
+import org.apache.cassandra.sidecar.common.data.RestoreJobSecrets;
+import org.apache.cassandra.sidecar.common.data.RestoreJobStatus;
+import org.apache.cassandra.sidecar.common.data.SSTableImportOptions;
+import org.apache.cassandra.sidecar.common.utils.Preconditions;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_AGENT;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_CONSISTENCY_LEVEL;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_EXPIRE_AT;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_IMPORT_OPTIONS;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_LOCAL_DATA_CENTER;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_SECRETS;
+
+/**
+ * Request payload for creating restore jobs.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CreateRestoreJobRequestPayload
+{
+ private final UUID jobId;
+ private final String jobAgent;
+ private final RestoreJobSecrets secrets;
+ private final SSTableImportOptions importOptions;
+ private final long expireAtInMillis;
+ private final ConsistencyConfig consistencyConfig;
+
+ /**
+ * Builder to build a CreateRestoreJobRequest
+ *
+ * @param secrets secrets for access objects on storage cloud
+ * @param expireAtInMillis time in future that the job expires,
+ * i.e. fail the restore job if it is not in a final {@link RestoreJobStatus} yet
+ * @return builder
+ */
+ public static Builder builder(RestoreJobSecrets secrets, long expireAtInMillis)
+ {
+ return new Builder(secrets, expireAtInMillis);
+ }
+
+ /**
+ * CreateRestoreJobRequest deserializer
+ *
+ * @param jobId job id of restore job
+ * @param jobAgent arbitrary text a job can put, which can be used to identity itself during Http request
+ * @param secrets secrets to be used by restore job to download data
+ * @param importOptions the configured options for SSTable import
+ * @param expireAtInMillis a timestamp in the future when the job is considered expired
+ * @param consistencyLevel consistency level a job should satisfy
+ */
+ @JsonCreator
+ public CreateRestoreJobRequestPayload(@JsonProperty(JOB_ID) UUID jobId,
+ @JsonProperty(JOB_AGENT) String jobAgent,
+ @JsonProperty(JOB_SECRETS) RestoreJobSecrets secrets,
+ @JsonProperty(JOB_IMPORT_OPTIONS) SSTableImportOptions importOptions,
+ @JsonProperty(JOB_EXPIRE_AT) long expireAtInMillis,
+ @JsonProperty(JOB_CONSISTENCY_LEVEL) String consistencyLevel,
+ @JsonProperty(JOB_LOCAL_DATA_CENTER) String localDatacenter)
+ {
+ Preconditions.checkArgument(jobId == null || jobId.version() == 1,
+ "Only time based UUIDs allowed for jobId");
+ Preconditions.checkArgument(expireAtInMillis != 0 && expireAtInMillis > System.currentTimeMillis(),
+ "expireAt cannot be absent or a time in past");
+ Objects.requireNonNull(secrets, "secrets cannot be null");
+ this.jobId = jobId;
+ this.jobAgent = jobAgent;
+ this.secrets = secrets;
+ this.importOptions = importOptions == null
+ ? SSTableImportOptions.defaults()
+ : importOptions;
+ this.expireAtInMillis = expireAtInMillis;
+ this.consistencyConfig = ConsistencyConfig.parseString(consistencyLevel, localDatacenter);
+ }
+
+ private CreateRestoreJobRequestPayload(Builder builder)
+ {
+ this(builder.jobId,
+ builder.jobAgent,
+ builder.secrets,
+ builder.importOptions,
+ builder.expireAtInMillis,
+ nameOrNull(builder.consistencyLevel),
+ builder.localDc);
+ }
+
+ /**
+ * @return job id of restore job
+ */
+ @JsonProperty(JOB_ID)
+ public UUID jobId()
+ {
+ return jobId;
+ }
+
+ /**
+ * @return arbitrary text a job can put, which can be used to identity itself during Http request
+ */
+ @JsonProperty(JOB_AGENT)
+ public String jobAgent()
+ {
+ return jobAgent;
+ }
+
+ /**
+ * @return secrets to be used by restore job to download data
+ */
+ @JsonProperty(JOB_SECRETS)
+ public RestoreJobSecrets secrets()
+ {
+ return secrets;
+ }
+
+ /**
+ * @return the options used for importing SSTables
+ */
+ @JsonProperty(JOB_IMPORT_OPTIONS)
+ public SSTableImportOptions importOptions()
+ {
+ return importOptions;
+ }
+
+ /**
+ * @return timestamp the job expires, i.e. fail the restore job if it is not in a final {@link RestoreJobStatus} yet
+ */
+ @JsonProperty(JOB_EXPIRE_AT)
+ public long expireAtInMillis()
+ {
+ return expireAtInMillis;
+ }
+
+ /**
+ * Convert the expireAtInMillis timestamp as {@link Date}
+ *
+ * @return date
+ */
+ public Date expireAtAsDate()
+ {
+ return new Date(expireAtInMillis);
+ }
+
+ /**
+ * @return the consistency level a job should satisfy
+ */
+ @JsonProperty(JOB_CONSISTENCY_LEVEL)
+ @Nullable
+ public String consistencyLevel()
+ {
+ return nameOrNull(consistencyConfig.consistencyLevel);
+ }
+
+ /**
+ * @return the local data center the job restore data too. The field is only required when consistency level is for local DC, e.g. LOCAL_QUORUM
+ */
+ @JsonProperty(JOB_LOCAL_DATA_CENTER)
+ @Nullable
+ public String localDatacenter()
+ {
+ return consistencyConfig.localDatacenter;
+ }
+
+ public ConsistencyConfig consistencyConfig()
+ {
+ return consistencyConfig;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "CreateRestoreJobRequest{" +
+ JOB_ID + "='" + jobId + "', " +
+ JOB_AGENT + "='" + jobAgent + "', " +
+ JOB_SECRETS + "='" + secrets + "', " +
+ JOB_EXPIRE_AT + "='" + expireAtInMillis + "', " +
+ JOB_CONSISTENCY_LEVEL + "='" + consistencyLevel() + "', " +
+ JOB_LOCAL_DATA_CENTER + "='" + localDatacenter() + "', " +
+ JOB_IMPORT_OPTIONS + "='" + importOptions + "'}";
+ }
+
+ /**
+ * Builds the CreateRestoreJobRequest
+ */
+ public static class Builder implements DataObjectBuilder<Builder, CreateRestoreJobRequestPayload>
+ {
+ private final RestoreJobSecrets secrets;
+ private final SSTableImportOptions importOptions = SSTableImportOptions.defaults();
+ private final long expireAtInMillis;
+
+ private UUID jobId = null;
+ private String jobAgent = null;
+ private ConsistencyLevel consistencyLevel = null;
+ private String localDc = null;
+
+ Builder(RestoreJobSecrets secrets, long expireAtInMillis)
+ {
+ this.secrets = secrets;
+ this.expireAtInMillis = expireAtInMillis;
+ }
+
+ public Builder jobId(UUID jobId)
+ {
+ return update(b -> b.jobId = jobId);
+ }
+
+ public Builder jobAgent(String jobAgent)
+ {
+ return update(b -> b.jobAgent = jobAgent);
+ }
+
+ public Builder updateImportOptions(Consumer<SSTableImportOptions> updater)
+ {
+ return update(b -> updater.accept(b.importOptions));
+ }
+
+ public Builder consistencyLevel(ConsistencyLevel consistencyLevel)
+ {
+ return consistencyLevel(consistencyLevel, null);
+ }
+
+ public Builder consistencyLevel(ConsistencyLevel consistencyLevel, String localDc)
+ {
+ return update(b -> {
+ b.consistencyLevel = consistencyLevel;
+ b.localDc = localDc;
+ });
+ }
+
+ @Override
+ public Builder self()
+ {
+ return this;
+ }
+
+ public CreateRestoreJobRequestPayload build()
+ {
+ Preconditions.checkArgument(consistencyLevel == null
+ || !consistencyLevel.isLocalDcOnly
+ || (localDc != null && !localDc.isEmpty()),
+ "Must specify a non-empty " + JOB_LOCAL_DATA_CENTER + " for consistency level: " + consistencyLevel);
+ return new CreateRestoreJobRequestPayload(this);
+ }
+ }
+
+ private static String nameOrNull(ConsistencyLevel cl)
+ {
+ return cl == null ? null : cl.name();
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CreateSliceRequestPayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CreateSliceRequestPayload.java
new file mode 100644
index 00000000..d0e72c5a
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CreateSliceRequestPayload.java
@@ -0,0 +1,209 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.math.BigInteger;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.utils.Preconditions;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.BUCKET_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_CHECKSUM;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_COMPRESSED_SIZE;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_END_TOKEN;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_START_TOKEN;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_STORAGE_BUCKET;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_STORAGE_KEY;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_UNCOMPRESSED_SIZE;
+
+/**
+ * Request payload for creating a slice.
+ * A slice is a blob object that contains SSTables to be imported into Cassandra.
+ * The data covers a sub-range in the ring.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CreateSliceRequestPayload
+{
+ private final String sliceId;
+ private final int bucketId;
+ private final String bucket;
+ private final String key;
+ private final String checksum;
+ private final BigInteger firstToken; // inclusive
+ private final BigInteger endToken; // inclusive
+ // -- Optional fields - using Objects
+ private final Long uncompressedSize;
+ private final Long compressedSize;
+ // ----
+
+ @JsonCreator
+ public CreateSliceRequestPayload(@JsonProperty(SLICE_ID) String sliceId,
+ @JsonProperty(BUCKET_ID) int bucketId,
+ @JsonProperty(SLICE_STORAGE_BUCKET) String bucket,
+ @JsonProperty(SLICE_STORAGE_KEY) String key,
+ @JsonProperty(SLICE_CHECKSUM) String checksum,
+ @JsonProperty(SLICE_START_TOKEN) BigInteger firstToken,
+ @JsonProperty(SLICE_END_TOKEN) BigInteger endToken,
+ @JsonProperty(SLICE_UNCOMPRESSED_SIZE) Long uncompressedSize,
+ @JsonProperty(SLICE_COMPRESSED_SIZE) Long compressedSize)
+ {
+ Preconditions.checkArgument(sliceId != null
+ && checksum != null
+ && bucket != null
+ && key != null
+ && firstToken != null
+ && endToken != null,
+ "Invalid create slice request payload");
+ Preconditions.checkArgument(bucketId < Short.MAX_VALUE && bucketId >= 0,
+ "Invalid bucketId. Valid range: [0, " + Short.MAX_VALUE + "), " +
+ "but got " + bucketId);
+ this.sliceId = sliceId;
+ this.bucketId = bucketId;
+ this.bucket = bucket;
+ this.key = key;
+ this.checksum = checksum;
+ this.firstToken = firstToken;
+ this.endToken = endToken;
+ this.uncompressedSize = uncompressedSize;
+ this.compressedSize = compressedSize;
+ }
+
+ /**
+ * @return slice id to identify a slice uniquely.
+ */
+ @JsonProperty(SLICE_ID)
+ public String sliceId()
+ {
+ return sliceId;
+ }
+
+ /**
+ * @return bucket id to identify a bucket uniquely.
+ */
+ @JsonProperty(BUCKET_ID)
+ public int bucketId()
+ {
+ return bucketId;
+ }
+
+ public short bucketIdAsShort()
+ {
+ return (short) bucketId;
+ }
+
+ /**
+ * @return upload bucket used for slice upload
+ */
+ @JsonProperty(SLICE_STORAGE_BUCKET)
+ public String bucket()
+ {
+ return bucket;
+ }
+
+ /**
+ * @return upload key used for slice upload
+ */
+ @JsonProperty(SLICE_STORAGE_KEY)
+ public String key()
+ {
+ return key;
+ }
+
+ /**
+ * @return first token of slice; inclusive
+ */
+ @JsonProperty(SLICE_START_TOKEN)
+ public BigInteger firstToken()
+ {
+ return firstToken;
+ }
+
+ /**
+ * @return end token of slice; inclusive
+ */
+ @JsonProperty(SLICE_END_TOKEN)
+ public BigInteger endToken()
+ {
+ return endToken;
+ }
+
+ /**
+ * @return checksum of a slice
+ */
+ @JsonProperty(SLICE_CHECKSUM)
+ public String checksum()
+ {
+ return checksum;
+ }
+
+ /**
+ * @return the size of all files in the slice after unzipping, or null if not defined
+ */
+ @JsonProperty(SLICE_UNCOMPRESSED_SIZE)
+ public Long uncompressedSize()
+ {
+ return uncompressedSize;
+ }
+
+ /**
+ * @return the size of all files in the slice after unzipping, or 0 if not defined
+ */
+ public long uncompressedSizeOrZero()
+ {
+ return uncompressedSize == null ? 0 : uncompressedSize;
+ }
+
+ /**
+ * @return the size of the slice, or null if not defined
+ */
+ @JsonProperty(SLICE_COMPRESSED_SIZE)
+ public Long compressedSize()
+ {
+ return compressedSize;
+ }
+
+ /**
+ * @return the size of the slice, or 0 if not defined
+ */
+ public long compressedSizeOrZero()
+ {
+ return compressedSize == null ? 0 : compressedSize;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "CreateSliceRequest{" + SLICE_ID + "='" + sliceId + "', " +
+ BUCKET_ID + "='" + bucketId + "', " +
+ SLICE_STORAGE_BUCKET + "='" + bucket + "', " +
+ SLICE_STORAGE_KEY + "='" + key + "', " +
+ SLICE_CHECKSUM + "='" + checksum + "', " +
+ SLICE_START_TOKEN + "='" + firstToken + "', " +
+ SLICE_END_TOKEN + "='" + endToken + "', " +
+ SLICE_COMPRESSED_SIZE + "='" + compressedSize + "', " +
+ SLICE_UNCOMPRESSED_SIZE + "='" + uncompressedSize + "'}";
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/Digest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/Digest.java
new file mode 100644
index 00000000..fdd9f3a8
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/Digest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.Map;
+
+/**
+ * Interface that represents a checksum digest
+ */
+public interface Digest
+{
+ /**
+ * @return headers to be used in the HTTP request
+ */
+ Map<String, String> headers();
+
+ /**
+ * @return the string representation of the digest
+ */
+ String value();
+
+ /**
+ * @return the name of the digest's algorithm
+ */
+ String algorithm();
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/MD5Digest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/MD5Digest.java
new file mode 100644
index 00000000..30c9c1e2
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/MD5Digest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+
+import io.netty.handler.codec.http.HttpHeaderNames;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Implements the MD5 checksum digest
+ */
+public class MD5Digest implements Digest
+{
+ private final @NotNull String value;
+
+ /**
+ * Constructs a new MD5Digest with the provided MD5 {@code value}
+ *
+ * @param value the MD5 value
+ */
+ public MD5Digest(@NotNull String value)
+ {
+ this.value = Objects.requireNonNull(value, "value is required");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String value()
+ {
+ return value;
+ }
+
+ @Override
+ public String algorithm()
+ {
+ return "MD5";
+ }
+
+ /**
+ * @return MD5 headers for the Digest
+ */
+ @Override
+ public Map<String, String> headers()
+ {
+ return Collections.singletonMap(HttpHeaderNames.CONTENT_MD5.toString(), value);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/RestoreJobProgressRequestParams.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/RestoreJobProgressRequestParams.java
new file mode 100644
index 00000000..e1efdd3b
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/RestoreJobProgressRequestParams.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.UUID;
+
+import org.apache.cassandra.sidecar.common.data.RestoreJobProgressFetchPolicy;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Parameters to fetch the restore job progress
+ */
+public class RestoreJobProgressRequestParams
+{
+ public final String keyspace;
+ public final String table;
+ public final UUID jobId;
+ public final RestoreJobProgressFetchPolicy fetchPolicy;
+
+ public RestoreJobProgressRequestParams(@NotNull String keyspace,
+ @NotNull String table,
+ @NotNull UUID jobId)
+ {
+ this(keyspace, table, jobId, RestoreJobProgressFetchPolicy.FIRST_FAILED);
+ }
+
+ public RestoreJobProgressRequestParams(@NotNull String keyspace,
+ @NotNull String table,
+ @NotNull UUID jobId,
+ @NotNull RestoreJobProgressFetchPolicy fetchPolicy)
+ {
+ this.keyspace = keyspace;
+ this.table = table;
+ this.jobId = jobId;
+ this.fetchPolicy = fetchPolicy;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/UpdateCdcServiceConfigPayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/UpdateCdcServiceConfigPayload.java
new file mode 100644
index 00000000..731c7520
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/UpdateCdcServiceConfigPayload.java
@@ -0,0 +1,64 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.Map;
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * A class representing a response for the {@link UpdateCdcServiceConfigPayload}.
+ */
+public class UpdateCdcServiceConfigPayload
+{
+ public final Map<String, String> config;
+
+ @JsonCreator
+ public UpdateCdcServiceConfigPayload(@JsonProperty("config") Map<String, String> config)
+ {
+ this.config = config;
+ }
+
+ @JsonProperty("config")
+ public Map<String, String> config()
+ {
+ return config;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ UpdateCdcServiceConfigPayload that = (UpdateCdcServiceConfigPayload) o;
+ return Objects.equals(config, that.config);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(config);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/UpdateRestoreJobRequestPayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/UpdateRestoreJobRequestPayload.java
new file mode 100644
index 00000000..0ae725c7
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/UpdateRestoreJobRequestPayload.java
@@ -0,0 +1,202 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.DataObjectBuilder;
+import org.apache.cassandra.sidecar.common.data.RestoreJobSecrets;
+import org.apache.cassandra.sidecar.common.data.RestoreJobStatus;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_AGENT;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_EXPIRE_AT;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_SECRETS;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_SLICE_COUNT;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_STATUS;
+
+/**
+ * Request payload for updating existing restore job
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UpdateRestoreJobRequestPayload
+{
+ private final String jobAgent;
+ private final RestoreJobSecrets secrets;
+ private final RestoreJobStatus status;
+ private final Long expireAtInMillis; // timestamp; use Long because the field can be absent
+ private final Long sliceCount; // number of slices (s3 objects) produced by the job; use Long as the field can be absent
+
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+ // NOTE: if adding a new field, update isEmpty() and toString()
+ @JsonCreator
+ public UpdateRestoreJobRequestPayload(@JsonProperty(JOB_AGENT) String jobAgent,
+ @JsonProperty(JOB_SECRETS) RestoreJobSecrets secrets,
+ @JsonProperty(JOB_STATUS) RestoreJobStatus status,
+ @JsonProperty(JOB_EXPIRE_AT) Long expireAtInMillis,
+ @JsonProperty(JOB_SLICE_COUNT) Long sliceCount)
+ {
+ this.jobAgent = jobAgent;
+ this.secrets = secrets;
+ this.status = status;
+ this.expireAtInMillis = expireAtInMillis;
+ this.sliceCount = sliceCount;
+ }
+
+ private UpdateRestoreJobRequestPayload(Builder builder)
+ {
+ this.jobAgent = builder.jobAgent;
+ this.secrets = builder.secrets;
+ this.status = builder.status;
+ this.expireAtInMillis = builder.expireAtInMillis;
+ this.sliceCount = builder.sliceCount;
+ }
+
+ /**
+ * @return arbitrary text a job can put, which can be used to identity itself during Http request
+ */
+ @Nullable @JsonProperty(JOB_AGENT)
+ public String jobAgent()
+ {
+ return jobAgent;
+ }
+
+ /**
+ * @return secrets to be used by restore job to download data
+ */
+ @Nullable @JsonProperty(JOB_SECRETS)
+ public RestoreJobSecrets secrets()
+ {
+ return secrets;
+ }
+
+ /**
+ * @return status of the restore job
+ */
+ @Nullable @JsonProperty(JOB_STATUS)
+ public RestoreJobStatus status()
+ {
+ return status;
+ }
+
+ /**
+ * @return timestamp the job expires, i.e. fail the restore job if it is not in a final {@link RestoreJobStatus} yet
+ */
+ @Nullable @JsonProperty(JOB_EXPIRE_AT)
+ public Long expireAtInMillis()
+ {
+ return expireAtInMillis;
+ }
+
+ /**
+ * @return number of total slices (s3 objects) produced. The field is only present when the restore job is managed by Sidecar
+ */
+ @Nullable @JsonProperty(JOB_SLICE_COUNT)
+ public Long sliceCount()
+ {
+ return sliceCount;
+ }
+
+ /**
+ * Convert the expireAtInMillis timestamp as {@link Date}
+ * @return date or null
+ */
+ public Date expireAtAsDate()
+ {
+ return expireAtInMillis == null
+ ? null
+ : new Date(expireAtInMillis);
+ }
+
+ @JsonIgnore
+ public boolean isEmpty()
+ {
+ return jobAgent == null && secrets == null && status == null && expireAtInMillis == null && sliceCount == null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "UpdateRestoreJobRequest{" +
+ JOB_AGENT + "='" + jobAgent + "', " +
+ JOB_STATUS + "='" + status + "', " +
+ JOB_SECRETS + "='" + secrets + "', " +
+ JOB_EXPIRE_AT + "='" + expireAtInMillis + "', " +
+ JOB_SLICE_COUNT + "='" + sliceCount + "'}";
+ }
+
+ /**
+ * Builder for {@link UpdateRestoreJobRequestPayload}
+ */
+ public static class Builder implements DataObjectBuilder<Builder, UpdateRestoreJobRequestPayload>
+ {
+ private String jobAgent;
+ private RestoreJobSecrets secrets;
+ private RestoreJobStatus status;
+ private Long expireAtInMillis; // timestamp; use Long because the field can be absent
+ private Long sliceCount; // number of slices (s3 objects) produced by the job; use Long as the field can be absent
+
+ public Builder withJobAgent(String jobAgent)
+ {
+ return update(b -> b.jobAgent = jobAgent);
+ }
+
+ public Builder withSecrets(RestoreJobSecrets secrets)
+ {
+ return update(b -> b.secrets = secrets);
+ }
+
+ public Builder withStatus(RestoreJobStatus status)
+ {
+ return update(b -> b.status = status);
+ }
+
+ public Builder withExpireAtInMillis(Long expireAtInMillis)
+ {
+ return update(b -> b.expireAtInMillis = expireAtInMillis);
+ }
+
+ public Builder withSliceCount(Long sliceCount)
+ {
+ return update(b -> b.sliceCount = sliceCount);
+ }
+
+ @Override
+ public Builder self()
+ {
+ return this;
+ }
+
+ @Override
+ public UpdateRestoreJobRequestPayload build()
+ {
+ return new UpdateRestoreJobRequestPayload(this);
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/XXHash32Digest.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/XXHash32Digest.java
new file mode 100644
index 00000000..7ed192a0
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/XXHash32Digest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.cassandra.sidecar.common.http.SidecarHttpHeaderNames.CONTENT_XXHASH32;
+import static org.apache.cassandra.sidecar.common.http.SidecarHttpHeaderNames.CONTENT_XXHASH32_SEED;
+
+/**
+ * Implements the XXHash32 Digest
+ */
+public class XXHash32Digest implements Digest
+{
+ private final @NotNull String value;
+ private final @Nullable String seedHex;
+
+ /**
+ * Constructs a new XXHashDigest with the provided XXHash {@code value}
+ *
+ * @param value the xxhash value
+ */
+ public XXHash32Digest(String value)
+ {
+ this(value, null);
+ }
+
+ /**
+ * Constructs a new instance with the provided XXHash {@code value} and the {@code seed} value.
+ *
+ * @param value the xxhash value
+ * @param seed the seed
+ */
+ public XXHash32Digest(String value, int seed)
+ {
+ this(value, Integer.toHexString(seed));
+ }
+
+ /**
+ * Constructs a new XXHashDigest with the provided XXHash {@code value} and the seed value represented as
+ * a hexadecimal string
+ *
+ * @param value the xxhash value
+ * @param seedHex the value of the seed represented as a hexadecimal value
+ */
+ public XXHash32Digest(@NotNull String value, @Nullable String seedHex)
+ {
+ this.value = Objects.requireNonNull(value, "value is required");
+ this.seedHex = seedHex;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String value()
+ {
+ return value;
+ }
+
+ /**
+ * @return the optional seed in hexadecimal format
+ */
+ public @Nullable String seedHex()
+ {
+ return seedHex;
+ }
+
+ @Override
+ public String algorithm()
+ {
+ return "XXHash32";
+ }
+
+ /**
+ * @return XXHash headers for the digest
+ */
+ @Override
+ public Map<String, String> headers()
+ {
+ Map<String, String> headers = new HashMap<>();
+ headers.put(CONTENT_XXHASH32, value);
+ if (seedHex != null)
+ {
+ headers.put(CONTENT_XXHASH32_SEED, seedHex);
+ }
+ return headers;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ConnectedClientStatsResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ConnectedClientStatsResponse.java
new file mode 100644
index 00000000..fb243187
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ConnectedClientStatsResponse.java
@@ -0,0 +1,75 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.response.data.ClientConnectionEntry;
+
+/**
+ * Class response for the ConnectedClientStats API
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ConnectedClientStatsResponse
+{
+
+ @JsonProperty("clientConnections")
+ public List<ClientConnectionEntry> clientConnections()
+ {
+ return clientConnections;
+ }
+
+ @JsonProperty("totalConnectedClients")
+ public long totalConnectedClients()
+ {
+ return totalConnectedClients;
+ }
+
+ @JsonProperty("connectionsByUser")
+ public Map<String, Long> connectionsByUser()
+ {
+ return connectionsByUser;
+ }
+
+ private final List<ClientConnectionEntry> clientConnections;
+ private final long totalConnectedClients;
+ private final Map<String, Long> connectionsByUser;
+
+
+ /**
+ * Constructs a new {@link ConnectedClientStatsResponse}.
+ *
+ * @param clientConnections list of client connection stats
+ * @param totalConnectedClients total count of the connected clients
+ * @param connectionsByUser mapping of user to the no. connections
+ */
+ @JsonCreator
+ public ConnectedClientStatsResponse(@JsonProperty("clientConnections") List<ClientConnectionEntry> clientConnections,
+ @JsonProperty("totalConnectedClients") long totalConnectedClients,
+ @JsonProperty("connectionsByUser") Map<String, Long> connectionsByUser)
+ {
+ this.clientConnections = clientConnections;
+ this.totalConnectedClients = totalConnectedClients;
+ this.connectionsByUser = connectionsByUser;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/GossipInfoResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/GossipInfoResponse.java
new file mode 100644
index 00000000..11891ea3
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/GossipInfoResponse.java
@@ -0,0 +1,323 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.DC;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.DISK_USAGE;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.GENERATION;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.HEARTBEAT;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.HOST_ID;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.INDEX_STATUS;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.INTERNAL_ADDRESS_AND_PORT;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.INTERNAL_IP;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.LOAD;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.NATIVE_ADDRESS_AND_PORT;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.NET_VERSION;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.RACK;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.RELEASE_VERSION;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.REMOVAL_COORDINATOR;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.RPC_ADDRESS;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.RPC_READY;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.SCHEMA;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.SEVERITY;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.SSTABLE_VERSIONS;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.STATUS;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.STATUS_WITH_PORT;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.TOKENS;
+import static org.apache.cassandra.sidecar.common.response.GossipInfoResponse.GossipField.read;
+
+/**
+ * A class representing the response of the cassandra gossip endpoint
+ */
+public class GossipInfoResponse extends HashMap<String, GossipInfoResponse.GossipInfo>
+{
+ /**
+ * Overrides the {@link #get(Object)} method. The gossip info keys usually start with the format
+ * {@code /ip:port}. Some clients may be unaware of the preceding {@code slash}, and lookups can
+ * fail. This method attempts to lookup the value by prepending the {@code slash} at the beginning.
+ * If the lookup fails, it defaults to the original behavior.
+ *
+ * @param key the key whose associated value is to be returned
+ * @return {@link GossipInfo}
+ */
+ @Override
+ public GossipInfo get(Object key)
+ {
+ if (key instanceof String)
+ {
+ String keyAsString = (String) key;
+ if (keyAsString.length() > 0 && keyAsString.charAt(0) != '/')
+ {
+ GossipInfo value = super.get("/" + key);
+ if (value != null)
+ {
+ return value;
+ }
+ }
+ }
+ return super.get(key);
+ }
+
+ /**
+ * Data accessor for reading Gossip states
+ */
+ public static class GossipInfo extends HashMap<String, String>
+ {
+ /**
+ * Converts the key, if it is using the UPPER UNDERSCORE format, into camel case.
+ * Then, put the new key and value.
+ *
+ * @param key the key to convert
+ * @param value the value for the gossip info entry
+ */
+ public void camelizeKeyAndPut(String key, String value)
+ {
+ String lowerCamelCasedKey = GossipField.valueOf(key.toUpperCase()).toLowerCamelCase();
+ super.put(lowerCamelCasedKey, value);
+ }
+
+ @NotNull
+ public String generation()
+ {
+ return read(this, GENERATION);
+ }
+
+ @NotNull
+ public String heartbeat()
+ {
+ return read(this, HEARTBEAT);
+ }
+
+ @Nullable
+ public String status()
+ {
+ return read(this, STATUS);
+ }
+
+ @Nullable
+ public String load()
+ {
+ return read(this, LOAD);
+ }
+
+ /**
+ * @return schema version, uuid string
+ */
+ @Nullable
+ public String schema()
+ {
+ return read(this, SCHEMA);
+ }
+
+ /**
+ * @return datacenter name
+ */
+ @Nullable
+ public String datacenter()
+ {
+ return read(this, DC);
+ }
+
+ /**
+ * @return rack name
+ */
+ @Nullable
+ public String rack()
+ {
+ return read(this, RACK);
+ }
+
+ @Nullable
+ public String releaseVersion()
+ {
+ return read(this, RELEASE_VERSION);
+ }
+
+ @Nullable
+ public String removalCoordinator()
+ {
+ return read(this, REMOVAL_COORDINATOR);
+ }
+
+ @Nullable
+ public String internalIp()
+ {
+ return read(this, INTERNAL_IP);
+ }
+
+ @Nullable
+ public String rpcAddress()
+ {
+ return read(this, RPC_ADDRESS);
+ }
+
+ @Nullable
+ public String severity()
+ {
+ return read(this, SEVERITY);
+ }
+
+ @Nullable
+ public String netVersion()
+ {
+ return read(this, NET_VERSION);
+ }
+
+ @Nullable
+ public String hostId()
+ {
+ return read(this, HOST_ID);
+ }
+
+ @Nullable
+ public String indexStatus()
+ {
+ return read(this, INDEX_STATUS);
+ }
+
+ @Nullable
+ public String tokens()
+ {
+ return read(this, TOKENS);
+ }
+
+ @Nullable
+ public Boolean rpcReady()
+ {
+ String value = read(this, RPC_READY);
+ return value == null ? null : Boolean.valueOf(value);
+ }
+
+ @Nullable
+ public String internalAddressAndPort()
+ {
+ return read(this, INTERNAL_ADDRESS_AND_PORT);
+ }
+
+ @Nullable
+ public String nativeAddressAndPort()
+ {
+ return read(this, NATIVE_ADDRESS_AND_PORT);
+ }
+
+ @Nullable
+ public String statusWithPort()
+ {
+ return read(this, STATUS_WITH_PORT);
+ }
+
+ @Nullable
+ public List<String> sstableVersions()
+ {
+ String value = read(this, SSTABLE_VERSIONS);
+ return value == null ? null : Arrays.asList(value.split(","));
+ }
+
+ @Nullable
+ public String diskUsage()
+ {
+ return read(this, DISK_USAGE);
+ }
+ }
+
+ /**
+ * Declares all fields that gossip info can possibly contain.
+ *
+ * <p>Note: When adding a new field, make sure there is a pairing access method defined in {@link GossipInfo}.
+ */
+ protected enum GossipField
+ {
+ GENERATION,
+ HEARTBEAT,
+
+ // Below are copied from org.apache.cassandra.gms.ApplicationState
+ // Note: that all padding fields are not included.
+ @Deprecated STATUS, //Deprecated and unused in 4.0, stop publishing in 5.0, reclaim in 6.0
+ LOAD,
+ SCHEMA,
+ DC,
+ RACK,
+ RELEASE_VERSION,
+ REMOVAL_COORDINATOR,
+ @Deprecated INTERNAL_IP, //Deprecated and unused in 4.0, stop publishing in 5.0, reclaim in 6.0
+ @Deprecated RPC_ADDRESS, // ^ Same
+ SEVERITY,
+ NET_VERSION,
+ HOST_ID,
+ TOKENS,
+ RPC_READY,
+ // pad to allow adding new states to existing cluster
+ INTERNAL_ADDRESS_AND_PORT, //Replacement for INTERNAL_IP with up to two ports
+ NATIVE_ADDRESS_AND_PORT, //Replacement for RPC_ADDRESS
+ STATUS_WITH_PORT, //Replacement for STATUS
+ /**
+ * The set of sstable versions on this node. This will usually be only the "current" sstable format (the one
+ * with which new sstables are written), but may contain more on newly upgraded nodes before `upgradesstable`
+ * has been run.
+ *
+ * <p>The value (a set of sstable {@code org.apache.cassandra.io.sstable.format.VersionAndType}) is serialized
+ * as a comma-separated list.
+ **/
+ SSTABLE_VERSIONS,
+ DISK_USAGE,
+ INDEX_STATUS,; // Introduced in Cassandra 5.0 for SAI
+
+ static String read(GossipInfo gossipInfo, GossipField field)
+ {
+ return gossipInfo.get(field.toLowerCamelCase());
+ }
+
+ /**
+ * Returns the lower case camel version for the given {@code upperUnderscoreCase}. This method allows us not to
+ * add a dependency to guava for the client, because guava can cause a lot of conflicts when used in libraries.
+ *
+ * @return the lower case camel version for the given {@code upperUnderscoreCase}
+ */
+ String toLowerCamelCase()
+ {
+ String upperUnderscoreCase = name();
+
+ StringBuilder sb = new StringBuilder(upperUnderscoreCase.length());
+ sb.append(Character.toLowerCase(upperUnderscoreCase.charAt(0)));
+
+ int length = upperUnderscoreCase.length();
+ for (int i = 1; i < length; i++)
+ {
+ if (upperUnderscoreCase.charAt(i) == '_' && i + 1 < length)
+ {
+ i++;
+ sb.append(upperUnderscoreCase.charAt(i));
+ }
+ else
+ {
+ sb.append(Character.toLowerCase(upperUnderscoreCase.charAt(i)));
+ }
+ }
+
+ return sb.toString();
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/HealthResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/HealthResponse.java
new file mode 100644
index 00000000..a5dadd8c
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/HealthResponse.java
@@ -0,0 +1,63 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * A class representing a response for a health request
+ * (either {@code SidecarHealthRequest} or {@code CassandraHealthRequest})
+ */
+public class HealthResponse
+{
+ @NotNull
+ private final String status;
+
+ /**
+ * Constructs a {@link HealthResponse} object with the given {@code status}
+ *
+ * @param status the status
+ */
+ public HealthResponse(@NotNull @JsonProperty("status") String status)
+ {
+ this.status = Objects.requireNonNull(status, "status must not be null").toUpperCase();
+ }
+
+ /**
+ * @return the status
+ */
+ @JsonProperty("status")
+ public String status()
+ {
+ return status;
+ }
+
+ /**
+ * @return whether the status is OK
+ */
+ @JsonIgnore
+ public boolean isOk()
+ {
+ return status.equals("OK");
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponse.java
new file mode 100644
index 00000000..6fe812cb
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListCdcSegmentsResponse.java
@@ -0,0 +1,90 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.response.data.CdcSegmentInfo;
+
+/**
+ * A class representing a response for a list CDC Segment request
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ListCdcSegmentsResponse
+{
+ private final String host;
+ private final int port;
+ private final List<CdcSegmentInfo> segmentsInfo;
+
+ @JsonCreator
+ public ListCdcSegmentsResponse(@JsonProperty("host") String host,
+ @JsonProperty("port") int port,
+ @JsonProperty("segmentsInfo") List<CdcSegmentInfo> segmentsInfo)
+ {
+ this.host = host;
+ this.port = port;
+ this.segmentsInfo = segmentsInfo == null ? Collections.emptyList() : Collections.unmodifiableList(segmentsInfo);
+ }
+
+ @JsonProperty("host")
+ public String host()
+ {
+ return host;
+ }
+
+ @JsonProperty("port")
+ public int port()
+ {
+ return port;
+ }
+
+ @JsonProperty("segmentsInfo")
+ public List<CdcSegmentInfo> segmentsInfo()
+ {
+ return segmentsInfo;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ ListCdcSegmentsResponse that = (ListCdcSegmentsResponse) o;
+ return port == that.port && Objects.equals(host, that.host) && Objects.equals(segmentsInfo, that.segmentsInfo);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(host, port, segmentsInfo);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListOperationalJobsResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListOperationalJobsResponse.java
new file mode 100644
index 00000000..1f9f1eaa
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListOperationalJobsResponse.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Response structure of the list operational jobs API
+ */
+public class ListOperationalJobsResponse
+{
+ private final List<OperationalJobResponse> jobs;
+
+ /**
+ * Constructs a {@link ListOperationalJobsResponse} object.
+ */
+ public ListOperationalJobsResponse()
+ {
+ this.jobs = new ArrayList<>();
+ }
+
+ public void addJob(OperationalJobResponse job)
+ {
+ jobs.add(job);
+ }
+
+ @JsonProperty("jobs")
+ public List<OperationalJobResponse> jobs()
+ {
+ return jobs;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListSnapshotFilesResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListSnapshotFilesResponse.java
new file mode 100644
index 00000000..a409c789
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListSnapshotFilesResponse.java
@@ -0,0 +1,152 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import com.google.common.annotations.Beta;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
+
+/**
+ * A class representing a response for the {@code SnapshotRequest}.
+ * This class is expected to evolve and has been mark with the {@link Beta} annotation.
+ */
+@Beta
+public class ListSnapshotFilesResponse
+{
+ private final List<FileInfo> snapshotFilesInfo;
+
+ public ListSnapshotFilesResponse()
+ {
+ this.snapshotFilesInfo = new ArrayList<>();
+ }
+
+ public void addSnapshotFile(FileInfo fileInfo)
+ {
+ snapshotFilesInfo.add(fileInfo);
+ }
+
+ @JsonProperty("snapshotFilesInfo")
+ public List<FileInfo> snapshotFilesInfo()
+ {
+ return snapshotFilesInfo;
+ }
+
+ /**
+ * Json data model of file attributes
+ */
+ public static class FileInfo
+ {
+ public final long size;
+ public final String host;
+ public final int port;
+ public final int dataDirIndex;
+ public final String snapshotName;
+ public final String keySpaceName;
+ public final String tableName;
+ public final String fileName;
+ private String componentDownloadUrl;
+
+ public FileInfo(@JsonProperty("size") long size,
+ @JsonProperty("host") String host,
+ @JsonProperty("port") int port,
+ @JsonProperty("dataDirIndex") int dataDirIndex,
+ @JsonProperty("snapshotName") String snapshotName,
+ @JsonProperty("keySpaceName") String keySpaceName,
+ @JsonProperty("tableName") String tableName,
+ @JsonProperty("fileName") String fileName)
+ {
+ this.size = size;
+ this.host = host;
+ this.port = port;
+ this.dataDirIndex = dataDirIndex;
+ this.snapshotName = snapshotName;
+ this.keySpaceName = keySpaceName;
+ this.tableName = tableName;
+ this.fileName = fileName;
+ }
+
+ public String componentDownloadUrl()
+ {
+ if (componentDownloadUrl == null)
+ {
+ componentDownloadUrl = ApiEndpointsV1.COMPONENTS_ROUTE
+ .replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keySpaceName)
+ .replaceAll(ApiEndpointsV1.TABLE_PATH_PARAM, tableName)
+ .replaceAll(ApiEndpointsV1.SNAPSHOT_PATH_PARAM, snapshotName)
+ .replaceAll(ApiEndpointsV1.COMPONENT_PATH_PARAM, fileName)
+ + "?dataDirectoryIndex=" + dataDirIndex;
+ }
+ return componentDownloadUrl;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ FileInfo fileInfo = (FileInfo) o;
+ return size == fileInfo.size &&
+ port == fileInfo.port &&
+ dataDirIndex == fileInfo.dataDirIndex &&
+ Objects.equals(host, fileInfo.host) &&
+ Objects.equals(snapshotName, fileInfo.snapshotName) &&
+ Objects.equals(keySpaceName, fileInfo.keySpaceName) &&
+ Objects.equals(tableName, fileInfo.tableName) &&
+ Objects.equals(fileName, fileInfo.fileName);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(size, host, port, dataDirIndex, snapshotName, keySpaceName, tableName, fileName);
+ }
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ ListSnapshotFilesResponse that = (ListSnapshotFilesResponse) o;
+ return Objects.equals(snapshotFilesInfo, that.snapshotFilesInfo);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(snapshotFilesInfo);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/NodeSettings.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/NodeSettings.java
new file mode 100644
index 00000000..d2e26a02
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/NodeSettings.java
@@ -0,0 +1,296 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.net.InetAddress;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.DataObjectBuilder;
+
+/**
+ * Holds information about the specific node settings
+ */
+public class NodeSettings
+{
+ private static final String VERSION = "version";
+
+ @JsonProperty("releaseVersion")
+ private final String releaseVersion;
+ @JsonProperty("partitioner")
+ private final String partitioner;
+ @JsonProperty("datacenter")
+ private final String datacenter;
+ @JsonProperty("rpcAddress")
+ private final InetAddress rpcAddress;
+ @JsonProperty("rpcPort")
+ private final int rpcPort;
+ @JsonProperty("tokens")
+ private final Set<String> tokens;
+ @JsonProperty("sidecar")
+ private final Map<String, String> sidecar;
+
+ /**
+ * Constructs a new {@link NodeSettings}.
+ */
+ public NodeSettings()
+ {
+ this(builder());
+ }
+
+ /**
+ * Constructs a new {@link NodeSettings} from the configured {@link Builder}.
+ *
+ * @param builder the builder used to create this object
+ */
+ protected NodeSettings(Builder builder)
+ {
+ releaseVersion = builder.releaseVersion;
+ partitioner = builder.partitioner;
+ datacenter = builder.datacenter;
+ rpcAddress = builder.rpcAddress;
+ rpcPort = builder.rpcPort;
+ tokens = builder.tokens;
+ sidecar = builder.sidecar;
+ }
+
+ @JsonProperty("releaseVersion")
+ public String releaseVersion()
+ {
+ return releaseVersion;
+ }
+
+ @JsonProperty("partitioner")
+ public String partitioner()
+ {
+ return partitioner;
+ }
+
+ @JsonProperty("sidecar")
+ public Map<String, String> sidecar()
+ {
+ return sidecar;
+ }
+
+ public String sidecarVersion()
+ {
+ return sidecar != null ? sidecar.get(VERSION) : "unknown";
+ }
+
+ @JsonProperty("datacenter")
+ public String datacenter()
+ {
+ return datacenter;
+ }
+
+ @JsonProperty("rpcAddress")
+ public InetAddress rpcAddress()
+ {
+ return rpcAddress;
+ }
+
+ @JsonProperty("rpcPort")
+ public int rpcPort()
+ {
+ return rpcPort;
+ }
+
+ @JsonProperty("tokens")
+ public Set<String> tokens()
+ {
+ return tokens;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object other)
+ {
+ if (this == other)
+ {
+ return true;
+ }
+ if (other == null || this.getClass() != other.getClass())
+ {
+ return false;
+ }
+ NodeSettings that = (NodeSettings) other;
+ return Objects.equals(this.releaseVersion, that.releaseVersion)
+ && Objects.equals(this.partitioner, that.partitioner)
+ && Objects.equals(this.sidecar, that.sidecar)
+ && Objects.equals(this.datacenter, that.datacenter)
+ && Objects.equals(this.rpcAddress, that.rpcAddress)
+ && Objects.equals(this.rpcPort, that.rpcPort)
+ && Objects.equals(this.tokens, that.tokens);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(releaseVersion, partitioner, sidecar, datacenter, rpcAddress, rpcPort, tokens);
+ }
+
+ /**
+ * @return a new NodeSettings builder
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+ /**
+ * {@code NodeSettings} builder static inner class.
+ */
+ public static final class Builder implements DataObjectBuilder<Builder, NodeSettings>
+ {
+ private String releaseVersion;
+ private String partitioner;
+ private String datacenter;
+ private InetAddress rpcAddress;
+ private int rpcPort;
+ private Set<String> tokens;
+ private Map<String, String> sidecar;
+
+ private Builder()
+ {
+ }
+
+ @Override
+ public Builder self()
+ {
+ return this;
+ }
+
+ /**
+ * Sets the {@code releaseVersion} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param releaseVersion the {@code releaseVersion} to set
+ * @return a reference to this Builder
+ */
+ public Builder releaseVersion(String releaseVersion)
+ {
+ return update(b -> b.releaseVersion = releaseVersion);
+ }
+
+ /**
+ * Sets the {@code partitioner} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param partitioner the {@code partitioner} to set
+ * @return a reference to this Builder
+ */
+ public Builder partitioner(String partitioner)
+ {
+ return update(b -> b.partitioner = partitioner);
+ }
+
+ /**
+ * Sets the {@code datacenter} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param datacenter the {@code datacenter} to set
+ * @return a reference to this Builder
+ */
+ public Builder datacenter(String datacenter)
+ {
+ return update(b -> b.datacenter = datacenter);
+ }
+
+ /**
+ * Sets the {@code rpcAddress} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param rpcAddress the {@code rpcAddress} to set
+ * @return a reference to this Builder
+ */
+ public Builder rpcAddress(InetAddress rpcAddress)
+ {
+ return update(b -> b.rpcAddress = rpcAddress);
+ }
+
+ /**
+ * Sets the {@code rpcPort} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param rpcPort the {@code rpcPort} to set
+ * @return a reference to this Builder
+ */
+ public Builder rpcPort(int rpcPort)
+ {
+ return update(b -> b.rpcPort = rpcPort);
+ }
+
+ /**
+ * Sets the {@code tokens} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param tokens the {@code tokens} to set
+ * @return a reference to this Builder
+ */
+ public Builder tokens(Set<String> tokens)
+ {
+ return update(b -> b.tokens = tokens);
+ }
+
+ /**
+ * Sets the {@code sidecar} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param sidecar the {@code sidecar} to set
+ * @return a reference to this Builder
+ */
+ public Builder sidecar(Map<String, String> sidecar)
+ {
+ return update(b -> b.sidecar = sidecar);
+ }
+
+ /**
+ * Sets the {@code sidecarVersion} in the {@code sidecar} map and returns a reference to this Builder
+ * enabling method chaining.
+ *
+ * @param sidecarVersion the {@code sidecarVersion} to set
+ * @return a reference to this Builder
+ */
+ public Builder sidecarVersion(String sidecarVersion)
+ {
+ return update(b -> {
+ if (b.sidecar != null)
+ {
+ b.sidecar.put(VERSION, sidecarVersion);
+ }
+ else
+ {
+ b.sidecar = Collections.singletonMap(VERSION, sidecarVersion);
+ }
+ });
+ }
+
+ /**
+ * Returns a {@code NodeSettings} built from the parameters previously set.
+ *
+ * @return a {@code NodeSettings} built with parameters of this {@code NodeSettings.Builder}
+ */
+ @Override
+ public NodeSettings build()
+ {
+ return new NodeSettings(this);
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/OperationalJobResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/OperationalJobResponse.java
new file mode 100644
index 00000000..271f398a
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/OperationalJobResponse.java
@@ -0,0 +1,89 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.data.OperationalJobStatus;
+
+/**
+ * Response structure of the operational jobs API
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class OperationalJobResponse
+{
+ private final UUID jobId;
+ private final OperationalJobStatus status;
+ private final String operation;
+ private final String reason;
+
+ @JsonCreator
+ public OperationalJobResponse(@JsonProperty("jobId") UUID jobId,
+ @JsonProperty("jobStatus") OperationalJobStatus status,
+ @JsonProperty("operation") String operation,
+ @JsonProperty("reason") String reason)
+ {
+ this.jobId = jobId;
+ this.status = status;
+ this.operation = operation;
+ this.reason = reason;
+ }
+
+ /**
+ * @return job id of operational job
+ */
+ @JsonProperty("jobId")
+ public UUID jobId()
+ {
+ return jobId;
+ }
+
+ /**
+ * @return status of the job
+ */
+ @JsonProperty("jobStatus")
+ public OperationalJobStatus status()
+ {
+ return status;
+ }
+
+ /**
+ * @return operation of the job
+ */
+ @JsonProperty("operation")
+ public String operation()
+ {
+ return operation;
+ }
+
+ /**
+ * @return reason for job failure
+ */
+ @JsonProperty("reason")
+ public String reason()
+ {
+ return reason;
+ }
+
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/RingResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/RingResponse.java
new file mode 100644
index 00000000..16609031
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/RingResponse.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.sidecar.common.response;
+
+import java.math.BigInteger;
+import java.util.Comparator;
+import java.util.PriorityQueue;
+
+import org.apache.cassandra.sidecar.common.response.data.RingEntry;
+
+/**
+ * Json format for ring response. It also sorts the entries on adding.
+ */
+public class RingResponse extends PriorityQueue<RingEntry>
+{
+ // sort by datacenter first and then by token
+ private static final Comparator<RingEntry> DEFAULT_COMPARATOR =
+ Comparator.<RingEntry, String>comparing(RingEntry::datacenter)
+ .thenComparing(e -> new BigInteger(e.token()));
+
+ // used by json deserialization
+ public RingResponse()
+ {
+ this(4);
+ }
+
+ public RingResponse(int capacity)
+ {
+ super(capacity, DEFAULT_COMPARATOR);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SSTableImportResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SSTableImportResponse.java
new file mode 100644
index 00000000..5940c07f
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SSTableImportResponse.java
@@ -0,0 +1,79 @@
+/*
+ * 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.sidecar.common.response;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Represents the response for an SSTable import status
+ */
+public class SSTableImportResponse
+{
+ private final boolean success;
+ private final String uploadId;
+ private final String keyspace;
+ private final String tableName;
+
+ public SSTableImportResponse(@JsonProperty("success") boolean success,
+ @JsonProperty("uploadId") String uploadId,
+ @JsonProperty("keyspace") String keyspace,
+ @JsonProperty("tableName") String tableName)
+ {
+ this.success = success;
+ this.uploadId = uploadId;
+ this.keyspace = keyspace;
+ this.tableName = tableName;
+ }
+
+ /**
+ * @return true if the import was successful, false otherwise
+ */
+ @JsonProperty("success")
+ public boolean success()
+ {
+ return success;
+ }
+
+ /**
+ * @return an identifier for the upload session
+ */
+ @JsonProperty("uploadId")
+ public String uploadId()
+ {
+ return uploadId;
+ }
+
+ /**
+ * @return the name of the Cassandra keyspace
+ */
+ @JsonProperty("keyspace")
+ public String keyspace()
+ {
+ return keyspace;
+ }
+
+ /**
+ * @return the name of the Cassandra table
+ */
+ @JsonProperty("tableName")
+ public String tableName()
+ {
+ return tableName;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SSTableUploadResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SSTableUploadResponse.java
new file mode 100644
index 00000000..d6e779ed
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SSTableUploadResponse.java
@@ -0,0 +1,77 @@
+/*
+ * 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.sidecar.common.response;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * A class representing a response for the {@code SSTableUploadRequest}.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class SSTableUploadResponse
+{
+ private final String uploadId;
+ private final long uploadSizeBytes;
+ private final long serviceTimeMillis;
+
+ /**
+ * Constructs upload response object with given params.
+ * @param uploadId an identifier for the upload
+ * @param uploadSizeBytes size of SSTable component uploaded
+ * @param serviceTimeMillis time taken to complete upload job
+ */
+ @JsonCreator
+ public SSTableUploadResponse(@JsonProperty("uploadId") String uploadId,
+ @JsonProperty("uploadSizeBytes") long uploadSizeBytes,
+ @JsonProperty("serviceTimeMillis") long serviceTimeMillis)
+ {
+ this.uploadId = uploadId;
+ this.uploadSizeBytes = uploadSizeBytes;
+ this.serviceTimeMillis = serviceTimeMillis;
+ }
+
+ /**
+ * @return upload id passed along with upload request.
+ */
+ @JsonProperty("uploadId")
+ public String uploadId()
+ {
+ return uploadId;
+ }
+
+ /**
+ * @return size of uploaded SSTable component.
+ */
+ @JsonProperty("uploadSizeBytes")
+ public long uploadSizeBytes()
+ {
+ return uploadSizeBytes;
+ }
+
+ /**
+ * @return time taken in milliseconds for upload to complete.
+ */
+ @JsonProperty("serviceTimeMillis")
+ public long serviceTimeMillis()
+ {
+ return serviceTimeMillis;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SchemaResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SchemaResponse.java
new file mode 100644
index 00000000..8f51ece8
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/SchemaResponse.java
@@ -0,0 +1,74 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * A class representing a response for the {@code SchemaRequest}.
+ */
+public class SchemaResponse
+{
+ private final String keyspace;
+ private final String schema;
+
+ /**
+ * Constructs a {@link SchemaResponse} object with the given {@code schema}.
+ *
+ * @param schema the schema for all keyspaces
+ */
+ public SchemaResponse(String schema)
+ {
+ this(null, schema);
+ }
+
+ /**
+ * Constructs a {@link SchemaResponse} object with the {@code schema} for the given {@code keyspace}.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param schema the schema for the given {@code keyspace}
+ */
+ public SchemaResponse(@JsonProperty("keyspace") String keyspace,
+ @JsonProperty("schema") String schema)
+ {
+ this.keyspace = keyspace;
+ this.schema = Objects.requireNonNull(schema, "schema must be non-null");
+ }
+
+ /**
+ * @return the name of the Cassandra keyspace
+ */
+ @JsonProperty("keyspace")
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public String keyspace()
+ {
+ return keyspace;
+ }
+
+ /**
+ * @return the string representing the schema for the response
+ */
+ @JsonProperty("schema")
+ public String schema()
+ {
+ return schema;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/StreamStatsResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/StreamStatsResponse.java
new file mode 100644
index 00000000..396374a9
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/StreamStatsResponse.java
@@ -0,0 +1,60 @@
+/*
+ * 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.sidecar.common.response;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.response.data.StreamsProgressStats;
+
+/**
+ * Class response for the StreamStats API
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class StreamStatsResponse
+{
+ private final String mode;
+ private final StreamsProgressStats stats;
+
+ /**
+ * Constructs a new {@link StreamStatsResponse}.
+ *
+ * @param mode list of client connection stats
+ * @param stats stream progress stats for the node
+ */
+ @JsonCreator
+ public StreamStatsResponse(@JsonProperty("operationMode") String mode,
+ @JsonProperty("streamsProgressStats") StreamsProgressStats stats)
+ {
+ this.mode = mode;
+ this.stats = stats;
+ }
+
+ @JsonProperty("operationMode")
+ public String operationMode()
+ {
+ return mode;
+ }
+
+ @JsonProperty("streamsProgressStats")
+ public StreamsProgressStats streamsProgressStats()
+ {
+ return stats;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TableStatsResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TableStatsResponse.java
new file mode 100644
index 00000000..552603a3
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TableStatsResponse.java
@@ -0,0 +1,100 @@
+/*
+ * 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.sidecar.common.response;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Class response for the TableStats API
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class TableStatsResponse
+{
+ private final String keyspace;
+ private final String table;
+ private final long sstableCount;
+ private final long diskSpaceUsedBytes;
+ private final long totalDiskSpaceUsedBytes;
+ private final long snapshotsSizeBytes;
+
+ /**
+ * Constructs a new {@link TableStatsResponse}.
+ *
+ * @param keyspace the keyspace in Cassandra
+ * @param table the table in Cassandra
+ * @param sstableCount total count of the sstables
+ * @param diskSpaceUsedBytes disk space used in MB for the table
+ * @param totalDiskSpaceUsedBytes disk space used in MB for the table
+ * @param snapshotsSizeBytes size on disk in MB for the snapshots of the table
+ */
+ @JsonCreator
+ public TableStatsResponse(@JsonProperty("keyspace") String keyspace,
+ @JsonProperty("table") String table,
+ @JsonProperty("sstableCount") long sstableCount,
+ @JsonProperty("diskSpaceUsedBytes") long diskSpaceUsedBytes,
+ @JsonProperty("totalDiskSpaceUsedBytes") long totalDiskSpaceUsedBytes,
+ @JsonProperty("snapshotsSizeBytes") long snapshotsSizeBytes)
+ {
+ this.keyspace = keyspace;
+ this.table = table;
+ this.sstableCount = sstableCount;
+ this.diskSpaceUsedBytes = diskSpaceUsedBytes;
+ this.totalDiskSpaceUsedBytes = totalDiskSpaceUsedBytes;
+ this.snapshotsSizeBytes = snapshotsSizeBytes;
+ }
+
+ @JsonProperty("keyspace")
+ public String keyspace()
+ {
+ return keyspace;
+ }
+
+ @JsonProperty("table")
+ public String table()
+ {
+ return table;
+ }
+
+ @JsonProperty("sstableCount")
+ public long sstableCount()
+ {
+ return sstableCount;
+ }
+
+ @JsonProperty("diskSpaceUsedBytes")
+ public long diskSpaceUsedBytes()
+ {
+ return diskSpaceUsedBytes;
+ }
+
+ @JsonProperty("totalDiskSpaceUsedBytes")
+ public long totalDiskSpaceUsedBytes()
+ {
+ return totalDiskSpaceUsedBytes;
+ }
+
+ @JsonProperty("snapshotsSizeBytes")
+ public long snapshotsSizeBytes()
+ {
+ return snapshotsSizeBytes;
+ }
+
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TimeSkewResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TimeSkewResponse.java
new file mode 100644
index 00000000..a945c2ed
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TimeSkewResponse.java
@@ -0,0 +1,41 @@
+/*
+ * 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.sidecar.common.response;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Data class to define the json format of time skew response.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class TimeSkewResponse
+{
+ public final long currentTime;
+ public final int allowableSkewInMinutes;
+
+ @JsonCreator
+ public TimeSkewResponse(@JsonProperty("currentTime") long currentTime,
+ @JsonProperty("allowableSkewInMinutes") int allowableSkewInMinutes)
+ {
+ this.currentTime = currentTime;
+ this.allowableSkewInMinutes = allowableSkewInMinutes;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TokenRangeReplicasResponse.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TokenRangeReplicasResponse.java
new file mode 100644
index 00000000..3c79c4ce
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/TokenRangeReplicasResponse.java
@@ -0,0 +1,267 @@
+/*
+ * 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.sidecar.common.response;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.request.TokenRangeReplicasRequest;
+
+/**
+ * Class response for the {@link TokenRangeReplicasRequest}
+ */
+public class TokenRangeReplicasResponse
+{
+ private final List<ReplicaInfo> writeReplicas;
+ private final List<ReplicaInfo> readReplicas;
+
+ private final Map<String, ReplicaMetadata> replicaMetadata;
+
+ /**
+ * Constructs token range replicas response object with given params.
+ *
+ * @param writeReplicas list of write replicas {@link ReplicaInfo} instances breakdown by token range
+ * @param readReplicas list of read replica {@link ReplicaInfo} instances breakdown by token range
+ * @param replicaMetadata mapping replica to it's state and status information
+ */
+ public TokenRangeReplicasResponse(@JsonProperty("writeReplicas") List<ReplicaInfo> writeReplicas,
+ @JsonProperty("readReplicas") List<ReplicaInfo> readReplicas,
+ @JsonProperty("replicaMetadata") Map<String, ReplicaMetadata> replicaMetadata)
+ {
+ this.writeReplicas = writeReplicas;
+ this.readReplicas = readReplicas;
+ this.replicaMetadata = replicaMetadata;
+ }
+
+ /**
+ * @return metadata associated with each replica
+ */
+ @JsonProperty("replicaMetadata")
+ public Map<String, ReplicaMetadata> replicaMetadata()
+ {
+ return replicaMetadata;
+ }
+
+ /**
+ * @return the {@link ReplicaInfo} instances representing write replicas for each token range
+ */
+ @JsonProperty("writeReplicas")
+ public List<ReplicaInfo> writeReplicas()
+ {
+ return writeReplicas;
+ }
+
+ /**
+ * @return the {@link ReplicaInfo} instances representing read replicas for each token range
+ */
+ @JsonProperty("readReplicas")
+ public List<ReplicaInfo> readReplicas()
+ {
+ return readReplicas;
+ }
+
+ /**
+ * Class representing replica instances for a token range grouped by datacenter
+ */
+ public static class ReplicaInfo
+ {
+ // exclusive
+ private final String start;
+ // inclusive
+ private final String end;
+ private final Map<String, List<String>> replicasByDatacenter;
+
+ public ReplicaInfo(@JsonProperty("start") String start,
+ @JsonProperty("end") String end,
+ @JsonProperty("replicas") Map<String, List<String>> replicasByDatacenter)
+ {
+ this.start = start;
+ this.end = end;
+ this.replicasByDatacenter = replicasByDatacenter;
+ }
+
+ /**
+ * @return the start value of the token range, exclusive
+ */
+ @JsonProperty("start")
+ public String start()
+ {
+ return start;
+ }
+
+ /**
+ * @return the end value of the token range, inclusive
+ */
+ @JsonProperty("end")
+ public String end()
+ {
+ return end;
+ }
+
+ /**
+ * @return mapping of datacenter to a list of replicas that map to the token range
+ */
+ @JsonProperty("replicasByDatacenter")
+ public Map<String, List<String>> replicasByDatacenter()
+ {
+ return replicasByDatacenter;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ ReplicaInfo that = (ReplicaInfo) o;
+ return start.equals(that.start)
+ && end.equals(that.end)
+ && replicasByDatacenter.equals(that.replicasByDatacenter);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(start, end, replicasByDatacenter);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "ReplicaInfo{" +
+ "start='" + start + '\'' +
+ ", end='" + end + '\'' +
+ ", replicasByDatacenter=" + replicasByDatacenter +
+ '}';
+ }
+ }
+
+ /**
+ * Class representing metadata associated with replica instances
+ */
+ public static class ReplicaMetadata
+ {
+ private final String state;
+ private final String status;
+ private final String fqdn;
+ private final String address;
+ private final int port;
+ private final String datacenter;
+
+ public ReplicaMetadata(@JsonProperty("state") String state,
+ @JsonProperty("status") String status,
+ @JsonProperty("fqdn") String fqdn,
+ @JsonProperty("address") String address,
+ @JsonProperty("port") int port,
+ @JsonProperty("datacenter") String datacenter)
+ {
+ this.state = state;
+ this.status = status;
+ this.fqdn = fqdn;
+ this.address = address;
+ this.port = port;
+ this.datacenter = datacenter;
+ }
+
+ /**
+ * @return the node state. eg. NORMAL, JOINING, LEAVING, etc.
+ */
+ @JsonProperty("state")
+ public String state()
+ {
+ return state;
+ }
+
+ /**
+ * @return the node status. eg. UP, DOWN
+ */
+ @JsonProperty("status")
+ public String status()
+ {
+ return status;
+ }
+
+ /**
+ * @return FQDN of the node
+ */
+ @JsonProperty("fqdn")
+ public String fqdn()
+ {
+ return fqdn;
+ }
+
+ /**
+ * @return IP address of the node
+ */
+ @JsonProperty("address")
+ public String address()
+ {
+ return address;
+ }
+
+ /**
+ * @return port number of the node as specified by the replica-set returned
+ */
+ @JsonProperty("port")
+ public int port()
+ {
+ return port;
+ }
+
+ /**
+ * @return datacenter address of the node
+ */
+ @JsonProperty("datacenter")
+ public String datacenter()
+ {
+ return datacenter;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "ReplicaMetadata{" +
+ "state='" + state + '\'' +
+ ", status='" + status + '\'' +
+ ", fqdn='" + fqdn + '\'' +
+ ", address='" + address + '\'' +
+ ", port='" + port + '\'' +
+ ", datacenter='" + datacenter + '\'' +
+ '}';
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/CdcSegmentInfo.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/CdcSegmentInfo.java
new file mode 100644
index 00000000..a5ae9874
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/CdcSegmentInfo.java
@@ -0,0 +1,72 @@
+/*
+ * 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.sidecar.common.response.data;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Class representing segment information.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CdcSegmentInfo
+{
+ public final String name;
+ public final long size;
+ public final long idx;
+ public final boolean completed;
+ public final long lastModifiedTimestamp;
+
+ public CdcSegmentInfo(@JsonProperty("name") String name, @JsonProperty("size") long size,
+ @JsonProperty("idx") long idx, @JsonProperty("completed") boolean completed,
+ @JsonProperty("lastModifiedTimestamp") long lastModifiedTimestamp)
+ {
+ this.name = name;
+ this.size = size;
+ this.idx = idx;
+ this.completed = completed;
+ this.lastModifiedTimestamp = lastModifiedTimestamp;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ CdcSegmentInfo that = (CdcSegmentInfo) o;
+ return size == that.size && idx == that.idx && completed == that.completed && lastModifiedTimestamp == that.lastModifiedTimestamp &&
+ Objects.equals(name, that.name);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(name, size, idx, completed, lastModifiedTimestamp);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/ClientConnectionEntry.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/ClientConnectionEntry.java
new file mode 100644
index 00000000..afb4c824
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/ClientConnectionEntry.java
@@ -0,0 +1,166 @@
+/*
+ * 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.sidecar.common.response.data;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Class representing an entry of the Client Connection Stats
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ClientConnectionEntry
+{
+ @JsonProperty("address")
+ public String address()
+ {
+ return address;
+ }
+
+ @JsonProperty("port")
+ public int port()
+ {
+ return port;
+ }
+
+ @JsonProperty("sslEnabled")
+ public Boolean sslEnabled()
+ {
+ return sslEnabled;
+ }
+
+ @JsonProperty("sslCipherSuite")
+ public String sslCipherSuite()
+ {
+ return sslCipherSuite;
+ }
+
+ @JsonProperty("sslProtocol")
+ public String sslProtocol()
+ {
+ return sslProtocol;
+ }
+
+ @JsonProperty("protocolVersion")
+ public String protocolVersion()
+ {
+ return protocolVersion;
+ }
+
+ @JsonProperty("username")
+ public String username()
+ {
+ return username;
+ }
+
+ @JsonProperty("requestCount")
+ public long requestCount()
+ {
+ return requestCount;
+ }
+
+ @JsonProperty("driverName")
+ public String driverName()
+ {
+ return driverName;
+ }
+
+ @JsonProperty("driverVersion")
+ public String driverVersion()
+ {
+ return driverVersion;
+ }
+ @JsonProperty("keyspaceName")
+ public String keyspaceName()
+ {
+ return keyspaceName;
+ }
+
+ @JsonProperty("clientOptions")
+ public Map<String, String> clientOptions()
+ {
+ return clientOptions;
+ }
+
+ @JsonProperty("authenticationMode")
+ public String authenticationMode()
+ {
+ return authenticationMode;
+ }
+
+ @JsonProperty("authenticationMetadata")
+ public Map<String, String> authenticationMetadata()
+ {
+ return authenticationMetadata;
+ }
+
+
+ private final String address;
+ private final int port;
+ private final Boolean sslEnabled;
+ private final String sslCipherSuite;
+ private final String sslProtocol;
+ private final String protocolVersion;
+ private final String username;
+ private final long requestCount;
+ private final String driverName;
+ private final String driverVersion;
+
+ private final Map<String, String> clientOptions;
+ private final String keyspaceName;
+ private final String authenticationMode;
+ private final Map<String, String> authenticationMetadata;
+
+
+ @JsonCreator
+ public ClientConnectionEntry(@NotNull @JsonProperty("address") String address,
+ @NotNull @JsonProperty("port") int port,
+ @NotNull @JsonProperty("sslEnabled") boolean sslEnabled,
+ @JsonProperty("sslCipherSuite") String sslCipherSuite,
+ @JsonProperty("sslProtocol") String sslProtocol,
+ @NotNull @JsonProperty("protocolVersion") String protocolVersion,
+ @NotNull @JsonProperty("username") String username,
+ @NotNull @JsonProperty("requestCount") long requestCount,
+ @NotNull @JsonProperty("driverName") String driverName,
+ @NotNull @JsonProperty("driverVersion") String driverVersion,
+ @JsonProperty("keyspaceName") String keyspaceName,
+ @JsonProperty("clientOptions") Map<String, String> clientOptions,
+ @JsonProperty("authenticationMode") String authMode,
+ @JsonProperty("authenticationMetadata") Map<String, String> authMetadata)
+ {
+ this.address = address;
+ this.port = port;
+ this.sslEnabled = sslEnabled;
+ this.sslCipherSuite = sslCipherSuite;
+ this.sslProtocol = sslProtocol;
+ this.protocolVersion = protocolVersion;
+ this.username = username;
+ this.requestCount = requestCount;
+ this.driverName = driverName;
+ this.driverVersion = driverVersion;
+ this.keyspaceName = keyspaceName;
+ this.clientOptions = clientOptions;
+ this.authenticationMode = authMode;
+ this.authenticationMetadata = authMetadata;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/CreateRestoreJobResponsePayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/CreateRestoreJobResponsePayload.java
new file mode 100644
index 00000000..fec43a4c
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/CreateRestoreJobResponsePayload.java
@@ -0,0 +1,60 @@
+/*
+ * 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.sidecar.common.response.data;
+
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_STATUS;
+
+/**
+ * A class representing a response for the {@link org.apache.cassandra.sidecar.common.request.CreateRestoreJobRequest}.
+ */
+public class CreateRestoreJobResponsePayload
+{
+ private final UUID jobId;
+ private final String status;
+
+ @JsonCreator
+ public CreateRestoreJobResponsePayload(@JsonProperty(JOB_ID) UUID jobId,
+ @JsonProperty(JOB_STATUS) String status)
+ {
+ this.jobId = jobId;
+ this.status = status;
+ }
+
+ /**
+ * @return job id of restore job
+ */
+ @JsonProperty(JOB_ID)
+ public UUID jobId()
+ {
+ return jobId;
+ }
+
+ /**
+ * @return status of the job
+ */
+ @JsonProperty(JOB_STATUS)
+ public String status()
+ {
+ return status;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreJobProgressResponsePayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreJobProgressResponsePayload.java
new file mode 100644
index 00000000..1cc43389
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreJobProgressResponsePayload.java
@@ -0,0 +1,221 @@
+/*
+ * 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.sidecar.common.response.data;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.DataObjectBuilder;
+import org.apache.cassandra.sidecar.common.data.ConsistencyVerificationResult;
+import org.apache.cassandra.sidecar.common.request.RestoreJobProgressRequest;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_PROGRESS_ABORTED_RANGES;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_PROGRESS_FAILED_RANGES;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_PROGRESS_MESSAGE;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_PROGRESS_PENDING_RANGES;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_PROGRESS_STATUS;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_PROGRESS_SUCCEEDED_RANGES;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_PROGRESS_SUMMARY;
+
+/**
+ * A class representing a response for the {@link RestoreJobProgressRequest}.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class RestoreJobProgressResponsePayload
+{
+ private final String message;
+ private final ConsistencyVerificationResult status;
+ private final RestoreJobSummaryResponsePayload summary;
+ // the ranges can be null/absent, if they are not required to be included in the response payload, depending on the fetch policy
+ @Nullable // failed due to unrecoverable exceptions
+ private final List<RestoreRangeJson> failedRanges;
+ @Nullable // aborted due to the job has failed/aborted
+ private final List<RestoreRangeJson> abortedRanges;
+ @Nullable
+ private final List<RestoreRangeJson> pendingRanges;
+ @Nullable
+ private final List<RestoreRangeJson> succeededRanges;
+
+ /**
+ * @return builder to build the {@link RestoreJobProgressResponsePayload}
+ */
+ public static Builder builder()
+ {
+ return new Builder();
+ }
+
+ /**
+ * Constructor for json deserialization
+ */
+ @JsonCreator
+ public RestoreJobProgressResponsePayload(@NotNull @JsonProperty(JOB_PROGRESS_MESSAGE) String message,
+ @NotNull @JsonProperty(JOB_PROGRESS_STATUS) ConsistencyVerificationResult status,
+ @NotNull @JsonProperty(JOB_PROGRESS_SUMMARY) RestoreJobSummaryResponsePayload summary,
+ @Nullable @JsonProperty(JOB_PROGRESS_FAILED_RANGES) List<RestoreRangeJson> failedRanges,
+ @Nullable @JsonProperty(JOB_PROGRESS_ABORTED_RANGES) List<RestoreRangeJson> abortedRanges,
+ @Nullable @JsonProperty(JOB_PROGRESS_PENDING_RANGES) List<RestoreRangeJson> pendingRanges,
+ @Nullable @JsonProperty(JOB_PROGRESS_SUCCEEDED_RANGES) List<RestoreRangeJson> succeededRanges)
+ {
+ this.message = message;
+ this.status = status;
+ this.summary = summary;
+ this.failedRanges = failedRanges;
+ this.abortedRanges = abortedRanges;
+ this.pendingRanges = pendingRanges;
+ this.succeededRanges = succeededRanges;
+ }
+
+ private RestoreJobProgressResponsePayload(Builder builder)
+ {
+ this(builder.message,
+ builder.status,
+ builder.summary,
+ builder.failedRanges,
+ builder.abortedRanges,
+ builder.pendingRanges,
+ builder.succeededRanges);
+ }
+
+ @NotNull
+ @JsonProperty(JOB_PROGRESS_MESSAGE)
+ public String message()
+ {
+ return this.message;
+ }
+
+ @NotNull
+ @JsonProperty(JOB_PROGRESS_STATUS)
+ public ConsistencyVerificationResult status()
+ {
+ return this.status;
+ }
+
+ @NotNull
+ @JsonProperty(JOB_PROGRESS_SUMMARY)
+ public RestoreJobSummaryResponsePayload summary()
+ {
+ return this.summary;
+ }
+
+ @Nullable
+ @JsonProperty(JOB_PROGRESS_FAILED_RANGES)
+ public List<RestoreRangeJson> failedRanges()
+ {
+ return this.failedRanges;
+ }
+
+ @Nullable
+ @JsonProperty(JOB_PROGRESS_ABORTED_RANGES)
+ public List<RestoreRangeJson> abortedRanges()
+ {
+ return this.abortedRanges;
+ }
+
+ @Nullable
+ @JsonProperty(JOB_PROGRESS_PENDING_RANGES)
+ public List<RestoreRangeJson> pendingRanges()
+ {
+ return this.pendingRanges;
+ }
+
+ @Nullable
+ @JsonProperty(JOB_PROGRESS_SUCCEEDED_RANGES)
+ public List<RestoreRangeJson> succeededRanges()
+ {
+ return this.succeededRanges;
+ }
+
+ /**
+ * Builds {@link RestoreJobProgressResponsePayload}
+ */
+ public static class Builder implements DataObjectBuilder<Builder, RestoreJobProgressResponsePayload>
+ {
+ String message;
+ ConsistencyVerificationResult status;
+ RestoreJobSummaryResponsePayload summary;
+ List<RestoreRangeJson> failedRanges = null;
+ List<RestoreRangeJson> abortedRanges = null;
+ List<RestoreRangeJson> pendingRanges = null;
+ List<RestoreRangeJson> succeededRanges = null;
+
+ public Builder withStatus(ConsistencyVerificationResult status)
+ {
+ return update(b -> b.status = status);
+ }
+
+ public Builder withMessage(String message)
+ {
+ return update(b -> b.message = message);
+ }
+
+ public Builder withJobSummary(String createdAt,
+ UUID jobId,
+ String jobAgent,
+ String keyspace,
+ String table,
+ String status)
+ {
+ return update(b -> b.summary = new RestoreJobSummaryResponsePayload(createdAt, jobId, jobAgent, keyspace, table, null, status));
+ }
+
+ public Builder withFailedRanges(List<RestoreRangeJson> failedRanges)
+ {
+ return update(b -> b.failedRanges = copyNullableList(failedRanges));
+ }
+
+ public Builder withAbortedRanges(List<RestoreRangeJson> abortedRanges)
+ {
+ return update(b -> b.abortedRanges = copyNullableList(abortedRanges));
+ }
+
+ public Builder withPendingRanges(List<RestoreRangeJson> pendingRanges)
+ {
+ return update(b -> b.pendingRanges = copyNullableList(pendingRanges));
+ }
+
+ public Builder withSucceededRanges(List<RestoreRangeJson> succeededRanges)
+ {
+ return update(b -> b.succeededRanges = copyNullableList(succeededRanges));
+ }
+
+ private static List<RestoreRangeJson> copyNullableList(List<RestoreRangeJson> list)
+ {
+ return list == null ? null : new ArrayList<>(list);
+ }
+
+ @Override
+ public Builder self()
+ {
+ return this;
+ }
+
+ @Override
+ public RestoreJobProgressResponsePayload build()
+ {
+ return new RestoreJobProgressResponsePayload(self());
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreJobSummaryResponsePayload.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreJobSummaryResponsePayload.java
new file mode 100644
index 00000000..7723e2d6
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreJobSummaryResponsePayload.java
@@ -0,0 +1,109 @@
+/*
+ * 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.sidecar.common.response.data;
+
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.cassandra.sidecar.common.data.RestoreJobSecrets;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_AGENT;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_CREATED_AT;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_KEYSPACE;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_SECRETS;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_STATUS;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_TABLE;
+
+/**
+ * Restore job summary view for client
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class RestoreJobSummaryResponsePayload
+{
+ private final String createdAt;
+ private final UUID jobId;
+ private final String jobAgent;
+ private final String keyspace;
+ private final String table;
+ private final RestoreJobSecrets secrets;
+ private final String status;
+
+ @JsonCreator
+ public RestoreJobSummaryResponsePayload(@JsonProperty(JOB_CREATED_AT) String createdAt,
+ @JsonProperty(JOB_ID) UUID jobId,
+ @JsonProperty(JOB_AGENT) String jobAgent,
+ @JsonProperty(JOB_KEYSPACE) String keyspace,
+ @JsonProperty(JOB_TABLE) String table,
+ @JsonProperty(JOB_SECRETS) RestoreJobSecrets secrets,
+ @JsonProperty(JOB_STATUS) String status)
+ {
+ this.createdAt = createdAt;
+ this.jobId = jobId;
+ this.jobAgent = jobAgent;
+ this.keyspace = keyspace;
+ this.table = table;
+ this.secrets = secrets;
+ this.status = status;
+ }
+
+ @JsonProperty(JOB_CREATED_AT)
+ public String createdAt()
+ {
+ return createdAt;
+ }
+
+ @JsonProperty(JOB_ID)
+ public UUID jobId()
+ {
+ return jobId;
+ }
+
+ @JsonProperty(JOB_AGENT)
+ public String jobAgent()
+ {
+ return jobAgent;
+ }
+
+ @JsonProperty(JOB_KEYSPACE)
+ public String keyspace()
+ {
+ return keyspace;
+ }
+
+ @JsonProperty(JOB_TABLE)
+ public String table()
+ {
+ return table;
+ }
+
+ @JsonProperty(JOB_SECRETS)
+ public RestoreJobSecrets secrets()
+ {
+ return secrets;
+ }
+
+ @JsonProperty(JOB_STATUS)
+ public String status()
+ {
+ return status;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreRangeJson.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreRangeJson.java
new file mode 100644
index 00000000..07bd2c3f
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RestoreRangeJson.java
@@ -0,0 +1,99 @@
+/*
+ * 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.sidecar.common.response.data;
+
+import java.math.BigInteger;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.BUCKET_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_END_TOKEN;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_ID;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_START_TOKEN;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_STORAGE_BUCKET;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.SLICE_STORAGE_KEY;
+
+/**
+ * The minimum data presentation (in json) of a range of data in the restore job. The data structure is client-facing.
+ * A range is fully enclosed in a slice, i.e. range covers the smaller or same amount of data of the enclosing slice.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class RestoreRangeJson
+{
+ private final String sliceId;
+ private final int bucketId;
+ private final String bucket;
+ private final String key;
+ private final BigInteger startToken;
+ private final BigInteger endToken;
+
+ @JsonCreator
+ public RestoreRangeJson(@JsonProperty(SLICE_ID) String sliceId,
+ @JsonProperty(BUCKET_ID) int bucketId,
+ @JsonProperty(SLICE_STORAGE_BUCKET) String bucket,
+ @JsonProperty(SLICE_STORAGE_KEY) String key,
+ @JsonProperty(SLICE_START_TOKEN) BigInteger startToken,
+ @JsonProperty(SLICE_END_TOKEN) BigInteger endToken)
+ {
+ this.sliceId = sliceId;
+ this.bucketId = bucketId;
+ this.bucket = bucket;
+ this.key = key;
+ this.startToken = startToken;
+ this.endToken = endToken;
+ }
+
+ @JsonProperty(SLICE_ID)
+ public String sliceId()
+ {
+ return this.sliceId;
+ }
+
+ @JsonProperty(BUCKET_ID)
+ public int bucketId()
+ {
+ return this.bucketId;
+ }
+
+ @JsonProperty(SLICE_STORAGE_BUCKET)
+ public String bucket()
+ {
+ return this.bucket;
+ }
+
+ @JsonProperty(SLICE_STORAGE_KEY)
+ public String key()
+ {
+ return this.key;
+ }
+
+ @JsonProperty(SLICE_START_TOKEN)
+ public BigInteger startToken()
+ {
+ return this.startToken;
+ }
+
+ @JsonProperty(SLICE_END_TOKEN)
+ public BigInteger endToken()
+ {
+ return this.endToken;
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RingEntry.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RingEntry.java
new file mode 100644
index 00000000..5e1786e3
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/RingEntry.java
@@ -0,0 +1,404 @@
+/*
+ * 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.sidecar.common.response.data;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * A class representing an entry in the Cassandra Ring
+ */
+public class RingEntry
+{
+ private final String datacenter;
+ private final String address;
+ private final int port;
+ private final String rack;
+ private final String status;
+ private final String state;
+ private final String load;
+ private final String owns;
+ private final String token;
+ private final String fqdn;
+ private final String hostId;
+
+ @JsonCreator
+ public RingEntry(
+ @JsonProperty("datacenter") String datacenter,
+ @JsonProperty("address") String address,
+ @JsonProperty("port") int port,
+ @JsonProperty("rack") String rack,
+ @JsonProperty("status") String status,
+ @JsonProperty("state") String state,
+ @JsonProperty("load") String load,
+ @JsonProperty("owns") String owns,
+ @JsonProperty("token") String token,
+ @JsonProperty("fqdn") String fqdn,
+ @JsonProperty("hostId") String hostId)
+ {
+ this.datacenter = datacenter;
+ this.address = address;
+ this.port = port;
+ this.rack = rack;
+ this.status = status;
+ this.state = state;
+ this.load = load;
+ this.owns = owns;
+ this.token = token;
+ this.fqdn = fqdn;
+ this.hostId = hostId;
+ }
+
+ private RingEntry(Builder builder)
+ {
+ datacenter = builder.datacenter;
+ address = builder.address;
+ port = builder.port;
+ rack = builder.rack;
+ status = builder.status;
+ state = builder.state;
+ load = builder.load;
+ owns = builder.owns;
+ token = builder.token;
+ fqdn = builder.fqdn;
+ hostId = builder.hostId;
+ }
+
+ /**
+ * @return data center the node is part of
+ */
+ @JsonProperty("datacenter")
+ public String datacenter()
+ {
+ return datacenter;
+ }
+
+ /**
+ * @return address of a node in cassandra ring
+ */
+ @JsonProperty("address")
+ public String address()
+ {
+ return address;
+ }
+
+ /**
+ * @return port of a node in cassandra ring
+ */
+ @JsonProperty("port")
+ public int port()
+ {
+ return port;
+ }
+
+ /**
+ * @return rack the node is part of
+ */
+ @JsonProperty("rack")
+ public String rack()
+ {
+ return rack;
+ }
+
+ /**
+ * @return status of node
+ */
+ @JsonProperty("status")
+ public String status()
+ {
+ return status;
+ }
+
+ /**
+ * @return state of node in cassandra ring
+ */
+ @JsonProperty("state")
+ public String state()
+ {
+ return state;
+ }
+
+ /**
+ * @return The amount of file system data under the cassandra data directory after excluding all content in the
+ * snapshots subdirectories
+ */
+ @JsonProperty("load")
+ public String load()
+ {
+ return load;
+ }
+
+ /**
+ * @return token range the node owns
+ */
+ @JsonProperty("owns")
+ public String owns()
+ {
+ return owns;
+ }
+
+ /**
+ * @return starting token of the range
+ */
+ @JsonProperty("token")
+ public String token()
+ {
+ return token;
+ }
+
+ /**
+ * @return domain name of the node
+ */
+ @JsonProperty("fqdn")
+ public String fqdn()
+ {
+ return fqdn;
+ }
+
+ /**
+ * @return identifier for the host
+ */
+ @JsonProperty("hostId")
+ public String hostId()
+ {
+ return hostId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "RingEntry{" +
+ "datacenter='" + datacenter + '\'' +
+ ", address='" + address + '\'' +
+ ", port=" + port +
+ ", rack='" + rack + '\'' +
+ ", status='" + status + '\'' +
+ ", state='" + state + '\'' +
+ ", load='" + load + '\'' +
+ ", owns='" + owns + '\'' +
+ ", token='" + token + '\'' +
+ ", fqdn='" + fqdn + '\'' +
+ ", hostId='" + hostId + '\'' +
+ '}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ RingEntry ringEntry = (RingEntry) o;
+ return port == ringEntry.port
+ && Objects.equals(datacenter, ringEntry.datacenter)
+ && Objects.equals(address, ringEntry.address)
+ && Objects.equals(rack, ringEntry.rack)
+ && Objects.equals(status, ringEntry.status)
+ && Objects.equals(state, ringEntry.state)
+ && Objects.equals(load, ringEntry.load)
+ && Objects.equals(owns, ringEntry.owns)
+ && Objects.equals(token, ringEntry.token)
+ && Objects.equals(fqdn, ringEntry.fqdn)
+ && Objects.equals(hostId, ringEntry.hostId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(datacenter, address, port, rack, status, state, load, owns, token, fqdn, hostId);
+ }
+
+ /**
+ * {@code RingEntry} builder static inner class.
+ */
+ public static final class Builder
+ {
+ private String datacenter;
+ private String address;
+ private int port;
+ private String rack;
+ private String status;
+ private String state;
+ private String load;
+ private String owns;
+ private String token;
+ private String fqdn;
+ private String hostId;
+
+ /**
+ * Sets the {@code datacenter} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param datacenter the {@code datacenter} to set
+ * @return a reference to this Builder
+ */
+ public Builder datacenter(String datacenter)
+ {
+ this.datacenter = datacenter;
+ return this;
+ }
+
+ /**
+ * Sets the {@code address} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param address the {@code address} to set
+ * @return a reference to this Builder
+ */
+ public Builder address(String address)
+ {
+ this.address = address;
+ return this;
+ }
+
+ /**
+ * Sets the {@code port} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param port the {@code port} to set
+ * @return a reference to this Builder
+ */
+ public Builder port(int port)
+ {
+ this.port = port;
+ return this;
+ }
+
+ /**
+ * Sets the {@code rack} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param rack the {@code rack} to set
+ * @return a reference to this Builder
+ */
+ public Builder rack(String rack)
+ {
+ this.rack = rack;
+ return this;
+ }
+
+ /**
+ * Sets the {@code status} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param status the {@code status} to set
+ * @return a reference to this Builder
+ */
+ public Builder status(String status)
+ {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * Sets the {@code state} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param state the {@code state} to set
+ * @return a reference to this Builder
+ */
+ public Builder state(String state)
+ {
+ this.state = state;
+ return this;
+ }
+
+ /**
+ * Sets the {@code load} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param load the {@code load} to set
+ * @return a reference to this Builder
+ */
+ public Builder load(String load)
+ {
+ this.load = load;
+ return this;
+ }
+
+ /**
+ * Sets the {@code owns} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param owns the {@code owns} to set
+ * @return a reference to this Builder
+ */
+ public Builder owns(String owns)
+ {
+ this.owns = owns;
+ return this;
+ }
+
+ /**
+ * Sets the {@code token} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param token the {@code token} to set
+ * @return a reference to this Builder
+ */
+ public Builder token(String token)
+ {
+ this.token = token;
+ return this;
+ }
+
+ /**
+ * Sets the {@code fqdn} (fully qualified domain name) and
+ * returns a reference to this Builder enabling method chaining.
+ *
+ * @param fqdn the {@code fqdn} to set
+ * @return a reference to this Builder
+ */
+ public Builder fqdn(String fqdn)
+ {
+ this.fqdn = fqdn;
+ return this;
+ }
+
+ /**
+ * Sets the {@code hostId} and returns a reference to this Builder enabling method chaining.
+ *
+ * @param hostId the {@code hostId} to set
+ * @return a reference to this Builder
+ */
+ public Builder hostId(String hostId)
+ {
+ this.hostId = hostId;
+ return this;
+ }
+
+ /**
+ * Returns a {@code RingEntry} built from the parameters previously set.
+ *
+ * @return a {@code RingEntry} built with parameters of this {@code RingEntry.Builder}
+ */
+ public RingEntry build()
+ {
+ return new RingEntry(this);
+ }
+ }
+}
+
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/StreamsProgressStats.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/StreamsProgressStats.java
new file mode 100644
index 00000000..9b1d990d
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/response/data/StreamsProgressStats.java
@@ -0,0 +1,122 @@
+/*
+ * 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.sidecar.common.response.data;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * A class representing stats summarizing the progress of streamed bytes and files on the node
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class StreamsProgressStats
+{
+ private final long totalFilesToReceive;
+ private final long totalFilesReceived;
+ private final long totalBytesToReceive;
+ private final long totalBytesReceived;
+ private final long totalFilesToSend;
+ private final long totalFilesSent;
+ private final long totalBytesToSend;
+ private final long totalBytesSent;
+
+ @JsonCreator
+ public StreamsProgressStats(@JsonProperty("totalFilesToReceive") long totalFilesToReceive,
+ @JsonProperty("totalFilesReceived") long totalFilesReceived,
+ @JsonProperty("totalBytesToReceive") long totalBytesToReceive,
+ @JsonProperty("totalBytesReceived") long totalBytesReceived,
+ @JsonProperty("totalFilesToSend") long totalFilesToSend,
+ @JsonProperty("totalFilesSent") long totalFilesSent,
+ @JsonProperty("totalBytesToSend") long totalBytesToSend,
+ @JsonProperty("totalBytesSent") long totalBytesSent)
+ {
+ this.totalFilesToReceive = totalFilesToReceive;
+ this.totalFilesReceived = totalFilesReceived;
+ this.totalBytesToReceive = totalBytesToReceive;
+ this.totalBytesReceived = totalBytesReceived;
+ this.totalFilesToSend = totalFilesToSend;
+ this.totalFilesSent = totalFilesSent;
+ this.totalBytesToSend = totalBytesToSend;
+ this.totalBytesSent = totalBytesSent;
+ }
+
+ @JsonProperty("totalFilesToReceive")
+ public long totalFilesToReceive()
+ {
+ return totalFilesToReceive;
+ }
+
+ @JsonProperty("totalFilesReceived")
+ public long totalFilesReceived()
+ {
+ return totalFilesReceived;
+ }
+
+ @JsonProperty("totalBytesToReceive")
+ public long totalBytesToReceive()
+ {
+ return totalBytesToReceive;
+ }
+
+ @JsonProperty("totalBytesReceived")
+ public long totalBytesReceived()
+ {
+ return totalBytesReceived;
+ }
+
+ @JsonProperty("totalFilesToSend")
+ public long totalFilesToSend()
+ {
+ return totalFilesToSend;
+ }
+
+ @JsonProperty("totalFilesSent")
+ public long totalFilesSent()
+ {
+ return totalFilesSent;
+ }
+
+ @JsonProperty("totalBytesToSend")
+ public long totalBytesToSend()
+ {
+ return totalBytesToSend;
+ }
+
+ @JsonProperty("totalBytesSent")
+ public long totalBytesSent()
+ {
+ return totalBytesSent;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "StreamsProgressStats{" +
+ "totalFilesToReceive=" + totalFilesToReceive +
+ ", totalFilesReceived=" + totalFilesReceived +
+ ", totalBytesToReceive=" + totalBytesToReceive +
+ ", totalBytesReceived=" + totalBytesReceived +
+ ", totalFilesToSend=" + totalFilesToSend +
+ ", totalFilesSent=" + totalFilesSent +
+ ", totalBytesToSend=" + totalBytesToSend +
+ ", totalBytesSent=" + totalBytesSent +
+ '}';
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/HttpRange.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/HttpRange.java
new file mode 100644
index 00000000..8a9235a8
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/HttpRange.java
@@ -0,0 +1,195 @@
+/*
+ * 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.sidecar.common.utils;
+
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.cassandra.sidecar.common.exceptions.RangeException;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Accepted Range formats are start-end, start-, -suffix_length
+ * start-end (start = start index of the range, end = end index of the range, both inclusive)
+ * start- (start = start index of the range, end = end of file)
+ * -suffix-length (Requested length from end of file. The length should be positive)
+ */
+public class HttpRange
+{
+ private static final String RANGE_UNIT = "bytes";
+ // matches a. bytes=1-2, b. bytes=1-, c. bytes=-2, d. bytes=-. Need to do another valid for case d.
+ private static final Pattern RANGE_HEADER = Pattern.compile("^" + RANGE_UNIT + "=(\\d*)-(\\d*)$");
+ private static final long BOUND_ABSENT = -1L;
+ private final long start;
+ private final long end;
+ private final long length;
+
+ // An initialized range is always valid; invalid params fail range initialization.
+ private HttpRange(final long start, final long end)
+ {
+ Preconditions.checkArgument(start >= 0,
+ () -> String.format("Range start can not be negative. range=[%s, %s]", start, end));
+ Preconditions.checkArgument(end >= start,
+ () -> String.format("Range does not satisfy boundary requirements. range=[%s, %s]", start, end));
+ this.start = start;
+ this.end = end;
+ long len = end - start + 1; // Assign long max if overflows
+ this.length = len < 0 ? Long.MAX_VALUE : len;
+ }
+
+ /**
+ * Accepted RangeHeader formats are bytes=start-end, bytes=start-, bytes=-suffix_length
+ *
+ * @param header the header string to be parsed
+ * @param fileSize the size of the file
+ * @return the parsed HTTP range header
+ */
+ public static HttpRange parseHeader(final String header, final long fileSize)
+ {
+ if (header == null)
+ {
+ return new HttpRange(0, fileSize - 1);
+ }
+ return HttpRange.parse(header, fileSize);
+ }
+
+ public static HttpRange of(final long start, final long end)
+ {
+ return new HttpRange(start, end);
+ }
+
+ /**
+ * Accepted string formats "bytes=1453-3563", "bytes=-22344", "bytes=5346-"
+ * Sample invalid string formats "bytes=8-3", "bytes=-", "bytes=-0", "bytes=a-b"
+ *
+ * @param fileSize - passed in to convert partial range into absolute range
+ */
+ private static HttpRange parse(@NotNull String rangeHeader, final long fileSize)
+ {
+ Matcher m = RANGE_HEADER.matcher(rangeHeader);
+ if (!m.matches())
+ {
+ throw invalidRangeHeaderException(rangeHeader);
+ }
+
+ long left = parseLong(m.group(1), rangeHeader);
+ long right = parseLong(m.group(2), rangeHeader);
+
+ if (left == BOUND_ABSENT && right == BOUND_ABSENT) // matching "bytes=-"
+ {
+ throw invalidRangeHeaderException(rangeHeader);
+ }
+ else if (left == BOUND_ABSENT) // matching "bytes=-1"
+ {
+ long len = Math.min(right, fileSize); // correct the range if it exceeds file size.
+ return new HttpRange(fileSize - len, fileSize - 1);
+ }
+ else if (right == BOUND_ABSENT) // matching "bytes=1-"
+ {
+ return new HttpRange(left, fileSize - 1);
+ }
+ else
+ {
+ return new HttpRange(left, right);
+ }
+ }
+
+ // return -1 for empty string; return long value otherwise.
+ // throws IllegalArgumentException for invalid value string
+ private static long parseLong(String valStr, String rangeHeader)
+ {
+ if (valStr == null || valStr.isEmpty())
+ {
+ return BOUND_ABSENT;
+ }
+
+ try
+ {
+ return Long.parseLong(valStr);
+ }
+ catch (NumberFormatException e)
+ {
+ throw invalidRangeHeaderException(rangeHeader);
+ }
+ }
+
+ private static IllegalArgumentException invalidRangeHeaderException(String rangeHeader)
+ {
+ return new IllegalArgumentException("Invalid range header: " + rangeHeader + ". " +
+ "Supported Range formats are bytes=<start>-<end>, " +
+ "bytes=<start>-, bytes=-<suffix-length>");
+ }
+
+ public long start()
+ {
+ return this.start;
+ }
+
+ public long end()
+ {
+ return this.end;
+ }
+
+ public long length()
+ {
+ return this.length;
+ }
+
+ public HttpRange intersect(@NotNull final HttpRange range)
+ {
+ long newStart = Math.max(start, range.start());
+ long newEnd = Math.min(end, range.end());
+ if (newStart > newEnd)
+ {
+ throw new RangeException("Range does not overlap");
+ }
+
+ return new HttpRange(newStart, newEnd);
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (!(o instanceof HttpRange))
+ {
+ return false;
+ }
+ HttpRange range = (HttpRange) o;
+ return start == range.start &&
+ end == range.end &&
+ length == range.length;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(start, end, length);
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format("%s=%d-%d", RANGE_UNIT, start, end);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/Preconditions.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/Preconditions.java
new file mode 100644
index 00000000..04a51914
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/Preconditions.java
@@ -0,0 +1,91 @@
+/*
+ * 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.sidecar.common.utils;
+
+import java.util.function.Supplier;
+
+/**
+ * A class to prevent introducing a dependency to guava in common and client
+ */
+public class Preconditions
+{
+ private Preconditions()
+ {
+ }
+
+ /**
+ * Throws an {@link IllegalArgumentException} when the {@code validCondition} is {@code false}, otherwise
+ * no action is taken.
+ *
+ * @param validCondition the condition to evaluate
+ * @param errorMessage the error message to use for the {@link IllegalArgumentException}
+ * @throws IllegalArgumentException when the condition is not valid (i.e. {@code false})
+ */
+ public static void checkArgument(boolean validCondition, String errorMessage)
+ {
+ if (!validCondition)
+ {
+ throw new IllegalArgumentException(errorMessage);
+ }
+ }
+
+ /**
+ * Similar to {@link #checkArgument(boolean, String)}, but allows to evaluate the error message lazily
+ *
+ * @param validCondition the condition to evaluate
+ * @param errorMessageSupplier supplies the error message to use for the {@link IllegalArgumentException}
+ * @throws IllegalArgumentException when the condition is not valid (i.e. {@code false})
+ */
+ public static void checkArgument(boolean validCondition, Supplier<String> errorMessageSupplier)
+ {
+ if (!validCondition)
+ {
+ throw new IllegalArgumentException(errorMessageSupplier.get());
+ }
+ }
+
+ /**
+ * Throws an {@link IllegalStateException} when the {@code validCondition} is {@code false}, otherwise
+ * no action is taken.
+ *
+ * @param validCondition the condition to evaluate
+ * @param errorMessage the error message to use for the {@link IllegalStateException}
+ */
+ public static void checkState(boolean validCondition, String errorMessage)
+ {
+ if (!validCondition)
+ {
+ throw new IllegalStateException(errorMessage);
+ }
+ }
+
+ /**
+ * Similar to {@link #checkState(boolean, String)}, but allows to evaluate the error message lazily
+ *
+ * @param validCondition the condition to evaluate
+ * @param errorMessageSupplier supplies the error message to use for the {@link IllegalStateException}
+ */
+ public static void checkState(boolean validCondition, Supplier<String> errorMessageSupplier)
+ {
+ if (!validCondition)
+ {
+ throw new IllegalStateException(errorMessageSupplier.get());
+ }
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/StringUtils.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/StringUtils.java
new file mode 100644
index 00000000..8c52929b
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/StringUtils.java
@@ -0,0 +1,49 @@
+/*
+ * 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.sidecar.common.utils;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Collection of utility methods for String
+ */
+public class StringUtils
+{
+ private StringUtils()
+ {
+ }
+
+ /**
+ * @param string string value to test
+ * @return true when the string is null or its length is 0; false otherwise
+ */
+ public static boolean isNullOrEmpty(@Nullable String string)
+ {
+ return string == null || string.isEmpty();
+ }
+
+ /**
+ * @param string string value to test
+ * @return true only when the string is not null and its length is not 0; false otherwise
+ */
+ public static boolean isNotEmpty(@Nullable String string)
+ {
+ return !isNullOrEmpty(string);
+ }
+}
diff --git a/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/TimeUtils.java b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/TimeUtils.java
new file mode 100644
index 00000000..a44f1f66
--- /dev/null
+++ b/analytics-sidecar-client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/TimeUtils.java
@@ -0,0 +1,56 @@
+/*
+ * 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.sidecar.common.utils;
+
+import java.time.Duration;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Utility class for manipulating dates, times, and durations
+ */
+public final class TimeUtils
+{
+ /**
+ * Private constructor that prevents unnecessary instantiation
+ *
+ * @throws IllegalStateException when called
+ */
+ private TimeUtils()
+ {
+ throw new IllegalStateException(getClass() + " is a static utility class and shall not be instantiated");
+ }
+
+ /**
+ * Returns a random duration with millisecond precision that is uniformly distributed between two provided durations
+ *
+ * @param minimum minimum possible duration, inclusive
+ * @param maximum maximum possible duration, inclusive
+ *
+ * @return random duration uniformly distributed between two provided durations, with millisecond precision
+ *
+ * @throws IllegalArgumentException if minimum duration is greater than maximum duration
+ */
+ public static Duration randomDuration(Duration minimum, Duration maximum)
+ {
+ Preconditions.checkArgument(minimum.compareTo(maximum) <= 0,
+ "Minimum duration must be less or equal to maximum duration");
+ return Duration.ofMillis(ThreadLocalRandom.current().nextLong(minimum.toMillis(), maximum.toMillis() + 1L));
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/data/RestoreJobProgressFetchPolicyTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/data/RestoreJobProgressFetchPolicyTest.java
new file mode 100644
index 00000000..e8fd3871
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/data/RestoreJobProgressFetchPolicyTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.sidecar.common.data;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobProgressFetchPolicy.ALL;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobProgressFetchPolicy.ALL_FAILED_AND_PENDING;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobProgressFetchPolicy.FIRST_FAILED;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class RestoreJobProgressFetchPolicyTest
+{
+ @Test
+ void testFromString()
+ {
+ assertThat(RestoreJobProgressFetchPolicy.fromString("FIRST_failed"))
+ .isEqualTo(FIRST_FAILED);
+ assertThat(RestoreJobProgressFetchPolicy.fromString("first_failed"))
+ .isEqualTo(FIRST_FAILED);
+ assertThat(RestoreJobProgressFetchPolicy.fromString("FIRST_FAILED"))
+ .isEqualTo(FIRST_FAILED);
+
+ assertThat(RestoreJobProgressFetchPolicy.fromString("all_failed_and_pending"))
+ .isEqualTo(ALL_FAILED_AND_PENDING);
+ assertThat(RestoreJobProgressFetchPolicy.fromString("ALL_FAILED_and_pending"))
+ .isEqualTo(ALL_FAILED_AND_PENDING);
+ assertThat(RestoreJobProgressFetchPolicy.fromString("ALL_FAILED_AND_PENDING"))
+ .isEqualTo(ALL_FAILED_AND_PENDING);
+
+ assertThat(RestoreJobProgressFetchPolicy.fromString("all"))
+ .isEqualTo(ALL);
+ assertThat(RestoreJobProgressFetchPolicy.fromString("ALL"))
+ .isEqualTo(ALL);
+ }
+
+ @Test
+ void testFromStringFails()
+ {
+ assertThatThrownBy(() -> RestoreJobProgressFetchPolicy.fromString("unknown"))
+ .isExactlyInstanceOf(IllegalArgumentException.class)
+ .hasMessage("No RestoreJobProgressFetchPolicy found for unknown");
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/data/RestoreJobStatusTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/data/RestoreJobStatusTest.java
new file mode 100644
index 00000000..e690a158
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/data/RestoreJobStatusTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.sidecar.common.data;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobStatus.ABORTED;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobStatus.CREATED;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobStatus.FAILED;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobStatus.IMPORT_READY;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobStatus.STAGED;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobStatus.STAGE_READY;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobStatus.SUCCEEDED;
+import static org.assertj.core.api.Assertions.assertThat;
+
+class RestoreJobStatusTest
+{
+ @Test
+ void testIsFinal()
+ {
+ assertThat(STAGE_READY.isFinal()).isFalse();
+ assertThat(IMPORT_READY.isFinal()).isFalse();
+ assertThat(STAGED.isFinal()).isFalse();
+ assertThat(CREATED.isFinal()).isFalse();
+ assertThat(FAILED.isFinal()).isTrue();
+ assertThat(ABORTED.isFinal()).isTrue();
+ assertThat(SUCCEEDED.isFinal()).isTrue();
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/http/SidecarHttpResponseStatusTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/http/SidecarHttpResponseStatusTest.java
new file mode 100644
index 00000000..b8dcfbbf
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/http/SidecarHttpResponseStatusTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.sidecar.common.http;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.cassandra.sidecar.common.http.SidecarHttpResponseStatus.CHECKSUM_MISMATCH;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Unit tests for {@link SidecarHttpResponseStatus}
+ */
+class SidecarHttpResponseStatusTest
+{
+
+ @Test
+ void testInvalidChecksum()
+ {
+ assertThat(CHECKSUM_MISMATCH.code()).isEqualTo(455);
+ assertThat(CHECKSUM_MISMATCH.reasonPhrase()).isEqualTo("Checksum Mismatch");
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobRequestPayloadTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobRequestPayloadTest.java
new file mode 100644
index 00000000..2b8b17bb
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/CreateRestoreJobRequestPayloadTest.java
@@ -0,0 +1,230 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.time.Instant;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.UUID;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
+import com.fasterxml.jackson.databind.exc.ValueInstantiationException;
+import org.apache.cassandra.sidecar.common.data.ConsistencyLevel;
+import org.apache.cassandra.sidecar.common.data.RestoreJobSecrets;
+import org.apache.cassandra.sidecar.common.data.SSTableImportOptions;
+import org.apache.cassandra.sidecar.common.request.data.CreateRestoreJobRequestPayload;
+import org.apache.cassandra.sidecar.foundation.RestoreJobSecretsGen;
+
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_CONSISTENCY_LEVEL;
+import static org.apache.cassandra.sidecar.common.data.RestoreJobConstants.JOB_LOCAL_DATA_CENTER;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class CreateRestoreJobRequestPayloadTest
+{
+ private static final ObjectMapper MAPPER = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ @Test
+ void testSerDeser() throws JsonProcessingException
+ {
+ String id = "e870e5dc-d25e-11ed-afa1-0242ac120002";
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+ long expireAt = System.currentTimeMillis() + 10000;
+ Date date = Date.from(Instant.ofEpochMilli(expireAt));
+ CreateRestoreJobRequestPayload req = CreateRestoreJobRequestPayload.builder(secrets, expireAt)
+ .jobId(UUID.fromString(id))
+ .consistencyLevel(ConsistencyLevel.QUORUM)
+ .jobAgent("agent")
+ .build();
+ String json = MAPPER.writeValueAsString(req);
+ assertThat(json).describedAs("Null value fields should be excluded").doesNotContain(JOB_LOCAL_DATA_CENTER)
+ .describedAs("Non-null value fields should be included").contains(JOB_CONSISTENCY_LEVEL)
+ .isEqualTo("{\"jobId\":\"e870e5dc-d25e-11ed-afa1-0242ac120002\"," +
+ "\"jobAgent\":\"agent\"," +
+ "\"secrets\":" + MAPPER.writeValueAsString(secrets) + "," +
+ "\"importOptions\":{" +
+ "\"verifyTokens\":\"true\"," +
+ "\"resetLevel\":\"true\"," +
+ "\"clearRepaired\":\"true\"," +
+ "\"extendedVerify\":\"true\"," +
+ "\"verifySSTables\":\"true\"," +
+ "\"invalidateCaches\":\"true\"," +
+ "\"copyData\":\"false\"}," +
+ "\"expireAt\":" + expireAt + "," +
+ "\"consistencyLevel\":\"QUORUM\"}");
+ CreateRestoreJobRequestPayload test = MAPPER.readValue(json, CreateRestoreJobRequestPayload.class);
+ assertThat(test.jobId()).hasToString(id);
+ assertThat(test.jobAgent()).isEqualTo("agent");
+ assertThat(test.secrets()).isEqualTo(secrets);
+ assertThat(test.expireAtInMillis()).isEqualTo(expireAt);
+ assertThat(test.expireAtAsDate()).isEqualTo(date);
+ assertThat(test.importOptions()).isEqualTo(SSTableImportOptions.defaults());
+ assertThat(test.consistencyLevel()).isEqualTo("QUORUM");
+ assertThat(test.localDatacenter()).isNull();
+ }
+
+ @Test
+ void testReadFromJsonFailsWithUnknownFields() throws JsonProcessingException
+ {
+ String uuid = "e870e5dc-d25e-11ed-afa1-0242ac120002";
+ String json = "{\"jobId\":\"" + uuid + "\"," +
+ "\"jobAgent\":\"Spark Bulk Analytics\"," +
+ "\"status\":\"Completed\"," +
+ "\"expireAt\":" + System.currentTimeMillis() + 1000 +
+ ",\"secrets\":" + MAPPER.writeValueAsString(RestoreJobSecretsGen.genRestoreJobSecrets()) + "}";
+ assertThatThrownBy(() -> MAPPER.readValue(json, CreateRestoreJobRequestPayload.class))
+ .isInstanceOf(UnrecognizedPropertyException.class)
+ .hasMessageContaining("Unrecognized field \"status\"");
+ }
+
+ @Test
+ void testReadFromJsonWithInvalidSecrets()
+ {
+ String json = "{\"secrets\":" +
+ "{\"readCredentials\":{\"accessKeyId\":\"accessKeyId\"}," +
+ "\"writeCredentials\":{\"accessKeyId\":\"accessKeyId\"}}}";
+ assertThatThrownBy(() -> MAPPER.readValue(json, CreateRestoreJobRequestPayload.class))
+ .isInstanceOf(ValueInstantiationException.class)
+ .hasMessageContaining("Cannot construct instance");
+ }
+
+ @Test
+ void testReadFromJsonWithPartialFields() throws JsonProcessingException
+ {
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+ String json = "{\"secrets\":" + MAPPER.writeValueAsString(secrets) +
+ ", \"expireAt\":" + System.currentTimeMillis() + 1000 + "}";
+ CreateRestoreJobRequestPayload req = MAPPER.readValue(json, CreateRestoreJobRequestPayload.class);
+ assertThat(req).isNotNull();
+ assertThat(req.jobId()).isNull();
+ assertThat(req.jobAgent()).isNull();
+ assertThat(req.secrets()).isEqualTo(secrets);
+ assertThat(req.importOptions()).isEqualTo(SSTableImportOptions.defaults());
+ }
+
+ @Test
+ void testReadFromJsonFailsWithoutSecrets()
+ {
+ String json = "{\"expireAt\":" + System.currentTimeMillis() + 1000 + "}";
+ assertThatThrownBy(() -> MAPPER.readValue(json, CreateRestoreJobRequestPayload.class))
+ .isInstanceOf(ValueInstantiationException.class)
+ .hasCauseInstanceOf(NullPointerException.class)
+ .hasMessageContaining("secrets cannot be null");
+ }
+
+ @Test
+ void testReadFromJsonFailsWithOutExpireAt() throws JsonProcessingException
+ {
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+ String json = "{\"secrets\":" + MAPPER.writeValueAsString(secrets) + "}";
+ assertThatThrownBy(() -> MAPPER.readValue(json, CreateRestoreJobRequestPayload.class))
+ .isInstanceOf(ValueInstantiationException.class)
+ .hasCauseInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("expireAt cannot be absent or a time in past");
+ }
+
+ @Test
+ void testReadFromJsonFailWithInvalidExpireAt() throws JsonProcessingException
+ {
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+ String json = "{\"secrets\":" + MAPPER.writeValueAsString(secrets) +
+ ", \"expireAt\":" + (System.currentTimeMillis() - 1000) + "}";
+ assertThatThrownBy(() -> MAPPER.readValue(json, CreateRestoreJobRequestPayload.class))
+ .isInstanceOf(ValueInstantiationException.class)
+ .hasCauseInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("expireAt cannot be absent or a time in past");
+ }
+
+ @Test
+ void testReadFromJsonFailsWithInvalidJobId() throws JsonProcessingException
+ {
+ String json = "{\"jobId\":\"12951f25-d393-4158-9e90-ec0cbe05af21\"," +
+ "\"expireAt\":\"" + System.currentTimeMillis() + 1000 + "\"," +
+ "\"secrets\":" + MAPPER.writeValueAsString(RestoreJobSecretsGen.genRestoreJobSecrets()) + "}";
+ assertThatThrownBy(() -> MAPPER.readValue(json, CreateRestoreJobRequestPayload.class))
+ .isInstanceOf(ValueInstantiationException.class);
+ }
+
+ @Test
+ void testReadFromJsonWithoutConsistencyLevel() throws JsonProcessingException
+ {
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+ long time = System.currentTimeMillis() + 10000;
+ Date date = Date.from(Instant.ofEpochMilli(time));
+ String json = "{\"jobId\":\"e870e5dc-d25e-11ed-afa1-0242ac120002\"," +
+ "\"jobAgent\":\"agent\"," +
+ "\"expireAt\":\"" + time + "\"," +
+ "\"secrets\":" + MAPPER.writeValueAsString(secrets) + "}";
+ CreateRestoreJobRequestPayload test = MAPPER.readValue(json, CreateRestoreJobRequestPayload.class);
+ assertThat(test.jobId()).hasToString("e870e5dc-d25e-11ed-afa1-0242ac120002");
+ assertThat(test.jobAgent()).isEqualTo("agent");
+ assertThat(test.secrets()).isEqualTo(secrets);
+ assertThat(test.expireAtInMillis()).isEqualTo(time);
+ assertThat(test.expireAtAsDate()).isEqualTo(date);
+ assertThat(test.importOptions()).isEqualTo(SSTableImportOptions.defaults());
+ assertThat(test.consistencyLevel()).isNull();
+ }
+
+ @Test
+ void testBuilder()
+ {
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+ CreateRestoreJobRequestPayload req = CreateRestoreJobRequestPayload
+ .builder(secrets, System.currentTimeMillis() + 10000)
+ .jobAgent("agent")
+ .updateImportOptions(options -> {
+ options
+ .resetLevel(false)
+ .clearRepaired(false);
+ })
+ .consistencyLevel(ConsistencyLevel.QUORUM)
+ .build();
+ assertThat(req.secrets()).isEqualTo(secrets);
+ assertThat(req.jobAgent()).isEqualTo("agent");
+ assertThat(req.importOptions()).isEqualTo(SSTableImportOptions.defaults()
+ .resetLevel(false)
+ .clearRepaired(false));
+ assertThat(req.consistencyLevel()).isEqualTo("QUORUM");
+ }
+
+ @Test
+ void testCreateLocalQuorumJobWithoutLocalDCFails()
+ {
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+
+ for (ConsistencyLevel localCL : Arrays.asList(ConsistencyLevel.LOCAL_QUORUM, ConsistencyLevel.LOCAL_ONE))
+ {
+ assertThatThrownBy(() -> CreateRestoreJobRequestPayload.builder(secrets, System.currentTimeMillis())
+ .consistencyLevel(localCL)
+ .build())
+ .hasMessage("Must specify a non-empty localDatacenter for consistency level: " + localCL.name());
+
+ assertThatThrownBy(() -> CreateRestoreJobRequestPayload.builder(secrets, System.currentTimeMillis())
+ .consistencyLevel(localCL, "")
+ .build())
+ .hasMessage("Must specify a non-empty localDatacenter for consistency level: " + localCL.name());
+ }
+
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/CreateSliceRequestPayloadTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/CreateSliceRequestPayloadTest.java
new file mode 100644
index 00000000..d9064e96
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/CreateSliceRequestPayloadTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.math.BigInteger;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.exc.ValueInstantiationException;
+import org.apache.cassandra.sidecar.common.request.data.CreateSliceRequestPayload;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class CreateSliceRequestPayloadTest
+{
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ @Test
+ void testReadFromJsonString() throws JsonProcessingException
+ {
+ int bucketId = 0;
+ String json = "{\"sliceId\":\"TASK_ID-RETRY_COUNT-SEQUENCE\"," +
+ "\"bucketId\": " + bucketId + "," +
+ "\"startToken\":\"1\"," +
+ "\"endToken\":\"10\"," +
+ "\"storageBucket\":\"myBucket\"," +
+ "\"storageKey\":\"/path/to/object\"," +
+ "\"sliceChecksum\":\"12321abc\"}";
+ CreateSliceRequestPayload req = MAPPER.readValue(json, CreateSliceRequestPayload.class);
+ assertThat(req).isNotNull();
+ assertThat(req.sliceId()).isEqualTo("TASK_ID-RETRY_COUNT-SEQUENCE");
+ assertThat(req.bucketId()).isEqualTo(bucketId);
+ assertThat(req.checksum()).isEqualTo("12321abc");
+ assertThat(req.bucket()).isEqualTo("myBucket");
+ assertThat(req.key()).isEqualTo("/path/to/object");
+ assertThat(req.firstToken()).isEqualTo(BigInteger.ONE);
+ assertThat(req.endToken()).isEqualTo(BigInteger.TEN);
+ assertThat(req.compressedSize())
+ .describedAs("size is not present in the json")
+ .isNull();
+ assertThat(req.uncompressedSize())
+ .describedAs("uncompressed size is not present in the json")
+ .isNull();
+ }
+
+ @Test
+ void testReadFromJsonFailsWithMissingFields()
+ {
+ String json = "{\"sliceId\":\"TASK_ID-RETRY_COUNT-SEQUENCE\"}";
+ assertThatThrownBy(() -> MAPPER.readValue(json, CreateSliceRequestPayload.class))
+ .isInstanceOf(ValueInstantiationException.class)
+ .hasCauseInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Invalid create slice request payload");
+ }
+
+ @Test
+ void testSerDeser() throws JsonProcessingException
+ {
+ int bucketId = 2;
+ CreateSliceRequestPayload req = new CreateSliceRequestPayload("id", bucketId, "bucket", "key", "checksum",
+ BigInteger.ONE, BigInteger.TEN, 234L, 123L);
+ String json = MAPPER.writeValueAsString(req);
+ CreateSliceRequestPayload test = MAPPER.readValue(json, CreateSliceRequestPayload.class);
+ assertThat(test.sliceId()).isEqualTo("id");
+ assertThat(test.bucketId()).isEqualTo(bucketId);
+ assertThat(test.bucket()).isEqualTo("bucket");
+ assertThat(test.key()).isEqualTo("key");
+ assertThat(test.checksum()).isEqualTo("checksum");
+ assertThat(test.firstToken()).isEqualTo(BigInteger.ONE);
+ assertThat(test.endToken()).isEqualTo(BigInteger.TEN);
+ assertThat(test.uncompressedSize()).isEqualTo(234L);
+ assertThat(test.compressedSize()).isEqualTo(123L);
+ }
+
+ @Test
+ void testSerDeserWithoutOptionalFields() throws JsonProcessingException
+ {
+ CreateSliceRequestPayload req = new CreateSliceRequestPayload("id", 1, "bucket", "key", "checksum",
+ BigInteger.ONE, BigInteger.TEN, null, null);
+ String json = MAPPER.writeValueAsString(req);
+ assertThat(json).doesNotContain("uncompressedSize")
+ .doesNotContain("compressedSize");
+ CreateSliceRequestPayload test = MAPPER.readValue(json, CreateSliceRequestPayload.class);
+ assertThat(test.compressedSize())
+ .describedAs("size was not set in the original object")
+ .isNull();
+ assertThat(test.uncompressedSize())
+ .describedAs("uncompressed size was not set in the original object")
+ .isNull();
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/RestoreJobProgressRequestTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/RestoreJobProgressRequestTest.java
new file mode 100644
index 00000000..f157a974
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/RestoreJobProgressRequestTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.util.UUID;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.cassandra.sidecar.common.data.RestoreJobProgressFetchPolicy;
+import org.apache.cassandra.sidecar.common.request.data.RestoreJobProgressRequestParams;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class RestoreJobProgressRequestTest
+{
+ @Test
+ void testBuildRequestURI()
+ {
+ UUID jobId = UUID.randomUUID();
+ RestoreJobProgressRequestParams params = new RestoreJobProgressRequestParams("cycling",
+ "rank_by_year_and_name",
+ jobId,
+ RestoreJobProgressFetchPolicy.FIRST_FAILED);
+ String uri = RestoreJobProgressRequest.requestURI(params);
+ assertThat(uri).isEqualTo("/api/v1/keyspaces/cycling/tables/rank_by_year_and_name" +
+ "/restore-jobs/" + jobId +
+ "/progress?fetch-policy=first_failed");
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/UpdateRestoreJobRequestPayloadTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/UpdateRestoreJobRequestPayloadTest.java
new file mode 100644
index 00000000..1d2d746c
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/UpdateRestoreJobRequestPayloadTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.sidecar.common.request;
+
+import java.time.Instant;
+import java.util.Date;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.cassandra.sidecar.common.data.RestoreJobConstants;
+import org.apache.cassandra.sidecar.common.data.RestoreJobSecrets;
+import org.apache.cassandra.sidecar.common.request.data.UpdateRestoreJobRequestPayload;
+import org.apache.cassandra.sidecar.foundation.RestoreJobSecretsGen;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class UpdateRestoreJobRequestPayloadTest
+{
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ void testEmptySecrets() throws JsonProcessingException
+ {
+ String json = "{\"jobAgent\":\"Spark Bulk Analytics\"}";
+ UpdateRestoreJobRequestPayload req = mapper.readValue(json, UpdateRestoreJobRequestPayload.class);
+
+ assertThat(req).isNotNull();
+ assertThat(req.jobAgent()).isEqualTo("Spark Bulk Analytics");
+ assertThat(req.status()).isNull();
+ assertThat(req.expireAtInMillis()).isNull();
+ assertThat(req.expireAtAsDate()).isNull();
+ assertThat(req.sliceCount()).isNull();
+ assertThat(req.secrets()).isNull();
+ }
+
+ @Test
+ void testExpireAt() throws JsonProcessingException
+ {
+ long time = System.currentTimeMillis() + 1000;
+ Date date = Date.from(Instant.ofEpochMilli(time));
+ String json = "{\"expireAt\":" + time + "}";
+ UpdateRestoreJobRequestPayload req = mapper.readValue(json, UpdateRestoreJobRequestPayload.class);
+
+ assertThat(req.expireAtAsDate()).isEqualTo(date);
+ assertThat(req.expireAtInMillis()).isEqualTo(time);
+
+ assertThat(mapper.writeValueAsString(req)).isEqualTo(json);
+ }
+
+ @Test
+ void testSliceCount() throws JsonProcessingException
+ {
+ long sliceCount = 123L;
+ String json = "{\"sliceCount\":" + sliceCount + "}";
+ UpdateRestoreJobRequestPayload req = mapper.readValue(json, UpdateRestoreJobRequestPayload.class);
+ assertThat(req.sliceCount()).isEqualTo(sliceCount);
+
+ assertThat(mapper.writeValueAsString(req)).isEqualTo(json);
+ }
+
+ @Test
+ void testJsonSerializationShouldIgnoreUnwantedFields() throws JsonProcessingException
+ {
+ RestoreJobSecrets secrets = RestoreJobSecretsGen.genRestoreJobSecrets();
+ UpdateRestoreJobRequestPayload payload = new UpdateRestoreJobRequestPayload(null, secrets,
+ null, null, null);
+ String json = mapper.writeValueAsString(payload);
+ assertThat(json).contains(RestoreJobConstants.JOB_SECRETS)
+ .doesNotContain(RestoreJobConstants.JOB_AGENT,
+ RestoreJobConstants.JOB_EXPIRE_AT,
+ RestoreJobConstants.JOB_STATUS,
+ RestoreJobConstants.JOB_SLICE_COUNT)
+ .doesNotContain("empty"); // ignored by @JsonIgnore
+ }
+}
diff --git a/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/data/AbortRestoreJobRequestPayloadTest.java b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/data/AbortRestoreJobRequestPayloadTest.java
new file mode 100644
index 00000000..283cdb9a
--- /dev/null
+++ b/analytics-sidecar-client-common/src/test/java/org/apache/cassandra/sidecar/common/request/data/AbortRestoreJobRequestPayloadTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.sidecar.common.request.data;
+
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.Test;
+
... 11398 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org