@Override public OperatorStateBackend createOperatorStateBackend(Environment env, String operatorIdentifier) throws Exception { OperatorStateBackend operatorStateBackend = mock(OperatorStateBackend.class); when(operatorStateBackend.snapshot(anyLong(), anyLong(), any(CheckpointStreamFactory.class), any(CheckpointOptions.class))) .thenReturn(new FutureTask<>(new BlockingCallable())); return operatorStateBackend; } }
operatorStateBackend.snapshot(checkpointId, timestamp, factory, checkpointOptions));
when(operatorStateBackend.snapshot( eq(checkpointId), eq(timestamp),
originalBackend.snapshot(0L, 0L, checkpointStreamFactory, CheckpointOptions.forCheckpointWithDefaultLocation());
private StateObjectCollection<OperatorStateHandle> transformSubtaskOpState(Path outDir, Integer subtaskId, StateObjectCollection<OperatorStateHandle> baseState) { if (transformer == null) { return baseState; } StateObjectCollection<OperatorStateHandle> opHandle = baseState; try (OperatorStateBackend opBackend = OperatorStateReader .restoreOperatorStateBackend(opHandle)) { transformer.accept(subtaskId, opBackend); OperatorStateHandle newSnapshot = opBackend .snapshot(checkpointId, System.currentTimeMillis(), new CheckpointStreamFactory() { @Override public CheckpointStateOutputStream createCheckpointStateOutputStream( CheckpointedStateScope scope) throws IOException { return new FileBasedStateOutputStream(outDir.getFileSystem(), new Path(outDir, String.valueOf(UUID.randomUUID()))); } }, null).get().getJobManagerOwnedSnapshot(); return new StateObjectCollection<>(Lists.newArrayList(newSnapshot)); } catch (Exception e) { throw new RuntimeException(e); } }
operatorStateBackend.snapshot(checkpointId, timestamp, factory, checkpointOptions));
operatorStateBackend.snapshot(checkpointId, timestamp, factory, checkpointOptions));
operatorStateBackend.snapshot(checkpointId, timestamp, factory, checkpointOptions));