Search in sources :

Example 6 with Mount

use of org.apache.jackrabbit.oak.spi.mount.Mount in project jackrabbit-oak by apache.

the class MultiplexersTest method customNodeName.

@Test
public void customNodeName() throws Exception {
    MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/a", "/b").build();
    Mount m = mip.getMountByName("foo");
    assertEquals(":index", getIndexNodeName(mip, "/foo", INDEX_CONTENT_NODE_NAME));
    assertEquals(":index", getNodeForMount(mip.getDefaultMount(), INDEX_CONTENT_NODE_NAME));
    assertEquals(":" + m.getPathFragmentName() + "-index", getIndexNodeName(mip, "/a", INDEX_CONTENT_NODE_NAME));
    assertEquals(":" + m.getPathFragmentName() + "-index", getNodeForMount(m, INDEX_CONTENT_NODE_NAME));
}
Also used : Multiplexers.getNodeForMount(org.apache.jackrabbit.oak.plugins.index.property.Multiplexers.getNodeForMount) Mount(org.apache.jackrabbit.oak.spi.mount.Mount) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Test(org.junit.Test)

Example 7 with Mount

use of org.apache.jackrabbit.oak.spi.mount.Mount in project jackrabbit-oak by apache.

the class MultiplexingIndexWriter method deleteDocuments.

@Override
public void deleteDocuments(String path) throws IOException {
    Mount mount = mountInfoProvider.getMountByPath(path);
    getWriter(mount).deleteDocuments(path);
    //Note that one mount cannot be part of another mount
    if (mount.isDefault()) {
        //If any mount falls under given path then delete all documents in that
        for (Mount m : mountInfoProvider.getMountsPlacedUnder(path)) {
            getWriter(m).deleteAll();
        }
    }
}
Also used : Mount(org.apache.jackrabbit.oak.spi.mount.Mount)

Example 8 with Mount

use of org.apache.jackrabbit.oak.spi.mount.Mount in project jackrabbit-oak by apache.

the class DefaultIndexReaderFactory method createMountedReaders.

private List<LuceneIndexReader> createMountedReaders(IndexDefinition definition, NodeState defnState, String indexPath) throws IOException {
    ImmutableList.Builder<LuceneIndexReader> readers = ImmutableList.builder();
    LuceneIndexReader reader = createReader(mountInfoProvider.getDefaultMount(), definition, defnState, indexPath);
    //support multiple readers
    if (reader != null) {
        readers.add(reader);
    }
    for (Mount m : mountInfoProvider.getNonDefaultMounts()) {
        reader = createReader(m, definition, defnState, indexPath);
        if (reader != null) {
            readers.add(reader);
        }
    }
    return readers.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Mount(org.apache.jackrabbit.oak.spi.mount.Mount)

Example 9 with Mount

use of org.apache.jackrabbit.oak.spi.mount.Mount in project jackrabbit-oak by apache.

the class CompositeNodeStoreService method registerCompositeNodeStore.

private void registerCompositeNodeStore() {
    if (nsReg != null) {
        // already registered
        return;
    }
    NodeStoreWithProps globalNs = null;
    Set<String> availableMounts = new HashSet<>();
    for (NodeStoreWithProps ns : nodeStores) {
        if (isGlobalNodeStore(ns)) {
            globalNs = ns;
        } else {
            availableMounts.add(getMountName(ns));
        }
    }
    if (globalNs == null) {
        LOG.info("Composite node store registration is deferred until there's a global node store registered in OSGi");
        return;
    } else {
        LOG.info("Found global node store: {}", getDescription(globalNs));
    }
    for (Mount m : mountInfoProvider.getNonDefaultMounts()) {
        if (!availableMounts.contains(m.getName())) {
            LOG.info("Composite node store registration is deferred until there's mount {} registered in OSGi", m.getName());
            return;
        }
    }
    LOG.info("Node stores for all configured mounts are available");
    CompositeNodeStore.Builder builder = new CompositeNodeStore.Builder(mountInfoProvider, globalNs.getNodeStoreProvider().getNodeStore());
    for (String p : ignoreReadOnlyWritePaths) {
        builder.addIgnoredReadOnlyWritePath(p);
    }
    for (NodeStoreWithProps ns : nodeStores) {
        if (isGlobalNodeStore(ns)) {
            continue;
        }
        String mountName = getMountName(ns);
        if (mountName != null) {
            builder.addMount(mountName, ns.getNodeStoreProvider().getNodeStore());
            LOG.info("Mounting {} as {}", getDescription(ns), mountName);
        }
    }
    Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(Constants.SERVICE_PID, CompositeNodeStore.class.getName());
    props.put("oak.nodestore.description", new String[] { "nodeStoreType=compositeStore" });
    CompositeNodeStore store = builder.build();
    observerTracker = new ObserverTracker(store);
    observerTracker.start(context.getBundleContext());
    LOG.info("Registering the composite node store");
    nsReg = context.getBundleContext().registerService(new String[] { NodeStore.class.getName() }, store, props);
}
Also used : ObserverTracker(org.apache.jackrabbit.oak.spi.commit.ObserverTracker) Hashtable(java.util.Hashtable) Mount(org.apache.jackrabbit.oak.spi.mount.Mount) HashSet(java.util.HashSet)

Example 10 with Mount

use of org.apache.jackrabbit.oak.spi.mount.Mount in project jackrabbit-oak by apache.

the class CompositionContext method getContributingStores.

private List<MountedNodeStore> getContributingStores(String path, Function<MountedNodeStore, Iterable<String>> childrenProvider) {
    Mount owningMount = mip.getMountByPath(path);
    if (!owningMount.isDefault() && nodeStoresByMount.containsKey(owningMount)) {
        MountedNodeStore nodeStore = nodeStoresByMount.get(owningMount);
        if (nodeStore != globalStore) {
            return singletonList(nodeStore);
        }
    }
    // scenario 2 - multiple mounts participate
    List<MountedNodeStore> mountedStores = newArrayList();
    mountedStores.add(globalStore);
    // we need mounts placed exactly one level beneath this path
    Collection<Mount> mounts = mip.getMountsPlacedDirectlyUnder(path);
    // query the mounts next
    for (MountedNodeStore mountedNodeStore : nonDefaultStores) {
        final Mount mount = mountedNodeStore.getMount();
        if (mounts.contains(mount)) {
            mountedStores.add(mountedNodeStore);
        } else if (hasChildrenContainingPathFragmentName(mountedNodeStore, path, childrenProvider)) {
            mountedStores.add(mountedNodeStore);
        }
    }
    return mountedStores;
}
Also used : Mount(org.apache.jackrabbit.oak.spi.mount.Mount)

Aggregations

Mount (org.apache.jackrabbit.oak.spi.mount.Mount)12 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)6 Test (org.junit.Test)6 HashSet (java.util.HashSet)2 Mounts.defaultMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider)2 SimpleMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.SimpleMountInfoProvider)2 ImmutableList (com.google.common.collect.ImmutableList)1 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 Collection (java.util.Collection)1 Hashtable (java.util.Hashtable)1 Map (java.util.Map)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)1 Multiplexers.getNodeForMount (org.apache.jackrabbit.oak.plugins.index.property.Multiplexers.getNodeForMount)1 FilteringIndexStoreStrategy (org.apache.jackrabbit.oak.plugins.index.property.strategy.FilteringIndexStoreStrategy)1 IndexStoreStrategy (org.apache.jackrabbit.oak.plugins.index.property.strategy.IndexStoreStrategy)1 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)1 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)1 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)1