use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.
the class BufferedOakDirectoryTest method dontWarnUnnecesarily.
@Test
public void dontWarnUnnecesarily() {
String oldVal = System.getProperty(ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM);
final LogCustomizer custom = LogCustomizer.forLogger(BufferedOakDirectory.class.getName()).contains("Ignoring configuration ").enable(Level.WARN).create();
custom.starting();
BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(true);
assertEquals("Don't warn unnecessarily", 0, custom.getLogs().size());
System.setProperty(ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM, "true");
reReadCommandLineParam();
assertEquals("Don't warn unnecessarily", 0, custom.getLogs().size());
BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(true);
assertEquals("Don't warn unnecessarily", 0, custom.getLogs().size());
System.clearProperty(ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM);
System.setProperty(ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM, "false");
reReadCommandLineParam();
assertEquals("Don't warn unnecessarily", 0, custom.getLogs().size());
BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(false);
assertEquals("Don't warn unnecessarily", 0, custom.getLogs().size());
System.clearProperty(ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM);
custom.finished();
if (oldVal == null) {
System.clearProperty(ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM);
} else {
System.setProperty(ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM, oldVal);
}
}
use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.
the class MongoBlobGCTest method checkGcPathLogging.
@Test
public void checkGcPathLogging() throws Exception {
String rootFolder = folder.newFolder().getAbsolutePath();
LogCustomizer customLogs = LogCustomizer.forLogger(MarkSweepGarbageCollector.class.getName()).enable(Level.TRACE).filter(Level.TRACE).create();
setUp(false);
customLogs.starting();
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
MarkSweepGarbageCollector gcObj = init(0, executor, rootFolder);
gcObj.collectGarbage(true);
customLogs.finished();
assertBlobReferenceRecords(1, rootFolder);
}
use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method closeWithHardLimit.
@Test
public void closeWithHardLimit() throws Exception {
NodeStore store = new MemoryNodeStore();
IndexEditorProvider provider = new PropertyIndexEditorProvider();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("testRoot").setProperty("foo", "abc");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
final Semaphore asyncLock = new Semaphore(1);
final AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider) {
@Override
protected AsyncUpdateCallback newAsyncUpdateCallback(NodeStore store, String name, long leaseTimeOut, String beforeCheckpoint, AsyncIndexStats indexStats, AtomicBoolean stopFlag) {
try {
asyncLock.acquire();
} catch (InterruptedException ignore) {
}
return super.newAsyncUpdateCallback(store, name, leaseTimeOut, beforeCheckpoint, indexStats, stopFlag);
}
};
// Set a 1 sec close timeout
async.setCloseTimeOut(1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
async.run();
}
});
Thread closer = new Thread(new Runnable() {
@Override
public void run() {
async.close();
}
});
// Lock to ensure that AsyncIndexUpdate waits
asyncLock.acquire();
t.start();
// Wait till async gets to wait state i.e. inside run
while (!asyncLock.hasQueuedThreads()) ;
LogCustomizer lc = createLogCustomizer(Level.DEBUG);
closer.start();
// Wait till stopFlag is set
while (!async.isClosed()) ;
assertLogPhrase(lc.getLogs(), "[SOFT LIMIT HIT]");
// Let indexing run complete now
asyncLock.release();
// Wait for both threads
t.join();
// Async run would have exited with log message logged
assertLogPhrase(lc.getLogs(), "The index update interrupted");
// Wait for close call to complete
closer.join();
lc.finished();
}
use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method closeWithSoftLimit.
@Test
public void closeWithSoftLimit() throws Exception {
NodeStore store = new MemoryNodeStore();
IndexEditorProvider provider = new PropertyIndexEditorProvider();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("testRoot").setProperty("foo", "abc");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
final Semaphore asyncLock = new Semaphore(1);
final AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider) {
@Override
protected AsyncUpdateCallback newAsyncUpdateCallback(NodeStore store, String name, long leaseTimeOut, String beforeCheckpoint, AsyncIndexStats indexStats, AtomicBoolean stopFlag) {
try {
asyncLock.acquire();
} catch (InterruptedException ignore) {
}
return super.newAsyncUpdateCallback(store, name, leaseTimeOut, beforeCheckpoint, indexStats, stopFlag);
}
};
async.setCloseTimeOut(1000);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
async.run();
}
});
Thread closer = new Thread(new Runnable() {
@Override
public void run() {
async.close();
}
});
asyncLock.acquire();
t.start();
// Wait till async gets to wait state i.e. inside run
while (!asyncLock.hasQueuedThreads()) ;
LogCustomizer lc = createLogCustomizer(Level.DEBUG);
closer.start();
// Wait till closer is in waiting state
while (!async.isClosing()) ;
// For softLimit case the flag should not be set
assertFalse(async.isClosed());
assertLogPhrase(lc.getLogs(), "[WAITING]");
// Let indexing run complete now
asyncLock.release();
// Wait for both threads
t.join();
closer.join();
// Close call should complete
assertLogPhrase(lc.getLogs(), "[CLOSED OK]");
}
use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.
the class DataStoreTrackerGCTest method clusterGCInternal.
private void clusterGCInternal(Cluster cluster1, Cluster cluster2, boolean same) throws Exception {
BlobStore s1 = cluster1.blobStore;
BlobIdTracker tracker1 = (BlobIdTracker) ((BlobTrackingStore) s1).getTracker();
DataStoreState state1 = init(cluster1.nodeStore, 0);
cluster1.nodeStore.runBackgroundOperations();
ScheduledFuture<?> scheduledFuture1 = newSingleThreadScheduledExecutor().schedule(tracker1.new SnapshotJob(), 0, MILLISECONDS);
scheduledFuture1.get();
// Add blobs to cluster1
BlobStore s2 = cluster2.blobStore;
BlobIdTracker tracker2 = (BlobIdTracker) ((BlobTrackingStore) s2).getTracker();
cluster2.nodeStore.runBackgroundOperations();
DataStoreState state2 = init(cluster2.nodeStore, 20);
cluster2.nodeStore.runBackgroundOperations();
cluster1.nodeStore.runBackgroundOperations();
ScheduledFuture<?> scheduledFuture2 = newSingleThreadScheduledExecutor().schedule(tracker2.new SnapshotJob(), 0, MILLISECONDS);
scheduledFuture2.get();
// If not same cluster need to mark references on other repositories
if (!same) {
cluster2.gc.collectGarbage(true);
}
// do a gc on cluster1 with sweep
cluster1.gc.collectGarbage(false);
Set<String> existingAfterGC = iterate(s1);
// Check the state of the blob store after gc
assertEquals(union(state1.blobsPresent, state2.blobsPresent), existingAfterGC);
// Tracked blobs should reflect deletions after gc
assertEquals(union(state1.blobsPresent, state2.blobsPresent), retrieveTracked(tracker1));
// Again create snapshots at both cluster nodes to synchronize the latest state of
// local references with datastore at each node
scheduledFuture1 = newSingleThreadScheduledExecutor().schedule(tracker1.new SnapshotJob(), 0, MILLISECONDS);
scheduledFuture1.get();
scheduledFuture2 = newSingleThreadScheduledExecutor().schedule(tracker2.new SnapshotJob(), 0, MILLISECONDS);
scheduledFuture2.get();
// Capture logs for the second round of gc
LogCustomizer customLogs = LogCustomizer.forLogger(MarkSweepGarbageCollector.class.getName()).enable(Level.WARN).filter(Level.WARN).contains("Error occurred while deleting blob with id").create();
customLogs.starting();
if (!same) {
cluster2.gc.collectGarbage(true);
}
cluster1.gc.collectGarbage(false);
existingAfterGC = iterate(s1);
assertEquals(0, customLogs.getLogs().size());
customLogs.finished();
// Check the state of the blob store after gc
assertEquals(union(state1.blobsPresent, state2.blobsPresent), existingAfterGC);
}
Aggregations