sashapolo commented on code in PR #5714: URL: https://github.com/apache/ignite-3/pull/5714#discussion_r2065923557
########## modules/configuration/src/testFixtures/java/org/apache/ignite/internal/configuration/TestConfigurationChanger.java: ########## @@ -40,15 +40,18 @@ public class TestConfigurationChanger extends ConfigurationChanger { * @param rootKeys Configuration root keys. * @param storage Configuration storage. * @param generator Runtime implementations tree generator for node classes. + * @param validator Configuration validator. + * @param migrator Configuration migrator. Review Comment: 1. We don't align parameters. 2. These descriptions are pretty much useless, I propose to remove them. ########## modules/configuration/src/main/java/org/apache/ignite/internal/configuration/ConfigurationChanger.java: ########## @@ -700,6 +712,33 @@ private ConfigurationStorageListener configurationStorageListener() { }; } + private static Data mergeData(Data currentData, Data delta) { + assert delta.changeId() > currentData.changeId() : currentData.changeId() + " " + delta.changeId(); + + Map<String, Serializable> newState = new HashMap<>(currentData.values()); + + for (Entry<String, ? extends Serializable> entry : delta.values().entrySet()) { + if (entry.getValue() == null) { + newState.remove(entry.getKey()); + } else { + newState.put(entry.getKey(), entry.getValue()); + } + } + + return new Data(newState, delta.changeId()); + } + + private static void dropUnnecessarilyDeletedKeys(Map<String, Serializable> allChanges, StorageRoots localRoots) { + // "toList" is necessary to avoid "ConcurrentModificationException". + List<String> unnecessarilyDeletedKeys = allChanges.entrySet().stream() + .filter(e -> e.getValue() == null) + .map(Entry::getKey) + .filter(k -> !localRoots.data.values().containsKey(k)) + .collect(Collectors.toList()); + + unnecessarilyDeletedKeys.forEach(allChanges::remove); Review Comment: Can we use `removeIf`? ########## modules/configuration/src/main/java/org/apache/ignite/internal/configuration/util/ConfigurationUtil.java: ########## @@ -768,10 +767,6 @@ public static void compressDeletedEntries(Map<String, ?> prefixMap) { if (map.containsKey(NamedListNode.NAME) && map.get(NamedListNode.NAME) == null) { entry.setValue(null); } - } else if (value == null) { Review Comment: Why did you remove this clause but not the other? ########## modules/configuration/src/main/java/org/apache/ignite/internal/configuration/ConfigurationChanger.java: ########## @@ -145,7 +149,7 @@ private static class StorageRoots { private final SuperRoot roots; /** Version associated with the currently known storage state. */ - private final long version; + private final Data data; Review Comment: The javadoc is now obsolete ########## modules/configuration/src/main/java/org/apache/ignite/internal/configuration/ConfigurationRegistry.java: ########## @@ -68,18 +68,20 @@ public class ConfigurationRegistry implements IgniteComponent { * @param storage Configuration storage. * @param generator Configuration tree generator. * @param configurationValidator Configuration validator. + * @param migrator Configuration migrator. Review Comment: Same comment about unnecessary parameters ########## modules/configuration/src/test/java/org/apache/ignite/internal/configuration/deprecation/DeprecatedConfigurationTest.java: ########## @@ -0,0 +1,455 @@ +/* + * 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.configuration.deprecation; + +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import org.apache.ignite.configuration.RootKey; +import org.apache.ignite.configuration.SuperRootChange; +import org.apache.ignite.configuration.annotation.ConfigValue; +import org.apache.ignite.configuration.annotation.ConfigurationRoot; +import org.apache.ignite.configuration.annotation.ConfigurationType; +import org.apache.ignite.configuration.annotation.NamedConfigValue; +import org.apache.ignite.configuration.annotation.Value; +import org.apache.ignite.internal.configuration.ConfigurationChanger; +import org.apache.ignite.internal.configuration.ConfigurationMigrator; +import org.apache.ignite.internal.configuration.ConfigurationTreeGenerator; +import org.apache.ignite.internal.configuration.SuperRoot; +import org.apache.ignite.internal.configuration.SuperRootChangeImpl; +import org.apache.ignite.internal.configuration.TestConfigurationChanger; +import org.apache.ignite.internal.configuration.storage.ConfigurationStorage; +import org.apache.ignite.internal.configuration.storage.Data; +import org.apache.ignite.internal.configuration.storage.TestConfigurationStorage; +import org.apache.ignite.internal.configuration.tree.ConfigurationSource; +import org.apache.ignite.internal.configuration.tree.ConstructableTreeNode; +import org.apache.ignite.internal.configuration.tree.InnerNode; +import org.apache.ignite.internal.configuration.tree.TraversableTreeNodeTest.ChildConfigurationSchema; +import org.apache.ignite.internal.configuration.tree.TraversableTreeNodeTest.NamedElementConfigurationSchema; +import org.apache.ignite.internal.configuration.util.ConfigurationUtil; +import org.apache.ignite.internal.configuration.validation.TestConfigurationValidator; +import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.invocation.InvocationOnMock; + +/** + * Tests for configuration schemas with {@link Deprecated} properties. + */ +public class DeprecatedConfigurationTest extends BaseIgniteAbstractTest { + private static final ConfigurationType TEST_CONFIGURATION_TYPE = ConfigurationType.LOCAL; + + private ConfigurationStorage storage; + + /** + * Argument captor for {@link ConfigurationStorage#write(Map, long)}. + */ + @SuppressWarnings("unchecked") Review Comment: You can use `@Captor` annotation instead ########## modules/configuration/src/main/java/org/apache/ignite/internal/configuration/util/ConfigurationUtil.java: ########## @@ -1010,7 +1007,12 @@ public void descend(ConstructableTreeNode node) { } if (val == null) { - node.construct(key, null, true); + try { Review Comment: What's this about? ########## modules/configuration/src/main/java/org/apache/ignite/internal/configuration/ConfigurationChanger.java: ########## @@ -700,6 +712,33 @@ private ConfigurationStorageListener configurationStorageListener() { }; } + private static Data mergeData(Data currentData, Data delta) { + assert delta.changeId() > currentData.changeId() : currentData.changeId() + " " + delta.changeId(); + + Map<String, Serializable> newState = new HashMap<>(currentData.values()); + + for (Entry<String, ? extends Serializable> entry : delta.values().entrySet()) { + if (entry.getValue() == null) { + newState.remove(entry.getKey()); + } else { + newState.put(entry.getKey(), entry.getValue()); + } + } + + return new Data(newState, delta.changeId()); + } + + private static void dropUnnecessarilyDeletedKeys(Map<String, Serializable> allChanges, StorageRoots localRoots) { Review Comment: Please add a javadoc about what "UnnecessarilyDeleted" means -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org