arjunashok commented on code in PR #272: URL: https://github.com/apache/cassandra-sidecar/pull/272#discussion_r2539711237
########## 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_KEY = "compaction_type"; + public static final String COMPACTION_ID_KEY = "compaction_id"; + public static final String STATUS_KEY = "status"; + public static final String ERROR_CODE_KEY = "error_code"; Review Comment: Let's evaluate the intended usage of the `error_code` field in determining the values. Based on the current name, it seems to suggest this is a status code (currently returning `200 OK`) The 200 status code would be redundant in this case, as it is implied with the HTTP response code. The other option is to do away with this field since we have a `reason` field to denote an arbitrary string reason when there is an error (or a non-200 response). ########## 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 stop operation + */ +public class CompactionStopRequest extends JsonRequest<OperationalJobResponse> Review Comment: Should this be `extends JsonRequest<CompactionStopResponse>` ########## server/src/main/java/org/apache/cassandra/sidecar/modules/CassandraOperationsModule.java: ########## @@ -112,6 +98,27 @@ 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))) + @APIResponse(responseCode = "500", description = "Internal server error") + @APIResponse(responseCode = "400", description = "Internal server error on getting the ring view") Review Comment: Is this the appropriate description? `400` implies bad request, so it should not state "Internal server error" ########## 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_KEY = "compaction_type"; + public static final String COMPACTION_ID_KEY = "compaction_id"; + public static final String STATUS_KEY = "status"; + public static final String ERROR_CODE_KEY = "error_code"; + public static final String REASON_KEY = "reason"; + + private final String compactionType; Review Comment: This should use the enum for consistency. ########## 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_KEY = "compaction_type"; + public static final String COMPACTION_ID_KEY = "compaction_id"; + public static final String STATUS_KEY = "status"; + public static final String ERROR_CODE_KEY = "error_code"; Review Comment: Also, can `status` be an enum here? Seems like it can be one of 3 or 4 values - `SUBMITTED`, `PENDING` or `FAILED` -- 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]

