Search in sources :

Example 6 with DefaultServerFactory

use of io.dropwizard.server.DefaultServerFactory in project atlasdb by palantir.

the class TimeLockServerConfiguration method computeNumberOfAvailableThreads.

private int computeNumberOfAvailableThreads() {
    Preconditions.checkState(getServerFactory() instanceof DefaultServerFactory, "Unexpected serverFactory instance on TimeLockServerConfiguration.");
    DefaultServerFactory serverFactory = (DefaultServerFactory) getServerFactory();
    int maxServerThreads = serverFactory.getMaxThreads();
    Preconditions.checkNotNull(serverFactory.getApplicationConnectors(), "applicationConnectors of TimeLockServerConfiguration must not be null.");
    Preconditions.checkState(serverFactory.getApplicationConnectors().get(0) instanceof HttpConnectorFactory, "applicationConnectors of TimeLockServerConfiguration must have a HttpConnectorFactory instance.");
    HttpConnectorFactory connectorFactory = (HttpConnectorFactory) serverFactory.getApplicationConnectors().get(0);
    int selectorThreads = connectorFactory.getSelectorThreads();
    int acceptorThreads = connectorFactory.getAcceptorThreads();
    // TODO(gmaretic): consider reserving numClients more threads or something similar for unlocks
    return maxServerThreads - selectorThreads - acceptorThreads - 1;
}
Also used : HttpConnectorFactory(io.dropwizard.jetty.HttpConnectorFactory) DefaultServerFactory(io.dropwizard.server.DefaultServerFactory)

Example 7 with DefaultServerFactory

use of io.dropwizard.server.DefaultServerFactory in project helios by spotify.

the class ServiceUtil method createServerFactory.

public static DefaultServerFactory createServerFactory(final InetSocketAddress httpEndpoint, final InetSocketAddress adminEndpoint, final boolean noHttp) {
    final DefaultServerFactory serverFactory = new DefaultServerFactory();
    if (noHttp) {
        serverFactory.setApplicationConnectors(Collections.<ConnectorFactory>emptyList());
        serverFactory.setAdminConnectors(Collections.<ConnectorFactory>emptyList());
    } else {
        final HttpConnectorFactory serviceConnector = new HttpConnectorFactory();
        serviceConnector.setPort(httpEndpoint.getPort());
        serviceConnector.setBindHost(httpEndpoint.getHostString());
        serverFactory.setApplicationConnectors(ImmutableList.<ConnectorFactory>of(serviceConnector));
        final HttpConnectorFactory adminConnector = new HttpConnectorFactory();
        adminConnector.setPort(adminEndpoint.getPort());
        adminConnector.setBindHost(adminEndpoint.getHostString());
        serverFactory.setAdminConnectors(ImmutableList.<ConnectorFactory>of(adminConnector));
    }
    return serverFactory;
}
Also used : HttpConnectorFactory(io.dropwizard.jetty.HttpConnectorFactory) DefaultServerFactory(io.dropwizard.server.DefaultServerFactory)

Aggregations

DefaultServerFactory (io.dropwizard.server.DefaultServerFactory)7 HttpConnectorFactory (io.dropwizard.jetty.HttpConnectorFactory)6 AuthDynamicFeature (io.dropwizard.auth.AuthDynamicFeature)2 BasicCredentialAuthFilter (io.dropwizard.auth.basic.BasicCredentialAuthFilter)2 ConnectorFactory (io.dropwizard.jetty.ConnectorFactory)2 DefaultLoggingFactory (io.dropwizard.logging.DefaultLoggingFactory)2 AuthResponseFilter (io.irontest.auth.AuthResponseFilter)2 ResourceAuthenticator (io.irontest.auth.ResourceAuthenticator)2 ResourceAuthorizer (io.irontest.auth.ResourceAuthorizer)2 SimplePrincipal (io.irontest.auth.SimplePrincipal)2 AppInfo (io.irontest.models.AppInfo)2 LoggingFilter (org.glassfish.jersey.filter.LoggingFilter)2 FileStorage (com.hortonworks.registries.common.util.FileStorage)1 NOOPTransactionManager (com.hortonworks.registries.storage.NOOPTransactionManager)1 Storable (com.hortonworks.registries.storage.Storable)1 StorageManager (com.hortonworks.registries.storage.StorageManager)1 StorageManagerAware (com.hortonworks.registries.storage.StorageManagerAware)1 TransactionManager (com.hortonworks.registries.storage.TransactionManager)1 TransactionManagerAware (com.hortonworks.registries.storage.TransactionManagerAware)1 TransactionEventListener (com.hortonworks.registries.storage.transaction.TransactionEventListener)1