@Override public String toString() { return baseFilename(); }
@Override public String toString() { return baseFilename(); }
@Override public String toString() { return baseFilename(); }
@Override public String toString() { return baseFilename(); }
/** * @param suffix A component suffix, such as 'Data.db'/'Index.db'/etc * @return A filename for this descriptor with the given suffix. */ public String filenameFor(String suffix) { return baseFilename() + separator + suffix; }
@Override public String toString() { return baseFilename(); }
public String filenameFor(Component component) { return baseFilename() + separator + component.name(); }
public String filenameFor(Component component) { return baseFilename() + separator + component.name(); }
public String filenameFor(Component component) { return baseFilename() + separator + component.name(); }
public String filenameFor(Component component) { return baseFilename() + separator + component.name(); }
public void create(Collection<SSTableWriter> sstables) { List<String> sstablePaths = new ArrayList<>(sstables.size()); for (SSTableWriter writer : sstables) { /* write out the file names *without* the 'tmp-file' flag in the file name. this class will not need to clean up tmp files (on restart), CassandraDaemon does that already, just make sure we delete the fully-formed SSTRs. */ sstablePaths.add(writer.descriptor.asType(Descriptor.Type.FINAL).baseFilename()); } try { Files.write(lockfile.toPath(), sstablePaths, Charsets.UTF_8, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE, StandardOpenOption.DSYNC); } catch (IOException e) { logger.warn(String.format("Could not create lockfile %s for stream session, nothing to worry too much about", lockfile), e); } }
public static Map<SSTable, LogRecord> make(Type type, Iterable<SSTableReader> tables) { // contains a mapping from sstable absolute path (everything up until the 'Data'/'Index'/etc part of the filename) to the sstable Map<String, SSTable> absolutePaths = new HashMap<>(); for (SSTableReader table : tables) absolutePaths.put(absolutePath(table.descriptor.baseFilename()), table); // maps sstable base file name to the actual files on disk Map<String, List<File>> existingFiles = getExistingFiles(absolutePaths.keySet()); Map<SSTable, LogRecord> records = new HashMap<>(existingFiles.size()); for (Map.Entry<String, List<File>> entry : existingFiles.entrySet()) { List<File> filesOnDisk = entry.getValue(); String baseFileName = entry.getKey(); SSTable sstable = absolutePaths.get(baseFileName); records.put(sstable, make(type, filesOnDisk, sstable.getAllFilePaths().size(), baseFileName)); } return records; }
public static Collection<LogRecord> make(Type type, Iterable<SSTableReader> tables) { // contains a mapping from sstable absolute path (everything up until the 'Data'/'Index'/etc part of the filename) to the sstable Map<String, SSTable> absolutePaths = new HashMap<>(); for (SSTableReader table : tables) absolutePaths.put(absolutePath(table.descriptor.baseFilename()), table); // maps sstable base file name to the actual files on disk Map<String, List<File>> existingFiles = getExistingFiles(absolutePaths.keySet()); List<LogRecord> records = new ArrayList<>(existingFiles.size()); for (Map.Entry<String, List<File>> entry : existingFiles.entrySet()) { List<File> filesOnDisk = entry.getValue(); String baseFileName = entry.getKey(); SSTable sstable = absolutePaths.get(baseFileName); records.add(make(type, filesOnDisk, sstable.getAllFilePaths().size(), baseFileName)); } return records; }
public static Map<SSTable, LogRecord> make(Type type, Iterable<SSTableReader> tables) { // contains a mapping from sstable absolute path (everything up until the 'Data'/'Index'/etc part of the filename) to the sstable Map<String, SSTable> absolutePaths = new HashMap<>(); for (SSTableReader table : tables) absolutePaths.put(absolutePath(table.descriptor.baseFilename()), table); // maps sstable base file name to the actual files on disk Map<String, List<File>> existingFiles = getExistingFiles(absolutePaths.keySet()); Map<SSTable, LogRecord> records = new HashMap<>(existingFiles.size()); for (Map.Entry<String, List<File>> entry : existingFiles.entrySet()) { List<File> filesOnDisk = entry.getValue(); String baseFileName = entry.getKey(); SSTable sstable = absolutePaths.get(baseFileName); records.put(sstable, make(type, filesOnDisk, sstable.getAllFilePaths().size(), baseFileName)); } return records; }
/** * absoluteFilePaths contains full file parts up to the component name * * this method finds all files on disk beginning with any of the paths in absoluteFilePaths * @return a map from absoluteFilePath to actual file on disk. */ public static Map<String, List<File>> getExistingFiles(Set<String> absoluteFilePaths) { Set<File> uniqueDirectories = absoluteFilePaths.stream().map(path -> Paths.get(path).getParent().toFile()).collect(Collectors.toSet()); Map<String, List<File>> fileMap = new HashMap<>(); FilenameFilter ff = (dir, name) -> { Descriptor descriptor = null; try { descriptor = Descriptor.fromFilename(dir, name).left; } catch (Throwable t) {// ignored - if we can't parse the filename, just skip the file } String absolutePath = descriptor != null ? absolutePath(descriptor.baseFilename()) : null; if (absolutePath != null && absoluteFilePaths.contains(absolutePath)) fileMap.computeIfAbsent(absolutePath, k -> new ArrayList<>()).add(new File(dir, name)); return false; }; // populate the file map: for (File f : uniqueDirectories) f.listFiles(ff); return fileMap; }
/** * absoluteFilePaths contains full file parts up to the component name * * this method finds all files on disk beginning with any of the paths in absoluteFilePaths * @return a map from absoluteFilePath to actual file on disk. */ public static Map<String, List<File>> getExistingFiles(Set<String> absoluteFilePaths) { Set<File> uniqueDirectories = absoluteFilePaths.stream().map(path -> Paths.get(path).getParent().toFile()).collect(Collectors.toSet()); Map<String, List<File>> fileMap = new HashMap<>(); FilenameFilter ff = (dir, name) -> { Descriptor descriptor = null; try { descriptor = Descriptor.fromFilename(dir, name).left; } catch (Throwable t) {// ignored - if we can't parse the filename, just skip the file } String absolutePath = descriptor != null ? absolutePath(descriptor.baseFilename()) : null; if (absolutePath != null && absoluteFilePaths.contains(absolutePath)) fileMap.computeIfAbsent(absolutePath, k -> new ArrayList<>()).add(new File(dir, name)); return false; }; // populate the file map: for (File f : uniqueDirectories) f.listFiles(ff); return fileMap; }
public static LogRecord make(Type type, SSTable table) { // CASSANDRA-13294: add the sstable component separator because for legacy (2.1) files // there is no separator after the generation number, and this would cause files of sstables with // a higher generation number that starts with the same number, to be incorrectly classified as files // of this record sstable String absoluteTablePath = absolutePath(table.descriptor.baseFilename()); return make(type, getExistingFiles(absoluteTablePath), table.getAllFilePaths().size(), absoluteTablePath); }
public static LogRecord make(Type type, SSTable table) { // CASSANDRA-13294: add the sstable component separator because for legacy (2.1) files // there is no separator after the generation number, and this would cause files of sstables with // a higher generation number that starts with the same number, to be incorrectly classified as files // of this record sstable String absoluteTablePath = absolutePath(table.descriptor.baseFilename()); return make(type, getExistingFiles(absoluteTablePath), table.getAllFilePaths().size(), absoluteTablePath); }
public static LogRecord make(Type type, SSTable table) { // CASSANDRA-13294: add the sstable component separator because for legacy (2.1) files // there is no separator after the generation number, and this would cause files of sstables with // a higher generation number that starts with the same number, to be incorrectly classified as files // of this record sstable String absoluteTablePath = absolutePath(table.descriptor.baseFilename()); return make(type, getExistingFiles(absoluteTablePath), table.getAllFilePaths().size(), absoluteTablePath); }
public static LogRecord make(Type type, SSTable table) { String absoluteTablePath = FileUtils.getCanonicalPath(table.descriptor.baseFilename()); return make(type, getExistingFiles(absoluteTablePath), table.getAllFilePaths().size(), absoluteTablePath); }