Search in sources :

Example 76 with NodeStore

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

the class FailoverIPRangeIT method createTestWithConfig.

private void createTestWithConfig(String host, String[] ipRanges, boolean expectedToWork) throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ipRanges);
        StandbyClientSync clientSync = new StandbyClientSync(host, serverPort.getPort(), storeC, false, getClientTimeout(), false)) {
        serverSync.start();
        addTestContent(store, "server");
        // this speeds up the test a little bit...
        storeS.flush();
        clientSync.run();
        if (expectedToWork) {
            assertEquals(storeS.getHead(), storeC.getHead());
        } else {
            assertFalse("stores are equal but shouldn't!", storeS.getHead().equals(storeC.getHead()));
        }
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)

Example 77 with NodeStore

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

the class FailoverMultipleClientsTestIT method testMultipleClients.

@Test
public void testMultipleClients() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore1.fileStore();
    FileStore storeC2 = clientFileStore2.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS);
        StandbyClientSync cl1 = newStandbyClientSync(storeC, serverPort.getPort());
        StandbyClientSync cl2 = newStandbyClientSync(storeC2, serverPort.getPort())) {
        serverSync.start();
        SegmentTestUtils.addTestContent(store, "server");
        // this speeds up the test a little bit...
        storeS.flush();
        assertFalse("first client has invalid initial store!", storeS.getHead().equals(storeC.getHead()));
        assertFalse("second client has invalid initial store!", storeS.getHead().equals(storeC2.getHead()));
        assertEquals(storeC.getHead(), storeC2.getHead());
        cl1.run();
        cl2.run();
        assertEquals(storeS.getHead(), storeC.getHead());
        assertEquals(storeS.getHead(), storeC2.getHead());
        cl1.stop();
        SegmentTestUtils.addTestContent(store, "test");
        storeS.flush();
        cl1.run();
        cl2.run();
        assertEquals(storeS.getHead(), storeC2.getHead());
        assertFalse("first client updated in stopped state!", storeS.getHead().equals(storeC.getHead()));
        cl1.start();
        cl1.run();
        assertEquals(storeS.getHead(), storeC.getHead());
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) Test(org.junit.Test)

Example 78 with NodeStore

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

the class FailoverSslTestIT method synchronizeAndCompareHead.

private boolean synchronizeAndCompareHead(StandbyServerSync serverSync, StandbyClientSync clientSync) throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    serverSync.start();
    addTestContent(store, "server");
    // this speeds up the test a little bit...
    storeS.flush();
    clientSync.run();
    return storeS.getHead().equals(storeC.getHead());
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore)

Example 79 with NodeStore

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

the class RecoverTestIT method testLocalChanges.

@Test
public void testLocalChanges() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeC).build();
    addTestContent(store, "client");
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS);
        StandbyClientSync cl = newStandbyClientSync(storeC, serverPort.getPort())) {
        serverSync.start();
        store = SegmentNodeStoreBuilders.builder(storeS).build();
        addTestContent(store, "server");
        storeS.flush();
        assertFalse("stores are not expected to be equal", storeS.getHead().equals(storeC.getHead()));
        cl.run();
        assertEquals(storeS.getHead(), storeC.getHead());
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) Test(org.junit.Test)

Example 80 with NodeStore

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

the class CopyVersionHistoryTest method performCopy.

protected Session performCopy(VersionCopySetup setup) throws RepositoryException, IOException {
    final RepositoryConfig sourceConfig = RepositoryConfig.create(source);
    final RepositoryContext sourceContext = RepositoryContext.create(sourceConfig);
    final NodeStore targetNodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    try {
        final RepositoryUpgrade upgrade = new RepositoryUpgrade(sourceContext, targetNodeStore);
        setup.setup(upgrade.versionCopyConfiguration);
        upgrade.setEarlyShutdown(true);
        upgrade.copy(null);
    } finally {
        sourceContext.getRepository().shutdown();
    }
    repository = (RepositoryImpl) new Jcr(new Oak(targetNodeStore)).createRepository();
    Session s = repository.login(AbstractRepositoryUpgradeTest.CREDENTIALS);
    sessions.add(s);
    return s;
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) Session(javax.jcr.Session)

Aggregations

NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)141 Test (org.junit.Test)81 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)58 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)52 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)29 Blob (org.apache.jackrabbit.oak.api.Blob)24 Before (org.junit.Before)18 FileInputStream (java.io.FileInputStream)16 Hex.encodeHexString (org.apache.commons.codec.binary.Hex.encodeHexString)16 File (java.io.File)14 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)14 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)14 ProxyNodeStore (org.apache.jackrabbit.oak.spi.state.ProxyNodeStore)13 Oak (org.apache.jackrabbit.oak.Oak)10 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)10 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)10 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)10 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)9 MemoryStore (org.apache.jackrabbit.oak.segment.memory.MemoryStore)9 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)9