use of org.apache.flink.runtime.state.RetrievableStateHandle in project flink by apache.
the class DefaultJobGraphStoreTest method testRecoverJobGraph.
@Test
public void testRecoverJobGraph() throws Exception {
final RetrievableStateHandle<JobGraph> stateHandle = jobGraphStorageHelper.store(testingJobGraph);
final TestingStateHandleStore<JobGraph> stateHandleStore = builder.setGetFunction(ignore -> stateHandle).build();
final JobGraphStore jobGraphStore = createAndStartJobGraphStore(stateHandleStore);
final JobGraph recoveredJobGraph = jobGraphStore.recoverJobGraph(testingJobGraph.getJobID());
assertThat(recoveredJobGraph, is(notNullValue()));
assertThat(recoveredJobGraph.getJobID(), is(testingJobGraph.getJobID()));
}
use of org.apache.flink.runtime.state.RetrievableStateHandle in project flink by apache.
the class ZooKeeperStateHandleStoreTest method testCorruptedData.
/**
* Tests that the ZooKeeperStateHandleStore can handle corrupted data by releasing and trying to
* remove the respective ZooKeeper ZNodes.
*/
@Test
public void testCorruptedData() throws Exception {
final TestingLongStateHandleHelper stateStorage = new TestingLongStateHandleHelper();
ZooKeeperStateHandleStore<TestingLongStateHandleHelper.LongStateHandle> store = new ZooKeeperStateHandleStore<>(ZOOKEEPER.getClient(), stateStorage);
final Collection<Long> input = new HashSet<>();
input.add(1L);
input.add(2L);
input.add(3L);
for (Long aLong : input) {
store.addAndLock("/" + aLong, new TestingLongStateHandleHelper.LongStateHandle(aLong));
}
// corrupt one of the entries
ZOOKEEPER.getClient().setData().forPath("/" + 2, new byte[2]);
List<Tuple2<RetrievableStateHandle<TestingLongStateHandleHelper.LongStateHandle>, String>> allEntries = store.getAllAndLock();
Collection<Long> expected = new HashSet<>(input);
expected.remove(2L);
Collection<Long> actual = new HashSet<>(expected.size());
for (Tuple2<RetrievableStateHandle<TestingLongStateHandleHelper.LongStateHandle>, String> entry : allEntries) {
actual.add(entry.f0.retrieveState().getValue());
}
assertEquals(expected, actual);
}
use of org.apache.flink.runtime.state.RetrievableStateHandle in project flink by apache.
the class ZooKeeperStateHandleStoreTest method testGetAll.
/**
* Tests that all added state is returned.
*/
@Test
public void testGetAll() throws Exception {
// Setup
final TestingLongStateHandleHelper stateHandleProvider = new TestingLongStateHandleHelper();
ZooKeeperStateHandleStore<TestingLongStateHandleHelper.LongStateHandle> store = new ZooKeeperStateHandleStore<>(ZOOKEEPER.getClient(), stateHandleProvider);
// Config
final String pathInZooKeeper = "/testGetAll";
final Set<Long> expected = new HashSet<>();
expected.add(311222268470898L);
expected.add(132812888L);
expected.add(27255442L);
expected.add(11122233124L);
// Test
for (long val : expected) {
store.addAndLock(pathInZooKeeper + val, new TestingLongStateHandleHelper.LongStateHandle(val));
}
for (Tuple2<RetrievableStateHandle<TestingLongStateHandleHelper.LongStateHandle>, String> val : store.getAllAndLock()) {
assertTrue(expected.remove(val.f0.retrieveState().getValue()));
}
assertEquals(0, expected.size());
}
Aggregations