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()));
}
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));
}
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();
}
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));
}
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);
}
Aggregations