Search in sources :

Example 6 with MemoryDocumentStore

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

the class ClusterPermissionsTest method before.

@Before
public void before() throws Exception {
    MemoryDocumentStore ds = new MemoryDocumentStore();
    MemoryBlobStore bs = new MemoryBlobStore();
    DocumentMK.Builder builder;
    builder = new DocumentMK.Builder();
    builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
    ns1 = builder.setClusterId(1).getNodeStore();
    builder = new DocumentMK.Builder();
    builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
    ns2 = builder.setClusterId(2).getNodeStore();
    Oak oak = new Oak(ns1).with(new InitialContent()).with(new ReferenceEditorProvider()).with(new ReferenceIndexProvider()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(securityProvider1 = new SecurityProviderImpl(getSecurityConfigParameters()));
    contentRepository1 = oak.createContentRepository();
    adminSession1 = login1(getAdminCredentials());
    root1 = adminSession1.getLatestRoot();
    userManager1 = securityProvider1.getConfiguration(UserConfiguration.class).getUserManager(root1, namePathMapper);
    aclMgr1 = securityProvider1.getConfiguration(AuthorizationConfiguration.class).getAccessControlManager(root1, namePathMapper);
    // make sure initial content is visible to ns2
    syncClusterNodes();
    oak = new Oak(ns2).with(new InitialContent()).with(new ReferenceEditorProvider()).with(new ReferenceIndexProvider()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(securityProvider2 = new SecurityProviderImpl(getSecurityConfigParameters()));
    contentRepository2 = oak.createContentRepository();
    adminSession2 = login2(getAdminCredentials());
    root2 = adminSession2.getLatestRoot();
    userManager2 = securityProvider2.getConfiguration(UserConfiguration.class).getUserManager(root2, namePathMapper);
    aclMgr2 = securityProvider2.getConfiguration(AuthorizationConfiguration.class).getAccessControlManager(root2, namePathMapper);
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) ReferenceIndexProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceIndexProvider) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) Oak(org.apache.jackrabbit.oak.Oak) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) SecurityProviderImpl(org.apache.jackrabbit.oak.security.SecurityProviderImpl) Before(org.junit.Before)

Example 7 with MemoryDocumentStore

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

the class DocumentDiscoveryLiteServiceCrashTest method setup.

@Before
public void setup() throws Exception {
    clock = new Clock.Virtual();
    clock.waitUntil(System.currentTimeMillis());
    ClusterNodeInfo.setClock(clock);
    store = new MemoryDocumentStore();
    wd1 = UUID.randomUUID().toString();
    wd2 = UUID.randomUUID().toString();
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) Clock(org.apache.jackrabbit.oak.stats.Clock) Before(org.junit.Before)

Example 8 with MemoryDocumentStore

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

the class ClusterBranchCommitTest method before.

@Before
public void before() {
    DocumentStore store = new MemoryDocumentStore();
    ns1 = builderProvider.newBuilder().setDocumentStore(store).setAsyncDelay(0).setClusterId(1).getNodeStore();
    ns2 = builderProvider.newBuilder().setDocumentStore(store).setAsyncDelay(0).setClusterId(2).getNodeStore();
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) Before(org.junit.Before)

Example 9 with MemoryDocumentStore

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

the class ClusterConflictTest method setUp.

@Before
public void setUp() {
    MemoryDocumentStore store = new MemoryDocumentStore();
    ns1 = newDocumentNodeStore(store, 1);
    ns2 = newDocumentNodeStore(store, 2);
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) Before(org.junit.Before)

Example 10 with MemoryDocumentStore

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

the class ClusterInfoTest method useAbandoned.

@Test
public void useAbandoned() throws InterruptedException {
    Clock clock = new Clock.Virtual();
    clock.waitUntil(System.currentTimeMillis());
    ClusterNodeInfo.setClock(clock);
    MemoryDocumentStore mem = new MemoryDocumentStore();
    DocumentNodeStore ns1 = new DocumentMK.Builder().setDocumentStore(mem).clock(clock).setAsyncDelay(0).setLeaseCheck(false).getNodeStore();
    DocumentStore ds = ns1.getDocumentStore();
    int cid = ns1.getClusterId();
    ClusterNodeInfoDocument cnid = ds.find(Collection.CLUSTER_NODES, "" + cid);
    assertNotNull(cnid);
    assertEquals(ClusterNodeState.ACTIVE.toString(), cnid.get(ClusterNodeInfo.STATE));
    ns1.dispose();
    long waitFor = 2000;
    // modify record to indicate "active" with a lease end in the future
    UpdateOp up = new UpdateOp("" + cid, false);
    up.set(ClusterNodeInfo.STATE, ClusterNodeState.ACTIVE.toString());
    long now = clock.getTime();
    up.set(ClusterNodeInfo.LEASE_END_KEY, now + waitFor);
    ds.findAndUpdate(Collection.CLUSTER_NODES, up);
    // try restart
    ns1 = new DocumentMK.Builder().setDocumentStore(mem).clock(clock).setAsyncDelay(0).setLeaseCheck(false).getNodeStore();
    assertEquals("should have re-used existing cluster id", cid, ns1.getClusterId());
    ns1.dispose();
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) Clock(org.apache.jackrabbit.oak.stats.Clock) Test(org.junit.Test)

Aggregations

MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)132 Test (org.junit.Test)113 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)72 Clock (org.apache.jackrabbit.oak.stats.Clock)21 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)19 Before (org.junit.Before)13 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)11 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 Utils.getRootDocument (org.apache.jackrabbit.oak.plugins.document.util.Utils.getRootDocument)9 Random (java.util.Random)8 CONSTRAINT (org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT)8 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)7 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)6 ArrayList (java.util.ArrayList)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 StringSort (org.apache.jackrabbit.oak.commons.sort.StringSort)5 List (java.util.List)4 Semaphore (java.util.concurrent.Semaphore)4 VersionGCStats (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats)4