skoppu22 commented on code in PR #360:
URL: https://github.com/apache/cassandra-sidecar/pull/360#discussion_r3436977162
##########
server/src/main/java/org/apache/cassandra/sidecar/job/OperationalJobManager.java:
##########
@@ -131,4 +150,26 @@ private void checkConflict(OperationalJob job) throws
OperationalJobConflictExce
throw new OperationalJobConflictException("The same operational
job is already running on Cassandra. operationName='" + job.name() + '\'');
}
}
+
+ /**
+ * For jobs that require cluster-wide coordination, attempts to acquire
the active operation lock
+ * via the coordinator. Throws a conflict if another operation is already
active.
+ *
+ * @param job instance of the job to coordinate
+ * @throws OperationalJobConflictException when the coordinator cannot
activate the operation
+ */
+ private void tryCoordination(OperationalJob job) throws
OperationalJobConflictException
+ {
+ if (job.requiresCoordination())
+ {
+ Preconditions.checkState(coordinator != null,
+ "Job requires coordination but no
OperationalJobCoordinator is configured");
+ boolean activated = coordinator.trySetActive(job.operationType(),
job.jobId());
Review Comment:
I am afraid to merge this PR without calling clearActive. If we delay adding
that in a subsequent PR and if someone enables requiresCoordination() for any
job meanwhile, then no more further operations will be allowed. I would
recommend implementing calling clearActive in the same PR.
--
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]