public static RemoteLogSegmentFileset openExistingFileset(final RemoteTopicPartitionDirectory tpDirectory,
                                                              final Uuid uuid) {
        try {
            final Map<RemoteLogSegmentFileType, File> files =
                    Files.list(tpDirectory.getDirectory().toPath())
                            .filter(path -> path.getFileName().toString().contains(uuid.toString()))
                            .collect(toMap(path -> getFileType(path.getFileName().toString()), Path::toFile));

            final Set<RemoteLogSegmentFileType> expectedFileTypes = stream(RemoteLogSegmentFileType.values())
                    .filter(x -> !x.isOptional()).collect(Collectors.toSet());

            if (!files.keySet().containsAll(expectedFileTypes)) {
                expectedFileTypes.removeAll(files.keySet());
                throw new IllegalStateException(format("Invalid fileset, missing files: %s", expectedFileTypes));
            }

            final RemoteLogSegmentId id = new RemoteLogSegmentId(tpDirectory.getTopicIdPartition(), uuid);
            return new RemoteLogSegmentFileset(tpDirectory, id, files);
        } catch (IOException ex) {
            throw new RuntimeException(format("Unable to list the files in the directory '%s'", tpDirectory.getDirectory()), ex);
        }
    }
Creates a fileset instance for the physical set of files located under the given topic-partition directory.
The fileset MUST exist on the file system with the given uuid.

@param tpDirectory The topic-partition directory which this fileset's segment belongs to.
@param uuid The expected UUID of the fileset.
@return A new fileset instance.
storage/src/test/java/org/apache/kafka/server/log/remote/storage/RemoteLogSegmentFileset.java