@Override public void onInit(List<? extends IndexCommit> commits) throws IOException { verifyCommitOrder(commits); numOnInit++; // On init, delete all commit points: for (final IndexCommit commit : commits) { commit.delete(); assertTrue(commit.isDeleted()); } }
@Override public void delete() { synchronized (SnapshotDeletionPolicy.this) { // Suppress the delete request if this commit point is // currently snapshotted. if (shouldDelete(getSegmentsFileName())) { cp.delete(); } } }
@Override public void onCommit(List<? extends IndexCommit> commits) throws IOException { verifyCommitOrder(commits); IndexCommit lastCommit = commits.get(commits.size() - 1); // Any commit older than expireTime should be deleted: double expireTime = getCommitTime(lastCommit) / 1000.0 - expirationTimeSeconds; for (final IndexCommit commit : commits) { double modTime = getCommitTime(commit) / 1000.0; if (commit != lastCommit && modTime < expireTime) { commit.delete(); numDelete += 1; } } }