andresbeckruiz commented on code in PR #339:
URL: https://github.com/apache/cassandra-sidecar/pull/339#discussion_r3262114167


##########
server/src/main/java/org/apache/cassandra/sidecar/db/ActiveClusterOpsDatabaseAccessor.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.db;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import com.datastax.driver.core.BoundStatement;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.apache.cassandra.sidecar.common.server.CQLSessionProvider;
+import org.apache.cassandra.sidecar.db.schema.ActiveClusterOpsSchema;
+import org.apache.cassandra.sidecar.db.schema.SidecarSchema;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.VisibleForTesting;
+
+/**
+ * Database accessor for the {@code active_cluster_ops} table.
+ * Provides mutual exclusion for active operations via lightweight 
transactions (LWT).
+ */
+@Singleton
+public class ActiveClusterOpsDatabaseAccessor extends 
DatabaseAccessor<ActiveClusterOpsSchema>
+{
+    @Inject
+    public ActiveClusterOpsDatabaseAccessor(SidecarSchema sidecarSchema, 
CQLSessionProvider sessionProvider)
+    {
+        this(sidecarSchema.tableSchema(ActiveClusterOpsSchema.class), 
sessionProvider);
+    }
+
+    @VisibleForTesting
+    public ActiveClusterOpsDatabaseAccessor(ActiveClusterOpsSchema schema, 
CQLSessionProvider sessionProvider)
+    {
+        super(schema, sessionProvider);
+    }
+
+    public boolean trySetActiveOperation(String clusterName, String 
operationType, UUID operationId)
+    {
+        BoundStatement statement = 
tableSchema.trySetActive().bind(clusterName, operationType, operationId);
+        statement.setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
+        statement.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL);

Review Comment:
   Added datacenter to schema in 
[55bdd43](https://github.com/apache/cassandra-sidecar/pull/339/commits/55bdd43c84f613c43558ee4a31091a410b3b78dd)



-- 
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]

Reply via email to