Search in sources :

Example 16 with BaselineTopology

use of org.apache.ignite.internal.processors.cluster.BaselineTopology in project ignite by apache.

the class IgniteBaselineAffinityTopologyActivationTest method testNodeWithOldBltIsAllowedToJoinCluster.

/**
 * Test verifies that node with out-of-data but still compatible Baseline Topology is allowed to join the cluster.
 */
@Test
public void testNodeWithOldBltIsAllowedToJoinCluster() throws Exception {
    final long expectedHash1 = (long) "A".hashCode() + "B".hashCode() + "C".hashCode();
    BaselineTopologyVerifier verifier1 = new BaselineTopologyVerifier() {

        @Override
        public void verify(BaselineTopology blt) {
            assertNotNull(blt);
            assertEquals(3, blt.consistentIds().size());
            long activationHash = U.field(blt, "branchingPntHash");
            assertEquals(expectedHash1, activationHash);
        }
    };
    final long expectedHash2 = (long) "A".hashCode() + "B".hashCode();
    BaselineTopologyVerifier verifier2 = new BaselineTopologyVerifier() {

        @Override
        public void verify(BaselineTopology blt) {
            assertNotNull(blt);
            assertEquals(3, blt.consistentIds().size());
            long activationHash = U.field(blt, "branchingPntHash");
            assertEquals(expectedHash2, activationHash);
        }
    };
    Ignite nodeA = startGridWithConsistentId("A");
    Ignite nodeB = startGridWithConsistentId("B");
    Ignite nodeC = startGridWithConsistentId("C");
    nodeC.cluster().active(true);
    verifyBaselineTopologyOnNodes(verifier1, new Ignite[] { nodeA, nodeB, nodeC });
    stopAllGrids(false);
    nodeA = startGridWithConsistentId("A");
    nodeB = startGridWithConsistentId("B");
    nodeB.cluster().active(true);
    verifyBaselineTopologyOnNodes(verifier2, new Ignite[] { nodeA, nodeB });
    stopAllGrids(false);
    nodeA = startGridWithConsistentId("A");
    nodeB = startGridWithConsistentId("B");
    nodeC = startGridWithConsistentId("C");
    awaitPartitionMapExchange();
    verifyBaselineTopologyOnNodes(verifier1, new Ignite[] { nodeA, nodeB, nodeC });
}
Also used : BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

BaselineTopology (org.apache.ignite.internal.processors.cluster.BaselineTopology)16 Ignite (org.apache.ignite.Ignite)8 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 List (java.util.List)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 BaselineNode (org.apache.ignite.cluster.BaselineNode)3 Collection (java.util.Collection)2 UUID (java.util.UUID)2 IgniteException (org.apache.ignite.IgniteException)2 ClusterState (org.apache.ignite.cluster.ClusterState)2 BaselineTopologyHistory (org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory)2 Nullable (org.jetbrains.annotations.Nullable)2 Externalizable (java.io.Externalizable)1 File (java.io.File)1 IOException (java.io.IOException)1 ObjectInput (java.io.ObjectInput)1 ObjectOutput (java.io.ObjectOutput)1