use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.
the class GridCacheAdapter method sizeLongAsync.
/**
* {@inheritDoc}
*/
@Override
public IgniteInternalFuture<Long> sizeLongAsync(final CachePeekMode[] peekModes) {
assert peekModes != null;
PeekModes modes = parsePeekModes(peekModes, true);
IgniteClusterEx cluster = ctx.grid().cluster();
ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, true, false) : cluster.forDataNodes(name());
Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes());
if (nodes.isEmpty())
return new GridFinishedFuture<>(0L);
ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
return ctx.kernalContext().task().execute(new SizeLongTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null);
}
use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.
the class GridCacheAdapter method sizeAsync.
/**
* {@inheritDoc}
*/
@Override
public IgniteInternalFuture<Integer> sizeAsync(final CachePeekMode[] peekModes) {
assert peekModes != null;
PeekModes modes = parsePeekModes(peekModes, true);
IgniteClusterEx cluster = ctx.grid().cluster();
ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, true, false) : cluster.forDataNodes(name());
Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes());
if (nodes.isEmpty())
return new GridFinishedFuture<>(0);
ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
return ctx.kernalContext().task().execute(new SizeTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null);
}
use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.
the class PlatformAffinityUtils method readPartitionAssignment.
/**
* Reads the partition assignment.
*
* @param reader Reader.
* @param ctx Platform context.
* @return Partitions.
*/
@NotNull
public static List<List<ClusterNode>> readPartitionAssignment(BinaryRawReader reader, PlatformContext ctx) {
assert reader != null;
assert ctx != null;
int partCnt = reader.readInt();
List<List<ClusterNode>> res = new ArrayList<>(partCnt);
IgniteClusterEx cluster = ctx.kernalContext().grid().cluster();
for (int i = 0; i < partCnt; i++) {
int partSize = reader.readInt();
List<ClusterNode> part = new ArrayList<>(partSize);
for (int j = 0; j < partSize; j++) part.add(cluster.node(reader.readUuid()));
res.add(part);
}
return res;
}
use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.
the class BaselineEventsTest method testEventsDisabledByDefault.
/**
*/
@Test
public void testEventsDisabledByDefault() throws Exception {
// noinspection ZeroLengthArrayAllocation
includedEvtTypes = new int[0];
IgniteClusterEx cluster = startGrid(0).cluster();
cluster.active(true);
AtomicInteger evtsTriggered = new AtomicInteger();
listen(grid(0), event -> {
evtsTriggered.incrementAndGet();
return true;
}, EventType.EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED, EventType.EVT_BASELINE_AUTO_ADJUST_AWAITING_TIME_CHANGED);
startGrid(1);
String consistentIds = grid(0).localNode().consistentId() + "," + grid(1).localNode().consistentId();
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "set", consistentIds, "--yes")));
awaitPartitionMapExchange();
startGrid(2);
cluster.setBaselineTopology(cluster.topologyVersion());
awaitPartitionMapExchange();
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "auto_adjust", "enable", "timeout", "10", "--yes")));
cluster.baselineAutoAdjustEnabled(false);
cluster.baselineAutoAdjustTimeout(50);
assertFalse(GridTestUtils.waitForCondition(() -> evtsTriggered.get() > 0, 3_000L));
}
use of org.apache.ignite.internal.cluster.IgniteClusterEx in project ignite by apache.
the class BaselineEventsTest method testChangeAutoAdjustEnabled.
/**
*/
@Test
public void testChangeAutoAdjustEnabled() throws Exception {
IgniteClusterEx cluster = startGrids(2).cluster();
cluster.active(true);
assertFalse(cluster.isBaselineAutoAdjustEnabled());
AtomicBoolean autoAdjustEnabled = new AtomicBoolean();
listen(grid(0), event -> {
BaselineConfigurationChangedEvent bltCfgChangedEvt = (BaselineConfigurationChangedEvent) event;
autoAdjustEnabled.set(bltCfgChangedEvt.isAutoAdjustEnabled());
return true;
}, EventType.EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED);
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "auto_adjust", "enable", "timeout", "10", "--yes")));
assertTrue(GridTestUtils.waitForCondition(autoAdjustEnabled::get, 3_000));
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "auto_adjust", "disable", "--yes")));
assertFalse(autoAdjustEnabled.get());
cluster.baselineAutoAdjustEnabled(true);
assertTrue(GridTestUtils.waitForCondition(autoAdjustEnabled::get, 3_000));
cluster.baselineAutoAdjustEnabled(false);
assertTrue(GridTestUtils.waitForCondition(() -> !autoAdjustEnabled.get(), 3_000));
}
Aggregations