alievmirza commented on code in PR #1729:
URL: https://github.com/apache/ignite-3/pull/1729#discussion_r1163572626
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -505,6 +543,148 @@ public int getZoneId(String name) {
}
}
+ /**
+ * The method for obtaining the data nodes of the specified zone.
+ * If {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleUp} and
+ * {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleDown} are immediate
then it waits that the data nodes
+ * are up-to-date for the passed topology version.
+ *
+ * <p>If the values of auto adjust scale up and auto adjust scale down are
zero, then on the cluster topology changes
+ * the data nodes for the zone should be updated immediately. Therefore,
this method must return the data nodes which is calculated
+ * based on the topology with passed or greater version. Since the date
nodes value is updated asynchronously, this method waits for
+ * the date nodes to be updated with new nodes in the topology if the
value of auto adjust scale up is 0. And also waits for
+ * the date nodes to be updated with nodes that have left the topology if
the value of auto adjust scale down is 0.
+ * After the zone manager has observed the logical topology change and the
data nodes value is updated according to cluster topology,
+ * then this method completes the returned future with the current value
of data nodes.
+ *
+ * <p>If the value of auto adjust scale up is greater than zero, then it
is not necessary to wait for the data nodes update triggered
+ * by new nodes in cluster topology. Similarly if the value of auto adjust
scale down is greater than zero, then it is not necessary to
+ * wait for the data nodes update triggered by new nodes that have left
the topology in cluster topology.
+ *
+ * <p>The returned future can be completed with {@link
DistributionZoneNotFoundException} and
+ * {@link DistributionZoneWasRemovedException} in case when the
distribution zone was removed during method execution.
+ *
+ * @param zoneId Zone id.
+ * @param topVer Topology version.
+ * @return The data nodes future which will be completed with data nodes
for the zoneId or with exception.
+ */
+ public CompletableFuture<Set<String>> topologyVersionedDataNodes(int
zoneId, long topVer) {
+ CompletableFuture<IgniteBiTuple<Boolean, Boolean>> timerValuesFut =
awaitTopologyVersion(topVer)
+ .thenCompose(ignored -> getImmediateTimers(zoneId));
+
+ return allOf(
+ timerValuesFut.thenCompose(timerValues ->
scaleUpAwaiting(zoneId, timerValues.get1())),
+ timerValuesFut.thenCompose(timerValues ->
scaleDownAwaiting(zoneId, timerValues.get2()))
+ ).thenCompose(ignored -> getDataNodesFuture(zoneId));
+ }
+
+ /**
+ * Waits for DistributionZoneManager waits for observing passed topology
version or greater version
Review Comment:
Waits for DistributionZoneManager waits?
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -505,6 +543,148 @@ public int getZoneId(String name) {
}
}
+ /**
+ * The method for obtaining the data nodes of the specified zone.
+ * If {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleUp} and
+ * {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleDown} are immediate
then it waits that the data nodes
+ * are up-to-date for the passed topology version.
+ *
+ * <p>If the values of auto adjust scale up and auto adjust scale down are
zero, then on the cluster topology changes
+ * the data nodes for the zone should be updated immediately. Therefore,
this method must return the data nodes which is calculated
+ * based on the topology with passed or greater version. Since the date
nodes value is updated asynchronously, this method waits for
+ * the date nodes to be updated with new nodes in the topology if the
value of auto adjust scale up is 0. And also waits for
+ * the date nodes to be updated with nodes that have left the topology if
the value of auto adjust scale down is 0.
+ * After the zone manager has observed the logical topology change and the
data nodes value is updated according to cluster topology,
+ * then this method completes the returned future with the current value
of data nodes.
+ *
+ * <p>If the value of auto adjust scale up is greater than zero, then it
is not necessary to wait for the data nodes update triggered
+ * by new nodes in cluster topology. Similarly if the value of auto adjust
scale down is greater than zero, then it is not necessary to
+ * wait for the data nodes update triggered by new nodes that have left
the topology in cluster topology.
+ *
+ * <p>The returned future can be completed with {@link
DistributionZoneNotFoundException} and
+ * {@link DistributionZoneWasRemovedException} in case when the
distribution zone was removed during method execution.
+ *
+ * @param zoneId Zone id.
+ * @param topVer Topology version.
+ * @return The data nodes future which will be completed with data nodes
for the zoneId or with exception.
+ */
+ public CompletableFuture<Set<String>> topologyVersionedDataNodes(int
zoneId, long topVer) {
+ CompletableFuture<IgniteBiTuple<Boolean, Boolean>> timerValuesFut =
awaitTopologyVersion(topVer)
+ .thenCompose(ignored -> getImmediateTimers(zoneId));
+
+ return allOf(
+ timerValuesFut.thenCompose(timerValues ->
scaleUpAwaiting(zoneId, timerValues.get1())),
+ timerValuesFut.thenCompose(timerValues ->
scaleDownAwaiting(zoneId, timerValues.get2()))
+ ).thenCompose(ignored -> getDataNodesFuture(zoneId));
+ }
+
+ /**
+ * Waits for DistributionZoneManager waits for observing passed topology
version or greater version
+ * in {@link DistributionZoneManager#topologyWatchListener}.
+ *
+ * @param topVer Topology version.
+ * @return Future for chaining.
+ */
+ private CompletableFuture<Void> awaitTopologyVersion(long topVer) {
+ return inBusyLock(busyLock, () -> topVerTracker.waitFor(topVer));
+ }
+
+ /**
+ * Transforms {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleUp}
+ * and {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleDown} values to
boolean values.
+ * True if it equals to zero and false if it greater than zero. Zero means
that data nodes changing must be started immediately.
+ *
+ * <p>The returned future can be completed with {@link
DistributionZoneNotFoundException}
Review Comment:
It's kinda strange that it completes with
`DistributionZoneNotFoundException` in case when the distribution zone was
removed, but not with `DistributionZoneWasRemovedException`
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -168,6 +186,19 @@ public class DistributionZoneManager implements
IgniteComponent {
*/
private final Map<Integer, ZoneState> zonesState;
+ /** The tracker for the last topology version which was observed by
distribution zone manager. */
+ private final PendingComparableValuesTracker<Long> topVerTracker;
+
+ /**
+ * The last meta storage revision on which scale up timer was started.
Review Comment:
formatting
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -168,6 +186,19 @@ public class DistributionZoneManager implements
IgniteComponent {
*/
private final Map<Integer, ZoneState> zonesState;
+ /** The tracker for the last topology version which was observed by
distribution zone manager. */
+ private final PendingComparableValuesTracker<Long> topVerTracker;
+
+ /**
+ * The last meta storage revision on which scale up timer was started.
+ */
+ private volatile long lastScaleUpRevision;
+
+ /**
+ * The last meta storage revision on which scale down timer was started.
Review Comment:
formatting
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -505,6 +543,148 @@ public int getZoneId(String name) {
}
}
+ /**
+ * The method for obtaining the data nodes of the specified zone.
+ * If {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleUp} and
+ * {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleDown} are immediate
then it waits that the data nodes
+ * are up-to-date for the passed topology version.
+ *
+ * <p>If the values of auto adjust scale up and auto adjust scale down are
zero, then on the cluster topology changes
+ * the data nodes for the zone should be updated immediately. Therefore,
this method must return the data nodes which is calculated
+ * based on the topology with passed or greater version. Since the date
nodes value is updated asynchronously, this method waits for
+ * the date nodes to be updated with new nodes in the topology if the
value of auto adjust scale up is 0. And also waits for
Review Comment:
comma before `and`
##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -505,6 +543,148 @@ public int getZoneId(String name) {
}
}
+ /**
+ * The method for obtaining the data nodes of the specified zone.
+ * If {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleUp} and
+ * {@link
DistributionZoneConfigurationSchema#dataNodesAutoAdjustScaleDown} are immediate
then it waits that the data nodes
+ * are up-to-date for the passed topology version.
+ *
+ * <p>If the values of auto adjust scale up and auto adjust scale down are
zero, then on the cluster topology changes
+ * the data nodes for the zone should be updated immediately. Therefore,
this method must return the data nodes which is calculated
+ * based on the topology with passed or greater version. Since the date
nodes value is updated asynchronously, this method waits for
+ * the date nodes to be updated with new nodes in the topology if the
value of auto adjust scale up is 0. And also waits for
+ * the date nodes to be updated with nodes that have left the topology if
the value of auto adjust scale down is 0.
+ * After the zone manager has observed the logical topology change and the
data nodes value is updated according to cluster topology,
+ * then this method completes the returned future with the current value
of data nodes.
+ *
+ * <p>If the value of auto adjust scale up is greater than zero, then it
is not necessary to wait for the data nodes update triggered
+ * by new nodes in cluster topology. Similarly if the value of auto adjust
scale down is greater than zero, then it is not necessary to
+ * wait for the data nodes update triggered by new nodes that have left
the topology in cluster topology.
+ *
+ * <p>The returned future can be completed with {@link
DistributionZoneNotFoundException} and
+ * {@link DistributionZoneWasRemovedException} in case when the
distribution zone was removed during method execution.
Review Comment:
We have two possible exceptions in case when the distribution zone was
removed during method execution. How is it possible?
--
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]