Search in sources :

Example 1 with NodeStoreProvider

use of org.apache.jackrabbit.oak.spi.state.NodeStoreProvider in project jackrabbit-oak by apache.

the class SecondaryStoreCacheServiceTest method configureDefaultServices.

@Before
public void configureDefaultServices() {
    context.registerService(BlobStore.class, new MemoryBlobStore());
    context.registerService(NodeStoreProvider.class, new NodeStoreProvider() {

        @Override
        public NodeStore getNodeStore() {
            return secondaryStore;
        }
    }, ImmutableMap.<String, Object>of("role", "secondary"));
    context.registerService(Executor.class, Executors.newSingleThreadExecutor());
    context.registerService(StatisticsProvider.class, StatisticsProvider.NOOP);
    MockOsgi.injectServices(cacheService, context.bundleContext());
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) NodeStoreProvider(org.apache.jackrabbit.oak.spi.state.NodeStoreProvider) Before(org.junit.Before)

Example 2 with NodeStoreProvider

use of org.apache.jackrabbit.oak.spi.state.NodeStoreProvider in project jackrabbit-oak by apache.

the class SegmentNodeStoreFactory method activate.

@Activate
public void activate(ComponentContext context) throws IOException {
    String role = property(ROLE, context);
    // In secondaryNodeStore mode customBlobStore is always enabled
    boolean isSecondaryStoreMode = "secondary".equals(role);
    boolean customBlobStore = Boolean.parseBoolean(property(CUSTOM_BLOB_STORE, context)) || isSecondaryStoreMode;
    boolean registerRepositoryDescriptors = Boolean.parseBoolean(property(REGISTER_DESCRIPTORS, context));
    log.info("activate: SegmentNodeStore '" + role + "' starting.");
    if (blobStore == null && customBlobStore) {
        log.info("BlobStore use enabled. SegmentNodeStore would be initialized when BlobStore would be available");
        return;
    }
    if (role != null) {
        registrations = Closer.create();
        OsgiWhiteboard whiteboard = new OsgiWhiteboard(context.getBundleContext());
        final SegmentNodeStore store = SegmentNodeStoreService.registerSegmentStore(context, blobStore, statisticsProvider, registrations, whiteboard, role, registerRepositoryDescriptors);
        if (store != null) {
            Map<String, Object> props = new HashMap<String, Object>();
            props.put(NodeStoreProvider.ROLE, role);
            registrations.register(asCloseable(whiteboard.register(NodeStoreProvider.class, new NodeStoreProvider() {

                @Override
                public NodeStore getNodeStore() {
                    return store;
                }
            }, props)));
            log.info("Registered NodeStoreProvider backed by SegmentNodeStore of type '{}'", role);
        }
    }
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) HashMap(java.util.HashMap) NodeStoreProvider(org.apache.jackrabbit.oak.spi.state.NodeStoreProvider) Activate(org.apache.felix.scr.annotations.Activate)

Aggregations

NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)2 NodeStoreProvider (org.apache.jackrabbit.oak.spi.state.NodeStoreProvider)2 HashMap (java.util.HashMap)1 Activate (org.apache.felix.scr.annotations.Activate)1 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)1 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)1 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)1 Before (org.junit.Before)1