bbotella commented on code in PR #272:
URL: https://github.com/apache/cassandra-sidecar/pull/272#discussion_r2478975926
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/ApiEndpointsV1.java:
##########
@@ -143,7 +143,7 @@ public final class ApiEndpointsV1
public static final String NODE_DRAIN_ROUTE = API_V1 + CASSANDRA +
"/operations/drain";
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";
-
+ public static final String COMPACTION_STOP_ROUTE = API_V1 + CASSANDRA +
"/operations/compaction/stop";
Review Comment:
nit: I see that `/operations/` is repeated across some routes. What about
extracting it to a static final?
##########
adapters/adapters-base/src/main/java/org/apache/cassandra/sidecar/adapters/base/CassandraCompactionManagerOperations.java:
##########
@@ -53,4 +53,27 @@ public List<Map<String, String>> getCompactions()
return jmxClient.proxy(CompactionManagerJmxOperations.class,
COMPACTION_MANAGER_OBJ_NAME)
.getCompactions();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void stopCompaction(String compactionId, String compactionType)
+ {
+ CompactionManagerJmxOperations proxy = jmxClient.proxy(
+ CompactionManagerJmxOperations.class,
+ COMPACTION_MANAGER_OBJ_NAME
+ );
+
+ // compactionId takes precedence over type if both are provided
+ if (compactionId != null && !compactionId.trim().isEmpty())
+ {
+ proxy.stopCompactionById(compactionId);
+ }
+ else
+ {
+ // Handler guarantees compactionType is non-null/non-empty
+ proxy.stopCompaction(compactionType);
Review Comment:
Maybe we should add a @NotNull annotation to compactionType?
##########
server/src/main/java/org/apache/cassandra/sidecar/modules/CassandraOperationsModule.java:
##########
@@ -21,37 +21,14 @@
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.ProvidesIntoMap;
import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import
org.apache.cassandra.sidecar.adapters.base.db.schema.ConnectedClientsSchema;
import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
-import org.apache.cassandra.sidecar.common.response.CompactionStatsResponse;
-import
org.apache.cassandra.sidecar.common.response.ConnectedClientStatsResponse;
-import org.apache.cassandra.sidecar.common.response.GossipInfoResponse;
-import
org.apache.cassandra.sidecar.common.response.ListOperationalJobsResponse;
-import org.apache.cassandra.sidecar.common.response.OperationalJobResponse;
-import org.apache.cassandra.sidecar.common.response.RingResponse;
-import org.apache.cassandra.sidecar.common.response.SchemaResponse;
-import org.apache.cassandra.sidecar.common.response.StreamStatsResponse;
-import org.apache.cassandra.sidecar.common.response.TableStatsResponse;
-import org.apache.cassandra.sidecar.common.response.TokenRangeReplicasResponse;
+import org.apache.cassandra.sidecar.common.response.*;
import org.apache.cassandra.sidecar.db.schema.TableSchema;
-import org.apache.cassandra.sidecar.handlers.CompactionStatsHandler;
-import org.apache.cassandra.sidecar.handlers.ConnectedClientStatsHandler;
-import org.apache.cassandra.sidecar.handlers.GossipInfoHandler;
-import org.apache.cassandra.sidecar.handlers.GossipUpdateHandler;
-import org.apache.cassandra.sidecar.handlers.KeyspaceRingHandler;
-import org.apache.cassandra.sidecar.handlers.KeyspaceSchemaHandler;
-import org.apache.cassandra.sidecar.handlers.ListOperationalJobsHandler;
-import org.apache.cassandra.sidecar.handlers.NativeUpdateHandler;
-import org.apache.cassandra.sidecar.handlers.NodeDecommissionHandler;
-import org.apache.cassandra.sidecar.handlers.NodeDrainHandler;
-import org.apache.cassandra.sidecar.handlers.OperationalJobHandler;
-import org.apache.cassandra.sidecar.handlers.RingHandler;
-import org.apache.cassandra.sidecar.handlers.SchemaHandler;
-import org.apache.cassandra.sidecar.handlers.StreamStatsHandler;
-import org.apache.cassandra.sidecar.handlers.TableStatsHandler;
-import org.apache.cassandra.sidecar.handlers.TokenRangeReplicaMapHandler;
+import org.apache.cassandra.sidecar.handlers.*;
Review Comment:
Please revert this. We try to avoid the * imports
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/CompactionStopRequest.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
Review Comment:
Is node decommission the same as compaction stop?
##########
server/src/main/java/org/apache/cassandra/sidecar/modules/CassandraOperationsModule.java:
##########
@@ -109,6 +86,25 @@ VertxRoute
cassandraCompactionStatsRoute(RouteBuilder.Factory factory,
return factory.buildRouteWithHandler(compactionStatsHandler);
}
+ @POST // Note: POST, not PUT, since we're sending data in the body
+ @Path(ApiEndpointsV1.COMPACTION_STOP_ROUTE)
+ @Operation(summary = "Stop compaction operation",
+ description = "Stops a compaction operation on the Cassandra node")
+ @APIResponse(description = "Compaction stop operation completed",
+ responseCode = "200",
+ content = @Content(mediaType = "application/json",
+ schema = @Schema(implementation =
CompactionStopResponse.class)))
Review Comment:
Please add the @APIResponse for the error codes as well
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/response/CompactionStopResponse.java:
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.DataObjectBuilder;
+
+/**
+ * Response class for the Compaction Stop API
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CompactionStopResponse
+{
+ public static final String COMPACTION_TYPE = "compaction_type";
+ public static final String COMPACTION_ID = "compaction_id";
+ public static final String STATUS = "status";
+ public static final String ERROR_CODE = "error_code";
+ public static final String REASON = "reason";
Review Comment:
nit: What about appending `_KEY` to the constant names?
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CompactionStopRequestPayload.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Request payload for stopping compaction operations.
+ *
+ * <p>Valid JSON:</p>
+ * <pre>
+ * { "compaction_type": "COMPACTION", "compaction_id": "abc-123" }
+ * { "compaction_type": "VALIDATION" }
+ * </pre>
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CompactionStopRequestPayload
+{
+ private final String compactionType;
Review Comment:
Should this be an enum instead of a free string?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]