Search in sources :

Example 1 with FileLineDifferenceIterator

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");
}
Also used : FileLineDifferenceIterator(org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator)

Example 2 with FileLineDifferenceIterator

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");
}
Also used : Stopwatch(com.google.common.base.Stopwatch) FileLineDifferenceIterator(org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator) Nullable(javax.annotation.Nullable)

Example 3 with FileLineDifferenceIterator

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;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FileLineDifferenceIterator(org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

FileLineDifferenceIterator (org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator)3 Stopwatch (com.google.common.base.Stopwatch)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Nullable (javax.annotation.Nullable)1