use of org.apache.ignite.IgniteCountDownLatch in project ignite by apache.
the class IgnitePersistentStoreDataStructuresTest method testLatchVolatility.
/**
* @throws Exception If failed.
*/
@Test
public void testLatchVolatility() throws Exception {
Ignite ignite = startGrids(4);
ignite.active(true);
IgniteCountDownLatch latch = ignite.countDownLatch("test", 10, false, true);
assert latch != null;
stopAllGrids();
ignite = startGrids(4);
ignite.active(true);
latch = ignite.countDownLatch("test", 10, false, false);
assert latch == null;
}
use of org.apache.ignite.IgniteCountDownLatch in project ignite by apache.
the class IgniteClientReconnectAtomicsTest method testLatchReconnect.
/**
* @throws Exception If failed.
*/
@Test
public void testLatchReconnect() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
Ignite srv = ignite(0);
IgniteCountDownLatch clientLatch = client.countDownLatch("latch1", 3, false, true);
assertEquals(3, clientLatch.count());
final IgniteCountDownLatch srvLatch = srv.countDownLatch("latch1", 3, false, false);
assertEquals(3, srvLatch.count());
reconnectClientNode(client, srv, new Runnable() {
@Override
public void run() {
srvLatch.countDown();
}
});
assertEquals(2, srvLatch.count());
assertEquals(2, clientLatch.count());
srvLatch.countDown();
assertEquals(1, srvLatch.count());
assertEquals(1, clientLatch.count());
clientLatch.countDown();
assertEquals(0, srvLatch.count());
assertEquals(0, clientLatch.count());
assertTrue(srvLatch.await(1000));
assertTrue(clientLatch.await(1000));
}
use of org.apache.ignite.IgniteCountDownLatch in project ignite by apache.
the class IgniteClientReconnectAtomicsTest method testAtomicsReconnectClusterRestart.
/**
* @throws Exception If failed.
*/
@Test
public void testAtomicsReconnectClusterRestart() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
final IgniteAtomicLong atomicLong = client.atomicLong("atomicLong", 1L, true);
final IgniteAtomicReference<Integer> atomicRef = client.atomicReference("atomicRef", 1, true);
final IgniteAtomicStamped<Integer, Integer> atomicStamped = client.atomicStamped("atomicStamped", 1, 1, true);
final IgniteCountDownLatch latch = client.countDownLatch("latch", 1, true, true);
final IgniteAtomicSequence seq = client.atomicSequence("seq", 1L, true);
Ignite srv = grid(0);
reconnectServersRestart(log, client, Collections.singleton(srv), new Callable<Collection<Ignite>>() {
@Override
public Collection<Ignite> call() throws Exception {
return Collections.singleton((Ignite) startGrid(0));
}
});
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
atomicStamped.compareAndSet(1, 1, 2, 2);
return null;
}
}, IgniteException.class, null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
atomicRef.compareAndSet(1, 2);
return null;
}
}, IgniteException.class, null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
atomicLong.incrementAndGet();
return null;
}
}, IgniteException.class, null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
seq.getAndAdd(1L);
return null;
}
}, IgniteException.class, null);
}
use of org.apache.ignite.IgniteCountDownLatch in project ignite by apache.
the class AbstractDistributedMvccBenchmark method setUp.
/**
* {@inheritDoc}
*/
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
memberId = cfg.memberId();
if (memberId < 0)
throw new IllegalStateException("Member id should be initialized with non-negative value");
// We assume there is no client nodes in the cluster except clients that are yardstick drivers.
driversNodesCnt = ignite().cluster().forClients().nodes().size();
IgniteCountDownLatch dataIsReady = ignite().countDownLatch("fillDataLatch", 1, true, true);
try {
if (memberId == 0) {
fillData(cfg, (IgniteEx) ignite(), args.range(), args.atomicMode());
dataIsReady.countDown();
} else {
println(cfg, "No need to upload data for memberId=" + memberId + ". Just waiting");
dataIsReady.await(DATA_WAIT_TIMEOUT_MIN, TimeUnit.MINUTES);
println(cfg, "Data is ready.");
}
} catch (Throwable th) {
dataIsReady.countDownAll();
throw new RuntimeException("Fill Data failed.", th);
}
// Workaround for "Table TEST_LONG not found" on sql update.
execute(new SqlFieldsQuery("SELECT COUNT(*) FROM test_long"));
}
Aggregations