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));
}
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();
}
}
}
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();
}
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);
}
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;
}
Aggregations