Search in sources :

Example 61 with NodeStore

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

the class IndexCommandIT method reindex.

@Test
public void reindex() throws Exception {
    createTestData(true);
    fixture.getAsyncIndexUpdate("async").run();
    //Close the repository so as all changes are flushed
    fixture.close();
    IndexCommand command = new IndexCommand();
    File outDir = temporaryFolder.newFolder();
    File storeDir = fixture.getDir();
    String[] args = { "--index-temp-dir=" + temporaryFolder.newFolder().getAbsolutePath(), "--index-out-dir=" + outDir.getAbsolutePath(), "--index-paths=/oak:index/fooIndex", "--read-write=true", "--reindex", // -- indicates that options have ended and rest needs to be treated as non option
    "--", storeDir.getAbsolutePath() };
    command.execute(args);
    RepositoryFixture fixture2 = new RepositoryFixture(storeDir);
    NodeStore store2 = fixture2.getNodeStore();
    PropertyState reindexCount = getNode(store2.getRoot(), "/oak:index/fooIndex").getProperty(IndexConstants.REINDEX_COUNT);
    assertEquals(2, reindexCount.getValue(Type.LONG).longValue());
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 62 with NodeStore

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

the class NodeStoreBinaryResourceProviderTest method countBinaries.

@Test
public void countBinaries() throws Exception {
    NodeBuilder builder = root.builder();
    createFileNode(builder, "a", new IdBlob("hello", null), "text/plain");
    createFileNode(builder, "b", new IdBlob("hello", "id1"), "text/plain");
    createFileNode(builder.child("a2"), "c", new IdBlob("hello", "id2"), "text/foo").setProperty(JcrConstants.JCR_ENCODING, "bar");
    NodeStore store = new MemoryNodeStore(builder.getNodeState());
    BlobStore blobStore = new MemoryBlobStore();
    NodeStoreBinaryResourceProvider extractor = new NodeStoreBinaryResourceProvider(store, blobStore);
    assertEquals(2, extractor.getBinaries("/").size());
    assertEquals(1, extractor.getBinaries("/a2").size());
    BinaryResource bs = extractor.getBinaries("/a2").first().get();
    assertEquals("text/foo", bs.getMimeType());
    assertEquals("bar", bs.getEncoding());
    assertEquals("id2", bs.getBlobId());
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Test(org.junit.Test)

Example 63 with NodeStore

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

the class NodeStoreBinaryResourceProviderTest method csvGenerator.

@Test
public void csvGenerator() throws Exception {
    File csv = new File(temporaryFolder.getRoot(), "test.csv");
    BlobStore blobStore = new MemoryBlobStore();
    NodeBuilder builder = root.builder();
    createFileNode(builder, "a", blobOf("foo", blobStore), "text/plain");
    createFileNode(builder, "b", blobOf("hello", blobStore), "text/plain");
    NodeStore store = new MemoryNodeStore(builder.getNodeState());
    NodeStoreBinaryResourceProvider extractor = new NodeStoreBinaryResourceProvider(store, blobStore);
    CSVFileGenerator generator = new CSVFileGenerator(csv);
    generator.generate(extractor.getBinaries("/"));
    CSVFileBinaryResourceProvider csvbrp = new CSVFileBinaryResourceProvider(csv, blobStore);
    assertEquals(2, csvbrp.getBinaries("/").size());
    csvbrp.close();
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) File(java.io.File) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Test(org.junit.Test)

Example 64 with NodeStore

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

the class BulkTransferBenchmark method test.

private void test(int number, int minExpectedSegments, int maxExpectedSegments, long minExpectedBytes, long maxExpectedBytes, boolean useSSL) throws Exception {
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    NodeBuilder rootbuilder = store.getRoot().builder();
    NodeBuilder b = rootbuilder.child("store");
    for (int j = 0; j <= number / 1000; j++) {
        NodeBuilder builder = b.child("Folder#" + j);
        for (int i = 0; i < (number < 1000 ? number : 1000); i++) {
            builder.child("Test#" + i).setProperty("ts", System.currentTimeMillis());
        }
    }
    store.merge(rootbuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    storeS.flush();
    final StandbyServerSync serverSync = new StandbyServerSync(port, storeS, useSSL);
    serverSync.start();
    System.setProperty(StandbyClientSync.CLIENT_ID_PROPERTY_NAME, "Bar");
    StandbyClientSync clientSync = newStandbyClientSync(storeC, port, useSSL);
    final MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName status = new ObjectName(StandbyStatusMBean.JMX_NAME + ",id=*");
    ObjectName clientStatus = new ObjectName(clientSync.getMBeanName());
    ObjectName serverStatus = new ObjectName(serverSync.getMBeanName());
    long start = System.currentTimeMillis();
    clientSync.run();
    try {
        Set<ObjectName> instances = jmxServer.queryNames(status, null);
        ObjectName connectionStatus = null;
        for (ObjectName s : instances) {
            if (!s.equals(clientStatus) && !s.equals(serverStatus))
                connectionStatus = s;
        }
        assert (connectionStatus != null);
        long segments = ((Long) jmxServer.getAttribute(connectionStatus, "TransferredSegments")).longValue();
        long bytes = ((Long) jmxServer.getAttribute(connectionStatus, "TransferredSegmentBytes")).longValue();
        System.out.println("did transfer " + segments + " segments with " + bytes + " bytes in " + (System.currentTimeMillis() - start) / 1000 + " seconds.");
    } finally {
        serverSync.close();
        clientSync.close();
    }
}
Also used : 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) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 65 with NodeStore

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

the class DataStoreTestBase method testSync.

@Test
public void testSync() throws Exception {
    final int blobSize = 5 * MB;
    FileStore primary = getPrimary();
    FileStore secondary = getSecondary();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    byte[] data = addTestContent(store, "server", blobSize);
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
        StandbyClientSync cl = newStandbyClientSync(secondary, serverPort.getPort())) {
        serverSync.start();
        primary.flush();
        cl.run();
        assertEquals(primary.getHead(), secondary.getHead());
    }
    assertTrue(primary.getStats().getApproximateSize() < MB);
    assertTrue(secondary.getStats().getApproximateSize() < MB);
    PropertyState ps = secondary.getHead().getChildNode("root").getChildNode("server").getProperty("testBlob");
    assertNotNull(ps);
    assertEquals(Type.BINARY.tag(), ps.getType().tag());
    Blob b = ps.getValue(Type.BINARY);
    assertEquals(blobSize, b.length());
    byte[] testData = new byte[blobSize];
    ByteStreams.readFully(b.getNewStream(), testData);
    assertArrayEquals(data, testData);
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) Blob(org.apache.jackrabbit.oak.api.Blob) 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) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) 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