Search in sources :

Example 81 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class IOTracerTest method collectBreadthFirstTrace.

@Test
public void collectBreadthFirstTrace() throws IOException, InvalidFileStoreVersionException {
    try (StringWriter out = new StringWriter()) {
        Function<IOMonitor, FileStore> factory = this::createFileStore;
        IOTracer ioTracer = newIOTracer(factory, out, BreadthFirstTrace.CONTEXT_SPEC);
        ioTracer.collectTrace(new BreadthFirstTrace(2, "/", ioTracer::setContext));
        try (BufferedReader reader = new BufferedReader(new StringReader(out.toString()))) {
            Optional<String> header = reader.lines().findFirst();
            List<String[]> entries = reader.lines().map(line -> line.split(",")).collect(toList());
            assertTrue(header.isPresent());
            assertEquals("timestamp,file,segmentId,length,elapsed,depth,count", header.get());
            long now = currentTimeMillis();
            assertTrue("The timestamps of all entries must be in the past", entries.stream().map(// ts
            row -> parseLong(row[0])).allMatch(ts -> ts <= now));
            assertEquals("Expected depths 0, 1 and 2", ImmutableSet.of(0, 1, 2), entries.stream().map(// depth
            row -> parseInt(row[5])).distinct().collect(toSet()));
            assertEquals("Expected max 10 nodes", Optional.of(true), entries.stream().map(// count
            row -> parseInt(row[6])).max(Comparator.naturalOrder()).map(max -> max <= 10));
        }
    }
}
Also used : IOMonitor(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitor) IOMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter) System.currentTimeMillis(java.lang.System.currentTimeMillis) FileStoreBuilder.fileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder) Function(java.util.function.Function) SegmentNodeBuilder(org.apache.jackrabbit.oak.segment.SegmentNodeBuilder) IOTracer.newIOTracer(org.apache.jackrabbit.oak.segment.tool.iotrace.IOTracer.newIOTracer) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) Nonnull(javax.annotation.Nonnull) Collectors.toSet(java.util.stream.Collectors.toSet) Before(org.junit.Before) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) ImmutableSet(com.google.common.collect.ImmutableSet) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) StringWriter(java.io.StringWriter) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Integer.parseInt(java.lang.Integer.parseInt) File(java.io.File) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Rule(org.junit.Rule) StringReader(java.io.StringReader) Optional(java.util.Optional) BufferedReader(java.io.BufferedReader) Long.parseLong(java.lang.Long.parseLong) Comparator(java.util.Comparator) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) StringWriter(java.io.StringWriter) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) IOMonitor(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitor) IOTracer.newIOTracer(org.apache.jackrabbit.oak.segment.tool.iotrace.IOTracer.newIOTracer) Test(org.junit.Test)

Example 82 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class FailoverSslTestIT method testFailoverSecure.

@Test
public void testFailoverSecure() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, MB, true);
        StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, true, getClientTimeout(), false, folder.newFolder())) {
        assertTrue(synchronizeAndCompareHead(serverSync, clientSync));
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) Test(org.junit.Test)

Example 83 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class FailoverSslTestIT method testFailoverPlainServerSecureClient.

@Test
public void testFailoverPlainServerSecureClient() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, MB);
        StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, true, getClientTimeout(), false, folder.newFolder())) {
        assertFalse(synchronizeAndCompareHead(serverSync, clientSync));
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) Test(org.junit.Test)

Example 84 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore 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, MB);
        StandbyClientSync cl = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, false, getClientTimeout(), false, folder.newFolder())) {
        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 85 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class DefaultStandbyHeadReaderTest method shouldReturnHeadSegmentId.

@Test
public void shouldReturnHeadSegmentId() throws Exception {
    try (FileStore store = newFileStore()) {
        store.flush();
        DefaultStandbyHeadReader reader = new DefaultStandbyHeadReader(store, 0L);
        assertEquals(store.getRevisions().getPersistedHead().toString(), reader.readHeadRecordId());
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) Test(org.junit.Test)

Aggregations

FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)106 Test (org.junit.Test)70 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)41 File (java.io.File)25 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)25 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)18 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)18 IOException (java.io.IOException)17 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)15 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)13 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)13 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)12 TemporaryFileStore (org.apache.jackrabbit.oak.segment.test.TemporaryFileStore)11 Blob (org.apache.jackrabbit.oak.api.Blob)10 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)9 Before (org.junit.Before)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)8 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)7