use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class AbstractLuceneIndex method isOnline.
/**
* Check if this index is marked as online.
*
* @return <code>true</code> if index is online, <code>false</code> otherwise
* @throws IOException
*/
public boolean isOnline() throws IOException {
ensureOpen();
AbstractIndexPartition partition = getFirstPartition(getPartitions());
Directory directory = partition.getDirectory();
try (DirectoryReader reader = DirectoryReader.open(directory)) {
Map<String, String> userData = reader.getIndexCommit().getUserData();
return ONLINE.equals(userData.get(KEY_STATUS));
}
}
use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class AbstractLuceneIndex method allDocumentsReader.
/**
* Creates an iterable over all {@link Document document}s in all partitions.
*
* @return LuceneAllDocumentsReader over all documents
*/
public LuceneAllDocumentsReader allDocumentsReader() {
ensureOpen();
List<SearcherReference> searchers = new ArrayList<>(partitions.size());
try {
for (AbstractIndexPartition partition : partitions) {
searchers.add(partition.acquireSearcher());
}
List<LucenePartitionAllDocumentsReader> partitionReaders = searchers.stream().map(LucenePartitionAllDocumentsReader::new).collect(toList());
return new LuceneAllDocumentsReader(partitionReaders);
} catch (IOException e) {
IOUtils.closeAllSilently(searchers);
throw new UncheckedIOException(e);
}
}
use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.
the class AbstractLuceneIndex method snapshot.
/**
* Snapshot of all file in all index partitions.
*
* @return iterator over all index files.
* @throws IOException
* @see WritableIndexSnapshotFileIterator
*/
public ResourceIterator<Path> snapshot() throws IOException {
ensureOpen();
List<ResourceIterator<Path>> snapshotIterators = null;
try {
List<AbstractIndexPartition> partitions = getPartitions();
snapshotIterators = new ArrayList<>(partitions.size());
for (AbstractIndexPartition partition : partitions) {
snapshotIterators.add(partition.snapshot());
}
return Iterators.concatResourceIterators(snapshotIterators.iterator());
} catch (Exception e) {
if (snapshotIterators != null) {
try {
IOUtils.closeAll(snapshotIterators);
} catch (IOException ex) {
e.addSuppressed(ex);
}
}
throw e;
}
}
Aggregations