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