private String format() { return String.format("%s:[%s,%d,%d][%d]", type.toString(), absolutePath(), updateTime, numFiles, checksum); }
private String format() { return String.format("%s:[%s,%d,%d][%d]", type.toString(), absolutePath(), updateTime, numFiles, checksum); }
private String format() { return String.format("%s:[%s,%d,%d][%d]", type.toString(), absolutePath(), updateTime, numFiles, checksum); }
private String format() { return String.format("%s:[%s,%d,%d][%d]", type.toString(), absolutePath(), updateTime, numFiles, checksum); }
long computeChecksum() { CRC32 crc32 = new CRC32(); crc32.update((absolutePath()).getBytes(FileUtils.CHARSET)); crc32.update(type.toString().getBytes(FileUtils.CHARSET)); FBUtilities.updateChecksumInt(crc32, (int) updateTime); FBUtilities.updateChecksumInt(crc32, (int) (updateTime >>> 32)); FBUtilities.updateChecksumInt(crc32, numFiles); return crc32.getValue() & (Long.MAX_VALUE); }
long computeChecksum() { CRC32 crc32 = new CRC32(); crc32.update((absolutePath()).getBytes(FileUtils.CHARSET)); crc32.update(type.toString().getBytes(FileUtils.CHARSET)); FBUtilities.updateChecksumInt(crc32, (int) updateTime); FBUtilities.updateChecksumInt(crc32, (int) (updateTime >>> 32)); FBUtilities.updateChecksumInt(crc32, numFiles); return crc32.getValue() & (Long.MAX_VALUE); }
long computeChecksum() { CRC32 crc32 = new CRC32(); crc32.update((absolutePath()).getBytes(FileUtils.CHARSET)); crc32.update(type.toString().getBytes(FileUtils.CHARSET)); FBUtilities.updateChecksumInt(crc32, (int) updateTime); FBUtilities.updateChecksumInt(crc32, (int) (updateTime >>> 32)); FBUtilities.updateChecksumInt(crc32, numFiles); return crc32.getValue() & (Long.MAX_VALUE); } }
long computeChecksum() { CRC32 crc32 = new CRC32(); crc32.update((absolutePath()).getBytes(FileUtils.CHARSET)); crc32.update(type.toString().getBytes(FileUtils.CHARSET)); FBUtilities.updateChecksumInt(crc32, (int) updateTime); FBUtilities.updateChecksumInt(crc32, (int) (updateTime >>> 32)); FBUtilities.updateChecksumInt(crc32, numFiles); return crc32.getValue() & (Long.MAX_VALUE); } }
/** * 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 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); }