sergeyuttsel commented on code in PR #1968:
URL: https://github.com/apache/ignite-3/pull/1968#discussion_r1182530556
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -1614,6 +1662,101 @@ CompletableFuture<Void>
saveDataNodesToMetaStorageOnScaleDown(int zoneId, long r
}
}
+ /**
+ * Gets direct id of the distribution zone with {@code zoneName}.
+ *
+ * @param zoneName Name of the distribution zone.
+ * @return Direct id of the distribution zone, or {@code null} if the zone
with the {@code zoneName} has not been found.
+ */
+ public CompletableFuture<Integer> zoneIdAsyncInternal(String zoneName) {
+ if (!busyLock.enterBusy()) {
+ throw new IgniteException(new NodeStoppingException());
+ }
+ try {
+ if (DEFAULT_ZONE_NAME.equals(zoneName)) {
+ return completedFuture(DEFAULT_ZONE_ID);
+ }
+
+ // TODO: IGNITE-16288 directZoneId should use async configuration
API
+ return supplyAsync(() -> inBusyLock(busyLock, () ->
directZoneIdInternal(zoneName)), executor)
+ .thenCompose(zoneId ->
waitZoneIdLocally(zoneId).thenCompose(ignored -> completedFuture(zoneId)));
+ } finally {
+ busyLock.leaveBusy();
+ }
+ }
+
+ @Nullable
+ private Integer directZoneIdInternal(String zoneName) {
+ try {
+ DistributionZoneConfiguration zoneCfg =
directProxy(zonesConfiguration.distributionZones()).get(zoneName);
+
+ if (zoneCfg == null) {
+ return null;
+ } else {
+ return zoneCfg.zoneId().value();
+ }
+ } catch (NoSuchElementException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Internal method for waiting that the zone is created locally.
+ *
+ * @param id Table id.
Review Comment:
Fixed.
--
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]