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));
}
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());
}
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 });
}
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);
}
}
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 });
}
Aggregations