Search in sources :

Example 1 with BaselineTopologyHistory

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

the class IgniteBaselineAffinityTopologyActivationTest method verifyBaselineTopologyHistoryOnNodes.

/**
 */
private void verifyBaselineTopologyHistoryOnNodes(BaselineTopologyHistoryVerifier bltHistVerifier, Ignite[] igs) {
    for (Ignite ig : igs) {
        BaselineTopologyHistory blt = getBaselineTopologyHistory(ig);
        bltHistVerifier.verify(blt);
    }
}
Also used : Ignite(org.apache.ignite.Ignite) BaselineTopologyHistory(org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory)

Example 2 with BaselineTopologyHistory

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

the class IgniteBaselineAffinityTopologyActivationTest method testBaselineHistorySyncWithOldNodeWithCompatibleHistory.

/**
 */
@Test
public void testBaselineHistorySyncWithOldNodeWithCompatibleHistory() throws Exception {
    final long expectedBranchingHash0 = "A".hashCode() + "B".hashCode() + "C".hashCode();
    final long expectedBranchingHash1 = "A".hashCode() + "B".hashCode();
    BaselineTopologyHistoryVerifier verifier = new BaselineTopologyHistoryVerifier() {

        @Override
        public void verify(BaselineTopologyHistory bltHist) {
            assertNotNull(bltHist);
            assertEquals(2, bltHist.history().size());
            BaselineTopologyHistoryItem histItem = bltHist.history().get(0);
            assertEquals(1, histItem.branchingHistory().size());
            long actualBranchingHash0 = histItem.branchingHistory().get(0);
            assertEquals(expectedBranchingHash0, actualBranchingHash0);
            histItem = bltHist.history().get(1);
            assertEquals(1, histItem.branchingHistory().size());
            long actualBranchingHash1 = histItem.branchingHistory().get(0);
            assertEquals(expectedBranchingHash1, actualBranchingHash1);
        }
    };
    Ignite nodeA = startGridWithConsistentId("A");
    startGridWithConsistentId("B");
    startGridWithConsistentId("C");
    nodeA.cluster().baselineAutoAdjustEnabled(false);
    nodeA.cluster().active(true);
    stopGrid("C", false);
    nodeA.cluster().setBaselineTopology(baselineNodes(nodeA.cluster().forServers().nodes()));
    stopGrid("B", false);
    nodeA.cluster().setBaselineTopology(baselineNodes(nodeA.cluster().forServers().nodes()));
    startGridWithConsistentId("B");
    stopAllGrids(false);
    startGridWithConsistentId("A");
    Ignite nodeB = startGridWithConsistentId("B");
    verifyBaselineTopologyHistoryOnNodes(verifier, new Ignite[] { nodeB });
}
Also used : BaselineTopologyHistoryItem(org.apache.ignite.internal.processors.cluster.BaselineTopologyHistoryItem) Ignite(org.apache.ignite.Ignite) BaselineTopologyHistory(org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with BaselineTopologyHistory

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

the class IgniteBaselineAffinityTopologyActivationTest method _testBaselineTopologyHistoryIsDeletedOnBaselineDelete.

/**
 * Restore this test when requirements for BaselineTopology deletion are clarified and this feature
 * is covered with more tests.
 */
public void _testBaselineTopologyHistoryIsDeletedOnBaselineDelete() throws Exception {
    BaselineTopologyHistoryVerifier verifier = new BaselineTopologyHistoryVerifier() {

        @Override
        public void verify(BaselineTopologyHistory bltHist) {
            assertNotNull(bltHist);
            assertEquals(0, bltHist.history().size());
        }
    };
    Ignite nodeA = startGridWithConsistentId("A");
    startGridWithConsistentId("B");
    startGridWithConsistentId("C");
    nodeA.active(true);
    stopAllGrids(false);
    nodeA = startGridWithConsistentId("A");
    startGridWithConsistentId("B");
    nodeA.active(true);
    nodeA.cluster().setBaselineTopology(baselineNodes(nodeA.cluster().forServers().nodes()));
    stopAllGrids(false);
    nodeA = startGridWithConsistentId("A");
    nodeA.active(true);
    nodeA.cluster().setBaselineTopology(baselineNodes(nodeA.cluster().forServers().nodes()));
    stopAllGrids(false);
    final Ignite node = startGridWithConsistentId("A");
    boolean activated = GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            return node.active();
        }
    }, 10_000);
    assertTrue(activated);
    node.cluster().setBaselineTopology(null);
    verifyBaselineTopologyHistoryOnNodes(verifier, new Ignite[] { node });
    stopAllGrids(false);
    nodeA = startGridWithConsistentId("A");
    verifyBaselineTopologyHistoryOnNodes(verifier, new Ignite[] { nodeA });
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) Ignite(org.apache.ignite.Ignite) BaselineTopologyHistory(org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory)

Example 4 with BaselineTopologyHistory

use of org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory 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 5 with BaselineTopologyHistory

use of org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory 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)

Aggregations

BaselineTopologyHistory (org.apache.ignite.internal.processors.cluster.BaselineTopologyHistory)6 Ignite (org.apache.ignite.Ignite)4 BaselineTopologyHistoryItem (org.apache.ignite.internal.processors.cluster.BaselineTopologyHistoryItem)3 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 BaselineTopology (org.apache.ignite.internal.processors.cluster.BaselineTopology)2 IgniteEx (org.apache.ignite.internal.IgniteEx)1 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)1