protected void stop(boolean graceful) { if (isStarted()) { if (stopped.compareAndSet(false, true)) { if (proxyServer != null) { if (graceful) { proxyServer.stop(); } else { proxyServer.abort(); } } else { log.warn("Attempted to stop proxy server, but proxy was never successfully started."); } } else { throw new IllegalStateException("Proxy server is already stopped. Cannot re-stop."); } } else { throw new IllegalStateException("Proxy server has not been started"); } }
@Override public int getPort() { if (started.get()) { return proxyServer.getListenAddress().getPort(); } else { return 0; } }
@Override public void setConnectTimeout(int connectTimeout, TimeUnit timeUnit) { this.connectTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(connectTimeout, timeUnit); if (isStarted()) { proxyServer.setConnectTimeout((int) TimeUnit.MILLISECONDS.convert(connectTimeout, timeUnit)); } }
@Override public void stopProxy(HttpProxyServer proxy) { proxy.stop(); }
@Override public void setWriteBandwidthLimit(long bytesPerSecond) { this.writeBandwidthLimitBps = bytesPerSecond; if (isStarted()) { proxyServer.setThrottle(this.readBandwidthLimitBps, this.writeBandwidthLimitBps); } }
/** * The LittleProxy implementation only allows idle connection timeouts to be specified in seconds. idleConnectionTimeouts greater than * 0 but less than 1 second will be set to 1 second; otherwise, values will be truncated (i.e. 1500ms will become 1s). */ @Override public void setIdleConnectionTimeout(int idleConnectionTimeout, TimeUnit timeUnit) { long timeout = TimeUnit.SECONDS.convert(idleConnectionTimeout, timeUnit); if (timeout == 0 && idleConnectionTimeout > 0) { this.idleConnectionTimeoutSec = 1; } else { this.idleConnectionTimeoutSec = (int) timeout; } if (isStarted()) { proxyServer.setIdleConnectionTimeout(idleConnectionTimeoutSec); } }
/** * Stops the proxy server */ private void stopProxy() { proxy.stop(); }
@Override public void setReadBandwidthLimit(long bytesPerSecond) { this.readBandwidthLimitBps = bytesPerSecond; if (isStarted()) { proxyServer.setThrottle(this.readBandwidthLimitBps, this.writeBandwidthLimitBps); } }
/** * The LittleProxy implementation only allows idle connection timeouts to be specified in seconds. idleConnectionTimeouts greater than * 0 but less than 1 second will be set to 1 second; otherwise, values will be truncated (i.e. 1500ms will become 1s). */ @Override public void setIdleConnectionTimeout(int idleConnectionTimeout, TimeUnit timeUnit) { long timeout = TimeUnit.SECONDS.convert(idleConnectionTimeout, timeUnit); if (timeout == 0 && idleConnectionTimeout > 0) { this.idleConnectionTimeoutSec = 1; } else { this.idleConnectionTimeoutSec = (int) timeout; } if (isStarted()) { proxyServer.setIdleConnectionTimeout(idleConnectionTimeoutSec); } }
@Override public void stop() { proxy.stop(); }
protected void stop(boolean graceful) { if (isStarted()) { if (stopped.compareAndSet(false, true)) { if (proxyServer != null) { if (graceful) { proxyServer.stop(); } else { proxyServer.abort(); } } else { log.warn("Attempted to stop proxy server, but proxy was never successfully started."); } } else { throw new IllegalStateException("Proxy server is already stopped. Cannot re-stop."); } } else { throw new IllegalStateException("Proxy server has not been started"); } }
@Override public InetAddress getClientBindAddress() { if (started.get()) { return proxyServer.getListenAddress().getAddress(); } else { return null; } }
@Override public void setWriteBandwidthLimit(long bytesPerSecond) { this.writeBandwidthLimitBps = bytesPerSecond; if (isStarted()) { proxyServer.setThrottle(this.readBandwidthLimitBps, this.writeBandwidthLimitBps); } }
@Override public void setConnectTimeout(int connectTimeout, TimeUnit timeUnit) { this.connectTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(connectTimeout, timeUnit); if (isStarted()) { proxyServer.setConnectTimeout((int) TimeUnit.MILLISECONDS.convert(connectTimeout, timeUnit)); } }
/** * The LittleProxy implementation only allows idle connection timeouts to be specified in seconds. idleConnectionTimeouts greater than * 0 but less than 1 second will be set to 1 second; otherwise, values will be truncated (i.e. 1500ms will become 1s). */ @Override public void setIdleConnectionTimeout(int idleConnectionTimeout, TimeUnit timeUnit) { long timeout = TimeUnit.SECONDS.convert(idleConnectionTimeout, timeUnit); if (timeout == 0 && idleConnectionTimeout > 0) { this.idleConnectionTimeoutSec = 1; } else { this.idleConnectionTimeoutSec = (int) timeout; } if (isStarted()) { proxyServer.setIdleConnectionTimeout(idleConnectionTimeoutSec); } }
public void stop() { verifyServerState(); server.stop(); }
protected void stop(boolean graceful) { if (isStarted()) { if (stopped.compareAndSet(false, true)) { if (proxyServer != null) { if (graceful) { proxyServer.stop(); } else { proxyServer.abort(); } } else { log.warn("Attempted to stop proxy server, but proxy was never successfully started."); } } else { throw new IllegalStateException("Proxy server is already stopped. Cannot re-stop."); } } else { throw new IllegalStateException("Proxy server has not been started"); } }
@Override public int getPort() { if (started.get()) { return proxyServer.getListenAddress().getPort(); } else { return 0; } }
@Override public void setReadBandwidthLimit(long bytesPerSecond) { this.readBandwidthLimitBps = bytesPerSecond; if (isStarted()) { proxyServer.setThrottle(this.readBandwidthLimitBps, this.writeBandwidthLimitBps); } }
@Override public void setConnectTimeout(int connectTimeout, TimeUnit timeUnit) { this.connectTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(connectTimeout, timeUnit); if (isStarted()) { proxyServer.setConnectTimeout((int) TimeUnit.MILLISECONDS.convert(connectTimeout, timeUnit)); } }