use of org.apache.flink.runtime.persistence.IntegerResourceVersion in project flink by apache.
the class DefaultJobGraphStoreTest method testPutJobGraphWhenAlreadyExist.
@Test
public void testPutJobGraphWhenAlreadyExist() throws Exception {
final CompletableFuture<Tuple3<String, IntegerResourceVersion, JobGraph>> replaceFuture = new CompletableFuture<>();
final int resourceVersion = 100;
final AtomicBoolean alreadyExist = new AtomicBoolean(false);
final TestingStateHandleStore<JobGraph> stateHandleStore = builder.setExistsFunction(ignore -> {
if (alreadyExist.get()) {
return IntegerResourceVersion.valueOf(resourceVersion);
} else {
alreadyExist.set(true);
return IntegerResourceVersion.notExisting();
}
}).setAddFunction((ignore, state) -> jobGraphStorageHelper.store(state)).setReplaceConsumer(replaceFuture::complete).build();
final JobGraphStore jobGraphStore = createAndStartJobGraphStore(stateHandleStore);
jobGraphStore.putJobGraph(testingJobGraph);
// Replace
jobGraphStore.putJobGraph(testingJobGraph);
final Tuple3<String, IntegerResourceVersion, JobGraph> actual = replaceFuture.get(timeout, TimeUnit.MILLISECONDS);
assertThat(actual.f0, is(testingJobGraph.getJobID().toString()));
assertThat(actual.f1, is(IntegerResourceVersion.valueOf(resourceVersion)));
assertThat(actual.f2.getJobID(), is(testingJobGraph.getJobID()));
}
Aggregations