/** * Compress the store by creating a new file and copying the live pages * there. Temporarily, a file with the suffix ".tempFile" is created. This * file is then renamed, replacing the original file, if possible. If not, * the new file is renamed to ".newFile", then the old file is removed, and * the new file is renamed. This might be interrupted, so it's better to * compactCleanUp before opening a store, in case this method was used. * * @param fileName the file name * @param compress whether to compress the data */ public static void compact(String fileName, boolean compress) { String tempName = fileName + Constants.SUFFIX_MV_STORE_TEMP_FILE; FileUtils.delete(tempName); compact(fileName, tempName, compress); try { FileUtils.moveAtomicReplace(tempName, fileName); } catch (DbException e) { String newName = fileName + Constants.SUFFIX_MV_STORE_NEW_FILE; FileUtils.delete(newName); FileUtils.move(tempName, newName); FileUtils.delete(fileName); FileUtils.move(newName, fileName); } }
MVStoreTool.compact(fileName, true);
/** * Copy all live pages from the source store to the target store. * * @param sourceFileName the name of the source store * @param targetFileName the name of the target store * @param compress whether to compress the data */ public static void compact(String sourceFileName, String targetFileName, boolean compress) { MVStore source = new MVStore.Builder(). fileName(sourceFileName). readOnly(). open(); FileUtils.delete(targetFileName); MVStore.Builder b = new MVStore.Builder(). fileName(targetFileName); if (compress) { b.compress(); } MVStore target = b.open(); compact(source, target); target.close(); source.close(); }
@Override synchronized void closeStore() { if (store == null) { return; } boolean compact = compactOnClose; try { if (store.getFileStore().isReadOnly()) { compact = false; } // clear the interrupted flag, if set Thread.interrupted(); store.close(); } catch (Exception e) { exceptionCount++; LOG.debug("Could not close the store", e); LOG.warn("Could not close the store: " + e); store.closeImmediately(); } if (compact) { try { MVStoreTool.compact(fileName, true); } catch (Exception e) { exceptionCount++; LOG.debug("Could not compact the store", e); LOG.warn("Could not compact the store: " + e); } } store = null; }
@Override synchronized void closeStore() { if (store == null) { return; } boolean compact = compactOnClose; try { if (store.getFileStore().isReadOnly()) { compact = false; } // clear the interrupted flag, if set Thread.interrupted(); store.close(); } catch (Exception e) { exceptionCount++; LOG.debug("Could not close the store", e); LOG.warn("Could not close the store: " + e); store.closeImmediately(); } if (compact) { try { MVStoreTool.compact(fileName, true); } catch (Exception e) { exceptionCount++; LOG.debug("Could not compact the store", e); LOG.warn("Could not compact the store: " + e); } } store = null; }
/** * Compress the store by creating a new file and copying the live pages * there. Temporarily, a file with the suffix ".tempFile" is created. This * file is then renamed, replacing the original file, if possible. If not, * the new file is renamed to ".newFile", then the old file is removed, and * the new file is renamed. This might be interrupted, so it's better to * compactCleanUp before opening a store, in case this method was used. * * @param fileName the file name * @param compress whether to compress the data */ public static void compact(String fileName, boolean compress) { String tempName = fileName + Constants.SUFFIX_MV_STORE_TEMP_FILE; FileUtils.delete(tempName); compact(fileName, tempName, compress); try { FileUtils.moveAtomicReplace(tempName, fileName); } catch (DbException e) { String newName = fileName + Constants.SUFFIX_MV_STORE_NEW_FILE; FileUtils.delete(newName); FileUtils.move(tempName, newName); FileUtils.delete(fileName); FileUtils.move(newName, fileName); } }
/** * Compress the store by creating a new file and copying the live pages * there. Temporarily, a file with the suffix ".tempFile" is created. This * file is then renamed, replacing the original file, if possible. If not, * the new file is renamed to ".newFile", then the old file is removed, and * the new file is renamed. This might be interrupted, so it's better to * compactCleanUp before opening a store, in case this method was used. * * @param fileName the file name * @param compress whether to compress the data */ public static void compact(String fileName, boolean compress) { String tempName = fileName + Constants.SUFFIX_MV_STORE_TEMP_FILE; FileUtils.delete(tempName); compact(fileName, tempName, compress); try { FileUtils.moveAtomicReplace(tempName, fileName); } catch (DbException e) { String newName = fileName + Constants.SUFFIX_MV_STORE_NEW_FILE; FileUtils.delete(newName); FileUtils.move(tempName, newName); FileUtils.delete(fileName); FileUtils.move(newName, fileName); } }
/** * Compress the store by creating a new file and copying the live pages * there. Temporarily, a file with the suffix ".tempFile" is created. This * file is then renamed, replacing the original file, if possible. If not, * the new file is renamed to ".newFile", then the old file is removed, and * the new file is renamed. This might be interrupted, so it's better to * compactCleanUp before opening a store, in case this method was used. * * @param fileName the file name * @param compress whether to compress the data */ public static void compact(String fileName, boolean compress) { String tempName = fileName + Constants.SUFFIX_MV_STORE_TEMP_FILE; FileUtils.delete(tempName); compact(fileName, tempName, compress); try { FileUtils.moveAtomicReplace(tempName, fileName); } catch (DbException e) { String newName = fileName + Constants.SUFFIX_MV_STORE_NEW_FILE; FileUtils.delete(newName); FileUtils.move(tempName, newName); FileUtils.delete(fileName); FileUtils.move(newName, fileName); } }
MVStoreTool.compact(fileName, true);
MVStoreTool.compact(fileName, true);
/** * Copy all live pages from the source store to the target store. * * @param sourceFileName the name of the source store * @param targetFileName the name of the target store * @param compress whether to compress the data */ public static void compact(String sourceFileName, String targetFileName, boolean compress) { MVStore source = new MVStore.Builder(). fileName(sourceFileName). readOnly(). open(); FileUtils.delete(targetFileName); MVStore.Builder b = new MVStore.Builder(). fileName(targetFileName); if (compress) { b.compress(); } MVStore target = b.open(); compact(source, target); target.close(); source.close(); }
/** * Copy all live pages from the source store to the target store. * * @param sourceFileName the name of the source store * @param targetFileName the name of the target store * @param compress whether to compress the data */ public static void compact(String sourceFileName, String targetFileName, boolean compress) { MVStore source = new MVStore.Builder(). fileName(sourceFileName). readOnly(). open(); FileUtils.delete(targetFileName); MVStore.Builder b = new MVStore.Builder(). fileName(targetFileName); if (compress) { b.compress(); } MVStore target = b.open(); compact(source, target); target.close(); source.close(); }
/** * Copy all live pages from the source store to the target store. * * @param sourceFileName the name of the source store * @param targetFileName the name of the target store * @param compress whether to compress the data */ public static void compact(String sourceFileName, String targetFileName, boolean compress) { MVStore source = new MVStore.Builder(). fileName(sourceFileName). readOnly(). open(); FileUtils.delete(targetFileName); MVStore.Builder b = new MVStore.Builder(). fileName(targetFileName); if (compress) { b.compress(); } MVStore target = b.open(); compact(source, target); target.close(); source.close(); }