use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class NonLocalObservationIT method getFixture.
@Override
protected NodeStoreFixture getFixture() {
/**
* Fixes the cluster use case plus allowing to control the cache sizes.
* In theory other users of DocumentMongoFixture might have similar
* test cases - but keeping it simple for now - thus going via subclass.
*/
return new DocumentMongoFixture() {
private String clusterSuffix = System.currentTimeMillis() + "-NonLocalObservationIT";
private DB db;
/** keep a reference to the node stores so that the db only gets closed after the last nodeStore was closed */
private Set<NodeStore> nodeStores = new HashSet<NodeStore>();
/**
* This is not implemented in the super class at all.
* <ul>
* <li>use a specific suffix to make sure we have our own, new db and clean it up after the test</li>
* <li>properly drop that db created above in dispose</li>
* <li>use only 32MB (vs default of 256MB) memory to ensure we're not going OOM just because of this (which happens with the default)</li>
* <li>disable the persistent cache for the same reason</li>
* </ul>
*/
@Override
public NodeStore createNodeStore(int clusterNodeId) {
try {
DocumentMK.Builder builder = new DocumentMK.Builder();
// keep this one low to avoid OOME
builder.memoryCacheSize(32 * 1024 * 1024);
// turn this one off to avoid OOME
builder.setPersistentCache(null);
final String suffix = clusterSuffix;
// db will be overwritten - but that's fine
db = getDb(suffix);
builder.setMongoDB(db);
DocumentNodeStore ns = builder.getNodeStore();
nodeStores.add(ns);
return ns;
} catch (Exception e) {
throw new AssumptionViolatedException("Mongo instance is not available", e);
}
}
@Override
public void dispose(NodeStore nodeStore) {
super.dispose(nodeStore);
nodeStores.remove(nodeStore);
if (db != null && nodeStores.size() == 0) {
try {
db.dropDatabase();
db.getMongo().close();
db = null;
} catch (Exception e) {
log.error("dispose: Can't close Mongo", e);
}
}
}
@Override
public String toString() {
return "NonLocalObservationIT's DocumentMongoFixture flavour";
}
};
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class ValidNamesTest method createRepository.
private Repository createRepository(NodeStoreFixture fixture) throws RepositoryException {
NodeStore ns = null;
for (Map.Entry<NodeStoreFixture, NodeStore> e : STORES.entrySet()) {
if (e.getKey().getClass().equals(fixture.getClass())) {
ns = e.getValue();
}
}
if (ns == null) {
ns = createNodeStore(fixture);
STORES.put(fixture, ns);
}
return createRepository(ns);
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class LuceneBlobCacheTest method setUp.
@Before
public void setUp() throws Exception {
fileDataStore = new ReadAccessCountingDataStore();
fileDataStore.init(tempFolder.newFolder().getAbsolutePath());
FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(tempFolder.newFolder()).withBlobStore(new DataStoreBlobStore(fileDataStore)).withMaxFileSize(256).withSegmentCacheSize(64).withMemoryMapping(false);
store = fileStoreBuilder.build();
NodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
root = nodeStore.getRoot();
builder = root.builder();
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class BrokenNetworkIT method useProxy.
private void useProxy(boolean ssl, int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
FileStore storeS = serverFileStore.fileStore();
FileStore storeC = clientFileStore1.fileStore();
FileStore storeC2 = clientFileStore2.fileStore();
NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
addTestContent(store, "server");
// this speeds up the test a little bit...
storeS.flush();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ssl);
StandbyClientSync clientSync = newStandbyClientSync(storeC, proxyPort.getPort(), ssl)) {
proxy.skipBytes(skipPosition, skipBytes);
proxy.flipByte(flipPosition);
proxy.connect();
serverSync.start();
clientSync.run();
if (skipBytes > 0 || flipPosition >= 0) {
assertFalse("stores are not expected to be equal", storeS.getHead().equals(storeC.getHead()));
assertEquals(storeC2.getHead(), storeC.getHead());
proxy.reset();
if (intermediateChange) {
addTestContent(store, "server2");
storeS.flush();
}
clientSync.run();
}
assertEquals(storeS.getHead(), storeC.getHead());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class DataStoreTestBase method testSyncUpdatedBinaryProperty.
/*
* See OAK-4969.
*/
@Test
public void testSyncUpdatedBinaryProperty() throws Exception {
final int blobSize = 5 * MB;
FileStore primary = getPrimary();
FileStore secondary = getSecondary();
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())) {
serverSync.start();
addTestContent(store, "server", blobSize);
primary.flush();
clientSync.run();
assertEquals(primary.getHead(), secondary.getHead());
addTestContent(store, "server", blobSize);
primary.flush();
clientSync.run();
assertEquals(primary.getHead(), secondary.getHead());
}
}
Aggregations