Fix nits
This commit is contained in:
parent
522c96f70f
commit
a70381eea4
|
@ -17,16 +17,16 @@ public final class ClientSettings {
|
||||||
@SerializedName("client_secret")
|
@SerializedName("client_secret")
|
||||||
private final String clientSecret;
|
private final String clientSecret;
|
||||||
@SerializedName("threads_per_cpu")
|
@SerializedName("threads_per_cpu")
|
||||||
private final int threadsPerCPU;
|
private final int threadsPerCpu;
|
||||||
|
|
||||||
public ClientSettings(long maxCacheSizeMib, long maxBandwidthMibPerHour, long maxBurstRateKibPerSecond,
|
public ClientSettings(long maxCacheSizeMib, long maxBandwidthMibPerHour, long maxBurstRateKibPerSecond,
|
||||||
int clientPort, String clientSecret, int threadsPerCPU) {
|
int clientPort, String clientSecret, int threadsPerCpu) {
|
||||||
this.maxCacheSizeMib = maxCacheSizeMib;
|
this.maxCacheSizeMib = maxCacheSizeMib;
|
||||||
this.maxBandwidthMibPerHour = maxBandwidthMibPerHour;
|
this.maxBandwidthMibPerHour = maxBandwidthMibPerHour;
|
||||||
this.maxBurstRateKibPerSecond = maxBurstRateKibPerSecond;
|
this.maxBurstRateKibPerSecond = maxBurstRateKibPerSecond;
|
||||||
this.clientPort = clientPort;
|
this.clientPort = clientPort;
|
||||||
this.clientSecret = Objects.requireNonNull(clientSecret);
|
this.clientSecret = Objects.requireNonNull(clientSecret);
|
||||||
this.threadsPerCPU = threadsPerCPU;
|
this.threadsPerCpu = threadsPerCpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMaxCacheSizeMib() {
|
public long getMaxCacheSizeMib() {
|
||||||
|
@ -49,15 +49,15 @@ public final class ClientSettings {
|
||||||
return clientSecret;
|
return clientSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getThreadsPerCPU() {
|
public int getThreadsPerCpu() {
|
||||||
return threadsPerCPU;
|
return threadsPerCpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ClientSettings{" + "maxCacheSizeMib=" + maxCacheSizeMib + ", maxBandwidthMibPerHour="
|
return "ClientSettings{" + "maxCacheSizeMib=" + maxCacheSizeMib + ", maxBandwidthMibPerHour="
|
||||||
+ maxBandwidthMibPerHour + ", maxBurstRateKibPerSecond=" + maxBurstRateKibPerSecond + ", clientPort="
|
+ maxBandwidthMibPerHour + ", maxBurstRateKibPerSecond=" + maxBurstRateKibPerSecond + ", clientPort="
|
||||||
+ clientPort + ", clientSecret='" + "<hidden>" + '\'' + ", threadsPerCPU=" + threadsPerCPU + "}";
|
+ clientPort + ", clientSecret='" + "<hidden>" + '\'' + ", threadsPerCPU=" + threadsPerCpu + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSecretValid(String clientSecret) {
|
public static boolean isSecretValid(String clientSecret) {
|
||||||
|
|
|
@ -35,12 +35,14 @@ import java.util.concurrent.atomic.AtomicReference
|
||||||
import javax.net.ssl.SSLException
|
import javax.net.ssl.SSLException
|
||||||
|
|
||||||
private val LOGGER = LoggerFactory.getLogger("Application")
|
private val LOGGER = LoggerFactory.getLogger("Application")
|
||||||
private val THREADS_TO_ALLOCATE = Runtime.getRuntime().availableProcessors()
|
|
||||||
|
|
||||||
class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings: ClientSettings, private val stats: AtomicReference<Statistics>) : ServerConfig {
|
class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings: ClientSettings, private val stats: AtomicReference<Statistics>) : ServerConfig {
|
||||||
|
private val threadsToAllocate: Int
|
||||||
|
get() = Runtime.getRuntime().availableProcessors() * clientSettings.threadsPerCpu
|
||||||
|
|
||||||
override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer {
|
override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer {
|
||||||
private val masterGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE * clientSettings.getThreadsPerCPU())
|
private val masterGroup = NioEventLoopGroup(threadsToAllocate)
|
||||||
private val workerGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE * clientSettings.getThreadsPerCPU())
|
private val workerGroup = NioEventLoopGroup(threadsToAllocate)
|
||||||
private lateinit var closeFuture: ChannelFuture
|
private lateinit var closeFuture: ChannelFuture
|
||||||
private lateinit var address: InetSocketAddress
|
private lateinit var address: InetSocketAddress
|
||||||
|
|
||||||
|
@ -54,7 +56,7 @@ class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings:
|
||||||
|
|
||||||
override fun start(): Http4kServer = apply {
|
override fun start(): Http4kServer = apply {
|
||||||
if (LOGGER.isInfoEnabled) {
|
if (LOGGER.isInfoEnabled) {
|
||||||
LOGGER.info("Starting webserver with {} threads", THREADS_TO_ALLOCATE * clientSettings.getThreadsPerCPU())
|
LOGGER.info("Starting webserver with {} threads", threadsToAllocate)
|
||||||
}
|
}
|
||||||
|
|
||||||
val (mainCert, chainCert) = getX509Certs(tls.certificate)
|
val (mainCert, chainCert) = getX509Certs(tls.certificate)
|
||||||
|
|
Loading…
Reference in a new issue