Search in sources :

Example 21 with Whiteboard

use of org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard in project jackrabbit-oak by apache.

the class AsyncIndexerService method activate.

@Activate
public void activate(BundleContext bundleContext, Map<String, Object> config) {
    List<AsyncConfig> asyncIndexerConfig = getAsyncConfig(PropertiesUtil.toStringArray(config.get(PROP_ASYNC_CONFIG), new String[0]));
    Whiteboard whiteboard = new OsgiWhiteboard(bundleContext);
    indexRegistration = new IndexMBeanRegistration(whiteboard);
    indexEditorProvider.start(whiteboard);
    executor = new WhiteboardExecutor();
    executor.start(whiteboard);
    long leaseTimeOutMin = PropertiesUtil.toInteger(config.get(PROP_LEASE_TIME_OUT), PROP_LEASE_TIMEOUT_DEFAULT);
    if (!(nodeStore instanceof Clusterable)) {
        leaseTimeOutMin = 0;
        log.info("Detected non clusterable setup. Lease checking would be disabled for async indexing");
    }
    TrackingCorruptIndexHandler corruptIndexHandler = createCorruptIndexHandler(config);
    for (AsyncConfig c : asyncIndexerConfig) {
        AsyncIndexUpdate task = new AsyncIndexUpdate(c.name, nodeStore, indexEditorProvider, statisticsProvider, false);
        task.setCorruptIndexHandler(corruptIndexHandler);
        task.setValidatorProviders(Collections.singletonList(validatorProvider));
        task.setLeaseTimeOut(TimeUnit.MINUTES.toMillis(leaseTimeOutMin));
        indexRegistration.registerAsyncIndexer(task, c.timeIntervalInSecs);
        closer.register(task);
    }
    registerAsyncReindexSupport(whiteboard);
    log.info("Configured async indexers {} ", asyncIndexerConfig);
    log.info("Lease time: {} mins and AsyncIndexUpdate configured with {}", leaseTimeOutMin, validatorProvider.getClass().getName());
}
Also used : Clusterable(org.apache.jackrabbit.oak.spi.state.Clusterable) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) WhiteboardExecutor(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.apache.felix.scr.annotations.Activate)

Example 22 with Whiteboard

use of org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard in project jackrabbit-oak by apache.

the class OakTest method checkMissingStrategySetting.

@Test(expected = CommitFailedException.class)
public void checkMissingStrategySetting() throws Exception {
    Whiteboard wb = new DefaultWhiteboard();
    WhiteboardIndexEditorProvider wbProvider = new WhiteboardIndexEditorProvider();
    wbProvider.start(wb);
    Registration r1 = wb.register(IndexEditorProvider.class, new PropertyIndexEditorProvider(), null);
    Registration r2 = wb.register(IndexEditorProvider.class, new ReferenceEditorProvider(), null);
    Oak oak = new Oak().with(new OpenSecurityProvider()).with(new InitialContent()).with(wb).with(wbProvider).withFailOnMissingIndexProvider();
    ContentRepository repo = oak.createContentRepository();
    ContentSession cs = repo.login(null, null);
    Root root = cs.getLatestRoot();
    Tree t = root.getTree("/");
    t.setProperty("foo", "u1", Type.REFERENCE);
    r1.unregister();
    root.commit();
    cs.close();
    ((Closeable) repo).close();
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Closeable(java.io.Closeable) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) WhiteboardIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.WhiteboardIndexEditorProvider) ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) Registration(org.apache.jackrabbit.oak.spi.whiteboard.Registration) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Tree(org.apache.jackrabbit.oak.api.Tree) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Test(org.junit.Test)

Example 23 with Whiteboard

use of org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard in project jackrabbit-oak by apache.

the class InternalSecurityProviderTest method testSetWhiteboard.

@Test
public void testSetWhiteboard() {
    Whiteboard wb = new DefaultWhiteboard();
    securityProvider.setWhiteboard(wb);
    assertSame(wb, securityProvider.getWhiteboard());
}
Also used : DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Test(org.junit.Test)

Example 24 with Whiteboard

use of org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard in project jackrabbit-oak by apache.

the class ObservationQueueTest method heavyLoad.

@Test
public void heavyLoad() throws Throwable {
    List<Whiteboard> whiteboards = Lists.newArrayList(w1, w2);
    Iterator<Repository> repos = Iterators.cycle(r1, r2);
    AtomicLong commitCounter = new AtomicLong();
    for (int i = 0; i < NUM_WRITERS; i++) {
        Session s = loginUser(repos.next());
        Node n = s.getRootNode().addNode("session-" + i, "oak:Unstructured");
        s.save();
        writers.add(new Thread(new Writer(n, commitCounter)));
    }
    for (int i = 0; i < NUM_READERS; i++) {
        Session s = loginUser(repos.next());
        readers.add(new Thread(new Reader(s)));
    }
    AtomicInteger queueLength = new AtomicInteger();
    loggers.add(new Thread(new QueueLogger(whiteboards, queueLength, commitCounter)));
    for (int i = 0; i < NUM_OBSERVERS; i++) {
        Session s = loginUser(repos.next());
        observers.add(new Thread(new Observer(s, queueLength)));
    }
    for (Thread t : Iterables.concat(writers, readers, observers, loggers)) {
        t.start();
    }
    for (Thread t : Iterables.concat(writers, readers)) {
        t.join();
    }
    LOG.info("Writes stopped. Waiting for observers...");
    for (Thread t : Iterables.concat(observers, loggers)) {
        t.join();
    }
    for (Throwable t : exceptions) {
        throw t;
    }
}
Also used : Node(javax.jcr.Node) Repository(javax.jcr.Repository) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) AbstractClusterTest(org.apache.jackrabbit.oak.jcr.cluster.AbstractClusterTest) Test(org.junit.Test)

Example 25 with Whiteboard

use of org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard in project jackrabbit-oak by apache.

the class RefreshOnGCTest method setup.

@Before
public void setup() throws Exception {
    File directory = createTempFile(getClass().getSimpleName(), "test", new File("target"));
    directory.delete();
    directory.mkdir();
    Whiteboard whiteboard = new DefaultWhiteboard();
    gcMonitor = new GCMonitorTracker();
    gcMonitor.start(whiteboard);
    Oak oak = new Oak(createSegmentTarStore(directory, gcMonitor));
    oak.with(whiteboard);
    repository = new Jcr(oak).createRepository();
}
Also used : GCMonitorTracker(org.apache.jackrabbit.oak.spi.gc.GCMonitorTracker) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Oak(org.apache.jackrabbit.oak.Oak) File.createTempFile(java.io.File.createTempFile) File(java.io.File) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Before(org.junit.Before)

Aggregations

Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)25 DefaultWhiteboard (org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard)11 Test (org.junit.Test)10 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)9 Activate (org.apache.felix.scr.annotations.Activate)7 Oak (org.apache.jackrabbit.oak.Oak)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Closeable (java.io.Closeable)2 Hashtable (java.util.Hashtable)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Repository (javax.jcr.Repository)2 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 CacheStatsMBean (org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean)2 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)2 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)2 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)2 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 BundleContext (org.osgi.framework.BundleContext)2