sergeyuttsel commented on code in PR #1729:
URL: https://github.com/apache/ignite-3/pull/1729#discussion_r1131487507
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -954,6 +1288,92 @@ public void onError(Throwable e) {
};
}
+ private WatchListener createMetastorageDataNodesListener() {
+ return new WatchListener() {
+ @Override
+ public void onUpdate(WatchEvent evt) {
+ if (!busyLock.enterBusy()) {
+ throw new IgniteInternalException(NODE_STOPPING_ERR, new
NodeStoppingException());
+ }
+
+ try {
+ int zoneId = 0;
+
+ Set<String> newDataNodes = null;
+
+ long scaleUpRevision = 0;
+
+ long scaleDownRevision = 0;
+
+ for (EntryEvent event : evt.entryEvents()) {
+ Entry e = event.newEntry();
+
+ if (startsWith(e.key(), zoneDataNodesKey().bytes())) {
+ zoneId = extractZoneId(e.key());
+
+ byte[] dataNodesBytes = e.value();
+
+ if (dataNodesBytes != null) {
+ newDataNodes =
DistributionZonesUtil.dataNodes(fromBytes(dataNodesBytes));
+ } else {
+ newDataNodes = emptySet();
+ }
+ } else if (startsWith(e.key(),
zoneScaleUpChangeTriggerKey().bytes())) {
+ if (e.value() != null) {
+ scaleUpRevision = bytesToLong(e.value());
+ }
+ } else if (startsWith(e.key(),
zoneScaleDownChangeTriggerKey().bytes())) {
+ if (e.value() != null) {
+ scaleDownRevision = bytesToLong(e.value());
+ }
+ }
+ }
+
+ synchronized (dataNodesMutex) {
+ DataNodes dataNodesMeta = dataNodes.get(zoneId);
+
+ if (dataNodesMeta != null) {
+ dataNodesMeta.nodes(newDataNodes);
+
+ if (scaleUpRevision > 0) {
+ dataNodesMeta.scaleUpRevision(scaleUpRevision);
+ }
+
+ if (scaleDownRevision > 0) {
+
dataNodesMeta.scaleDownRevision(scaleDownRevision);
+ }
+
+ if (scaleUpRevision > 0) {
+ SortedMap<Long, CompletableFuture<Void>>
revisionScaleUpFuts =
+
dataNodes.get(zoneId).revisionScaleUpFutures().headMap(scaleUpRevision, true);
+
+ revisionScaleUpFuts.values().forEach(v ->
v.complete(null));
+
+ revisionScaleUpFuts.clear();
+ }
+
+ if (scaleDownRevision > 0) {
+ SortedMap<Long, CompletableFuture<Void>>
revisionScaleDownFuts =
+
dataNodes.get(zoneId).revisionScaleDownFutures().headMap(scaleDownRevision,
true);
+
+ revisionScaleDownFuts.values().forEach(v ->
v.complete(null));
+
+ revisionScaleDownFuts.clear();
+ }
+ }
+ }
+ } finally {
+ busyLock.leaveBusy();
+ }
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ LOG.warn("Unable to process logical topology event", e);
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]