factory, keyGroupRange, getContainingTask().getCancelables())) { getOperatorName() + "."; if (!getContainingTask().isCanceled()) { LOG.info(snapshotFailMessage, snapshotException);
doReturn(containingTask).when(operator).getContainingTask();
Preconditions.checkNotNull(getContainingTask()); final CloseableRegistry streamTaskCloseableRegistry = Preconditions.checkNotNull(containingTask.getCancelables());
StreamTask<?, ?> containingTask = getContainingTask(); CloseableRegistry taskCloseableRegistry = containingTask != null ? containingTask.getCancelables() :
/** * Checks that the state snapshot context is closed after a successful snapshot operation. */ @Test public void testSnapshotMethod() throws Exception { final long checkpointId = 42L; final long timestamp = 1L; final CloseableRegistry closeableRegistry = new CloseableRegistry(); StateSnapshotContextSynchronousImpl context = spy(new StateSnapshotContextSynchronousImpl(0L, 0L)); whenNew(StateSnapshotContextSynchronousImpl.class).withAnyArguments().thenReturn(context); StreamTask<Void, AbstractStreamOperator<Void>> containingTask = mock(StreamTask.class); when(containingTask.getCancelables()).thenReturn(closeableRegistry); AbstractStreamOperator<Void> operator = mock(AbstractStreamOperator.class); when(operator.snapshotState(anyLong(), anyLong(), any(CheckpointOptions.class), any(CheckpointStreamFactory.class))).thenCallRealMethod(); doReturn(containingTask).when(operator).getContainingTask(); operator.snapshotState( checkpointId, timestamp, CheckpointOptions.forCheckpointWithDefaultLocation(), new MemCheckpointStreamFactory(Integer.MAX_VALUE)); verify(context).close(); }
doCallRealMethod().when(operator).dispose(); doReturn(containingTask).when(operator).getContainingTask();
/** * @deprecated Non-repartitionable operator state that has been deprecated. * Can be removed when we remove the APIs for non-repartitionable operator state. */ @Deprecated private void restoreStreamCheckpointed(OperatorStateHandles stateHandles) throws Exception { StreamStateHandle state = stateHandles.getLegacyOperatorState(); if (null != state) { if (this instanceof CheckpointedRestoringOperator) { LOG.debug("Restore state of task {} in chain ({}).", stateHandles.getOperatorChainIndex(), getContainingTask().getName()); FSDataInputStream is = state.openInputStream(); try { getContainingTask().getCancelables().registerClosable(is); ((CheckpointedRestoringOperator) this).restoreState(is); } finally { getContainingTask().getCancelables().unregisterClosable(is); is.close(); } } else { throw new Exception( "Found legacy operator state for operator that does not implement StreamCheckpointedOperator."); } } }
/** * @deprecated Non-repartitionable operator state that has been deprecated. * Can be removed when we remove the APIs for non-repartitionable operator state. */ @SuppressWarnings("deprecation") @Deprecated @Override public StreamStateHandle snapshotLegacyOperatorState(long checkpointId, long timestamp, CheckpointOptions checkpointOptions) throws Exception { if (this instanceof StreamCheckpointedOperator) { CheckpointStreamFactory factory = getCheckpointStreamFactory(checkpointOptions); final CheckpointStreamFactory.CheckpointStateOutputStream outStream = factory.createCheckpointStateOutputStream(checkpointId, timestamp); getContainingTask().getCancelables().registerClosable(outStream); try { ((StreamCheckpointedOperator) this).snapshotState(outStream, checkpointId, timestamp); return outStream.closeAndGetHandle(); } finally { getContainingTask().getCancelables().unregisterClosable(outStream); outStream.close(); } } else { return null; } }
factory, keyGroupRange, getContainingTask().getCancelables())) { getOperatorName() + "."; if (!getContainingTask().isCanceled()) { LOG.info(snapshotFailMessage, snapshotException);
factory, keyGroupRange, getContainingTask().getCancelables())) { getOperatorName() + "."; if (!getContainingTask().isCanceled()) { LOG.info(snapshotFailMessage, snapshotException);
factory, keyGroupRange, getContainingTask().getCancelables())) {
StreamTask<?, ?> containingTask = getContainingTask(); CloseableRegistry taskCloseableRegistry = containingTask != null ? containingTask.getCancelables() :
Preconditions.checkNotNull(getContainingTask()); final CloseableRegistry streamTaskCloseableRegistry = Preconditions.checkNotNull(containingTask.getCancelables());
Preconditions.checkNotNull(getContainingTask()); final CloseableRegistry streamTaskCloseableRegistry = Preconditions.checkNotNull(containingTask.getCancelables());
StreamTask<?, ?> containingTask = getContainingTask(); CloseableRegistry taskCloseableRegistry = containingTask != null ? containingTask.getCancelables() :
getContainingTask().getCancelables()); // access to register streams for canceling