in src/main/java/org/apache/cassandra/sidecar/snapshots/SnapshotPathBuilder.java [404:441]
protected Future<String> lastModifiedTableDirectory(List<String> fileList, String tableName)
{
if (fileList.size() == 0)
{
String errMsg = String.format("Table '%s' does not exist", tableName);
return Future.failedFuture(new NoSuchFileException(errMsg));
}
//noinspection rawtypes
List<Future> futures = fileList.stream()
.map(fs::props)
.collect(Collectors.toList());
Promise<String> promise = Promise.promise();
CompositeFuture.all(futures)
.onFailure(promise::fail)
.onSuccess(ar -> {
String directory = IntStream.range(0, fileList.size())
.mapToObj(i -> Pair.of(fileList.get(i),
ar.<FileProps>resultAt(i)))
.filter(pair -> pair.getRight().isDirectory())
.max(Comparator.comparingLong(pair -> pair.getRight()
.lastModifiedTime()))
.map(Pair::getLeft)
.orElse(null);
if (directory == null)
{
String errMsg = String.format("Table '%s' does not exist", tableName);
promise.fail(new NoSuchFileException(errMsg));
}
else
{
promise.complete(directory);
}
});
return promise.future();
}