Search in sources :

Example 31 with MemoryNodeStore

use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.

the class CopyVersionHistorySidegradeTest method upgradeRepository.

@Before
@Override
public void upgradeRepository() throws Exception {
    if (sourceNodeStore == null) {
        sourceNodeStore = new MemoryNodeStore();
        RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(sourceNodeStore)).createRepository();
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.logout();
            repository.shutdown();
        }
    }
}
Also used : MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) Session(javax.jcr.Session) Before(org.junit.Before)

Example 32 with MemoryNodeStore

use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project sling by apache.

the class OakVirtualInstanceBuilder method createNewRepository.

@Override
public VirtualInstanceBuilder createNewRepository() throws Exception {
    nodeStore = new MemoryNodeStore();
    SlingRepository repository = RepositoryTestHelper.newOakRepository(nodeStore);
    factory = MockFactory.mockResourceResolverFactory(repository);
    leaseCollection = new SimulatedLeaseCollection();
    return this;
}
Also used : SlingRepository(org.apache.sling.jcr.api.SlingRepository) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)

Example 33 with MemoryNodeStore

use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.

the class InitialContent method initialize.

@Override
public void initialize(@Nonnull NodeBuilder builder) {
    builder.setProperty(JCR_PRIMARYTYPE, NT_REP_ROOT, Type.NAME);
    if (!builder.hasChildNode(JCR_SYSTEM)) {
        NodeBuilder system = builder.child(JCR_SYSTEM);
        system.setProperty(JCR_PRIMARYTYPE, NT_REP_SYSTEM, Type.NAME);
        system.child(JCR_VERSIONSTORAGE).setProperty(JCR_PRIMARYTYPE, REP_VERSIONSTORAGE, Type.NAME);
        system.child(JCR_NODE_TYPES).setProperty(JCR_PRIMARYTYPE, NT_REP_NODE_TYPES, Type.NAME);
        system.child(VersionConstants.JCR_ACTIVITIES).setProperty(JCR_PRIMARYTYPE, VersionConstants.REP_ACTIVITIES, Type.NAME);
        Namespaces.setupNamespaces(system);
    }
    NodeBuilder versionStorage = builder.child(JCR_SYSTEM).child(JCR_VERSIONSTORAGE);
    if (prePopulateVS && !isInitialized(versionStorage)) {
        createIntermediateNodes(versionStorage);
    }
    if (!builder.hasChildNode(IndexConstants.INDEX_DEFINITIONS_NAME)) {
        NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
        NodeBuilder uuid = IndexUtils.createIndexDefinition(index, "uuid", true, true, ImmutableList.<String>of(JCR_UUID), null);
        uuid.setProperty("info", "Oak index for UUID lookup (direct lookup of nodes with the mixin 'mix:referenceable').");
        NodeBuilder nodetype = IndexUtils.createIndexDefinition(index, "nodetype", true, false, ImmutableList.of(JCR_PRIMARYTYPE, JCR_MIXINTYPES), null);
        nodetype.setProperty("info", "Oak index for queries with node type, and possibly path restrictions, " + "for example \"/jcr:root/content//element(*, mix:language)\".");
        IndexUtils.createReferenceIndex(index);
        index.child("counter").setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE, NAME).setProperty(TYPE_PROPERTY_NAME, NodeCounterEditorProvider.TYPE).setProperty(IndexConstants.ASYNC_PROPERTY_NAME, IndexConstants.ASYNC_PROPERTY_NAME).setProperty("info", "Oak index that allows to estimate " + "how many nodes are stored below a given path, " + "to decide whether traversing or using an index is faster.");
    }
    // squeeze node state before it is passed to store (OAK-2411)
    NodeState base = squeeze(builder.getNodeState());
    NodeStore store = new MemoryNodeStore(base);
    registerBuiltIn(RootFactory.createSystemRoot(store, new EditorHook(new CompositeEditorProvider(new NamespaceEditorProvider(), new TypeEditorProvider())), null, null, null));
    NodeState target = store.getRoot();
    target.compareAgainstBaseState(base, new ApplyDiff(builder));
}
Also used : NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) ApplyDiff(org.apache.jackrabbit.oak.spi.state.ApplyDiff) CompositeEditorProvider(org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 34 with MemoryNodeStore

use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.

the class TraversalAvoidanceTest method createRepository.

@Override
protected ContentRepository createRepository() {
    nodeStore = new MemoryNodeStore();
    Oak oak = new Oak(nodeStore).with(new OpenSecurityProvider()).with(new InitialContent()).with(new NodeCounterEditorProvider()).with(testIndexProvider).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    wb = oak.getWhiteboard();
    return oak.createContentRepository();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)

Example 35 with MemoryNodeStore

use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.

the class SessionImplCapabilityWithMountInfoProviderTest method prepare.

@Before
public void prepare() throws Exception {
    MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("ro", "/private").build();
    MemoryNodeStore roStore = new MemoryNodeStore();
    {
        NodeBuilder builder = roStore.getRoot().builder();
        builder.child("private").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED).setProperty("prop", "value").child("foo").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
        roStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    }
    MemoryNodeStore globalStore = new MemoryNodeStore();
    {
        NodeBuilder builder = globalStore.getRoot().builder();
        builder.child("foo").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED).setProperty("prop", "value").child("bar").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
        globalStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    }
    CompositeNodeStore store = new CompositeNodeStore.Builder(mip, globalStore).addMount("ro", roStore).build();
    Whiteboard whiteboard = new DefaultWhiteboard();
    whiteboard.register(MountInfoProvider.class, mip, Collections.emptyMap());
    Jcr jcr = new Jcr(store).with(whiteboard);
    jcr.createContentRepository();
    Repository repository = jcr.createRepository();
    adminSession = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) CompositeNodeStore(org.apache.jackrabbit.oak.composite.CompositeNodeStore) Repository(javax.jcr.Repository) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Before(org.junit.Before)

Aggregations

MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)121 Test (org.junit.Test)83 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)73 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)46 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)39 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)36 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)21 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 Oak (org.apache.jackrabbit.oak.Oak)14 ProxyNodeStore (org.apache.jackrabbit.oak.spi.state.ProxyNodeStore)14 InitialContent (org.apache.jackrabbit.oak.InitialContent)11 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)11 Before (org.junit.Before)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 MountedNodeStore (org.apache.jackrabbit.oak.composite.MountedNodeStore)7 AsyncIndexStats (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate.AsyncIndexStats)7 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)7 Nonnull (javax.annotation.Nonnull)6 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)6 PropertyIndexLookup (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup)6