Search in sources :

Example 1 with JettyServerModule

use of org.apache.druid.server.initialization.jetty.JettyServerModule in project druid by druid-io.

the class JettyTest method testNumConnectionsMetricHttp.

@Test
public void testNumConnectionsMetricHttp() throws Exception {
    String text = "hello";
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(out)) {
        gzipOutputStream.write(text.getBytes(Charset.defaultCharset()));
    }
    Request request = new Request(HttpMethod.GET, new URL("http://localhost:" + port + "/latched/hello"));
    request.setHeader("Content-Encoding", "gzip");
    request.setContent(MediaType.TEXT_PLAIN, out.toByteArray());
    JettyServerModule jsm = injector.getInstance(JettyServerModule.class);
    latchedRequestState.reset();
    waitForJettyServerModuleActiveConnectionsZero(jsm);
    Assert.assertEquals(0, jsm.getActiveConnections());
    ListenableFuture<InputStream> go = client.go(request, new InputStreamResponseHandler());
    latchedRequestState.clientWaitForServerToStartRequest();
    Assert.assertEquals(1, jsm.getActiveConnections());
    latchedRequestState.clientReadyToFinishRequest();
    go.get();
    waitForJettyServerModuleActiveConnectionsZero(jsm);
    Assert.assertEquals(0, jsm.getActiveConnections());
}
Also used : InputStreamResponseHandler(org.apache.druid.java.util.http.client.response.InputStreamResponseHandler) GZIPOutputStream(java.util.zip.GZIPOutputStream) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) Request(org.apache.druid.java.util.http.client.Request) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JettyServerModule(org.apache.druid.server.initialization.jetty.JettyServerModule) URL(java.net.URL) Test(org.junit.Test)

Example 2 with JettyServerModule

use of org.apache.druid.server.initialization.jetty.JettyServerModule in project druid by druid-io.

the class Initialization method makeInjectorWithModules.

public static Injector makeInjectorWithModules(final Set<NodeRole> nodeRoles, final Injector baseInjector, final Iterable<? extends Module> modules) {
    final ModuleList defaultModules = new ModuleList(baseInjector, nodeRoles);
    defaultModules.addModules(// New modules should be added after Log4jShutterDownerModule
    new Log4jShutterDownerModule(), new DruidAuthModule(), new LifecycleModule(), TLSCertificateCheckerModule.class, EmitterModule.class, HttpClientModule.global(), HttpClientModule.escalatedGlobal(), new HttpClientModule("druid.broker.http", Client.class), new HttpClientModule("druid.broker.http", EscalatedClient.class), new CuratorModule(), new AnnouncerModule(), new MetricsModule(), new SegmentWriteOutMediumModule(), new ServerModule(), new DruidProcessingConfigModule(), new StorageNodeModule(), new JettyServerModule(), new ExpressionModule(), new DiscoveryModule(), new ServerViewModule(), new MetadataConfigModule(), new DerbyMetadataStorageDruidModule(), new JacksonConfigManagerModule(), new IndexingServiceDiscoveryModule(), new CoordinatorDiscoveryModule(), new LocalDataStorageDruidModule(), new FirehoseModule(), new JavaScriptModule(), new AuthenticatorModule(), new AuthenticatorMapperModule(), new EscalatorModule(), new AuthorizerModule(), new AuthorizerMapperModule(), new StartupLoggingModule(), new ExternalStorageAccessSecurityModule());
    ModuleList actualModules = new ModuleList(baseInjector, nodeRoles);
    actualModules.addModule(DruidSecondaryModule.class);
    for (Object module : modules) {
        actualModules.addModule(module);
    }
    Module intermediateModules = Modules.override(defaultModules.getModules()).with(actualModules.getModules());
    ModuleList extensionModules = new ModuleList(baseInjector, nodeRoles);
    final ExtensionsConfig config = baseInjector.getInstance(ExtensionsConfig.class);
    for (DruidModule module : Initialization.getFromExtensions(config, DruidModule.class)) {
        extensionModules.addModule(module);
    }
    return Guice.createInjector(Modules.override(intermediateModules).with(extensionModules.getModules()));
}
Also used : CuratorModule(org.apache.druid.curator.CuratorModule) IndexingServiceDiscoveryModule(org.apache.druid.guice.IndexingServiceDiscoveryModule) DiscoveryModule(org.apache.druid.curator.discovery.DiscoveryModule) CoordinatorDiscoveryModule(org.apache.druid.guice.CoordinatorDiscoveryModule) ServerViewModule(org.apache.druid.guice.ServerViewModule) EscalatorModule(org.apache.druid.guice.security.EscalatorModule) JettyServerModule(org.apache.druid.server.initialization.jetty.JettyServerModule) JettyServerModule(org.apache.druid.server.initialization.jetty.JettyServerModule) ServerModule(org.apache.druid.guice.ServerModule) AuthenticatorMapperModule(org.apache.druid.server.initialization.AuthenticatorMapperModule) FirehoseModule(org.apache.druid.guice.FirehoseModule) LocalDataStorageDruidModule(org.apache.druid.guice.LocalDataStorageDruidModule) DerbyMetadataStorageDruidModule(org.apache.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule) Client(org.apache.druid.guice.annotations.Client) EscalatedClient(org.apache.druid.guice.annotations.EscalatedClient) ExtensionsConfig(org.apache.druid.guice.ExtensionsConfig) JacksonConfigManagerModule(org.apache.druid.guice.JacksonConfigManagerModule) LifecycleModule(org.apache.druid.guice.LifecycleModule) ExternalStorageAccessSecurityModule(org.apache.druid.server.initialization.ExternalStorageAccessSecurityModule) AuthorizerModule(org.apache.druid.guice.security.AuthorizerModule) IndexingServiceDiscoveryModule(org.apache.druid.guice.IndexingServiceDiscoveryModule) ExpressionModule(org.apache.druid.guice.ExpressionModule) LocalDataStorageDruidModule(org.apache.druid.guice.LocalDataStorageDruidModule) StartupLoggingModule(org.apache.druid.guice.StartupLoggingModule) SegmentWriteOutMediumModule(org.apache.druid.segment.writeout.SegmentWriteOutMediumModule) DerbyMetadataStorageDruidModule(org.apache.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule) DruidProcessingConfigModule(org.apache.druid.guice.DruidProcessingConfigModule) EscalatedClient(org.apache.druid.guice.annotations.EscalatedClient) MetadataConfigModule(org.apache.druid.guice.MetadataConfigModule) CoordinatorDiscoveryModule(org.apache.druid.guice.CoordinatorDiscoveryModule) AuthorizerMapperModule(org.apache.druid.server.initialization.AuthorizerMapperModule) DruidAuthModule(org.apache.druid.guice.security.DruidAuthModule) MetricsModule(org.apache.druid.server.metrics.MetricsModule) AnnouncerModule(org.apache.druid.guice.AnnouncerModule) StorageNodeModule(org.apache.druid.guice.StorageNodeModule) AuthenticatorModule(org.apache.druid.guice.security.AuthenticatorModule) Module(com.google.inject.Module) ExpressionModule(org.apache.druid.guice.ExpressionModule) DruidAuthModule(org.apache.druid.guice.security.DruidAuthModule) LifecycleModule(org.apache.druid.guice.LifecycleModule) StartupLoggingModule(org.apache.druid.guice.StartupLoggingModule) JacksonConfigManagerModule(org.apache.druid.guice.JacksonConfigManagerModule) AuthorizerMapperModule(org.apache.druid.server.initialization.AuthorizerMapperModule) AuthenticatorMapperModule(org.apache.druid.server.initialization.AuthenticatorMapperModule) TLSCertificateCheckerModule(org.apache.druid.server.security.TLSCertificateCheckerModule) IndexingServiceDiscoveryModule(org.apache.druid.guice.IndexingServiceDiscoveryModule) AuthenticatorModule(org.apache.druid.guice.security.AuthenticatorModule) HttpClientModule(org.apache.druid.guice.http.HttpClientModule) LocalDataStorageDruidModule(org.apache.druid.guice.LocalDataStorageDruidModule) DiscoveryModule(org.apache.druid.curator.discovery.DiscoveryModule) JettyServerModule(org.apache.druid.server.initialization.jetty.JettyServerModule) MetricsModule(org.apache.druid.server.metrics.MetricsModule) SegmentWriteOutMediumModule(org.apache.druid.segment.writeout.SegmentWriteOutMediumModule) FirehoseModule(org.apache.druid.guice.FirehoseModule) DerbyMetadataStorageDruidModule(org.apache.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule) StorageNodeModule(org.apache.druid.guice.StorageNodeModule) MetadataConfigModule(org.apache.druid.guice.MetadataConfigModule) JavaScriptModule(org.apache.druid.guice.JavaScriptModule) ServerViewModule(org.apache.druid.guice.ServerViewModule) CoordinatorDiscoveryModule(org.apache.druid.guice.CoordinatorDiscoveryModule) CuratorModule(org.apache.druid.curator.CuratorModule) AnnouncerModule(org.apache.druid.guice.AnnouncerModule) DruidSecondaryModule(org.apache.druid.guice.DruidSecondaryModule) EscalatorModule(org.apache.druid.guice.security.EscalatorModule) ExternalStorageAccessSecurityModule(org.apache.druid.server.initialization.ExternalStorageAccessSecurityModule) DruidProcessingConfigModule(org.apache.druid.guice.DruidProcessingConfigModule) ServerModule(org.apache.druid.guice.ServerModule) EmitterModule(org.apache.druid.server.emitter.EmitterModule) AuthorizerModule(org.apache.druid.guice.security.AuthorizerModule) HttpClientModule(org.apache.druid.guice.http.HttpClientModule) JavaScriptModule(org.apache.druid.guice.JavaScriptModule)

Example 3 with JettyServerModule

use of org.apache.druid.server.initialization.jetty.JettyServerModule in project druid by druid-io.

the class JettyTest method testNumConnectionsMetricHttps.

@Test
public void testNumConnectionsMetricHttps() throws Exception {
    String text = "hello";
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(out)) {
        gzipOutputStream.write(text.getBytes(Charset.defaultCharset()));
    }
    Request request = new Request(HttpMethod.GET, new URL("https://localhost:" + tlsPort + "/latched/hello"));
    request.setHeader("Content-Encoding", "gzip");
    request.setContent(MediaType.TEXT_PLAIN, out.toByteArray());
    HttpClient client;
    try {
        client = HttpClientInit.createClient(sslConfig, lifecycle);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    JettyServerModule jsm = injector.getInstance(JettyServerModule.class);
    latchedRequestState.reset();
    waitForJettyServerModuleActiveConnectionsZero(jsm);
    Assert.assertEquals(0, jsm.getActiveConnections());
    ListenableFuture<InputStream> go = client.go(request, new InputStreamResponseHandler());
    latchedRequestState.clientWaitForServerToStartRequest();
    Assert.assertEquals(1, jsm.getActiveConnections());
    latchedRequestState.clientReadyToFinishRequest();
    go.get();
    waitForJettyServerModuleActiveConnectionsZero(jsm);
    Assert.assertEquals(0, jsm.getActiveConnections());
}
Also used : InputStreamResponseHandler(org.apache.druid.java.util.http.client.response.InputStreamResponseHandler) GZIPOutputStream(java.util.zip.GZIPOutputStream) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) HttpClient(org.apache.druid.java.util.http.client.HttpClient) Request(org.apache.druid.java.util.http.client.Request) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JettyServerModule(org.apache.druid.server.initialization.jetty.JettyServerModule) URL(java.net.URL) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

JettyServerModule (org.apache.druid.server.initialization.jetty.JettyServerModule)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 GZIPInputStream (java.util.zip.GZIPInputStream)2 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 Request (org.apache.druid.java.util.http.client.Request)2 InputStreamResponseHandler (org.apache.druid.java.util.http.client.response.InputStreamResponseHandler)2 Module (com.google.inject.Module)1 IOException (java.io.IOException)1 CuratorModule (org.apache.druid.curator.CuratorModule)1 DiscoveryModule (org.apache.druid.curator.discovery.DiscoveryModule)1 AnnouncerModule (org.apache.druid.guice.AnnouncerModule)1 CoordinatorDiscoveryModule (org.apache.druid.guice.CoordinatorDiscoveryModule)1 DruidProcessingConfigModule (org.apache.druid.guice.DruidProcessingConfigModule)1 DruidSecondaryModule (org.apache.druid.guice.DruidSecondaryModule)1 ExpressionModule (org.apache.druid.guice.ExpressionModule)1 ExtensionsConfig (org.apache.druid.guice.ExtensionsConfig)1 FirehoseModule (org.apache.druid.guice.FirehoseModule)1 IndexingServiceDiscoveryModule (org.apache.druid.guice.IndexingServiceDiscoveryModule)1