AMashenkov commented on code in PR #2432: URL: https://github.com/apache/ignite-3/pull/2432#discussion_r1291581101
########## modules/catalog/src/main/java/org/apache/ignite/internal/catalog/utils/CatalogAlterZoneEventListener.java: ########## @@ -0,0 +1,201 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.catalog.utils; + +import static java.util.concurrent.CompletableFuture.allOf; +import static java.util.concurrent.CompletableFuture.completedFuture; +import static java.util.concurrent.CompletableFuture.failedFuture; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.internal.catalog.CatalogManager; +import org.apache.ignite.internal.catalog.CatalogService; +import org.apache.ignite.internal.catalog.commands.AlterZoneParams; +import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; +import org.apache.ignite.internal.catalog.events.AlterZoneEventParameters; +import org.apache.ignite.internal.manager.EventListener; +import org.jetbrains.annotations.Nullable; + +/** + * Event listener for changing the distribution zone and its fields via {@link CatalogManager#alterZone(AlterZoneParams)}. + * + * <p>To listen for changes to the distribution zone and / or any of the fields, you need to override the methods:</p> + * <ul> + * <li>{@link #onZoneUpdate(AlterZoneEventParameters, CatalogZoneDescriptor)};</li> + * <li>{@link #onPartitionsUpdate(AlterZoneEventParameters, int)};</li> + * <li>{@link #onReplicasUpdate(AlterZoneEventParameters, int)};</li> + * <li>{@link #onFilterUpdate(AlterZoneEventParameters, String)};</li> + * <li>{@link #onAutoAdjustUpdate(AlterZoneEventParameters, int)};</li> + * <li>{@link #onAutoAdjustScaleUpUpdate(AlterZoneEventParameters, int)};</li> + * <li>{@link #onAutoAdjustScaleDownUpdate(AlterZoneEventParameters, int)}.</li> + * </ul> + */ +public class CatalogAlterZoneEventListener implements EventListener<AlterZoneEventParameters> { Review Comment: So, when you alter both `partitions` and `replicas`, then you may want to have a single event to calculate new assignment once and run a rebalance... With your approach, you will have 2 independent events, and consequently you will calculate assignments twice with all of the consequences... and there will no good way back. When at some point you decide to `optimize`, then you will add hacks to merge these events, reinventing `causality token`. -- 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]
