chesnokoff commented on code in PR #355:
URL: https://github.com/apache/ignite-extensions/pull/355#discussion_r3804231401


##########
modules/auto-activation-ext/src/main/java/opt/apache/ignite/activation/ActivateByNodeAttribute.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Activate cluster when nodes with all specified attributes values join 
topology.
+ */
+public class ActivateByNodeAttribute implements 
IgnitePredicate<Collection<ClusterNode>> {
+    /** Node's attribute name. */
+    private final String attrName;
+
+    /** Collection of values for node's attribute. */
+    private final Set<String> requiredValues;
+
+    /**
+     * @param attributeName Node's attribute name.
+     * @param requiredValues List of values for node's attribute.
+     */
+    public ActivateByNodeAttribute(String attributeName, Set<String> 
requiredValues) {
+        if (attributeName == null || attributeName.isBlank())
+            throw new IllegalArgumentException("attributeName must be set");
+
+        if (requiredValues == null || requiredValues.isEmpty())
+            throw new IllegalArgumentException("requiredValues must be set");
+
+        this.attrName = attributeName;
+        this.requiredValues = requiredValues;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean apply(Collection<ClusterNode> nodes) {
+        Set<String> missingNodes = new HashSet<>(requiredValues);
+
+        for (ClusterNode node : nodes) {
+            String attrVal = node.attribute(attrName);
+
+            missingNodes.remove(attrVal);
+
+            if (missingNodes.isEmpty())
+                break;
+        }
+
+        return missingNodes.isEmpty();
+    }

Review Comment:
   ```suggestion
       @Override public boolean apply(Collection<ClusterNode> nodes) {
           Set<String> missingNodes = new HashSet<>(requiredValues);
   
           for (ClusterNode node : nodes) {
               String attrVal = node.attribute(attrName);
   
               missingNodes.remove(attrVal);
   
               if (missingNodes.isEmpty())
                   return true;
           }
   
           return false;
       }
   ```



##########
modules/auto-activation-ext/src/main/java/opt/apache/ignite/activation/ActivateByConsistentID.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Activate cluster when nodes with specified ConsistentID values join 
topology.
+ */
+public class ActivateByConsistentID implements 
IgnitePredicate<Collection<ClusterNode>> {
+    /** Collection of required nodes ConsistentIDs. */
+    private final Set<String> requiredNodes;
+
+    /**
+     * @param requiredNodes List of ConsistentIDs.
+     */
+    public ActivateByConsistentID(Set<String> requiredNodes) {
+        if (requiredNodes == null || requiredNodes.isEmpty())
+            throw new IllegalArgumentException("requiredNodes must be set");
+
+        this.requiredNodes = requiredNodes;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean apply(Collection<ClusterNode> nodes) {
+        Set<String> missingNodes = new HashSet<>(requiredNodes);
+
+        for (ClusterNode node : nodes) {
+            String nodeConsistentId = node.consistentId().toString();
+
+            missingNodes.remove(nodeConsistentId);
+
+            if (missingNodes.isEmpty())
+                break;
+        }
+
+        return missingNodes.isEmpty();
+    }

Review Comment:
   ```suggestion
       @Override public boolean apply(Collection<ClusterNode> nodes) {
           Set<String> missingNodes = new HashSet<>(requiredNodes);
   
           for (ClusterNode node : nodes) {
               String nodeConsistentId = node.consistentId().toString();
   
               missingNodes.remove(nodeConsistentId);
   
               if (missingNodes.isEmpty())
                   return true;
           }
   
           return false;
       }
   ```



##########
modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java:
##########
@@ -0,0 +1,737 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.cluster.ClusterState.INACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests {@link AutoActivationPluginProvider}.
+ */
+public class AutoActivationTest extends GridCommonAbstractTest {
+    /** Listening test logger. */
+    private final ListeningTestLogger listeningLog = new 
ListeningTestLogger(log);
+
+    /** */
+    private final LogListener lsnrAlreadyAct = LogListener
+            .matches("Auto activation skipped - cluster already 
activated").build();
+
+    /** */
+    private final LogListener lsnrBaseline = LogListener
+            .matches("Auto activation skipped - baseline is not 
empty").build();
+
+    /** */
+    private final LogListener lsnrActMeet = LogListener
+            .matches("Auto activation plugin set cluster state ACTIVE - 
activation condition meet").build();
+
+    /** */
+    private final LogListener lsnrActNotMeet = LogListener
+            .matches("Auto activation skipped - activation condition not 
meet").build();
+
+    /** */
+    private final String NODE_0 = "node_0";
+
+    /** */
+    private final String NODE_1 = "node_1";
+
+    /** */
+    private final String NODE_2 = "node_2";
+
+    /** */
+    private final String NODE_3 = "node_3";
+
+    /** */
+    private final String ATTR = "CELL";
+
+    /** */
+    private final String ATTR_VAL1 = "CELL_01";
+
+    /** */
+    private final String ATTR_VAL2 = "CELL_02";
+
+    /** */
+    private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, 
NODE_2);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, 
lsnrActMeet, lsnrActNotMeet);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+
+        cleanPersistenceDir();
+
+        listeningLog.clearListeners();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+                    .setConsistentId(igniteInstanceName)
+                    .setClusterStateOnStart(INACTIVE)
+                    .setGridLogger(listeningLog);
+    }
+
+    /** @return DataStorageConfiguration. */
+    private DataStorageConfiguration getDataStorageConfiguration() {
+        return new DataStorageConfiguration()
+                .setWalSegmentSize(4 * 1024 * 1024)
+                .setWalMode(WALMode.LOG_ONLY)
+                .setCheckpointFrequency(1000)
+                .setWalCompactionEnabled(true)
+                
.setDefaultDataRegionConfiguration(getDataRegionConfiguration());
+    }
+
+    /** @return DataRegionConfiguration. */
+    private DataRegionConfiguration getDataRegionConfiguration() {
+        return new DataRegionConfiguration()
+                .setPersistenceEnabled(true)
+                .setMaxSize(100L * 1024 * 1024);
+    }
+
+    /** @return CacheConfiguration. */
+    private CacheConfiguration getCacheConfiguration() {
+        return new CacheConfiguration<>()
+                .setName(DEFAULT_CACHE_NAME)
+                .setCacheMode(CacheMode.PARTITIONED)
+                .setBackups(0)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                .setIndexedTypes(String.class, Integer.class);
+    }
+
+    /** @return IgniteConfiguration from XML. */
+    private IgniteConfiguration getConfigurationFromXml(String xmlPath) throws 
Exception {
+        ApplicationContext ctx = new 
ClassPathXmlApplicationContext("common-ignite-server-node.xml", xmlPath);
+
+        return 
ctx.getBean(IgniteConfiguration.class).setGridLogger(listeningLog);
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdAllNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(nodesConsistentIds)
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdFirstTwoNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_0, NODE_1))
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertFalse(lsnrAlreadyAct.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrAlreadyAct.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdOnlyLastNode() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_2))
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdAllNodesPlusCacheConfig() 
throws Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_2))
+        );
+

Review Comment:
   remove nl



##########
modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java:
##########
@@ -0,0 +1,737 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.cluster.ClusterState.INACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests {@link AutoActivationPluginProvider}.
+ */
+public class AutoActivationTest extends GridCommonAbstractTest {
+    /** Listening test logger. */
+    private final ListeningTestLogger listeningLog = new 
ListeningTestLogger(log);
+
+    /** */
+    private final LogListener lsnrAlreadyAct = LogListener
+            .matches("Auto activation skipped - cluster already 
activated").build();
+
+    /** */
+    private final LogListener lsnrBaseline = LogListener
+            .matches("Auto activation skipped - baseline is not 
empty").build();
+
+    /** */
+    private final LogListener lsnrActMeet = LogListener
+            .matches("Auto activation plugin set cluster state ACTIVE - 
activation condition meet").build();
+
+    /** */
+    private final LogListener lsnrActNotMeet = LogListener
+            .matches("Auto activation skipped - activation condition not 
meet").build();
+
+    /** */
+    private final String NODE_0 = "node_0";
+
+    /** */
+    private final String NODE_1 = "node_1";
+
+    /** */
+    private final String NODE_2 = "node_2";
+
+    /** */
+    private final String NODE_3 = "node_3";
+
+    /** */
+    private final String ATTR = "CELL";
+
+    /** */
+    private final String ATTR_VAL1 = "CELL_01";
+
+    /** */
+    private final String ATTR_VAL2 = "CELL_02";
+
+    /** */
+    private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, 
NODE_2);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, 
lsnrActMeet, lsnrActNotMeet);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+
+        cleanPersistenceDir();
+
+        listeningLog.clearListeners();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+                    .setConsistentId(igniteInstanceName)
+                    .setClusterStateOnStart(INACTIVE)
+                    .setGridLogger(listeningLog);
+    }
+
+    /** @return DataStorageConfiguration. */
+    private DataStorageConfiguration getDataStorageConfiguration() {
+        return new DataStorageConfiguration()
+                .setWalSegmentSize(4 * 1024 * 1024)
+                .setWalMode(WALMode.LOG_ONLY)
+                .setCheckpointFrequency(1000)
+                .setWalCompactionEnabled(true)
+                
.setDefaultDataRegionConfiguration(getDataRegionConfiguration());
+    }
+
+    /** @return DataRegionConfiguration. */
+    private DataRegionConfiguration getDataRegionConfiguration() {
+        return new DataRegionConfiguration()
+                .setPersistenceEnabled(true)
+                .setMaxSize(100L * 1024 * 1024);
+    }
+
+    /** @return CacheConfiguration. */
+    private CacheConfiguration getCacheConfiguration() {
+        return new CacheConfiguration<>()

Review Comment:
   ```suggestion
       private CacheConfiguration<String, Integer> getCacheConfiguration() {
           return new CacheConfiguration<String, Integer>()
   ```



##########
modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java:
##########
@@ -0,0 +1,737 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.cluster.ClusterState.INACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests {@link AutoActivationPluginProvider}.
+ */
+public class AutoActivationTest extends GridCommonAbstractTest {
+    /** Listening test logger. */
+    private final ListeningTestLogger listeningLog = new 
ListeningTestLogger(log);
+
+    /** */
+    private final LogListener lsnrAlreadyAct = LogListener
+            .matches("Auto activation skipped - cluster already 
activated").build();
+
+    /** */
+    private final LogListener lsnrBaseline = LogListener
+            .matches("Auto activation skipped - baseline is not 
empty").build();
+
+    /** */
+    private final LogListener lsnrActMeet = LogListener
+            .matches("Auto activation plugin set cluster state ACTIVE - 
activation condition meet").build();
+
+    /** */
+    private final LogListener lsnrActNotMeet = LogListener
+            .matches("Auto activation skipped - activation condition not 
meet").build();
+
+    /** */
+    private final String NODE_0 = "node_0";
+
+    /** */
+    private final String NODE_1 = "node_1";
+
+    /** */
+    private final String NODE_2 = "node_2";
+
+    /** */
+    private final String NODE_3 = "node_3";
+
+    /** */
+    private final String ATTR = "CELL";
+
+    /** */
+    private final String ATTR_VAL1 = "CELL_01";
+
+    /** */
+    private final String ATTR_VAL2 = "CELL_02";
+
+    /** */
+    private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, 
NODE_2);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, 
lsnrActMeet, lsnrActNotMeet);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+
+        cleanPersistenceDir();
+
+        listeningLog.clearListeners();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+                    .setConsistentId(igniteInstanceName)
+                    .setClusterStateOnStart(INACTIVE)
+                    .setGridLogger(listeningLog);
+    }
+
+    /** @return DataStorageConfiguration. */
+    private DataStorageConfiguration getDataStorageConfiguration() {
+        return new DataStorageConfiguration()
+                .setWalSegmentSize(4 * 1024 * 1024)
+                .setWalMode(WALMode.LOG_ONLY)
+                .setCheckpointFrequency(1000)
+                .setWalCompactionEnabled(true)
+                
.setDefaultDataRegionConfiguration(getDataRegionConfiguration());
+    }
+
+    /** @return DataRegionConfiguration. */
+    private DataRegionConfiguration getDataRegionConfiguration() {
+        return new DataRegionConfiguration()
+                .setPersistenceEnabled(true)
+                .setMaxSize(100L * 1024 * 1024);
+    }
+
+    /** @return CacheConfiguration. */
+    private CacheConfiguration getCacheConfiguration() {
+        return new CacheConfiguration<>()

Review Comment:
   let's avoid raw usage of type



##########
modules/auto-activation-ext/src/main/java/opt/apache/ignite/activation/AutoActivationPluginProvider.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.UUID;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.plugin.CachePluginContext;
+import org.apache.ignite.plugin.CachePluginProvider;
+import org.apache.ignite.plugin.ExtensionRegistry;
+import org.apache.ignite.plugin.IgnitePlugin;
+import org.apache.ignite.plugin.PluginConfiguration;
+import org.apache.ignite.plugin.PluginContext;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.plugin.PluginValidationException;
+
+/**
+ * Activate cluster when specified condition meet.
+ */
+public class AutoActivationPluginProvider implements 
PluginProvider<PluginConfiguration> {
+    /** */
+    private final IgnitePredicate<Collection<ClusterNode>> condition;
+
+    /** */
+    private IgniteLogger logger;
+
+    /** */
+    private Ignite grid;
+
+    /**
+     * @param condition Auto activation condition.
+     */
+    public 
AutoActivationPluginProvider(IgnitePredicate<Collection<ClusterNode>> 
condition) {
+        if (condition == null)
+            throw new IllegalArgumentException("Auto activation condition must 
be set");
+
+        this.condition = condition;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String name() {
+        return "Auto Activation Plugin";
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T extends IgnitePlugin> T plugin() {
+        return (T)new IgnitePlugin() {
+            // No-op.
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public String version() {
+        return "1.0.0-SNAPSHOT";
+    }
+
+    /** {@inheritDoc} */
+    @Override public String copyright() {
+        return "Apache Software Foundation";
+    }
+
+    /** {@inheritDoc} */
+    @Override public void initExtensions(PluginContext pc, ExtensionRegistry 
er) {
+        logger = pc.log(this.getClass());        
+        grid = pc.grid();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T createComponent(PluginContext pc, Class<T> type) {
+        return null;
+    }
+ 
+    /** {@inheritDoc} */
+    @Override public CachePluginProvider 
createCacheProvider(CachePluginContext cpc) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start(PluginContext pc) {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop(boolean bln) {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onIgniteStart() {
+

Review Comment:
   ```suggestion
   ```



##########
modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java:
##########
@@ -0,0 +1,737 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.cluster.ClusterState.INACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests {@link AutoActivationPluginProvider}.
+ */
+public class AutoActivationTest extends GridCommonAbstractTest {
+    /** Listening test logger. */
+    private final ListeningTestLogger listeningLog = new 
ListeningTestLogger(log);
+
+    /** */
+    private final LogListener lsnrAlreadyAct = LogListener
+            .matches("Auto activation skipped - cluster already 
activated").build();
+
+    /** */
+    private final LogListener lsnrBaseline = LogListener
+            .matches("Auto activation skipped - baseline is not 
empty").build();
+
+    /** */
+    private final LogListener lsnrActMeet = LogListener
+            .matches("Auto activation plugin set cluster state ACTIVE - 
activation condition meet").build();
+
+    /** */
+    private final LogListener lsnrActNotMeet = LogListener
+            .matches("Auto activation skipped - activation condition not 
meet").build();
+
+    /** */
+    private final String NODE_0 = "node_0";
+
+    /** */
+    private final String NODE_1 = "node_1";
+
+    /** */
+    private final String NODE_2 = "node_2";
+
+    /** */
+    private final String NODE_3 = "node_3";
+
+    /** */
+    private final String ATTR = "CELL";
+
+    /** */
+    private final String ATTR_VAL1 = "CELL_01";
+
+    /** */
+    private final String ATTR_VAL2 = "CELL_02";
+
+    /** */
+    private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, 
NODE_2);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, 
lsnrActMeet, lsnrActNotMeet);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+
+        cleanPersistenceDir();
+
+        listeningLog.clearListeners();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+                    .setConsistentId(igniteInstanceName)
+                    .setClusterStateOnStart(INACTIVE)
+                    .setGridLogger(listeningLog);
+    }
+
+    /** @return DataStorageConfiguration. */
+    private DataStorageConfiguration getDataStorageConfiguration() {
+        return new DataStorageConfiguration()
+                .setWalSegmentSize(4 * 1024 * 1024)
+                .setWalMode(WALMode.LOG_ONLY)
+                .setCheckpointFrequency(1000)
+                .setWalCompactionEnabled(true)
+                
.setDefaultDataRegionConfiguration(getDataRegionConfiguration());
+    }
+
+    /** @return DataRegionConfiguration. */
+    private DataRegionConfiguration getDataRegionConfiguration() {
+        return new DataRegionConfiguration()
+                .setPersistenceEnabled(true)
+                .setMaxSize(100L * 1024 * 1024);
+    }
+
+    /** @return CacheConfiguration. */
+    private CacheConfiguration getCacheConfiguration() {
+        return new CacheConfiguration<>()
+                .setName(DEFAULT_CACHE_NAME)
+                .setCacheMode(CacheMode.PARTITIONED)
+                .setBackups(0)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                .setIndexedTypes(String.class, Integer.class);
+    }
+
+    /** @return IgniteConfiguration from XML. */
+    private IgniteConfiguration getConfigurationFromXml(String xmlPath) throws 
Exception {

Review Comment:
   From IDEA:  Exception 'java.lang.Exception' is never thrown in the method 



##########
modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java:
##########
@@ -0,0 +1,737 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.cluster.ClusterState.INACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests {@link AutoActivationPluginProvider}.
+ */
+public class AutoActivationTest extends GridCommonAbstractTest {
+    /** Listening test logger. */
+    private final ListeningTestLogger listeningLog = new 
ListeningTestLogger(log);
+
+    /** */
+    private final LogListener lsnrAlreadyAct = LogListener
+            .matches("Auto activation skipped - cluster already 
activated").build();
+
+    /** */
+    private final LogListener lsnrBaseline = LogListener
+            .matches("Auto activation skipped - baseline is not 
empty").build();
+
+    /** */
+    private final LogListener lsnrActMeet = LogListener
+            .matches("Auto activation plugin set cluster state ACTIVE - 
activation condition meet").build();
+
+    /** */
+    private final LogListener lsnrActNotMeet = LogListener
+            .matches("Auto activation skipped - activation condition not 
meet").build();
+
+    /** */
+    private final String NODE_0 = "node_0";
+
+    /** */
+    private final String NODE_1 = "node_1";
+
+    /** */
+    private final String NODE_2 = "node_2";
+
+    /** */
+    private final String NODE_3 = "node_3";
+
+    /** */
+    private final String ATTR = "CELL";
+
+    /** */
+    private final String ATTR_VAL1 = "CELL_01";
+
+    /** */
+    private final String ATTR_VAL2 = "CELL_02";
+
+    /** */
+    private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, 
NODE_2);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, 
lsnrActMeet, lsnrActNotMeet);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+
+        cleanPersistenceDir();
+
+        listeningLog.clearListeners();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+                    .setConsistentId(igniteInstanceName)
+                    .setClusterStateOnStart(INACTIVE)
+                    .setGridLogger(listeningLog);
+    }
+
+    /** @return DataStorageConfiguration. */
+    private DataStorageConfiguration getDataStorageConfiguration() {
+        return new DataStorageConfiguration()
+                .setWalSegmentSize(4 * 1024 * 1024)
+                .setWalMode(WALMode.LOG_ONLY)
+                .setCheckpointFrequency(1000)
+                .setWalCompactionEnabled(true)
+                
.setDefaultDataRegionConfiguration(getDataRegionConfiguration());
+    }
+
+    /** @return DataRegionConfiguration. */
+    private DataRegionConfiguration getDataRegionConfiguration() {
+        return new DataRegionConfiguration()
+                .setPersistenceEnabled(true)
+                .setMaxSize(100L * 1024 * 1024);
+    }
+
+    /** @return CacheConfiguration. */
+    private CacheConfiguration getCacheConfiguration() {
+        return new CacheConfiguration<>()
+                .setName(DEFAULT_CACHE_NAME)
+                .setCacheMode(CacheMode.PARTITIONED)
+                .setBackups(0)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                .setIndexedTypes(String.class, Integer.class);
+    }
+
+    /** @return IgniteConfiguration from XML. */
+    private IgniteConfiguration getConfigurationFromXml(String xmlPath) throws 
Exception {
+        ApplicationContext ctx = new 
ClassPathXmlApplicationContext("common-ignite-server-node.xml", xmlPath);
+
+        return 
ctx.getBean(IgniteConfiguration.class).setGridLogger(listeningLog);
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdAllNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(nodesConsistentIds)
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdFirstTwoNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_0, NODE_1))
+        );
+

Review Comment:
   remove nl



##########
modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java:
##########
@@ -0,0 +1,737 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.cluster.ClusterState.INACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests {@link AutoActivationPluginProvider}.
+ */
+public class AutoActivationTest extends GridCommonAbstractTest {
+    /** Listening test logger. */
+    private final ListeningTestLogger listeningLog = new 
ListeningTestLogger(log);
+
+    /** */
+    private final LogListener lsnrAlreadyAct = LogListener
+            .matches("Auto activation skipped - cluster already 
activated").build();
+
+    /** */
+    private final LogListener lsnrBaseline = LogListener
+            .matches("Auto activation skipped - baseline is not 
empty").build();
+
+    /** */
+    private final LogListener lsnrActMeet = LogListener
+            .matches("Auto activation plugin set cluster state ACTIVE - 
activation condition meet").build();
+
+    /** */
+    private final LogListener lsnrActNotMeet = LogListener
+            .matches("Auto activation skipped - activation condition not 
meet").build();
+
+    /** */
+    private final String NODE_0 = "node_0";
+
+    /** */
+    private final String NODE_1 = "node_1";
+
+    /** */
+    private final String NODE_2 = "node_2";
+
+    /** */
+    private final String NODE_3 = "node_3";
+
+    /** */
+    private final String ATTR = "CELL";
+
+    /** */
+    private final String ATTR_VAL1 = "CELL_01";
+
+    /** */
+    private final String ATTR_VAL2 = "CELL_02";
+
+    /** */
+    private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, 
NODE_2);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, 
lsnrActMeet, lsnrActNotMeet);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+
+        cleanPersistenceDir();
+
+        listeningLog.clearListeners();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+                    .setConsistentId(igniteInstanceName)
+                    .setClusterStateOnStart(INACTIVE)
+                    .setGridLogger(listeningLog);
+    }
+
+    /** @return DataStorageConfiguration. */
+    private DataStorageConfiguration getDataStorageConfiguration() {
+        return new DataStorageConfiguration()
+                .setWalSegmentSize(4 * 1024 * 1024)
+                .setWalMode(WALMode.LOG_ONLY)
+                .setCheckpointFrequency(1000)
+                .setWalCompactionEnabled(true)
+                
.setDefaultDataRegionConfiguration(getDataRegionConfiguration());
+    }
+
+    /** @return DataRegionConfiguration. */
+    private DataRegionConfiguration getDataRegionConfiguration() {
+        return new DataRegionConfiguration()
+                .setPersistenceEnabled(true)
+                .setMaxSize(100L * 1024 * 1024);
+    }
+
+    /** @return CacheConfiguration. */
+    private CacheConfiguration getCacheConfiguration() {
+        return new CacheConfiguration<>()
+                .setName(DEFAULT_CACHE_NAME)
+                .setCacheMode(CacheMode.PARTITIONED)
+                .setBackups(0)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                .setIndexedTypes(String.class, Integer.class);
+    }
+
+    /** @return IgniteConfiguration from XML. */
+    private IgniteConfiguration getConfigurationFromXml(String xmlPath) throws 
Exception {
+        ApplicationContext ctx = new 
ClassPathXmlApplicationContext("common-ignite-server-node.xml", xmlPath);
+
+        return 
ctx.getBean(IgniteConfiguration.class).setGridLogger(listeningLog);
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdAllNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(nodesConsistentIds)
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdFirstTwoNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_0, NODE_1))
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertFalse(lsnrAlreadyAct.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrAlreadyAct.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdOnlyLastNode() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_2))
+        );
+

Review Comment:
   remove nl



##########
modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java:
##########
@@ -0,0 +1,737 @@
+/*
+ * 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 opt.apache.ignite.activation;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.cluster.ClusterState.INACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests {@link AutoActivationPluginProvider}.
+ */
+public class AutoActivationTest extends GridCommonAbstractTest {
+    /** Listening test logger. */
+    private final ListeningTestLogger listeningLog = new 
ListeningTestLogger(log);
+
+    /** */
+    private final LogListener lsnrAlreadyAct = LogListener
+            .matches("Auto activation skipped - cluster already 
activated").build();
+
+    /** */
+    private final LogListener lsnrBaseline = LogListener
+            .matches("Auto activation skipped - baseline is not 
empty").build();
+
+    /** */
+    private final LogListener lsnrActMeet = LogListener
+            .matches("Auto activation plugin set cluster state ACTIVE - 
activation condition meet").build();
+
+    /** */
+    private final LogListener lsnrActNotMeet = LogListener
+            .matches("Auto activation skipped - activation condition not 
meet").build();
+
+    /** */
+    private final String NODE_0 = "node_0";
+
+    /** */
+    private final String NODE_1 = "node_1";
+
+    /** */
+    private final String NODE_2 = "node_2";
+
+    /** */
+    private final String NODE_3 = "node_3";
+
+    /** */
+    private final String ATTR = "CELL";
+
+    /** */
+    private final String ATTR_VAL1 = "CELL_01";
+
+    /** */
+    private final String ATTR_VAL2 = "CELL_02";
+
+    /** */
+    private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, 
NODE_2);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, 
lsnrActMeet, lsnrActNotMeet);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+
+        cleanPersistenceDir();
+
+        listeningLog.clearListeners();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+                    .setConsistentId(igniteInstanceName)
+                    .setClusterStateOnStart(INACTIVE)
+                    .setGridLogger(listeningLog);
+    }
+
+    /** @return DataStorageConfiguration. */
+    private DataStorageConfiguration getDataStorageConfiguration() {
+        return new DataStorageConfiguration()
+                .setWalSegmentSize(4 * 1024 * 1024)
+                .setWalMode(WALMode.LOG_ONLY)
+                .setCheckpointFrequency(1000)
+                .setWalCompactionEnabled(true)
+                
.setDefaultDataRegionConfiguration(getDataRegionConfiguration());
+    }
+
+    /** @return DataRegionConfiguration. */
+    private DataRegionConfiguration getDataRegionConfiguration() {
+        return new DataRegionConfiguration()
+                .setPersistenceEnabled(true)
+                .setMaxSize(100L * 1024 * 1024);
+    }
+
+    /** @return CacheConfiguration. */
+    private CacheConfiguration getCacheConfiguration() {
+        return new CacheConfiguration<>()
+                .setName(DEFAULT_CACHE_NAME)
+                .setCacheMode(CacheMode.PARTITIONED)
+                .setBackups(0)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                .setIndexedTypes(String.class, Integer.class);
+    }
+
+    /** @return IgniteConfiguration from XML. */
+    private IgniteConfiguration getConfigurationFromXml(String xmlPath) throws 
Exception {
+        ApplicationContext ctx = new 
ClassPathXmlApplicationContext("common-ignite-server-node.xml", xmlPath);
+
+        return 
ctx.getBean(IgniteConfiguration.class).setGridLogger(listeningLog);
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdAllNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(nodesConsistentIds)
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdFirstTwoNodes() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_0, NODE_1))
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertFalse(lsnrAlreadyAct.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrAlreadyAct.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdOnlyLastNode() throws 
Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_2))
+        );
+
+        try (IgniteEx node0 = 
startGrid(getConfiguration(NODE_0).setPluginProviders(autoActivationProvider))) 
{
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_1).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActNotMeet.check());
+            assertFalse(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), INACTIVE);
+
+            
startGrid(getConfiguration(NODE_2).setPluginProviders(autoActivationProvider));
+
+            assertTrue(lsnrActMeet.check());
+            assertEquals(node0.cluster().state(), ACTIVE);
+        }
+    }
+
+    /** */
+    @Test
+    public void 
testSuccessfulInMemoryClusterActivationByConsistentIdAllNodesPlusCacheConfig() 
throws Exception {
+        PluginProvider<?> autoActivationProvider = new 
AutoActivationPluginProvider(
+                new ActivateByConsistentID(Set.of(NODE_2))
+        );
+

Review Comment:
   same for other methods: remove empty lines as first lines in method bodies



-- 
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]

Reply via email to