Skip to content

Commit

Permalink
Respect bufferSize and ioThread congiguration options.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Nov 2, 2018
1 parent 11b554f commit 9fa5868
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/java/io/sinistral/proteus/ProteusApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@

import javax.ws.rs.core.MediaType;

import org.apache.commons.lang3.time.DurationFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Service;
Expand Down Expand Up @@ -176,6 +178,7 @@ public void healthy()
}

printStatus();


running.set(true);
}
Expand Down Expand Up @@ -281,8 +284,9 @@ public void buildServer()
}

Undertow.Builder undertowBuilder = Undertow.builder().addHttpListener(httpPort, config.getString("application.host"))
.setBufferSize(16 * 1024)
.setIoThreads(Runtime.getRuntime().availableProcessors() * 2)

.setBufferSize(Long.valueOf(config.getMemorySize("undertow.bufferSize").toBytes()).intValue())
.setIoThreads(Runtime.getRuntime().availableProcessors() * config.getInt("undertow.ioThreadsMultiplier"))
.setServerOption(UndertowOptions.ENABLE_HTTP2, config.getBoolean("undertow.server.enableHttp2"))
.setServerOption(UndertowOptions.ALWAYS_SET_DATE, config.getBoolean("undertow.server.alwaysSetDate"))
.setSocketOption(org.xnio.Options.BACKLOG, config.getInt("undertow.socket.backlog"))
Expand Down Expand Up @@ -426,12 +430,15 @@ public void printStatus()

ImmutableMultimap<State, Service> serviceStateMap = this.serviceManager.servicesByState();

tableHeaders = Arrays.asList("Service","State");
ImmutableMap<Service, Long> serviceStartupTimeMap = this.serviceManager.startupTimes();

tableHeaders = Arrays.asList("Service","State","Startup Time");

tableRows = serviceStateMap.asMap().entrySet().stream().flatMap(e -> {

return e.getValue().stream().map(s -> {
return Arrays.asList(s.getClass().getSimpleName() , e.getKey().toString() );
return e.getValue().stream().map(s -> {

return Arrays.asList(s.getClass().getSimpleName() , e.getKey().toString(), DurationFormatUtils.formatDurationHMS(serviceStartupTimeMap.get(s)) );
});

}).collect(Collectors.toList());
Expand All @@ -440,9 +447,9 @@ public void printStatus()

sb.append(printer.toString());

sb.append("\nListening on: " + this.ports );
sb.append("\nListening On: " + this.ports );

sb.append("\nStartup duration: " + this.startupDuration + "\n");
sb.append("\nApplication Startup Time: " + DurationFormatUtils.formatDurationHMS(this.startupDuration.toMillis()) + "\n");

log.info(sb.toString());
}
Expand Down

0 comments on commit 9fa5868

Please sign in to comment.