mansikhara commented on code in PR #346:
URL: https://github.com/apache/cassandra-sidecar/pull/346#discussion_r3237889912
##########
server/src/main/java/org/apache/cassandra/sidecar/handlers/restore/UpdateRestoreJobHandler.java:
##########
@@ -117,6 +125,12 @@ protected void handleInternal(RoutingContext context,
}
context.response().setStatusCode(HttpResponseStatus.OK.code()).end();
+ // Fire-and-forget on a worker thread — notifying the restore
system should not
+ // block the event loop or delay the HTTP response.
+ executorPools.service().executeBlocking(() -> {
+ notifyPhaseSignalMaybe(job);
+ return null;
+ });
Review Comment:
Done, thanks!
##########
server/src/main/java/org/apache/cassandra/sidecar/handlers/restore/UpdateRestoreJobHandler.java:
##########
@@ -147,4 +161,38 @@ protected UpdateRestoreJobRequestPayload
extractParamsOrThrow(RoutingContext con
throw wrapHttpException(HttpResponseStatus.BAD_REQUEST, "Invalid
request payload", decodeException);
}
}
+
+ private void notifyPhaseSignalMaybe(RestoreJob job)
+ {
+ if (job.status != RestoreJobStatus.IMPORT_READY && job.status !=
RestoreJobStatus.STAGE_READY)
+ {
+ return;
+ }
+
+ try
+ {
+ // The job returned from update() is sparse (only contains updated
fields).
+ // Re-read the full job from DB to get all required fields
(keyspace, consistency level, etc.).
+ RestoreJob fullJob = restoreJobDatabaseAccessor.find(job.jobId);
+ if (fullJob == null)
+ {
+ logger.warn("Cannot find restore job for phase signal
notification. jobId={}", job.jobId);
+ return;
+ }
+
+ if (fullJob.status == RestoreJobStatus.IMPORT_READY)
+ {
+ restoreJobManagerGroup.updateRestoreJob(fullJob);
+ }
+ else if (fullJob.status == RestoreJobStatus.STAGE_READY)
+ {
+ restoreJobDiscoverer.processJobNow(fullJob);
Review Comment:
done!
--
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]