use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker in project jackrabbit-oak by apache.
the class LuceneIndexMBeanImpl method getConsistencyCheckResult.
private Result getConsistencyCheckResult(String indexPath, boolean fullCheck) throws IOException {
NodeState root = nodeStore.getRoot();
Level level = fullCheck ? Level.FULL : Level.BLOBS_ONLY;
IndexConsistencyChecker checker = new IndexConsistencyChecker(root, indexPath, workDir);
return checker.check(level);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker in project jackrabbit-oak by apache.
the class IndexConsistencyCheckPrinter method print.
@Override
public void print(PrintWriter pw, Format format, boolean isZip) {
Stopwatch watch = Stopwatch.createStarted();
NodeState root = indexHelper.getNodeStore().getRoot();
List<String> validIndexes = new ArrayList<>();
List<String> invalidIndexes = new ArrayList<>();
List<String> ignoredIndexes = new ArrayList<>();
for (String indexPath : indexHelper.getIndexPathService().getIndexPaths()) {
NodeState indexState = NodeStateUtils.getNode(root, indexPath);
if (!TYPE_LUCENE.equals(indexState.getString(TYPE_PROPERTY_NAME))) {
ignoredIndexes.add(indexPath);
continue;
}
IndexConsistencyChecker checker = new IndexConsistencyChecker(root, indexPath, indexHelper.getWorkDir());
checker.setPrintStream(new PrintStream(new WriterOutputStream(pw, Charsets.UTF_8)));
try {
IndexConsistencyChecker.Result result = checker.check(level);
result.dump(pw);
if (result.clean) {
validIndexes.add(indexPath);
} else {
invalidIndexes.add(indexPath);
}
System.out.printf("%s => %s%n", indexPath, result.clean ? "valid" : "invalid <==");
} catch (IOException e) {
pw.printf("Error occurred while performing consistency check for index [%s]%n", indexPath);
e.printStackTrace(pw);
}
pw.println();
}
print(validIndexes, "Valid indexes :", pw);
print(invalidIndexes, "Invalid indexes :", pw);
print(ignoredIndexes, "Ignored indexes as these are not of type lucene:", pw);
pw.printf("Time taken %s%n", watch);
}
Aggregations