Search in sources :

Example 6 with BaselineNode

use of org.apache.ignite.cluster.BaselineNode in project ignite by apache.

the class BaselineTopology method calculateTopologyHash.

/**
 * @param nodes Nodes.
 */
private long calculateTopologyHash(Collection<? extends BaselineNode> nodes) {
    long res = 0;
    Set<Object> bltConsIds = nodeMap.keySet();
    for (BaselineNode node : nodes) {
        if (bltConsIds.contains(node.consistentId()))
            res += (long) node.consistentId().hashCode();
    }
    return res;
}
Also used : BaselineNode(org.apache.ignite.cluster.BaselineNode)

Example 7 with BaselineNode

use of org.apache.ignite.cluster.BaselineNode in project ignite by apache.

the class IgniteBaselineAffinityTopologyActivationTest method testAutoActivationWithBaselineTopologyPreset.

/**
 * Verifies that grid is autoactivated when full BaselineTopology is preset even on one node
 * and then all other nodes from BaselineTopology are started.
 */
public void testAutoActivationWithBaselineTopologyPreset() throws Exception {
    Ignite ig = startGridWithConsistentId("A");
    ig.active(true);
    ig.cluster().setBaselineTopology(Arrays.asList(new BaselineNode[] { createBaselineNodeWithConsId("A"), createBaselineNodeWithConsId("B"), createBaselineNodeWithConsId("C") }));
    stopAllGrids();
    final Ignite ig1 = startGridWithConsistentId("A");
    startGridWithConsistentId("B");
    startGridWithConsistentId("C");
    boolean activated = GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            return ig1.active();
        }
    }, 10_000);
    assertTrue(activated);
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) Ignite(org.apache.ignite.Ignite) BaselineNode(org.apache.ignite.cluster.BaselineNode)

Example 8 with BaselineNode

use of org.apache.ignite.cluster.BaselineNode in project ignite by apache.

the class IgniteBaselineAffinityTopologyActivationTest method testOnlineNodesCannotBeRemovedFromBaselineTopology.

/**
 * Verifies that online nodes cannot be removed from BaselineTopology (this may change in future).
 */
public void testOnlineNodesCannotBeRemovedFromBaselineTopology() throws Exception {
    Ignite nodeA = startGridWithConsistentId("A");
    Ignite nodeB = startGridWithConsistentId("B");
    Ignite nodeC = startGridWithConsistentId("OnlineConsID");
    nodeC.active(true);
    boolean expectedExceptionIsThrown = false;
    try {
        nodeC.cluster().setBaselineTopology(Arrays.asList((BaselineNode) nodeA.cluster().localNode(), nodeB.cluster().localNode()));
    } catch (IgniteException e) {
        String errMsg = e.getMessage();
        assertTrue(errMsg.startsWith("Removing online nodes"));
        assertTrue(errMsg.contains("[OnlineConsID]"));
        expectedExceptionIsThrown = true;
    }
    assertTrue(expectedExceptionIsThrown);
}
Also used : IgniteException(org.apache.ignite.IgniteException) Ignite(org.apache.ignite.Ignite) BaselineNode(org.apache.ignite.cluster.BaselineNode)

Aggregations

BaselineNode (org.apache.ignite.cluster.BaselineNode)8 ArrayList (java.util.ArrayList)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 Ignite (org.apache.ignite.Ignite)2 IgniteException (org.apache.ignite.IgniteException)2 List (java.util.List)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteSystemProperties.getInteger (org.apache.ignite.IgniteSystemProperties.getInteger)1 BaselineTopology (org.apache.ignite.internal.processors.cluster.BaselineTopology)1 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)1 IgniteProductVersion (org.apache.ignite.lang.IgniteProductVersion)1 NotNull (org.jetbrains.annotations.NotNull)1