use of org.apache.druid.java.util.common.lifecycle.Lifecycle in project druid by druid-io.
the class ITTLSTest method makeCertlessClient.
private HttpClient makeCertlessClient() {
SSLContext certlessClientSSLContext = new TLSUtils.ClientSSLContextBuilder().setProtocol(sslClientConfig.getProtocol()).setTrustStoreType(sslClientConfig.getTrustStoreType()).setTrustStorePath(sslClientConfig.getTrustStorePath()).setTrustStoreAlgorithm(sslClientConfig.getTrustStoreAlgorithm()).setTrustStorePasswordProvider(sslClientConfig.getTrustStorePasswordProvider()).setCertificateChecker(certificateChecker).build();
final HttpClientConfig.Builder builder = getHttpClientConfigBuilder(certlessClientSSLContext);
final Lifecycle lifecycle = new Lifecycle();
HttpClient client = HttpClientInit.createClient(builder.build(), lifecycle);
HttpClient adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), client);
return adminClient;
}
use of org.apache.druid.java.util.common.lifecycle.Lifecycle in project druid by druid-io.
the class ITTLSTest method makeCustomHttpClient.
private HttpClient makeCustomHttpClient(String keystorePath, String certAlias, TLSCertificateChecker certificateChecker) {
SSLContext intermediateClientSSLContext = new TLSUtils.ClientSSLContextBuilder().setProtocol(sslClientConfig.getProtocol()).setTrustStoreType(sslClientConfig.getTrustStoreType()).setTrustStorePath(sslClientConfig.getTrustStorePath()).setTrustStoreAlgorithm(sslClientConfig.getTrustStoreAlgorithm()).setTrustStorePasswordProvider(sslClientConfig.getTrustStorePasswordProvider()).setKeyStoreType(sslClientConfig.getKeyStoreType()).setKeyStorePath(keystorePath).setKeyStoreAlgorithm(sslClientConfig.getKeyManagerFactoryAlgorithm()).setCertAlias(certAlias).setKeyStorePasswordProvider(sslClientConfig.getKeyStorePasswordProvider()).setKeyManagerFactoryPasswordProvider(sslClientConfig.getKeyManagerPasswordProvider()).setCertificateChecker(certificateChecker).build();
final HttpClientConfig.Builder builder = getHttpClientConfigBuilder(intermediateClientSSLContext);
final Lifecycle lifecycle = new Lifecycle();
HttpClient client = HttpClientInit.createClient(builder.build(), lifecycle);
HttpClient adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), client);
return adminClient;
}
use of org.apache.druid.java.util.common.lifecycle.Lifecycle in project druid by druid-io.
the class PrioritizedListenableFutureTask method create.
public static PrioritizedExecutorService create(Lifecycle lifecycle, DruidProcessingConfig config) {
final PrioritizedExecutorService service = new PrioritizedExecutorService(new ThreadPoolExecutor(config.getNumThreads(), config.getNumThreads(), 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue<Runnable>(), new ThreadFactoryBuilder().setDaemon(true).setNameFormat(config.getFormatString()).build()), config);
lifecycle.addHandler(new Lifecycle.Handler() {
@Override
public void start() {
}
@Override
public void stop() {
service.shutdownNow();
}
});
return service;
}
use of org.apache.druid.java.util.common.lifecycle.Lifecycle in project druid by druid-io.
the class LifecycleScopeTest method testAnnotation.
@Test
public void testAnnotation() throws Exception {
final Injector injector = Guice.createInjector(new DruidGuiceExtensions(), new LifecycleModule(), new Module() {
@Override
public void configure(Binder binder) {
binder.bind(TestInterface.class).to(AnnotatedClass.class);
}
});
final Lifecycle lifecycle = injector.getInstance(Lifecycle.class);
final TestInterface instance = injector.getInstance(TestInterface.class);
testIt(injector, lifecycle, instance);
}
use of org.apache.druid.java.util.common.lifecycle.Lifecycle in project druid by druid-io.
the class LifecycleScopeTest method testExplicit.
@Test
public void testExplicit() throws Exception {
final Injector injector = Guice.createInjector(new DruidGuiceExtensions(), new LifecycleModule(), new Module() {
@Override
public void configure(Binder binder) {
binder.bind(TestInterface.class).to(ExplicitClass.class).in(ManageLifecycle.class);
}
});
final Lifecycle lifecycle = injector.getInstance(Lifecycle.class);
final TestInterface instance = injector.getInstance(TestInterface.class);
testIt(injector, lifecycle, instance);
}
Aggregations