@Override public int perServerWaterline() { return PER_SERVER_WATERLINE.get(); }
public ConnectionPoolConfigImpl(final String originName, IClientConfig clientConfig) { this.originName = originName; this.clientConfig = clientConfig; this.MAX_REQUESTS_PER_CONNECTION = new CachedDynamicIntProperty(originName+".netty.client.maxRequestsPerConnection", 1000); // NOTE that the each eventloop has it's own connection pool per host, and this is applied per event-loop. this.PER_SERVER_WATERLINE = new CachedDynamicIntProperty(originName+".netty.client.perServerWaterline", 4); this.SOCKET_KEEP_ALIVE = new CachedDynamicBooleanProperty(originName+".netty.client.TcpKeepAlive", false); this.TCP_NO_DELAY = new CachedDynamicBooleanProperty(originName+".netty.client.TcpNoDelay", false); this.WRITE_BUFFER_HIGH_WATER_MARK = new CachedDynamicIntProperty(originName+".netty.client.WriteBufferHighWaterMark", 32 * 1024); this.WRITE_BUFFER_LOW_WATER_MARK = new CachedDynamicIntProperty(originName+".netty.client.WriteBufferLowWaterMark", 8 * 1024); this.AUTO_READ = new CachedDynamicBooleanProperty(originName+".netty.client.AutoRead", false); }
public CachedDynamicIntProperty(String propName, int defaultValue) { super(propName, defaultValue); // Set the initial value of the cached primitive value. this.primitiveValue = chooseValue(); }
@Override protected void propertyChanged() { // Update the cached primitive value when the property is changed. this.primitiveValue = chooseValue(); }
@Override public int getMaxBodySize() { return MAX_BODY_SIZE_PROP.get(); }
public ConnectionPoolConfigImpl(final String originName, IClientConfig clientConfig) { this.originName = originName; this.clientConfig = clientConfig; this.MAX_REQUESTS_PER_CONNECTION = new CachedDynamicIntProperty(originName+".netty.client.maxRequestsPerConnection", 1000); // NOTE that the each eventloop has it's own connection pool per host, and this is applied per event-loop. this.PER_SERVER_WATERLINE = new CachedDynamicIntProperty(originName+".netty.client.perServerWaterline", 4); this.SOCKET_KEEP_ALIVE = new CachedDynamicBooleanProperty(originName+".netty.client.TcpKeepAlive", false); this.TCP_NO_DELAY = new CachedDynamicBooleanProperty(originName+".netty.client.TcpNoDelay", false); this.WRITE_BUFFER_HIGH_WATER_MARK = new CachedDynamicIntProperty(originName+".netty.client.WriteBufferHighWaterMark", 32 * 1024); this.WRITE_BUFFER_LOW_WATER_MARK = new CachedDynamicIntProperty(originName+".netty.client.WriteBufferLowWaterMark", 8 * 1024); this.AUTO_READ = new CachedDynamicBooleanProperty(originName+".netty.client.AutoRead", false); }
@Override public int getNettyWriteBufferHighWaterMark() { return WRITE_BUFFER_HIGH_WATER_MARK.get(); }
protected BaseFilter() { baseName = this.getClass().getSimpleName() + "." + filterType().toString(); concurrentCount = SpectatorUtils.newGauge("zuul.filter.concurrency.current", baseName, new AtomicInteger(0)); concurrencyRejections = SpectatorUtils.newCounter("zuul.filter.concurrency.rejected", baseName); filterDisabled = new CachedDynamicBooleanProperty(disablePropertyName(), false); filterConcurrencyLimit = new CachedDynamicIntProperty(maxConcurrencyPropertyName(), 4000); }
@Override public int getMaxRequestsPerConnection() { return MAX_REQUESTS_PER_CONNECTION.get(); }
public BasicNettyOrigin(String name, String vip, Registry registry) { this.name = name; this.vip = vip; this.registry = registry; this.config = setupClientConfig(name); this.clientChannelManager = new DefaultClientChannelManager(name, vip, config, registry); this.clientChannelManager.init(); this.requestAttemptFactory = new NettyRequestAttemptFactory(); this.concurrentRequests = SpectatorUtils.newGauge("zuul.origin.concurrent.requests", name, new AtomicInteger(0)); this.rejectedRequests = SpectatorUtils.newCounter("zuul.origin.rejected.requests", name); this.concurrencyMax = new CachedDynamicIntProperty("zuul.origin." + name + ".concurrency.max.requests", 200); this.concurrencyProtectionEnabled = new CachedDynamicBooleanProperty("zuul.origin." + name + ".concurrency.protect.enabled", true); }
@Override public int getNettyWriteBufferLowWaterMark() { return WRITE_BUFFER_LOW_WATER_MARK.get(); }
protected BaseFilter() { baseName = this.getClass().getSimpleName() + "." + filterType().toString(); concurrentCount = SpectatorUtils.newGauge("zuul.filter.concurrency.current", baseName, new AtomicInteger(0)); concurrencyRejections = SpectatorUtils.newCounter("zuul.filter.concurrency.rejected", baseName); filterDisabled = new CachedDynamicBooleanProperty(disablePropertyName(), false); filterConcurrencyLimit = new CachedDynamicIntProperty(maxConcurrencyPropertyName(), 4000); }
public PushConnection(PushProtocol pushProtocol, ChannelHandlerContext ctx) { this.pushProtocol = pushProtocol; this.ctx = ctx; tkBktAllowance = TOKEN_BUCKET_RATE.get(); tkBktLastCheckTime = System.currentTimeMillis(); }
public BasicNettyOrigin(String name, String vip, Registry registry) { this.name = name; this.vip = vip; this.registry = registry; this.config = setupClientConfig(name); this.clientChannelManager = new DefaultClientChannelManager(name, vip, config, registry); this.clientChannelManager.init(); this.requestAttemptFactory = new NettyRequestAttemptFactory(); this.concurrentRequests = SpectatorUtils.newGauge("zuul.origin.concurrent.requests", name, new AtomicInteger(0)); this.rejectedRequests = SpectatorUtils.newCounter("zuul.origin.rejected.requests", name); this.concurrencyMax = new CachedDynamicIntProperty("zuul.origin." + name + ".concurrency.max.requests", 200); this.concurrencyProtectionEnabled = new CachedDynamicBooleanProperty("zuul.origin." + name + ".concurrency.protect.enabled", true); }
public ServerStats() { connectionFailureThreshold = new CachedDynamicIntProperty( "niws.loadbalancer.default.connectionFailureCountThreshold", 3); circuitTrippedTimeoutFactor = new CachedDynamicIntProperty( "niws.loadbalancer.default.circuitTripTimeoutFactorSeconds", 10); maxCircuitTrippedTimeout = new CachedDynamicIntProperty( "niws.loadbalancer.default.circuitTripMaxTimeoutSeconds", 30); }
CachedDynamicIntProperty getConnectionFailureCountThreshold() { if (connectionFailureThreshold == null) { connectionFailureThreshold = new CachedDynamicIntProperty( "niws.loadbalancer." + name + ".connectionFailureCountThreshold", 3); } return connectionFailureThreshold; }
/** * Implementation of TokenBucket algorithm to do rate limiting: http://stackoverflow.com/a/668327 * @return true if should be rate limited, false if it is OK to send the message */ public synchronized boolean isRateLimited() { final double rate = TOKEN_BUCKET_RATE.get(); final double window = TOKEN_BUCKET_WINDOW.get(); final long current = System.currentTimeMillis(); final double timePassed = current - tkBktLastCheckTime; tkBktLastCheckTime = current; tkBktAllowance = tkBktAllowance + timePassed * (rate / window); if (tkBktAllowance > rate) { tkBktAllowance = rate; //cap max to rate } if (tkBktAllowance < 1.0) { return true; } tkBktAllowance = tkBktAllowance - 1.0; return false; }
CachedDynamicIntProperty getCircuitTrippedTimeoutFactor() { if (circuitTrippedTimeoutFactor == null) { circuitTrippedTimeoutFactor = new CachedDynamicIntProperty( "niws.loadbalancer." + name + ".circuitTripTimeoutFactorSeconds", 10); } return circuitTrippedTimeoutFactor; }