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());
}
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());
}
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();
}
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();
}
}
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);
}
Aggregations