private long getCommitVersion() throws IOException { List<IndexCommit> commits = DirectoryReader.listCommits(indexDir); if (commits.size() > 1) { throw new IllegalStateException("IndexDeletionPolicy changed, normally only one commit should be stored"); } IndexCommit commit = commits.get(0); return commit.getGeneration(); }
/** * Create index snapshot iterator for a read only index. * @param indexFolder index location folder * @param directory index directory * @return index file name resource iterator * @throws IOException */ public static ResourceIterator<File> forIndex( File indexFolder, Directory directory ) throws IOException { if ( !hasCommits( directory ) ) { return emptyResourceIterator(); } Collection<IndexCommit> indexCommits = DirectoryReader.listCommits( directory ); IndexCommit indexCommit = Iterables.last( indexCommits ); return new ReadOnlyIndexSnapshotFileIterator( indexFolder, indexCommit ); }
final Collection<IndexCommit> commits = DirectoryReader.listCommits(dir); if (commits.size() > 1) { throw new IllegalArgumentException("This tool was invoked to not delete prior commit points, but the following commits were found: " + commits);
private UpdateSequence getUpdateSequence(final Directory dir) throws IOException { if (!DirectoryReader.indexExists(dir)) { return UpdateSequence.START; } final List<IndexCommit> commits = DirectoryReader.listCommits(dir); final IndexCommit latest = commits.get(commits.size() - 1); return getUpdateSequence(latest.getUserData()); }
metadataLock.writeLock().lock(); try { final List<IndexCommit> existingCommits = DirectoryReader.listCommits(directory); if (existingCommits.isEmpty()) { throw new IllegalArgumentException("No index found to trim");
try { terminal.println("Reading translog UUID information from Lucene commit from shard at [" + indexPath + "]"); commits = DirectoryReader.listCommits(indexDirectory); } catch (IndexNotFoundException infe) { throw new ElasticsearchException("unable to find a valid shard at [" + indexPath + "]", infe);
public Tuple<RemoveCorruptedShardDataCommand.CleanStatus, String> getCleanStatus(ShardPath shardPath, Directory indexDirectory) throws IOException { final Path indexPath = shardPath.resolveIndex(); final Path translogPath = shardPath.resolveTranslog(); final List<IndexCommit> commits; try { commits = DirectoryReader.listCommits(indexDirectory); } catch (IndexNotFoundException infe) { throw new ElasticsearchException("unable to find a valid shard at [" + indexPath + "]", infe); } // Retrieve the generation and UUID from the existing data final Map<String, String> commitData = new HashMap<>(commits.get(commits.size() - 1).getUserData()); final String translogUUID = commitData.get(Translog.TRANSLOG_UUID_KEY); if (translogUUID == null) { throw new ElasticsearchException("shard must have a valid translog UUID but got: [null]"); } final boolean clean = isTranslogClean(shardPath, translogUUID); if (clean) { return Tuple.tuple(RemoveCorruptedShardDataCommand.CleanStatus.CLEAN, null); } // Hold the lock open for the duration of the tool running Set<Path> translogFiles; try { translogFiles = filesInDirectory(translogPath); } catch (IOException e) { throw new ElasticsearchException("failed to find existing translog files", e); } final String details = deletingFilesDetails(translogPath, translogFiles); return Tuple.tuple(RemoveCorruptedShardDataCommand.CleanStatus.CORRUPTED, details); }
final String translogUUID = store.readLastCommittedSegmentsInfo().getUserData().get(Translog.TRANSLOG_UUID_KEY); final long globalCheckpoint = Translog.readGlobalCheckpoint(recoveryTarget.translogLocation(), translogUUID); final List<IndexCommit> existingCommits = DirectoryReader.listCommits(store.directory()); final IndexCommit safeCommit = CombinedDeletionPolicy.findSafeCommitPoint(existingCommits, globalCheckpoint); final SequenceNumbers.CommitInfo seqNoStats = Store.loadSeqNoInfo(safeCommit);
public static IndexCommit findIndexCommit(Directory dir, String userData) throws IOException { Collection<IndexCommit> commits = DirectoryReader.listCommits(dir); for (final IndexCommit ic : commits) { Map<String,String> map = ic.getUserData(); String ud = null; if (map != null) { ud = map.get(USER_DATA); } if (ud != null && ud.equals(userData)) { return ic; } } throw new IOException("index does not contain commit with userData: " + userData); } }
private static long getLatestGeneration(Directory directory) throws IOException { if (DirectoryReader.indexExists(directory)) { List<IndexCommit> commits = DirectoryReader.listCommits(directory); if (!commits.isEmpty()) { //Look for that last commit as list is sorted from oldest to latest return commits.get(commits.size() - 1).getGeneration(); } } return -1; }
private static long getLatestGeneration(Directory directory) throws IOException { if (DirectoryReader.indexExists(directory)) { List<IndexCommit> commits = DirectoryReader.listCommits(directory); if (!commits.isEmpty()) { //Look for that last commit as list is sorted from oldest to latest return commits.get(commits.size() - 1).getGeneration(); } } return -1; }
public List<String> getIndexFiles(Directory dir) { List<IndexCommit> commits; try { commits = DirectoryReader.listCommits(dir); } catch (IndexNotFoundException e) { return Collections.emptyList(); } catch (IOException e) { return Collections.emptyList(); } Set<String> known = new HashSet<String>(); try { for (IndexCommit ic : commits) { known.addAll(ic.getFileNames()); } if (dir.fileExists(IndexFileNames.SEGMENTS_GEN)) { known.add(IndexFileNames.SEGMENTS_GEN); } } catch (IOException e) { // ignore } return new ArrayList<String>(known); }
List<IndexCommit> commits = DirectoryReader.listCommits(dir); if (commits != null && !commits.isEmpty()) { String lastCommitDate = commits.get(commits.size()-1).getUserData().get(LuceneIndexIO.LAST_COMMIT_DATE);
public Tuple<RemoveCorruptedShardDataCommand.CleanStatus, String> getCleanStatus(ShardPath shardPath, Directory indexDirectory) throws IOException { final Path indexPath = shardPath.resolveIndex(); final Path translogPath = shardPath.resolveTranslog(); final List<IndexCommit> commits; try { commits = DirectoryReader.listCommits(indexDirectory); } catch (IndexNotFoundException infe) { throw new ElasticsearchException("unable to find a valid shard at [" + indexPath + "]", infe); } // Retrieve the generation and UUID from the existing data final Map<String, String> commitData = new HashMap<>(commits.get(commits.size() - 1).getUserData()); final String translogUUID = commitData.get(Translog.TRANSLOG_UUID_KEY); if (translogUUID == null) { throw new ElasticsearchException("shard must have a valid translog UUID but got: [null]"); } final boolean clean = isTranslogClean(shardPath, translogUUID); if (clean) { return Tuple.tuple(RemoveCorruptedShardDataCommand.CleanStatus.CLEAN, null); } // Hold the lock open for the duration of the tool running Set<Path> translogFiles; try { translogFiles = filesInDirectory(translogPath); } catch (IOException e) { throw new ElasticsearchException("failed to find existing translog files", e); } final String details = deletingFilesDetails(translogPath, translogFiles); return Tuple.tuple(RemoveCorruptedShardDataCommand.CleanStatus.CORRUPTED, details); }
public Tuple<RemoveCorruptedShardDataCommand.CleanStatus, String> getCleanStatus(ShardPath shardPath, Directory indexDirectory) throws IOException { final Path indexPath = shardPath.resolveIndex(); final Path translogPath = shardPath.resolveTranslog(); final List<IndexCommit> commits; try { commits = DirectoryReader.listCommits(indexDirectory); } catch (IndexNotFoundException infe) { throw new ElasticsearchException("unable to find a valid shard at [" + indexPath + "]", infe); } // Retrieve the generation and UUID from the existing data final Map<String, String> commitData = new HashMap<>(commits.get(commits.size() - 1).getUserData()); final String translogUUID = commitData.get(Translog.TRANSLOG_UUID_KEY); if (translogUUID == null) { throw new ElasticsearchException("shard must have a valid translog UUID but got: [null]"); } final boolean clean = isTranslogClean(shardPath, translogUUID); if (clean) { return Tuple.tuple(RemoveCorruptedShardDataCommand.CleanStatus.CLEAN, null); } // Hold the lock open for the duration of the tool running Set<Path> translogFiles; try { translogFiles = filesInDirectory(translogPath); } catch (IOException e) { throw new ElasticsearchException("failed to find existing translog files", e); } final String details = deletingFilesDetails(translogPath, translogFiles); return Tuple.tuple(RemoveCorruptedShardDataCommand.CleanStatus.CORRUPTED, details); }
final String translogUUID = store.readLastCommittedSegmentsInfo().getUserData().get(Translog.TRANSLOG_UUID_KEY); final long globalCheckpoint = Translog.readGlobalCheckpoint(recoveryTarget.translogLocation(), translogUUID); final List<IndexCommit> existingCommits = DirectoryReader.listCommits(store.directory()); final IndexCommit safeCommit = CombinedDeletionPolicy.findSafeCommitPoint(existingCommits, globalCheckpoint); final SequenceNumbers.CommitInfo seqNoStats = Store.loadSeqNoInfo(safeCommit);
final String translogUUID = store.readLastCommittedSegmentsInfo().getUserData().get(Translog.TRANSLOG_UUID_KEY); final long globalCheckpoint = Translog.readGlobalCheckpoint(recoveryTarget.translogLocation(), translogUUID); final List<IndexCommit> existingCommits = DirectoryReader.listCommits(store.directory()); final IndexCommit safeCommit = CombinedDeletionPolicy.findSafeCommitPoint(existingCommits, globalCheckpoint); final SequenceNumbers.CommitInfo seqNoStats = Store.loadSeqNoInfo(safeCommit);
final Collection<IndexCommit> commits = DirectoryReader.listCommits(dir); if (commits.size() > 1) { throw new IllegalArgumentException("This tool was invoked to not delete prior commit points, but the following commits were found: " + commits);
final Collection<IndexCommit> commits = DirectoryReader.listCommits(dir); if (commits.size() > 1) { throw new IllegalArgumentException("This tool was invoked to not delete prior commit points, but the following commits were found: " + commits);
final Collection<IndexCommit> commits = DirectoryReader.listCommits(dir); if (commits.size() > 1) { throw new IllegalArgumentException("This tool was invoked to not delete prior commit points, but the following commits were found: " + commits);