use of io.undertow.server.ConnectorStatistics in project wildfly by wildfly.
the class ResetConnectorStatisticsHandler method execute.
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ListenerService service = ListenerResourceDefinition.getListenerService(context);
if (service != null) {
ConnectorStatistics stats = service.getOpenListener().getConnectorStatistics();
if (stats != null) {
stats.reset();
}
}
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
use of io.undertow.server.ConnectorStatistics in project oap by oaplatform.
the class NioHttpServer method start.
public void start() {
Undertow.Builder builder = Undertow.builder().addHttpListener(port, "0.0.0.0").setSocketOption(Options.REUSE_ADDRESSES, true).setSocketOption(Options.TCP_NODELAY, tcpNodelay).setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, true);
if (backlog > 0)
builder.setSocketOption(Options.BACKLOG, backlog);
if (ioThreads > 0)
builder.setIoThreads(ioThreads);
if (workerThreads > 0)
builder.setWorkerThreads(workerThreads);
if (idleTimeout > 0)
builder.setServerOption(UndertowOptions.IDLE_TIMEOUT, (int) idleTimeout);
if (maxEntitySize > 0)
builder.setServerOption(UndertowOptions.MAX_ENTITY_SIZE, maxEntitySize);
if (maxParameters > 0)
builder.setServerOption(UndertowOptions.MAX_PARAMETERS, maxParameters);
if (maxHeaders > 0)
builder.setServerOption(UndertowOptions.MAX_HEADERS, maxHeaders);
if (maxHeaderSize > 0)
builder.setServerOption(UndertowOptions.MAX_HEADER_SIZE, maxHeaderSize);
if (statistics)
builder.setServerOption(UndertowOptions.ENABLE_STATISTICS, true);
builder.setServerOption(UndertowOptions.ALWAYS_SET_DATE, alwaysSetDate);
builder.setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, alwaysSetKeepAlive);
io.undertow.server.HttpHandler handler = pathHandler;
if (forceCompressionSupport) {
handler = new EncodingHandler(handler, contentEncodingRepository);
handler = new RequestEncodingHandler(handler).addEncoding("gzip", GzipStreamSourceConduit.WRAPPER).addEncoding("deflate", InflatingStreamSourceConduit.WRAPPER);
}
handler = new BlockingHandler(handler);
handler = new GracefulShutdownHandler(handler);
builder.setHandler(handler);
server = builder.build();
server.start();
log.info("port {} statistics {} ioThreads {} workerThreads {}", port, statistics, server.getWorker().getMXBean().getIoThreadCount(), server.getWorker().getMXBean().getMaxWorkerPoolSize());
if (statistics) {
for (var listenerInfo : server.getListenerInfo()) {
var sa = (InetSocketAddress) listenerInfo.getAddress();
var port = String.valueOf(sa.getPort());
ConnectorStatistics connectorStatistics = listenerInfo.getConnectorStatistics();
Metrics.gauge("nio_requests", Tags.of("port", port, "type", "total"), connectorStatistics, ConnectorStatistics::getRequestCount);
Metrics.gauge("nio_requests", Tags.of("port", port, "type", "active"), connectorStatistics, ConnectorStatistics::getActiveRequests);
Metrics.gauge("nio_requests", Tags.of("port", port, "type", "errors"), connectorStatistics, ConnectorStatistics::getErrorCount);
Metrics.gauge("nio_connections", Tags.of("port", port, "type", "active"), connectorStatistics, ConnectorStatistics::getActiveConnections);
Metrics.gauge("nio_pool_size", Tags.of("port", port, "name", "worker", "type", "active"), server, server -> server.getWorker().getMXBean().getWorkerPoolSize());
Metrics.gauge("nio_pool_size", Tags.of("port", port, "name", "worker", "type", "core"), server, server -> server.getWorker().getMXBean().getCoreWorkerPoolSize());
Metrics.gauge("nio_pool_size", Tags.of("port", port, "name", "worker", "type", "max"), server, server -> server.getWorker().getMXBean().getMaxWorkerPoolSize());
Metrics.gauge("nio_pool_size", Tags.of("port", port, "name", "worker", "type", "busy"), server, server -> server.getWorker().getMXBean().getBusyWorkerThreadCount());
Metrics.gauge("nio_pool_size", Tags.of("port", port, "name", "worker", "type", "queue"), server, server -> server.getWorker().getMXBean().getWorkerQueueSize());
}
}
}
Aggregations