use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class LockBasedSchedulerCheckpointTest method testShortWait.
/**
* OAK-3587 test simulates a timeout while trying to create a checkpoint,
* then releases the lock and tries again
*/
@Test
public void testShortWait() throws Exception {
MemoryStore ms = new MemoryStore();
System.setProperty("oak.checkpoints.lockWaitTime", "1");
final LockBasedScheduler scheduler = LockBasedScheduler.builder(ms.getRevisions(), ms.getReader()).build();
final Semaphore semaphore = new Semaphore(0);
final AtomicBoolean blocking = new AtomicBoolean(true);
final Callable<Boolean> block = new Callable<Boolean>() {
@Override
public Boolean call() {
while (blocking.get()) {
if (semaphore.availablePermits() == 0) {
semaphore.release();
}
}
return true;
}
};
Thread background = new Thread() {
@Override
public void run() {
try {
Commit commit = createBlockingCommit(scheduler, "foo", "bar", block);
scheduler.schedule(commit);
} catch (Exception e) {
//
}
}
};
background.start();
semaphore.acquire();
String cp0 = scheduler.checkpoint(10, Collections.<String, String>emptyMap());
assertNull(retrieveCheckpoint(scheduler, cp0));
blocking.set(false);
String cp1 = scheduler.checkpoint(10, Collections.<String, String>emptyMap());
assertNotNull(retrieveCheckpoint(scheduler, cp1));
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class LongNameTest method longNameOnSegmentStoreWorksFine.
@Test
public void longNameOnSegmentStoreWorksFine() throws RepositoryException, IOException {
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
upgrade(nodeStore, false, false);
NodeState parent = getParent(nodeStore.getRoot());
Assert.assertTrue(parent.hasChildNode(NOT_TOO_LONG_NAME));
Assert.assertTrue(parent.hasChildNode(TOO_LONG_NAME));
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class RepositorySidegradeTest method upgradeRepository.
@Before
public synchronized void upgradeRepository() throws Exception {
targetNodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
targetRepository = new Jcr(new Oak(targetNodeStore)).createRepository();
NodeStore source = createSourceContent();
RepositorySidegrade sidegrade = new RepositorySidegrade(source, targetNodeStore);
sidegrade.copy();
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class HiddenNodeTest method before.
@Before
public void before() throws Exception {
store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
repo = new Jcr(store).createRepository();
session = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));
vMgr = session.getWorkspace().getVersionManager();
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class MergeTest method testSequentialMerge.
@Test
public void testSequentialMerge() throws CommitFailedException, IOException {
NodeStore store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
assertFalse(store.getRoot().hasProperty("foo"));
assertFalse(store.getRoot().hasProperty("bar"));
NodeBuilder a = store.getRoot().builder();
a.setProperty("foo", "abc");
store.merge(a, EmptyHook.INSTANCE, CommitInfo.EMPTY);
assertTrue(store.getRoot().hasProperty("foo"));
assertFalse(store.getRoot().hasProperty("bar"));
NodeBuilder b = store.getRoot().builder();
b.setProperty("bar", "xyz");
store.merge(b, EmptyHook.INSTANCE, CommitInfo.EMPTY);
assertTrue(store.getRoot().hasProperty("foo"));
assertTrue(store.getRoot().hasProperty("bar"));
}
Aggregations