use of org.apache.ignite.internal.util.lang.GridAbsClosureX in project ignite by apache.
the class S3CheckpointSpiSelfTest method testSaveWithExpire.
/**
* @throws Exception Thrown in case of any errors.
*/
@IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420")
public void testSaveWithExpire() throws Exception {
// Save states.
for (int i = 0; i < CHECK_POINT_COUNT; i++) {
GridCheckpointTestState state = new GridCheckpointTestState("Test check point data " + i + '.');
getSpi().saveCheckpoint(KEY_PREFIX + i, GridTestIoUtils.serializeJdk(state), 1, true);
}
// For small expiration intervals no warranty that state will be removed.
Thread.sleep(100);
// Check that states was removed.
for (int i = 0; i < CHECK_POINT_COUNT; i++) {
final String key = KEY_PREFIX + i;
assertWithRetries(new GridAbsClosureX() {
@Override
public void applyx() throws IgniteCheckedException {
assertNull("Checkpoint state should not be loaded with key: " + key, getSpi().loadCheckpoint(key));
}
});
}
}
use of org.apache.ignite.internal.util.lang.GridAbsClosureX in project ignite by apache.
the class S3CheckpointSpiSelfTest method testSaveLoadRemoveWithoutExpire.
/**
* @throws Exception Thrown in case of any errors.
*/
@IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420")
public void testSaveLoadRemoveWithoutExpire() throws Exception {
String dataPrefix = "Test check point data ";
// Save states.
for (int i = 0; i < CHECK_POINT_COUNT; i++) {
GridCheckpointTestState state = new GridCheckpointTestState(dataPrefix + i);
getSpi().saveCheckpoint(KEY_PREFIX + i, GridTestIoUtils.serializeJdk(state), 0, true);
}
// Load and check states.
for (int i = 0; i < CHECK_POINT_COUNT; i++) {
final String key = KEY_PREFIX + i;
assertWithRetries(new GridAbsClosureX() {
@Override
public void applyx() throws IgniteCheckedException {
assertNotNull("Missing checkpoint: " + key, getSpi().loadCheckpoint(key));
}
});
// Doing it again as pulling value from repeated assertion is tricky,
// and all assertions below shouldn't be retried in case of failure.
byte[] serState = getSpi().loadCheckpoint(key);
GridCheckpointTestState state = GridTestIoUtils.deserializeJdk(serState);
assertNotNull("Can't load checkpoint state for key: " + key, state);
assertEquals("Invalid state loaded [expected='" + dataPrefix + i + "', received='" + state.getData() + "']", dataPrefix + i, state.getData());
}
// Remove states.
for (int i = 0; i < CHECK_POINT_COUNT; i++) {
final String key = KEY_PREFIX + i;
assertWithRetries(new GridAbsClosureX() {
@Override
public void applyx() throws IgniteCheckedException {
assertTrue(getSpi().removeCheckpoint(key));
}
});
}
// Check that states was removed.
for (int i = 0; i < CHECK_POINT_COUNT; i++) {
final String key = KEY_PREFIX + i;
assertWithRetries(new GridAbsClosureX() {
@Override
public void applyx() throws IgniteCheckedException {
assertNull(getSpi().loadCheckpoint(key));
}
});
}
}
use of org.apache.ignite.internal.util.lang.GridAbsClosureX in project ignite by apache.
the class S3CheckpointSpiSelfTest method testDuplicates.
/**
* @throws Exception Thrown in case of any errors.
*/
@IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420")
public void testDuplicates() throws Exception {
int idx1 = 1;
int idx2 = 2;
GridCheckpointTestState state1 = new GridCheckpointTestState(Integer.toString(idx1));
GridCheckpointTestState state2 = new GridCheckpointTestState(Integer.toString(idx2));
getSpi().saveCheckpoint(KEY_PREFIX, GridTestIoUtils.serializeJdk(state1), 0, true);
getSpi().saveCheckpoint(KEY_PREFIX, GridTestIoUtils.serializeJdk(state2), 0, true);
assertWithRetries(new GridAbsClosureX() {
@Override
public void applyx() throws IgniteCheckedException {
assertNotNull(getSpi().loadCheckpoint(KEY_PREFIX));
}
});
byte[] serState = getSpi().loadCheckpoint(KEY_PREFIX);
GridCheckpointTestState state = GridTestIoUtils.deserializeJdk(serState);
assertNotNull(state);
assertEquals(state2, state);
// Remove.
getSpi().removeCheckpoint(KEY_PREFIX);
assertWithRetries(new GridAbsClosureX() {
@Override
public void applyx() throws IgniteCheckedException {
assertNull(getSpi().loadCheckpoint(KEY_PREFIX));
}
});
}
use of org.apache.ignite.internal.util.lang.GridAbsClosureX in project ignite by apache.
the class GridTaskExecutionContextSelfTest method testWithNoFailoverClosure.
/**
* @throws Exception If failed.
*/
public void testWithNoFailoverClosure() throws Exception {
final IgniteRunnable r = new GridAbsClosureX() {
@Override
public void applyx() {
CNT.incrementAndGet();
throw new ComputeExecutionRejectedException("Expected error.");
}
};
final Ignite g = grid(0);
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
g.compute().withNoFailover().run(r);
return null;
}
}, ComputeExecutionRejectedException.class, "Expected error.");
assertEquals(1, CNT.get());
}
Aggregations