Search in sources :

Example 1 with SegmentStore

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

the class StandbyStoreService method activate.

@Activate
private void activate(ComponentContext context) {
    SegmentStore segmentStore = storeProvider.getSegmentStore();
    if (!(segmentStore instanceof FileStore)) {
        throw new IllegalArgumentException("Unexpected SegmentStore implementation");
    }
    FileStore fileStore = (FileStore) segmentStore;
    String mode = valueOf(context.getProperties().get(MODE));
    if (MODE_PRIMARY.equals(mode)) {
        bootstrapMaster(context, fileStore);
        return;
    }
    if (MODE_STANDBY.equals(mode)) {
        bootstrapSlave(context, fileStore);
        return;
    }
    throw new IllegalArgumentException(String.format("Unexpected mode property, got '%s'", mode));
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) SegmentStore(org.apache.jackrabbit.oak.segment.SegmentStore) Activate(org.apache.felix.scr.annotations.Activate)

Example 2 with SegmentStore

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

the class StandbyTestUtils method mockSegment.

public static Segment mockSegment(UUID uuid, byte[] buffer) {
    SegmentStore store = mock(SegmentStore.class);
    SegmentIdProvider idProvider = mock(SegmentIdProvider.class);
    SegmentReader reader = mock(SegmentReader.class);
    long msb = uuid.getMostSignificantBits();
    long lsb = uuid.getLeastSignificantBits();
    SegmentId id = new SegmentId(store, msb, lsb);
    ByteBuffer data = ByteBuffer.wrap(buffer);
    return new Segment(idProvider, reader, id, data);
}
Also used : SegmentId(org.apache.jackrabbit.oak.segment.SegmentId) SegmentIdProvider(org.apache.jackrabbit.oak.segment.SegmentIdProvider) ByteBuffer(java.nio.ByteBuffer) SegmentReader(org.apache.jackrabbit.oak.segment.SegmentReader) Segment(org.apache.jackrabbit.oak.segment.Segment) SegmentStore(org.apache.jackrabbit.oak.segment.SegmentStore)

Aggregations

SegmentStore (org.apache.jackrabbit.oak.segment.SegmentStore)2 ByteBuffer (java.nio.ByteBuffer)1 Activate (org.apache.felix.scr.annotations.Activate)1 Segment (org.apache.jackrabbit.oak.segment.Segment)1 SegmentId (org.apache.jackrabbit.oak.segment.SegmentId)1 SegmentIdProvider (org.apache.jackrabbit.oak.segment.SegmentIdProvider)1 SegmentReader (org.apache.jackrabbit.oak.segment.SegmentReader)1 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)1