Search in sources :

Example 1 with LogCustomizer

use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.

the class ObservationQueueFullWarnTest method warnOnQueueFull.

@Test
public void warnOnQueueFull() throws RepositoryException, InterruptedException, ExecutionException {
    LogCustomizer customLogs = LogCustomizer.forLogger(ChangeProcessor.class.getName()).filter(Level.WARN).contains(OBS_QUEUE_FULL_WARN).create();
    observationManager.addEventListener(listener, NODE_ADDED, TEST_PATH, true, null, null, false);
    try {
        customLogs.starting();
        addNodeToFillObsQueue();
        assertTrue("Observation queue full warning must get logged", customLogs.getLogs().size() > 0);
        customLogs.finished();
    } finally {
        observationManager.removeEventListener(listener);
    }
}
Also used : LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) Test(org.junit.Test) AbstractRepositoryTest(org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)

Example 2 with LogCustomizer

use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.

the class SegmentDataStoreBlobGCIT method checkMark.

@Test
public void checkMark() throws Exception {
    LogCustomizer customLogs = LogCustomizer.forLogger(MarkSweepGarbageCollector.class.getName()).enable(Level.TRACE).filter(Level.TRACE).create();
    DataStoreState state = setUp(10);
    log.info("{} blobs available : {}", state.blobsPresent.size(), state.blobsPresent);
    customLogs.starting();
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    String rootFolder = folder.newFolder().getAbsolutePath();
    MarkSweepGarbageCollector gcObj = init(0, executor, rootFolder);
    gcObj.collectGarbage(true);
    customLogs.finished();
    assertBlobReferenceRecords(state.blobsPresent, rootFolder);
}
Also used : LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) Test(org.junit.Test)

Example 3 with LogCustomizer

use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.

the class RDBDocumentStoreJDBCTest method queryIteratorConsumedTest.

@Test
public void queryIteratorConsumedTest() throws SQLException {
    insertTestResource(this.getClass().getName() + "." + name.getMethodName());
    LogCustomizer customLogs = LogCustomizer.forLogger(RDBDocumentStoreJDBC.class.getName()).enable(Level.DEBUG).contains("Query on ").create();
    customLogs.starting();
    MyConnectionHandler ch = new MyConnectionHandler(super.rdbDataSource);
    RDBTableMetaData tmd = ((RDBDocumentStore) super.ds).getTable(Collection.NODES);
    List<QueryCondition> conditions = Collections.emptyList();
    try {
        Iterator<RDBRow> qi = jdbc.queryAsIterator(ch, tmd, null, null, RDBDocumentStore.EMPTY_KEY_PATTERN, conditions, Integer.MAX_VALUE, null);
        assertTrue(qi instanceof Closeable);
        assertEquals(1, ch.cnt.get());
        while (qi.hasNext()) {
            qi.next();
        }
        assertEquals(0, ch.cnt.get());
        assertEquals("should have a DEBUG level log entry", 1, customLogs.getLogs().size());
    } finally {
        customLogs.finished();
        customLogs = null;
    }
}
Also used : RDBTableMetaData(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData) LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) Closeable(java.io.Closeable) QueryCondition(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.QueryCondition) Test(org.junit.Test) AbstractDocumentStoreTest(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentStoreTest)

Example 4 with LogCustomizer

use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.

the class RDBDocumentStoreSchemaUpgradeTest method init01.

@Test
public void init01() {
    LogCustomizer logCustomizer = LogCustomizer.forLogger(RDBDocumentStore.class.getName()).enable(Level.INFO).contains("to DB level 1").create();
    logCustomizer.starting();
    RDBOptions op = new RDBOptions().tablePrefix("T01").initialSchema(0).upgradeToSchema(1).dropTablesOnClose(true);
    RDBDocumentStore rdb = null;
    try {
        rdb = new RDBDocumentStore(this.ds, new DocumentMK.Builder(), op);
        RDBTableMetaData meta = rdb.getTable(Collection.NODES);
        assertEquals(op.getTablePrefix() + "_NODES", meta.getName());
        assertTrue(meta.hasVersion());
        assertEquals("unexpected # of log entries: " + logCustomizer.getLogs(), RDBDocumentStore.getTableNames().size(), logCustomizer.getLogs().size());
    } finally {
        logCustomizer.finished();
        if (rdb != null) {
            rdb.dispose();
        }
    }
}
Also used : RDBTableMetaData(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData) LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) Test(org.junit.Test)

Example 5 with LogCustomizer

use of org.apache.jackrabbit.oak.commons.junit.LogCustomizer in project jackrabbit-oak by apache.

the class IndexUpdateTest method reindexForDisabledIndexes.

@Test
public void reindexForDisabledIndexes() throws Exception {
    EditorHook hook = new EditorHook(new IndexUpdateProvider(new CompositeIndexEditorProvider(new PropertyIndexEditorProvider(), new ReferenceEditorProvider())));
    NodeState before = builder.getNodeState();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "fooIndex", true, false, ImmutableSet.of("foo"), null);
    builder.child("testRoot").setProperty("foo", "abc");
    NodeState after = builder.getNodeState();
    NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    before = indexed;
    builder = before.builder();
    builder.getChildNode("oak:index").getChildNode("fooIndex").setProperty(TYPE_PROPERTY_NAME, TYPE_DISABLED);
    builder.getChildNode("oak:index").getChildNode("fooIndex").setProperty(REINDEX_PROPERTY_NAME, true);
    after = builder.getNodeState();
    LogCustomizer customLogs = LogCustomizer.forLogger(IndexUpdate.class.getName()).filter(Level.INFO).create();
    customLogs.starting();
    before = after;
    builder = before.builder();
    builder.child("testRoot2").setProperty("foo", "abc");
    after = builder.getNodeState();
    indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    assertTrue(customLogs.getLogs().isEmpty());
    customLogs.finished();
}
Also used : ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) Test(org.junit.Test)

Aggregations

LogCustomizer (org.apache.jackrabbit.oak.commons.junit.LogCustomizer)30 Test (org.junit.Test)28 RDBTableMetaData (org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData)8 MarkSweepGarbageCollector (org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector)5 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)4 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)4 ProxyNodeStore (org.apache.jackrabbit.oak.spi.state.ProxyNodeStore)4 AbstractDocumentStoreTest (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentStoreTest)3 QueryCondition (org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.QueryCondition)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Closeable (java.io.Closeable)2 Semaphore (java.util.concurrent.Semaphore)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)2 UpdateOp (org.apache.jackrabbit.oak.plugins.document.UpdateOp)2 AsyncIndexStats (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate.AsyncIndexStats)2 BlobDeletionCallback (org.apache.jackrabbit.oak.plugins.index.lucene.directory.ActiveDeletedBlobCollectorFactory.BlobDeletionCallback)2