Search in sources :

Example 1 with DefaultWhiteboard

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

the class StatisticManagerTest method timeSeriesOnly.

@Test
public void timeSeriesOnly() throws Exception {
    Whiteboard wb = new DefaultWhiteboard();
    final Map<String, StatsOptions> optionsPassed = Maps.newHashMap();
    wb.register(StatisticsProvider.class, new DummyStatsProvider() {

        @Override
        public MeterStats getMeter(String name, StatsOptions options) {
            optionsPassed.put(name, options);
            return super.getMeter(name, options);
        }
    }, null);
    StatisticManager mgr = new StatisticManager(wb, executorService);
    mgr.getMeter(Type.SESSION_READ_COUNTER);
    assertEquals(StatsOptions.TIME_SERIES_ONLY, optionsPassed.get(Type.SESSION_READ_COUNTER.name()));
    mgr.getMeter(Type.SESSION_WRITE_COUNTER);
    assertEquals(StatsOptions.DEFAULT, optionsPassed.get(Type.SESSION_WRITE_COUNTER.name()));
}
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 2 with DefaultWhiteboard

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

the class StatisticManagerTest method defaultSetup.

@Test
public void defaultSetup() throws Exception {
    Whiteboard wb = new DefaultWhiteboard();
    StatisticManager mgr = new StatisticManager(wb, executorService);
    MeterStats meterStats = mgr.getMeter(Type.QUERY_COUNT);
    meterStats.mark(5);
    assertNotNull(WhiteboardUtils.getServices(wb, RepositoryStatsMBean.class));
    assertNotNull(WhiteboardUtils.getServices(wb, QueryStatManagerMBean.class));
}
Also used : DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) QueryStatManagerMBean(org.apache.jackrabbit.api.jmx.QueryStatManagerMBean) RepositoryStatsMBean(org.apache.jackrabbit.oak.api.jmx.RepositoryStatsMBean) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Test(org.junit.Test)

Example 3 with DefaultWhiteboard

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

the class LoginContextProviderImplTest method testGetLoginContextWithInvalidProviderConfig.

@Test
public void testGetLoginContextWithInvalidProviderConfig() throws Exception {
    ConfigurationParameters params = ConfigurationParameters.of(AuthenticationConfiguration.PARAM_CONFIG_SPI_NAME, "invalid");
    LoginContextProvider provider = new LoginContextProviderImpl(AuthenticationConfiguration.DEFAULT_APP_NAME, params, getContentRepository(), getSecurityProvider(), new DefaultWhiteboard());
    // invalid configuration falls back to default configuration
    LoginContext ctx = provider.getLoginContext(new SimpleCredentials(getTestUser().getID(), getTestUser().getID().toCharArray()), null);
    ctx.login();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) JaasLoginContext(org.apache.jackrabbit.oak.spi.security.authentication.JaasLoginContext) LoginContext(org.apache.jackrabbit.oak.spi.security.authentication.LoginContext) LoginContextProvider(org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 4 with DefaultWhiteboard

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

the class OakTest method closeAsyncIndexers.

@Test
public void closeAsyncIndexers() throws Exception {
    final AtomicReference<AsyncIndexUpdate> async = new AtomicReference<AsyncIndexUpdate>();
    Whiteboard wb = new DefaultWhiteboard() {

        @Override
        public <T> Registration register(Class<T> type, T service, Map<?, ?> properties) {
            if (service instanceof AsyncIndexUpdate) {
                async.set((AsyncIndexUpdate) service);
            }
            return super.register(type, service, properties);
        }
    };
    Oak oak = new Oak().with(new OpenSecurityProvider()).with(wb).withAsyncIndexing("foo-async", 5);
    ContentRepository repo = oak.createContentRepository();
    ((Closeable) repo).close();
    assertNotNull(async.get());
    assertTrue(async.get().isClosed());
    assertNull(WhiteboardUtils.getService(wb, AsyncIndexUpdate.class));
}
Also used : DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Closeable(java.io.Closeable) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) AsyncIndexUpdate(org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Map(java.util.Map) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Test(org.junit.Test)

Example 5 with DefaultWhiteboard

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

the class AtomicCounterEditorTest method singleNodeAsync.

@Test
public void singleNodeAsync() throws CommitFailedException, InterruptedException, ExecutionException {
    NodeStore store = new MemoryNodeStore();
    MyExecutor exec1 = new MyExecutor();
    Whiteboard board = new DefaultWhiteboard();
    EditorHook hook1 = new EditorHook(new TestableACEProvider(CLUSTER_1, exec1, store, board));
    NodeBuilder builder, root;
    PropertyState p;
    board.register(CommitHook.class, EmptyHook.INSTANCE, null);
    root = store.getRoot().builder();
    builder = root.child("c");
    builder = setMixin(builder);
    builder = incrementBy(builder, INCREMENT_BY_1);
    store.merge(root, hook1, CommitInfo.EMPTY);
    // as we're providing all the information we expect the counter not to be consolidated for
    // as long as the scheduled process has run
    builder = store.getRoot().builder().getChildNode("c");
    assertTrue(builder.exists());
    p = builder.getProperty(PREFIX_PROP_REVISION + CLUSTER_1.getInstanceId());
    assertNotNull(p);
    assertEquals(1, p.getValue(LONG).longValue());
    p = builder.getProperty(PREFIX_PROP_COUNTER + CLUSTER_1.getInstanceId());
    assertNotNull(p);
    assertEquals(1, p.getValue(LONG).longValue());
    p = builder.getProperty(PROP_COUNTER);
    assertNull(p);
    // executing the consolidation
    exec1.execute();
    // fetching the latest store state to see the changes
    builder = store.getRoot().builder().getChildNode("c");
    assertTrue("the counter node should exists", builder.exists());
    assertCounterNodeState(builder, ImmutableSet.of(PREFIX_PROP_COUNTER + CLUSTER_1.getInstanceId(), PREFIX_PROP_REVISION + CLUSTER_1.getInstanceId()), 1);
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) LongPropertyState(org.apache.jackrabbit.oak.plugins.memory.LongPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

DefaultWhiteboard (org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard)20 Test (org.junit.Test)16 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)14 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 Map (java.util.Map)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)3 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)3 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)3 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)3 JaasLoginContext (org.apache.jackrabbit.oak.spi.security.authentication.JaasLoginContext)3 LoginContext (org.apache.jackrabbit.oak.spi.security.authentication.LoginContext)3 LoginContextProvider (org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Registration (org.apache.jackrabbit.oak.spi.whiteboard.Registration)3 Before (org.junit.Before)3 Closeable (java.io.Closeable)2 HashMap (java.util.HashMap)2 SimpleCredentials (javax.jcr.SimpleCredentials)2