use of org.apache.jackrabbit.oak.query.QueryEngineSettings in project jackrabbit-oak by apache.
the class ImportIgnoreTest method before.
@Before
public void before() throws Exception {
String importBehavior = getImportBehavior();
SecurityProvider securityProvider;
if (importBehavior != null) {
Map<String, String> params = new HashMap<String, String>();
params.put(ProtectedItemImporter.PARAM_IMPORT_BEHAVIOR, getImportBehavior());
ConfigurationParameters config = ConfigurationParameters.of(AuthorizationConfiguration.NAME, ConfigurationParameters.of(params));
securityProvider = SecurityProviderBuilder.newBuilder().with(config).build();
} else {
securityProvider = SecurityProviderBuilder.newBuilder().build();
}
QueryEngineSettings queryEngineSettings = new QueryEngineSettings();
queryEngineSettings.setFailTraversal(true);
Jcr jcr = new Jcr();
jcr.with(securityProvider);
jcr.with(queryEngineSettings);
repo = jcr.createRepository();
adminSession = repo.login(new SimpleCredentials(UserConstants.DEFAULT_ADMIN_ID, UserConstants.DEFAULT_ADMIN_ID.toCharArray()));
target = adminSession.getRootNode().addNode("nodeName1");
target.addMixin("rep:AccessControllable");
adminSession.save();
}
use of org.apache.jackrabbit.oak.query.QueryEngineSettings in project jackrabbit-oak by apache.
the class ExternalIdentityImporterTest method createRepo.
private Repository createRepo() throws Exception {
SecurityProvider securityProvider = TestSecurityProvider.newTestSecurityProvider(ConfigurationParameters.EMPTY, new ExternalPrincipalConfiguration());
QueryEngineSettings queryEngineSettings = new QueryEngineSettings();
queryEngineSettings.setFailTraversal(true);
Jcr jcr = new Jcr();
jcr.with(securityProvider);
jcr.with(queryEngineSettings);
return jcr.createRepository();
}
use of org.apache.jackrabbit.oak.query.QueryEngineSettings in project jackrabbit-oak by apache.
the class Oak method with.
@Nonnull
public Oak with(@Nonnull Whiteboard whiteboard) {
this.whiteboard = checkNotNull(whiteboard);
if (securityProvider instanceof WhiteboardAware) {
((WhiteboardAware) securityProvider).setWhiteboard(whiteboard);
}
QueryEngineSettings queryEngineSettings = WhiteboardUtils.getService(whiteboard, QueryEngineSettings.class);
if (queryEngineSettings != null) {
this.queryEngineSettings = new AnnotatedQueryEngineSettings(queryEngineSettings);
}
return this;
}
use of org.apache.jackrabbit.oak.query.QueryEngineSettings in project jackrabbit-oak by apache.
the class QueryStatsTest method testEviction.
@Test
public void testEviction() throws InterruptedException {
QueryStatsMBeanImpl bean = new QueryStatsMBeanImpl(new QueryEngineSettings());
for (int i = 0; i < 10010; i++) {
bean.getQueryExecution("old" + i, "");
if (i % 100 == 0) {
Thread.sleep(1);
}
}
assertEquals(1, bean.getEvictionCount());
// remain around 5000
Thread.sleep(5);
for (int i = 0; i < 10; i++) {
bean.getQueryExecution("slow" + i, "").execute(10000);
}
Thread.sleep(5);
assertEquals(1, bean.getEvictionCount());
for (int i = 0; i < 10010; i++) {
bean.getQueryExecution("new" + i, "");
if (i % 100 == 0) {
Thread.sleep(1);
}
}
assertEquals(3, bean.getEvictionCount());
String json = bean.asJson();
for (int i = 0; i < 10; i++) {
assertTrue(json.indexOf("slow" + i) >= 0);
}
assertTrue(json.indexOf("old") < 0);
}
Aggregations