pauloricardomg commented on code in PR #339: URL: https://github.com/apache/cassandra-sidecar/pull/339#discussion_r3248479413
########## server/src/main/java/org/apache/cassandra/sidecar/job/storage/StorageProvider.java: ########## @@ -0,0 +1,198 @@ +/* + * 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.job.storage; + +import java.io.Closeable; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.cassandra.sidecar.common.data.OperationalJobStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A provider-agnostic storage abstraction for durable operational job state. + * Each {@code StorageProvider} instance is scoped to a single cluster. The cluster + * identity is configuration, not a per-call parameter. + * <p> + * This interface defines a data access pattern for persisting, modifying, and querying OperationalJobs. + * Higher-level coordination logic, such as clearing the active operation lock when a job reaches + * a terminal state, belongs in the layers that depend on this interface. + */ +public interface StorageProvider extends Closeable +{ + // --- Operational Job Storage --- + + /** + * Persist a new operational job record. + * <p> + * Implementations must provide upsert semantics as a retry safety net: if called again with the + * same job ID (e.g., due to a network timeout where the caller does not know if the first write + * succeeded), the existing record should be overwritten rather than throwing. + * <p> + * Implementations should throw {@link StorageProviderException} on write failure. + * + * @param job the job record to store + */ + void persistJob(OperationalJobRecord job); + + /** + * Find a job by its ID. + * + * @param jobId the job identifier + * @return the job record, or {@code null} if not found + */ + @Nullable + OperationalJobRecord findJob(UUID jobId); + + /** + * Update the status of an existing job. + * <p> + * Implementations should throw {@link StorageProviderException} on write failure. + * + * @param jobId the job identifier + * @param operationType the operation type (e.g. "restart") + * @param status the new status + */ + void updateJobStatus(UUID jobId, String operationType, OperationalJobStatus status); Review Comment: Is there any reason `operationType` is a String and not an enum ? this would be safer. We could have it with the currently supported operations supported by the operational jobs framework (even if they don't currently use the backend). -- 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]

