Search in sources :

Example 16 with IgniteClusterEx

use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.

the class ClientClusterGroupGetNodesEndpointsResponse method encode.

/**
 * {@inheritDoc}
 */
@Override
public void encode(ClientConnectionContext ctx, BinaryRawWriterEx writer) {
    super.encode(ctx, writer);
    IgniteClusterEx cluster = ctx.kernalContext().grid().cluster();
    long endTopVer0 = endTopVer == UNKNOWN_TOP_VER ? cluster.topologyVersion() : endTopVer;
    Collection<ClusterNode> topology = cluster.topology(endTopVer0);
    writer.writeLong(endTopVer0);
    if (startTopVer == UNKNOWN_TOP_VER) {
        int pos = writer.reserveInt();
        int size = 0;
        for (ClusterNode node : topology) {
            if (writeNode(writer, node))
                size++;
        }
        writer.writeInt(pos, size);
        writer.writeInt(0);
        return;
    }
    Map<UUID, ClusterNode> startNodes = toMap(cluster.topology(startTopVer));
    Map<UUID, ClusterNode> endNodes = toMap(topology);
    int pos = writer.reserveInt();
    int cnt = 0;
    for (Map.Entry<UUID, ClusterNode> endNode : endNodes.entrySet()) {
        if (!startNodes.containsKey(endNode.getKey())) {
            if (writeNode(writer, endNode.getValue()))
                cnt++;
        }
    }
    writer.writeInt(pos, cnt);
    pos = writer.reserveInt();
    cnt = 0;
    for (Map.Entry<UUID, ClusterNode> startNode : startNodes.entrySet()) {
        if (!endNodes.containsKey(startNode.getKey()) && !startNode.getValue().isClient()) {
            writeUuid(writer, startNode.getKey());
            cnt++;
        }
    }
    writer.writeInt(pos, cnt);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteClusterEx(org.apache.ignite.internal.cluster.IgniteClusterEx) UUID(java.util.UUID) Map(java.util.Map) HashMap(java.util.HashMap)

Example 17 with IgniteClusterEx

use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.

the class DeadLockOnNodeLeftExchangeTest method test.

/**
 */
@Test
@WithSystemProperty(key = ExchangeContext.IGNITE_EXCHANGE_COMPATIBILITY_VER_1, value = "true")
public void test() throws Exception {
    startGrids(4);
    IgniteClusterEx cluster = grid(0).cluster();
    cluster.baselineAutoAdjustEnabled(false);
    cluster.active(true);
    TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(grid(3));
    spi.blockMessages(GridDhtPartitionsSingleMessage.class, getTestIgniteInstanceName(0));
    stopGrid(1);
    spi.waitForBlocked();
    IgniteInternalFuture setBaselineTopFut = GridTestUtils.runAsync(() -> {
        cluster.setBaselineTopology(cluster.topologyVersion());
    });
    assertTrue(GridTestUtils.waitForCondition(() -> grid(0).context().state().clusterState().transition(), 5_000L));
    stopGrid(2);
    spi.stopBlock();
    setBaselineTopFut.get(30_000L);
}
Also used : IgniteClusterEx(org.apache.ignite.internal.cluster.IgniteClusterEx) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 18 with IgniteClusterEx

use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.

the class IgniteDbAbstractTest method beforeTest.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTest() throws Exception {
    cleanPersistenceDir();
    startGrids(gridCount());
    if (withClientNearCache()) {
        client = true;
        startGrid(gridCount());
        client = false;
    }
    assert gridCount() > 0;
    final IgniteClusterEx cluster = grid(0).cluster();
    if (log.isInfoEnabled())
        log.info("BTL before activation: " + cluster.currentBaselineTopology());
    cluster.active(true);
    if (log.isInfoEnabled())
        log.info("BTL after activation: " + cluster.currentBaselineTopology());
    awaitPartitionMapExchange();
}
Also used : IgniteClusterEx(org.apache.ignite.internal.cluster.IgniteClusterEx)

Aggregations

IgniteClusterEx (org.apache.ignite.internal.cluster.IgniteClusterEx)18 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)7 Test (org.junit.Test)7 ClusterGroup (org.apache.ignite.cluster.ClusterGroup)5 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 ArrayList (java.util.ArrayList)4 CommandHandler (org.apache.ignite.internal.commandline.CommandHandler)3 IgniteClusterNode (org.apache.ignite.internal.managers.discovery.IgniteClusterNode)3 UUID (java.util.UUID)2 GridStringLogger (org.apache.ignite.testframework.GridStringLogger)2 GridTestLog4jLogger (org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1