private String[] getIndexFiles() throws IOException { String[] indexFiles = storeConfig.getIndexPath().list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".snapshot"); } }); if (indexFiles == null) { throw new IOException("can't list file in " + storeConfig.getIndexPath()); } if (indexFiles.length == 0) { return null; } Arrays.sort(indexFiles, new Comparator<String>() { @Override public int compare(String left, String right) { return left.compareTo(right); } }); return indexFiles; }
private String[] getIndexFiles() throws IOException { String[] indexFiles = storeConfig.getIndexPath().list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".snapshot"); } }); if (indexFiles == null) { throw new IOException("can't list file in " + storeConfig.getIndexPath()); } if (indexFiles.length == 0) { return null; } Arrays.sort(indexFiles, new Comparator<String>() { @Override public int compare(String left, String right) { return left.compareTo(right); } }); return indexFiles; }
/** * 删除多余的快照数目 */ private void deleteOverSnapshot() throws IOException { String[] indexFiles = getIndexFiles(); if (indexFiles == null || indexFiles.length == 0) { return; } if (storeConfig.getMaxIndexSnapshotSize() > 1 && indexFiles.length > storeConfig.getMaxIndexSnapshotSize()) { for (int i = 0; i < indexFiles.length - storeConfig.getMaxIndexSnapshotSize(); i++) { FileUtils.delete(new File(storeConfig.getIndexPath(), indexFiles[i])); LOGGER.info("delete index snapshot [" + indexFiles[i] + "] succeed"); } } } }
/** * 删除多余的快照数目 */ private void deleteOverSnapshot() throws IOException { String[] indexFiles = getIndexFiles(); if (indexFiles == null || indexFiles.length == 0) { return; } if (storeConfig.getMaxIndexSnapshotSize() > 1 && indexFiles.length > storeConfig.getMaxIndexSnapshotSize()) { for (int i = 0; i < indexFiles.length - storeConfig.getMaxIndexSnapshotSize(); i++) { FileUtils.delete(new File(storeConfig.getIndexPath(), indexFiles[i])); LOGGER.info("delete index snapshot [" + indexFiles[i] + "] succeed"); } } } }
File snapshot = new File(storeConfig.getIndexPath(), name); FileChannel fileChannel = FileUtils.newFileChannel(snapshot, "rw");
File snapshot = new File(storeConfig.getIndexPath(), name); FileChannel fileChannel = FileUtils.newFileChannel(snapshot, "rw");
@Override protected void loadFromDisk() throws IOException { FileUtils.createDirIfNotExist(storeConfig.getIndexPath()); File lastSnapshot = new File(storeConfig.getIndexPath(), indexFiles[indexFiles.length - 1]); fileChannel = FileUtils.newFileChannel(lastSnapshot, "rw"); IndexSnapshotFileHeader fileHeader = new IndexSnapshotFileHeader();
@Override protected void loadFromDisk() throws IOException { FileUtils.createDirIfNotExist(storeConfig.getIndexPath()); File lastSnapshot = new File(storeConfig.getIndexPath(), indexFiles[indexFiles.length - 1]); fileChannel = FileUtils.newFileChannel(lastSnapshot, "rw"); IndexSnapshotFileHeader fileHeader = new IndexSnapshotFileHeader();
private String[] getIndexFiles() throws IOException { String[] indexFiles = storeConfig.getIndexPath().list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".snapshot"); } }); if (indexFiles == null) { throw new IOException("can't list file in " + storeConfig.getIndexPath()); } if (indexFiles.length == 0) { return null; } Arrays.sort(indexFiles, new Comparator<String>() { @Override public int compare(String left, String right) { return left.compareTo(right); } }); return indexFiles; }
/** * 删除多余的快照数目 */ private void deleteOverSnapshot() throws IOException { String[] indexFiles = getIndexFiles(); if (indexFiles == null || indexFiles.length == 0) { return; } if (storeConfig.getMaxIndexSnapshotSize() > 1 && indexFiles.length > storeConfig.getMaxIndexSnapshotSize()) { for (int i = 0; i < indexFiles.length - storeConfig.getMaxIndexSnapshotSize(); i++) { FileUtils.delete(new File(storeConfig.getIndexPath(), indexFiles[i])); LOGGER.info("delete index snapshot [" + indexFiles[i] + "] succeed"); } } } }
File snapshot = new File(storeConfig.getIndexPath(), name); FileChannel fileChannel = FileUtils.newFileChannel(snapshot, "rw");
@Override protected void loadFromDisk() throws IOException { FileUtils.createDirIfNotExist(storeConfig.getIndexPath()); File lastSnapshot = new File(storeConfig.getIndexPath(), indexFiles[indexFiles.length - 1]); fileChannel = FileUtils.newFileChannel(lastSnapshot, "rw"); IndexSnapshotFileHeader fileHeader = new IndexSnapshotFileHeader();