yifan-c commented on code in PR #234:
URL: https://github.com/apache/cassandra-sidecar/pull/234#discussion_r2181109797
##########
server/src/main/java/org/apache/cassandra/sidecar/restore/RestoreJobDiscoverer.java:
##########
@@ -385,6 +399,41 @@ private void processSidecarManagedJobMaybe(RestoreJob job)
}
}
+ private void initLocalDatacenterMaybe()
+ {
+ if (localDatacenter != null)
+ {
+ return;
+ }
+
+ try
+ {
+ NodeSettings nodeSettings =
instanceMetadataFetcher.callOnFirstAvailableInstance(i ->
i.delegate().nodeSettings());
+ localDatacenter = nodeSettings.datacenter();
+ }
+ catch (CassandraUnavailableException cue)
+ {
+ LOGGER.debug("localDatacenter is not initialized", cue);
+ }
+ }
+
+ private boolean isLocalDatacenterExcluded(RestoreJob job)
+ {
+ if (!job.shouldRestoreToLocalDatacenterOnly)
+ {
+ return false;
+ }
+
+ if (localDatacenter == null)
+ {
+ LOGGER.debug("The restore job should restore only to the local
datacenter, but the local datacetner is undetermined yet; skip this run");
+ return true;
+ }
+
+ // when job should restore to local datacenter only, but the target
datacenter is not the local one
+ return !localDatacenter.equalsIgnoreCase(job.localDatacenter);
Review Comment:
Good catch!
##########
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/data/CreateRestoreJobRequestPayload.java:
##########
@@ -101,6 +105,9 @@ public CreateRestoreJobRequestPayload(@JsonProperty(JOB_ID)
UUID jobId,
: importOptions;
this.expireAtInMillis = expireAtInMillis;
this.consistencyConfig =
ConsistencyConfig.parseString(consistencyLevel, localDatacenter);
+ Preconditions.checkArgument(!localDatacenterOnly ||
StringUtils.isNotEmpty(localDatacenter),
+ "Must specify a non-empty localDatacenter
when restoreToLocalDatacenterOnly is configured to true");
Review Comment:
ok. 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]