public int toSecondsIntBound() { return asBoundInt(toSeconds()); }
@Override public void run() { try { while (!isTerminated() && !Thread.interrupted()) { final Socket socket = this.serverSocket.accept(); socket.setSoTimeout(this.socketConfig.getSoTimeout().toMillisIntBound()); socket.setKeepAlive(this.socketConfig.isSoKeepAlive()); socket.setTcpNoDelay(this.socketConfig.isTcpNoDelay()); if (this.socketConfig.getRcvBufSize() > 0) { socket.setReceiveBufferSize(this.socketConfig.getRcvBufSize()); } if (this.socketConfig.getSndBufSize() > 0) { socket.setSendBufferSize(this.socketConfig.getSndBufSize()); } if (this.socketConfig.getSoLinger().toSeconds() >= 0) { socket.setSoLinger(true, this.socketConfig.getSoLinger().toSecondsIntBound()); } final HttpServerConnection conn = this.connectionFactory.createConnection(socket); final Worker worker = new Worker(this.httpService, conn, this.exceptionListener); this.executorService.execute(worker); } } catch (final Exception ex) { this.exceptionListener.onError(ex); } }
@Override public void run() { try { while (!isTerminated() && !Thread.interrupted()) { final Socket socket = this.serverSocket.accept(); socket.setSoTimeout(this.socketConfig.getSoTimeout().toMillisIntBound()); socket.setKeepAlive(this.socketConfig.isSoKeepAlive()); socket.setTcpNoDelay(this.socketConfig.isTcpNoDelay()); if (this.socketConfig.getRcvBufSize() > 0) { socket.setReceiveBufferSize(this.socketConfig.getRcvBufSize()); } if (this.socketConfig.getSndBufSize() > 0) { socket.setSendBufferSize(this.socketConfig.getSndBufSize()); } if (this.socketConfig.getSoLinger().toSeconds() >= 0) { socket.setSoLinger(true, this.socketConfig.getSoLinger().toSecondsIntBound()); } final HttpServerConnection conn = this.connectionFactory.createConnection(socket); final Worker worker = new Worker(this.httpService, conn, this.exceptionListener); this.executorService.execute(worker); } } catch (final Exception ex) { this.exceptionListener.onError(ex); } }
public int toSecondsIntBound() { return asBoundInt(toSeconds()); }
@Test public void testDivide() { // nominator is 0, result should be 0. Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toDays()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toHours()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMicros()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMillis()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMinutes()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toNanos()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toSeconds()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMillisIntBound()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toSecondsIntBound()); // Assert.assertEquals(50, TimeValue.ofMilliseconds(100).divide(2).toMillis()); Assert.assertEquals(0, TimeValue.ofMinutes(1).divide(2).toSeconds()); Assert.assertEquals(30, TimeValue.ofMinutes(1).divide(2, TimeUnit.SECONDS).toSeconds()); Assert.assertEquals(30000, TimeValue.ofMinutes(1).divide(2, TimeUnit.MILLISECONDS).toMillis()); }
private void checkToSeconds(final long value, final TimeUnit timeUnit) { Assert.assertEquals(timeUnit.toSeconds(value), TimeValue.of(value, timeUnit).toSeconds()); }