Search in sources :

Example 11 with SegmentId

use of org.apache.jackrabbit.oak.segment.SegmentId in project jackrabbit-oak by apache.

the class DefaultStandbySegmentReader method readSegment.

@Override
public byte[] readSegment(String id) {
    UUID uuid = UUID.fromString(id);
    long msb = uuid.getMostSignificantBits();
    long lsb = uuid.getLeastSignificantBits();
    SegmentId segmentId = store.getSegmentIdProvider().newSegmentId(msb, lsb);
    if (store.containsSegment(segmentId)) {
        Segment segment = store.readSegment(segmentId);
        try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
            segment.writeTo(stream);
            return stream.toByteArray();
        } catch (IOException e) {
            log.warn("Error while reading segment content", e);
            return null;
        }
    }
    return null;
}
Also used : SegmentId(org.apache.jackrabbit.oak.segment.SegmentId) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) IOException(java.io.IOException) UUID(java.util.UUID) Segment(org.apache.jackrabbit.oak.segment.Segment)

Aggregations

SegmentId (org.apache.jackrabbit.oak.segment.SegmentId)11 UUID (java.util.UUID)6 Segment (org.apache.jackrabbit.oak.segment.Segment)5 ArrayList (java.util.ArrayList)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 IOException (java.io.IOException)2 RecordId (org.apache.jackrabbit.oak.segment.RecordId)2 SegmentNodeState (org.apache.jackrabbit.oak.segment.SegmentNodeState)2 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)2 File (java.io.File)1 ByteBuffer (java.nio.ByteBuffer)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)1 Blob (org.apache.jackrabbit.oak.api.Blob)1 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 RecordId.fromString (org.apache.jackrabbit.oak.segment.RecordId.fromString)1 RecordType (org.apache.jackrabbit.oak.segment.RecordType)1 RecordUsageAnalyser (org.apache.jackrabbit.oak.segment.RecordUsageAnalyser)1 SegmentBlob (org.apache.jackrabbit.oak.segment.SegmentBlob)1