use of org.apache.flink.core.fs.DuplicatingFileSystem.CopyRequest in project flink by apache.
the class FsCheckpointStateToolset method duplicate.
@Override
public List<StreamStateHandle> duplicate(List<StreamStateHandle> stateHandles) throws IOException {
final List<CopyRequest> requests = new ArrayList<>();
for (StreamStateHandle handle : stateHandles) {
if (!(handle instanceof FileStateHandle)) {
throw new IllegalArgumentException("We can duplicate only FileStateHandles.");
}
final Path srcPath = ((FileStateHandle) handle).getFilePath();
requests.add(CopyRequest.of(srcPath, getNewDstPath(srcPath.getName())));
}
fs.duplicate(requests);
return IntStream.range(0, stateHandles.size()).mapToObj(idx -> {
final StreamStateHandle originalHandle = stateHandles.get(idx);
final Path dst = requests.get(idx).getDestination();
if (originalHandle instanceof RelativeFileStateHandle) {
return new RelativeFileStateHandle(dst, dst.getName(), originalHandle.getStateSize());
} else {
return new FileStateHandle(dst, originalHandle.getStateSize());
}
}).collect(Collectors.toList());
}
Aggregations