Search in sources :

Example 1 with WriteStreamProfiler

use of com.cinchapi.concourse.server.storage.WriteStreamProfiler in project concourse by cinchapi.

the class Database method repair.

@Override
public void repair() {
    masterLock.writeLock().lock();
    try {
        WriteStreamProfiler<Segment> profiler = new WriteStreamProfiler<>(segments);
        Map<Segment, Segment> deduped = profiler.deduplicate(() -> Segment.create());
        if (!deduped.isEmpty()) {
            for (int i = 0; i < segments.size(); ++i) {
                Segment segment = segments.get(i);
                Segment clean = deduped.get(segment);
                if (clean != null) {
                    clean.transfer(storage.directory().resolve(UUID.randomUUID() + ".seg"));
                    segments.set(i, clean);
                    segment.delete();
                }
            }
            int total = profiler.duplicates().size();
            Logger.warn("Replaced {} Segments that contained duplicate data. In total, across all Segments, there were {} Write{} duplicated.", deduped.size(), total, total != 1 ? "s" : "");
        }
    } finally {
        masterLock.writeLock().unlock();
    }
}
Also used : WriteStreamProfiler(com.cinchapi.concourse.server.storage.WriteStreamProfiler) Segment(com.cinchapi.concourse.server.storage.db.kernel.Segment)

Aggregations

WriteStreamProfiler (com.cinchapi.concourse.server.storage.WriteStreamProfiler)1 Segment (com.cinchapi.concourse.server.storage.db.kernel.Segment)1