WritableIndexSnapshotFileIterator( File indexDirectory, SnapshotDeletionPolicy snapshotDeletionPolicy ) throws IOException { super( indexDirectory, snapshotDeletionPolicy.snapshot() ); this.snapshotDeletionPolicy = snapshotDeletionPolicy; }
/** * Snapshots the last commit. Once this method returns, the * snapshot information is persisted in the directory. * * @see SnapshotDeletionPolicy#snapshot */ @Override public synchronized IndexCommit snapshot() throws IOException { IndexCommit ic = super.snapshot(); boolean success = false; try { persist(); success = true; } finally { if (!success) { try { super.release(ic); } catch (Exception e) { // Suppress so we keep throwing original exception } } } return ic; }
FromCommit(final Path directoryPath, final SnapshotDeletionPolicy indexSnapshots) throws IOException { this(directoryPath, indexSnapshots, indexSnapshots.snapshot()); }
public IndexCommit backupIndex() { LoggingUtil.debug("Snapshotting at " + System.currentTimeMillis()/1000); return (IndexCommit)masterDeletionPolicy.snapshot(); }
/** * Snapshots the last commit. Once this method returns, the * snapshot information is persisted in the directory. * * @see SnapshotDeletionPolicy#snapshot */ @Override public synchronized IndexCommit snapshot() throws IOException { IndexCommit ic = super.snapshot(); boolean success = false; try { persist(); success = true; } finally { if (!success) { try { super.release(ic); } catch (Exception e) { // Suppress so we keep throwing original exception } } } return ic; }
@Override public IndexCommit acquireIndexCommit(final boolean flushFirst) throws EngineException { // we have to flush outside of the readlock otherwise we might have a problem upgrading // the to a write lock when we fail the engine in this operation if (flushFirst) { logger.trace("start flush for snapshot"); flush(false, true); logger.trace("finish flush for snapshot"); } try (ReleasableLock lock = readLock.acquire()) { ensureOpen(); logger.trace("pulling snapshot"); return deletionPolicy.snapshot(); } catch (IOException e) { throw new SnapshotFailedEngineException(shardId, e); } }
/** * Snapshots the last commit. Once this method returns, the * snapshot information is persisted in the directory. * * @see SnapshotDeletionPolicy#snapshot */ @Override public synchronized IndexCommit snapshot() throws IOException { IndexCommit ic = super.snapshot(); boolean success = false; try { persist(); success = true; } finally { if (!success) { try { super.release(ic); } catch (Exception e) { // Suppress so we keep throwing original exception } } } return ic; }
@Override public IndexCommit acquireIndexCommit(final boolean flushFirst) throws EngineException { // we have to flush outside of the readlock otherwise we might have a problem upgrading // the to a write lock when we fail the engine in this operation if (flushFirst) { logger.trace("start flush for snapshot"); flush(false, true); logger.trace("finish flush for snapshot"); } try (ReleasableLock lock = readLock.acquire()) { ensureOpen(); logger.trace("pulling snapshot"); return deletionPolicy.snapshot(); } catch (IOException e) { throw new SnapshotFailedEngineException(shardId, e); } }
/** * Snapshots the last commit. Once this method returns, the * snapshot information is persisted in the directory. * * @see SnapshotDeletionPolicy#snapshot */ @Override public synchronized IndexCommit snapshot() throws IOException { IndexCommit ic = super.snapshot(); boolean success = false; try { persist(); success = true; } finally { if (!success) { try { super.release(ic); } catch (Exception e) { // Suppress so we keep throwing original exception } } } return ic; }
commit = snapshotter.snapshot();
@Override public void snapshot(Directory destDir) throws IOException { assertWriterNotClosed(); try (Ticker ignored = snapShotIndexMetric.start()) { final IndexCommit snapshot = snapshotter.snapshot(); try { for (String fileName : snapshot.getFileNames()) { snapshot.getDirectory().copy(destDir, fileName, fileName, IOContext.DEFAULT); } } finally { snapshotter.release(snapshot); } } }
indexCommit = deletionPolicy.snapshot(); return store.getMetadata(indexCommit); } finally {
private void handleBackup(Operation op, BackupRequest req) throws Throwable { SnapshotDeletionPolicy snapshotter = null; IndexCommit commit = null; handleMaintenanceImpl(true); IndexWriter w = this.writer; if (w == null) { op.fail(new CancellationException()); return; } try { // Create a snapshot so the index files won't be deleted. snapshotter = (SnapshotDeletionPolicy) w.getConfig().getIndexDeletionPolicy(); commit = snapshotter.snapshot(); String indexDirectory = UriUtils.buildUriPath(getHost().getStorageSandbox().getPath(), FILE_PATH_LUCENE); // Add the files in the commit to a zip file. List<URI> fileList = FileUtils.filesToUris(indexDirectory, commit.getFileNames()); req.backupFile = FileUtils.zipFiles(fileList, this.indexDirectory + "-" + Utils.getNowMicrosUtc()); op.setBody(req).complete(); } catch (Exception e) { this.logSevere(e); throw e; } finally { if (snapshotter != null) { snapshotter.release(commit); } w.deleteUnusedFiles(); } }