Search in sources :

Example 11 with BaselineTopology

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

the class IgniteBaselineAffinityTopologyActivationTest method checkBaselineTopologyOnNode.

/**
 * @param ig Ignite.
 * @param expBltId Expected BaselineTopology ID.
 * @param expBltHistSize Expected Baseline history size.
 * @param expBranchingHistSize Expected branching history size.
 * @param expActivationHash Expected activation hash.
 */
private void checkBaselineTopologyOnNode(Ignite ig, int expBltId, int expBltHistSize, int expBranchingHistSize, long expActivationHash) {
    BaselineTopology blt = getBaselineTopology(ig);
    BaselineTopologyHistory bltHist = getBaselineTopologyHistory(ig);
    assertNotNull(bltHist);
    assertEquals(expBltId, blt.id());
    assertEquals(expBltHistSize, bltHist.history().size());
    BaselineTopologyHistoryItem histItem = bltHist.history().get(0);
    assertEquals(expBranchingHistSize, histItem.branchingHistory().size());
    assertEquals(expActivationHash, (long) histItem.branchingHistory().get(0));
}
Also used : BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) BaselineTopologyHistoryItem(org.apache.ignite.internal.processors.cluster.BaselineTopologyHistoryItem) BaselineTopologyHistory(org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory)

Example 12 with BaselineTopology

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

the class IgniteBaselineAffinityTopologyActivationTest method testBaselineTopologyRemainsTheSameOnClusterDeactivation.

/**
 * Verifies that neither BaselineTopology nor BaselineTopologyHistory are changed when cluster is deactivated.
 */
@Test
public void testBaselineTopologyRemainsTheSameOnClusterDeactivation() throws Exception {
    startGrids(2);
    IgniteEx srv = grid(0);
    srv.cluster().active(true);
    awaitPartitionMapExchange();
    assertTrue(srv.cluster().active());
    srv.cluster().active(false);
    BaselineTopology blt = getBaselineTopology(srv);
    BaselineTopologyHistory bltHist = getBaselineTopologyHistory(srv);
    assertEquals(0, blt.id());
    assertEquals(2, blt.consistentIds().size());
    assertEquals(1, blt.branchingHistory().size());
    assertEquals(0, bltHist.history().size());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) BaselineTopologyHistory(org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 13 with BaselineTopology

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

the class IgniteBaselineAffinityTopologyActivationTest method testActivationHashIsNotUpdatedOnMultipleActivationRequests.

/**
 * Verifies that when new node joins already active cluster and new activation request is issued,
 * no changes to BaselineTopology branching history happen.
 */
@Test
public void testActivationHashIsNotUpdatedOnMultipleActivationRequests() throws Exception {
    final long expectedActivationHash = (long) "A".hashCode();
    BaselineTopologyVerifier verifier = new BaselineTopologyVerifier() {

        @Override
        public void verify(BaselineTopology blt) {
            long activationHash = U.field(blt, "branchingPntHash");
            assertEquals(expectedActivationHash, activationHash);
        }
    };
    Ignite nodeA = startGridWithConsistentId("A");
    nodeA.cluster().active(true);
    Ignite nodeB = startGridWithConsistentId("B");
    nodeA.cluster().active(true);
    verifyBaselineTopologyOnNodes(verifier, new Ignite[] { nodeA, nodeB });
}
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)

Example 14 with BaselineTopology

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

the class IgniteBaselineAffinityTopologyActivationTest method verifyBaselineTopologyOnNodes.

/**
 */
private void verifyBaselineTopologyOnNodes(BaselineTopologyVerifier bltVerifier, Ignite[] igs) {
    for (Ignite ig : igs) {
        BaselineTopology blt = getBaselineTopology(ig);
        bltVerifier.verify(blt);
    }
}
Also used : BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) Ignite(org.apache.ignite.Ignite)

Example 15 with BaselineTopology

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

the class IgniteBaselineAffinityTopologyActivationTest method testRemoveNodeFromBaselineTopology.

/**
 */
@Test
public void testRemoveNodeFromBaselineTopology() throws Exception {
    final long expectedActivationHash = (long) "A".hashCode() + "C".hashCode();
    BaselineTopologyVerifier verifier = new BaselineTopologyVerifier() {

        @Override
        public void verify(BaselineTopology blt) {
            assertNotNull(blt);
            assertEquals(2, blt.consistentIds().size());
            long activationHash = U.field(blt, "branchingPntHash");
            assertEquals(expectedActivationHash, activationHash);
        }
    };
    Ignite nodeA = startGridWithConsistentId("A");
    startGridWithConsistentId("B");
    Ignite nodeC = startGridWithConsistentId("C");
    nodeA.cluster().baselineAutoAdjustEnabled(false);
    nodeC.cluster().active(true);
    stopGrid("B", false);
    nodeA.cluster().setBaselineTopology(baselineNodes(nodeA.cluster().forServers().nodes()));
    boolean activated = GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            return grid("A").active();
        }
    }, 10_000);
    assertEquals(true, activated);
    verifyBaselineTopologyOnNodes(verifier, new Ignite[] { nodeA, nodeC });
    stopAllGrids(false);
    nodeA = startGridWithConsistentId("A");
    nodeC = startGridWithConsistentId("C");
    activated = GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            return grid("A").active();
        }
    }, 10_000);
    assertTrue(activated);
    verifyBaselineTopologyOnNodes(verifier, new Ignite[] { nodeA, nodeC });
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) 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