use of org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator in project jackrabbit-oak by apache.
the class MarkSweepGarbageCollector method difference.
/**
* Difference phase where the GC candidates are identified.
*
* @param fs the garbage collector file state
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private void difference(GarbageCollectorFileState fs) throws IOException {
LOG.debug("Starting difference phase of the garbage collector");
FileLineDifferenceIterator iter = new FileLineDifferenceIterator(fs.getMarkedRefs(), fs.getAvailableRefs(), transformer);
int candidates = FileIOUtils.writeStrings(iter, fs.getGcCandidates(), true);
LOG.debug("Found candidates - " + candidates);
LOG.debug("Ending difference phase of the garbage collector");
}
use of org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator in project jackrabbit-oak by apache.
the class DataStoreCheckCommand method checkConsistency.
private static void checkConsistency(File ids, File refs, File missing) throws IOException {
System.out.println("Starting consistency check");
Stopwatch watch = createStarted();
FileLineDifferenceIterator iter = new FileLineDifferenceIterator(ids, refs, new Function<String, String>() {
@Nullable
@Override
public String apply(@Nullable String input) {
if (input != null) {
return input.split(DELIM)[0];
}
return "";
}
});
long candidates = writeStrings(iter, missing, true);
System.out.println("Consistency check found " + candidates + " missing blobs");
if (candidates > 0) {
System.out.println("Consistency check failure for the data store");
}
System.out.println("Finished in " + watch.elapsed(TimeUnit.SECONDS) + " seconds");
}
use of org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator in project jackrabbit-oak by apache.
the class MarkSweepGarbageCollector method checkConsistency.
/**
* Checks for the DataStore consistency and reports the number of missing blobs still referenced.
*
* @return the missing blobs
* @throws Exception
*/
@Override
public long checkConsistency() throws Exception {
boolean threw = true;
GarbageCollectorFileState fs = new GarbageCollectorFileState(root);
long candidates = 0;
try {
LOG.info("Starting blob consistency check");
// Find all blobs available in the blob store
ListenableFutureTask<Integer> blobIdRetriever = ListenableFutureTask.create(new BlobIdRetriever(fs, true));
executor.execute(blobIdRetriever);
// Mark all used blob references
iterateNodeTree(fs, true);
try {
blobIdRetriever.get();
} catch (ExecutionException e) {
LOG.warn("Error occurred while fetching all the blobIds from the BlobStore");
threw = false;
throw e;
}
LOG.trace("Starting difference phase of the consistency check");
FileLineDifferenceIterator iter = new FileLineDifferenceIterator(fs.getAvailableRefs(), fs.getMarkedRefs(), transformer);
candidates = FileIOUtils.writeStrings(iter, fs.getGcCandidates(), true);
LOG.trace("Ending difference phase of the consistency check");
LOG.info("Consistency check found [{}] missing blobs", candidates);
if (candidates > 0) {
LOG.warn("Consistency check failure in the the blob store : {}, check missing candidates in file {}", blobStore, fs.getGcCandidates().getAbsolutePath());
}
} finally {
if (!LOG.isTraceEnabled() && candidates == 0) {
Closeables.close(fs, threw);
}
}
return candidates;
}
Aggregations