use of org.apache.ignite.lang.IgnitePredicate in project ignite by apache.
the class IgniteTopologyPrintFormatSelfTest method doServerAndClientTest.
/**
* @param log Log.
* @throws Exception If failed.
*/
private void doServerAndClientTest(MockLogger log) throws Exception {
try {
Ignite server = startGrid("server");
setLogger(log, server);
Ignite server1 = startGrid("server1");
Ignite client1 = startGrid("first client");
Ignite client2 = startGrid("second client");
waitForDiscovery(server, server1, client1, client2);
} finally {
stopAllGrids();
}
assertTrue(F.forAny(log.logs(), new IgnitePredicate<String>() {
@Override
public boolean apply(String s) {
return s.contains("Topology snapshot [ver=4, servers=2, clients=2,") || (s.contains(">>> Number of server nodes: 2") && s.contains(">>> Number of client nodes: 2"));
}
}));
}
use of org.apache.ignite.lang.IgnitePredicate in project ignite by apache.
the class IgniteTopologyPrintFormatSelfTest method doForceServerAndClientTest.
/**
* @param log Log.
* @throws Exception If failed.
*/
private void doForceServerAndClientTest(MockLogger log) throws Exception {
try {
Ignite server = startGrid("server");
setLogger(log, server);
Ignite server1 = startGrid("server1");
Ignite client1 = startGrid("first client");
Ignite client2 = startGrid("second client");
Ignite forceServClnt3 = startGrid("third client_force_server");
waitForDiscovery(server, server1, client1, client2, forceServClnt3);
} finally {
stopAllGrids();
}
assertTrue(F.forAny(log.logs(), new IgnitePredicate<String>() {
@Override
public boolean apply(String s) {
return s.contains("Topology snapshot [ver=5, servers=2, clients=3,") || (s.contains(">>> Number of server nodes: 2") && s.contains(">>> Number of client nodes: 3"));
}
}));
}
use of org.apache.ignite.lang.IgnitePredicate in project ignite by apache.
the class GridCacheOrderedPreloadingSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setCacheConfiguration(cacheConfig(firstCacheMode, 1, FIRST_CACHE_NAME), cacheConfig(secondCacheMode, 2, SECOND_CACHE_NAME));
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(discoSpi);
Map<IgnitePredicate<? extends Event>, int[]> listeners = new HashMap<>();
listeners.put(new IgnitePredicate<CacheRebalancingEvent>() {
@Override
public boolean apply(CacheRebalancingEvent event) {
times.get(gridIdx(event)).putIfAbsent(event.cacheName(), event.timestamp());
return true;
}
}, new int[] { EventType.EVT_CACHE_REBALANCE_STOPPED });
cfg.setLocalEventListeners(listeners);
return cfg;
}
use of org.apache.ignite.lang.IgnitePredicate in project ignite by apache.
the class OffheapCacheMetricsForClusterGroupSelfTest method awaitMetricsUpdate.
/**
* Wait for {@link EventType#EVT_NODE_METRICS_UPDATED} event will be receieved.
*/
private void awaitMetricsUpdate() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch((GRID_CNT + 1) * 2);
IgnitePredicate<Event> lsnr = new IgnitePredicate<Event>() {
@Override
public boolean apply(Event ignore) {
latch.countDown();
return true;
}
};
for (int i = 0; i < GRID_CNT; i++) grid("server-" + i).events().localListen(lsnr, EVT_NODE_METRICS_UPDATED);
latch.await();
}
use of org.apache.ignite.lang.IgnitePredicate in project ignite by apache.
the class PartitionsExchangeOnDiscoveryHistoryOverflowTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
Map<IgnitePredicate<? extends Event>, int[]> map = new HashMap<>();
// To make partitions exchanges longer.
map.put(new P1<Event>() {
@Override
public boolean apply(Event evt) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// No op.
}
return false;
}
}, new int[] { EVT_NODE_JOINED, EVT_NODE_FAILED, EVT_NODE_LEFT, EVT_DISCOVERY_CUSTOM_EVT });
cfg.setLocalEventListeners(map);
return cfg;
}
Aggregations