yifan-c commented on code in PR #139:
URL: https://github.com/apache/cassandra-sidecar/pull/139#discussion_r1844358267
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/http/SidecarHttpHeaderNames.java:
##########
@@ -31,4 +31,9 @@ public final class SidecarHttpHeaderNames
* {@code "cassandra-content-xxhash32-seed"}
*/
public static final String CONTENT_XXHASH32_SEED =
"cassandra-content-xxhash32-seed";
+
+ /**
+ * {@code "cassandra-operations-job-uuid"}
+ */
+ public static final String OPERATIONS_JOB_HEADER_NAME =
"cassandra-operations-jobid";
Review Comment:
the header seems to be duplication since there is `OperationsJobsResponse`
that contains jobId too.
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/OperationsJobsRequest.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.OperationsJobsResponse;
+
+/**
+ * Represents a request to retrieve the status of a async operations job
+ */
+public class OperationsJobsRequest extends JsonRequest<OperationsJobsResponse>
+{
+
+ /**
+ * Constructs a request to retrieve status for a specified operations job
+ */
+ public OperationsJobsRequest(String jobId)
Review Comment:
if a jobId is a uuid, then the input type here should be uuid.
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/response/OperationsJobsResponse.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.JsonProperty;
+import org.apache.cassandra.sidecar.common.utils.OperationsJobResult;
+
+/**
+ * Response structure of the operations jobs API
+ */
+public class OperationsJobsResponse
+{
+ private final UUID jobId;
+ private final OperationsJobResult.OperationsJobStatus status;
+ private final String operation;
+ private final String reason;
Review Comment:
`OperationsJobResult` consists of status and reason. Why flatten here?
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/OperationsJobResult.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.utils;
+
+/**
+ * Holder class for the results of a job execution. Captures the job status
and reason
+ * as a result of performing the downstream operation.
+ */
+public class OperationsJobResult
+{
+ /**
+ * Encapsulates the states of the job lifecycle. All new jobs are in
Pending state.
+ */
+ public enum OperationsJobStatus
+ { Pending, Running, Completed, Failed }
+
+ private OperationsJobStatus status;
+ private String reason;
Review Comment:
`public final` is usually preferred over `private`
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/response/OperationsJobsResponse.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.JsonProperty;
+import org.apache.cassandra.sidecar.common.utils.OperationsJobResult;
+
+/**
+ * Response structure of the operations jobs API
+ */
+public class OperationsJobsResponse
Review Comment:
Add `@JsonIgnoreProperties(ignoreUnknown = true)` for compatibility.
Add `@JsonInclude(JsonInclude.Include.NON_NULL)` if any field is nullable.
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ListOperationsJobsRequest.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.ListOperationsJobsResponse;
+
+/**
+ * Represents a request to retrieve the list of async operations jobs
+ */
+public class ListOperationsJobsRequest extends
JsonRequest<ListOperationsJobsResponse>
Review Comment:
"OperationsJobs" reads unnatural. Should it be "OperationalJobs"?
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/response/ListOperationsJobsResponse.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 java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Response structure of the list operations jobs API
+ */
+public class ListOperationsJobsResponse
+{
+ private final List<OperationsJobsResponse> jobs;
+
+ /**
+ * Constructs a {@link ListOperationsJobsResponse} object.
+ */
+ public ListOperationsJobsResponse()
+ {
+ this.jobs = new ArrayList<>();
+ }
+
+ public void addJob(OperationsJobsResponse job)
+ {
+ jobs.add(job);
+ }
+
+ @JsonProperty("jobs")
+ public List<OperationsJobsResponse> jobs()
+ {
+ return jobs;
+ }
+
+ /**
+ * Structure of the operations job instance within the list operations
jobs API response
+ */
+ public static class OperationsJobsResponse
+ {
+ public final UUID jobId;
Review Comment:
I think the jobId does not necessarily be a `UUID`, since it is produced by
the local instance and queried against the instance only. It can be just an
integer.
But not necessarily to be addressed neither.
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/utils/OperationsJobResult.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.utils;
+
+/**
+ * Holder class for the results of a job execution. Captures the job status
and reason
+ * as a result of performing the downstream operation.
+ */
+public class OperationsJobResult
+{
+ /**
+ * Encapsulates the states of the job lifecycle. All new jobs are in
Pending state.
+ */
+ public enum OperationsJobStatus
+ { Pending, Running, Completed, Failed }
Review Comment:
nit: one line per variant, and `Completed --> Succeeded`
Do we really need to distinguish between `pending` and `running`?
--
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]