List of usage examples for java.util.concurrent RunnableFuture cancel
boolean cancel(boolean mayInterruptIfRunning);
From source file:org.apache.flink.contrib.streaming.state.RocksDBStateBackendTest.java
@Test public void testReleasingSnapshotAfterBackendClosed() throws Exception { setupRocksKeyedStateBackend();/*from ww w .ja va 2s . c o m*/ RunnableFuture<KeyGroupsStateHandle> snapshot = keyedStateBackend.snapshot(0L, 0L, testStreamFactory, CheckpointOptions.forFullCheckpoint()); RocksDB spyDB = keyedStateBackend.db; verify(spyDB, times(1)).getSnapshot(); verify(spyDB, times(0)).releaseSnapshot(any(Snapshot.class)); this.keyedStateBackend.dispose(); verify(spyDB, times(1)).close(); assertEquals(null, keyedStateBackend.db); //Ensure every RocksObjects not closed yet for (RocksObject rocksCloseable : allCreatedCloseables) { verify(rocksCloseable, times(0)).close(); } snapshot.cancel(true); //Ensure every RocksObjects was closed exactly once for (RocksObject rocksCloseable : allCreatedCloseables) { verify(rocksCloseable, times(1)).close(); } }
From source file:org.apache.flink.contrib.streaming.state.RocksDBStateBackendTest.java
@Test public void testDismissingSnapshot() throws Exception { setupRocksKeyedStateBackend();//ww w. ja va 2s.com RunnableFuture<KeyGroupsStateHandle> snapshot = keyedStateBackend.snapshot(0L, 0L, testStreamFactory, CheckpointOptions.forFullCheckpoint()); snapshot.cancel(true); verifyRocksObjectsReleased(); }
From source file:org.apache.flink.contrib.streaming.state.RocksDBStateBackendTest.java
@Test public void testDismissingSnapshotNotRunnable() throws Exception { setupRocksKeyedStateBackend();/* ww w . ja v a 2 s .c o m*/ RunnableFuture<KeyGroupsStateHandle> snapshot = keyedStateBackend.snapshot(0L, 0L, testStreamFactory, CheckpointOptions.forFullCheckpoint()); snapshot.cancel(true); Thread asyncSnapshotThread = new Thread(snapshot); asyncSnapshotThread.start(); try { snapshot.get(); fail(); } catch (Exception ignored) { } asyncSnapshotThread.join(); verifyRocksObjectsReleased(); }
From source file:org.apache.flink.contrib.streaming.state.RocksDBStateBackendTest.java
@Test public void testCancelRunningSnapshot() throws Exception { setupRocksKeyedStateBackend();//from w w w. j ava 2 s . c o m RunnableFuture<KeyGroupsStateHandle> snapshot = keyedStateBackend.snapshot(0L, 0L, testStreamFactory, CheckpointOptions.forFullCheckpoint()); Thread asyncSnapshotThread = new Thread(snapshot); asyncSnapshotThread.start(); waiter.await(); // wait for snapshot to run waiter.reset(); runStateUpdates(); blocker.trigger(); // allow checkpointing to start writing snapshot.cancel(true); assertTrue(testStreamFactory.getLastCreatedStream().isClosed()); waiter.await(); // wait for snapshot stream writing to run try { snapshot.get(); fail(); } catch (Exception ignored) { } verifyRocksObjectsReleased(); asyncSnapshotThread.join(); }