Search in sources :

Example 96 with NodeStore

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

the class NonLocalObservationIT method getFixture.

@Override
protected NodeStoreFixture getFixture() {
    /**
         * Fixes the cluster use case plus allowing to control the cache sizes.
         * In theory other users of DocumentMongoFixture might have similar 
         * test cases - but keeping it simple for now - thus going via subclass.
         */
    return new DocumentMongoFixture() {

        private String clusterSuffix = System.currentTimeMillis() + "-NonLocalObservationIT";

        private DB db;

        /** keep a reference to the node stores so that the db only gets closed after the last nodeStore was closed */
        private Set<NodeStore> nodeStores = new HashSet<NodeStore>();

        /**
             * This is not implemented in the super class at all.
             * <ul>
             *  <li>use a specific suffix to make sure we have our own, new db and clean it up after the test</li>
             *  <li>properly drop that db created above in dispose</li>
             *  <li>use only 32MB (vs default of 256MB) memory to ensure we're not going OOM just because of this (which happens with the default)</li>
             *  <li>disable the persistent cache for the same reason</li>
             * </ul>
             */
        @Override
        public NodeStore createNodeStore(int clusterNodeId) {
            try {
                DocumentMK.Builder builder = new DocumentMK.Builder();
                // keep this one low to avoid OOME
                builder.memoryCacheSize(32 * 1024 * 1024);
                // turn this one off to avoid OOME
                builder.setPersistentCache(null);
                final String suffix = clusterSuffix;
                // db will be overwritten - but that's fine
                db = getDb(suffix);
                builder.setMongoDB(db);
                DocumentNodeStore ns = builder.getNodeStore();
                nodeStores.add(ns);
                return ns;
            } catch (Exception e) {
                throw new AssumptionViolatedException("Mongo instance is not available", e);
            }
        }

        @Override
        public void dispose(NodeStore nodeStore) {
            super.dispose(nodeStore);
            nodeStores.remove(nodeStore);
            if (db != null && nodeStores.size() == 0) {
                try {
                    db.dropDatabase();
                    db.getMongo().close();
                    db = null;
                } catch (Exception e) {
                    log.error("dispose: Can't close Mongo", e);
                }
            }
        }

        @Override
        public String toString() {
            return "NonLocalObservationIT's DocumentMongoFixture flavour";
        }
    };
}
Also used : DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) HashSet(java.util.HashSet) Set(java.util.Set) AssumptionViolatedException(org.junit.AssumptionViolatedException) DocumentMongoFixture(org.apache.jackrabbit.oak.fixture.DocumentMongoFixture) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) DB(com.mongodb.DB) RepositoryException(javax.jcr.RepositoryException) AssumptionViolatedException(org.junit.AssumptionViolatedException)

Example 97 with NodeStore

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

the class ValidNamesTest method createRepository.

private Repository createRepository(NodeStoreFixture fixture) throws RepositoryException {
    NodeStore ns = null;
    for (Map.Entry<NodeStoreFixture, NodeStore> e : STORES.entrySet()) {
        if (e.getKey().getClass().equals(fixture.getClass())) {
            ns = e.getValue();
        }
    }
    if (ns == null) {
        ns = createNodeStore(fixture);
        STORES.put(fixture, ns);
    }
    return createRepository(ns);
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) NodeStoreFixture(org.apache.jackrabbit.oak.fixture.NodeStoreFixture) Map(java.util.Map)

Example 98 with NodeStore

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

the class LuceneBlobCacheTest method setUp.

@Before
public void setUp() throws Exception {
    fileDataStore = new ReadAccessCountingDataStore();
    fileDataStore.init(tempFolder.newFolder().getAbsolutePath());
    FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(tempFolder.newFolder()).withBlobStore(new DataStoreBlobStore(fileDataStore)).withMaxFileSize(256).withSegmentCacheSize(64).withMemoryMapping(false);
    store = fileStoreBuilder.build();
    NodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
    root = nodeStore.getRoot();
    builder = root.builder();
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Before(org.junit.Before)

Example 99 with NodeStore

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

the class BrokenNetworkIT method useProxy.

private void useProxy(boolean ssl, int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore1.fileStore();
    FileStore storeC2 = clientFileStore2.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    addTestContent(store, "server");
    // this speeds up the test a little bit...
    storeS.flush();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ssl);
        StandbyClientSync clientSync = newStandbyClientSync(storeC, proxyPort.getPort(), ssl)) {
        proxy.skipBytes(skipPosition, skipBytes);
        proxy.flipByte(flipPosition);
        proxy.connect();
        serverSync.start();
        clientSync.run();
        if (skipBytes > 0 || flipPosition >= 0) {
            assertFalse("stores are not expected to be equal", storeS.getHead().equals(storeC.getHead()));
            assertEquals(storeC2.getHead(), storeC.getHead());
            proxy.reset();
            if (intermediateChange) {
                addTestContent(store, "server2");
                storeS.flush();
            }
            clientSync.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)

Example 100 with NodeStore

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

the class DataStoreTestBase method testSyncUpdatedBinaryProperty.

/*
     * See OAK-4969.
     */
@Test
public void testSyncUpdatedBinaryProperty() throws Exception {
    final int blobSize = 5 * MB;
    FileStore primary = getPrimary();
    FileStore secondary = getSecondary();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
        StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())) {
        serverSync.start();
        addTestContent(store, "server", blobSize);
        primary.flush();
        clientSync.run();
        assertEquals(primary.getHead(), secondary.getHead());
        addTestContent(store, "server", blobSize);
        primary.flush();
        clientSync.run();
        assertEquals(primary.getHead(), secondary.getHead());
    }
}
Also used : 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)

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