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