use of org.apache.jackrabbit.oak.plugins.document.PathRev in project jackrabbit-oak by apache.
the class BroadcastTest method benchmark.
private static void benchmark() throws IOException {
FileUtils.deleteDirectory(new File("target/broadcastTest"));
new File("target/broadcastTest").mkdirs();
String type = "tcp:key 1;ports 9700 9800";
ArrayList<PersistentCache> nodeList = new ArrayList<PersistentCache>();
for (int nodes = 1; nodes < 20; nodes++) {
PersistentCache pc = new PersistentCache("target/broadcastTest/p" + nodes + ",broadcast=" + type);
Cache<PathRev, StringValue> cache = openCache(pc);
String key = "/test" + Math.random();
PathRev k = new PathRev(key, new RevisionVector(new Revision(0, 0, 0)));
long time = System.currentTimeMillis();
for (int i = 0; i < 2000; i++) {
cache.put(k, new StringValue("Hello World " + i));
cache.invalidate(k);
cache.getIfPresent(k);
}
time = System.currentTimeMillis() - time;
System.out.println("nodes: " + nodes + " time: " + time);
nodeList.add(pc);
}
for (PersistentCache c : nodeList) {
c.close();
}
}
use of org.apache.jackrabbit.oak.plugins.document.PathRev in project jackrabbit-oak by apache.
the class BroadcastTest method broadcastTry.
private static boolean broadcastTry(String type, int minPercentCorrect, boolean tryOnly) throws Exception {
FileUtils.deleteDirectory(new File("target/broadcastTest"));
new File("target/broadcastTest").mkdirs();
PersistentCache p1 = new PersistentCache("target/broadcastTest/p1,broadcast=" + type);
PersistentCache p2 = new PersistentCache("target/broadcastTest/p2,broadcast=" + type);
Cache<PathRev, StringValue> c1 = openCache(p1);
Cache<PathRev, StringValue> c2 = openCache(p2);
String key = "/test" + Math.random();
PathRev k = new PathRev(key, new RevisionVector(new Revision(0, 0, 0)));
int correct = 0;
for (int i = 0; i < 50; i++) {
c1.put(k, new StringValue("Hello World " + i));
waitFor(c2, k, 10000);
StringValue v2 = c2.getIfPresent(k);
if (v2 != null && v2.toString().equals("Hello World " + i)) {
correct++;
}
c2.invalidate(k);
assertNull(c2.getIfPresent(k));
waitFor(c1, k, null, 10000);
StringValue v1 = c1.getIfPresent(k);
if (v1 == null) {
correct++;
}
}
p1.close();
p2.close();
if (correct >= minPercentCorrect) {
return true;
}
if (tryOnly) {
return false;
}
Assert.fail("min: " + minPercentCorrect + " got: " + correct);
return false;
}
use of org.apache.jackrabbit.oak.plugins.document.PathRev in project jackrabbit-oak by apache.
the class NodeCacheTest method initializeNodeStore.
private void initializeNodeStore(boolean asyncCache, Consumer<DocumentMK.Builder> processor) {
store = new MemoryDocumentStore();
DocumentMK.Builder builder = builderProvider.newBuilder().setDocumentStore(store).setAsyncDelay(0).setStatisticsProvider(statsProvider);
if (asyncCache) {
builder.setPersistentCache("target/persistentCache,time");
} else {
builder.setPersistentCache("target/persistentCache,time,-async");
}
processor.accept(builder);
ns = builder.getNodeStore();
nodeCache = (NodeCache<PathRev, DocumentNodeState>) ns.getNodeCache();
nodeChildren = (NodeCache<PathRev, DocumentNodeState.Children>) ns.getNodeChildrenCache();
}
use of org.apache.jackrabbit.oak.plugins.document.PathRev in project jackrabbit-oak by apache.
the class DocumentBundlingTest method bundledNodeAndNodeChildrenCache.
@Test
public void bundledNodeAndNodeChildrenCache() throws Exception {
NodeBuilder builder = store.getRoot().builder();
NodeBuilder appNB = newNode("app:Asset");
createChild(appNB, "jcr:content", // not bundled
"jcr:content/comments", "jcr:content/metadata", // not bundled
"jcr:content/metadata/xmp", // includes all
"jcr:content/renditions", "jcr:content/renditions/original", "jcr:content/renditions/original/jcr:content");
builder.child("test").setChildNode("book.jpg", appNB.getNodeState());
merge(builder);
Set<PathRev> cachedPaths = store.getNodeChildrenCache().asMap().keySet();
for (PathRev pr : cachedPaths) {
assertFalse(pr.getPath().contains("jcr:content/renditions"));
}
}
use of org.apache.jackrabbit.oak.plugins.document.PathRev in project jackrabbit-oak by apache.
the class AsyncQueueTest method readItemsShouldntBePersistedAgain.
@Test
public void readItemsShouldntBePersistedAgain() {
PathRev k = generatePathRev();
nodeCache.put(k, VAL);
nodeCache.getIfPresent(k);
flush();
assertEquals(asList(k), putActions);
putActions.clear();
// k should be loaded from persisted cache
nodeCache.getIfPresent(k);
flush();
// k is not persisted again
assertEquals(emptyList(), putActions);
}
Aggregations