use of org.apache.ignite.lang.IgniteRunnable in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testReleasePartitionJobMasterLeave.
/**
* @throws Exception If failed.
*/
@Test
public void testReleasePartitionJobMasterLeave() throws Exception {
final int orgId = primaryKey(grid(0).cache(Organization.class.getSimpleName()));
try {
grid(1).compute().affinityRunAsync(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteRunnable() {
@IgniteInstanceResource
private Ignite ignite;
@Override
public void run() {
try {
checkPartitionsReservations((IgniteEx) ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
// No-op.
}
}
});
stopGrid(1, true);
Thread.sleep(3000);
awaitPartitionMapExchange();
checkPartitionsReservations(grid(0), orgId, 0);
} finally {
startGrid(1);
awaitPartitionMapExchange();
}
try {
grid(1).compute().affinityCallAsync(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteCallable<Object>() {
@IgniteInstanceResource
private Ignite ignite;
@Override
public Object call() {
try {
checkPartitionsReservations((IgniteEx) ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
// No-op.
}
return null;
}
});
stopGrid(1, true);
Thread.sleep(3000);
awaitPartitionMapExchange();
checkPartitionsReservations(grid(0), orgId, 0);
} finally {
startGrid(1);
awaitPartitionMapExchange();
}
}
use of org.apache.ignite.lang.IgniteRunnable in project ignite by apache.
the class GridFactorySelfTest method testCurrentIgnite.
/**
* @throws Exception If failed.
*/
@Test
public void testCurrentIgnite() throws Exception {
final String LEFT = "LEFT";
final String RIGHT = "RIGHT";
try {
Ignite iLEFT = startGrid(LEFT);
Ignite iRIGHT = startGrid(RIGHT);
waitForDiscovery(iLEFT, iRIGHT);
iLEFT.compute(iLEFT.cluster().forRemotes()).run(new IgniteRunnable() {
@Override
public void run() {
assert Ignition.localIgnite().name().equals(RIGHT);
}
});
iRIGHT.compute(iRIGHT.cluster().forRemotes()).run(new IgniteRunnable() {
@Override
public void run() {
assert Ignition.localIgnite().name().equals(LEFT);
}
});
} finally {
stopAllGrids();
}
}
Aggregations