@Override public Set<String> getRateLimiterPrivilegedClients() { return rateLimiterPrivilegedClients.get(); }
public DiscoveryNodeListProvider(ApplicationInfoManager applicationInfoManager, DiscoveryClient discoveryClient, String appName) { this.applicationInfoManager = applicationInfoManager; this._discoveryClient = discoveryClient; this._appName = appName; ignoreHosts = new DynamicStringSetProperty(appName + ".ignore.hosts", ""); }
@Override public boolean onThrottle(final EVCacheEvent e) { if(!enableThrottleOperations.get()) return false; final String appName = e.getAppName(); DynamicStringSetProperty throttleCalls = _ignoreOperationsMap.get(appName); if(throttleCalls == null) { throttleCalls = new DynamicStringSetProperty(appName + ".throttle.calls", ""); _ignoreOperationsMap.put(appName, throttleCalls ); } if(throttleCalls.get().size() > 0 && throttleCalls.get().contains(e.getCall().name())) { if(log.isDebugEnabled()) log.debug("Call : " + e.getCall() + " is throttled"); return true; } return false; }
this.logOperationCalls = new DynamicStringSetProperty(appName + ".log.operation.calls", "SET,DELETE,GMISS,TMISS,BMISS_ALL,TOUCH,REPLACE"); this.reconcileInterval = config.getDynamicIntProperty(appName + ".reconcile.interval", 600000); this.cloneWrite = new DynamicStringSetProperty(appName + ".clone.writes.to", ""); this.cloneWrite.addCallback(new Runnable() { public void run() { setupClones();
@Override public boolean onThrottle(final EVCacheEvent e) { if(!enableThrottleHotKeys.get()) return false; final String appName = e.getAppName(); DynamicStringSetProperty throttleKeysSet = throttleKeysMap.get(appName); if(throttleKeysSet == null) { throttleKeysSet = new DynamicStringSetProperty(appName + ".throttle.keys", ""); //keys without the cache prefix } if(throttleKeysSet.get().size() > 0) { if(log.isDebugEnabled()) log.debug("Throttle : " + throttleKeysSet); for(String key : e.getKeys()) { if(throttleKeysSet.get().contains(key)) { if(log.isDebugEnabled()) log.debug("Key : " + key + " is throttled"); return true; } } } final Cache<String, Integer> cache = getCache(appName); if(cache == null) return false; final DynamicIntProperty _throttleVal = EVCacheConfig.getInstance().getDynamicIntProperty("EVCacheThrottler." + appName + ".throttle.value", 3); for(String key : e.getKeys()) { Integer val = cache.getIfPresent(key); if(val.intValue() > _throttleVal.get()) { if(log.isDebugEnabled()) log.debug("Key : " + key + " has exceeded " + _throttleVal.get() + ". Will throttle this request"); return true; } } return false; }
protected boolean shouldLogFrame(String frame) { return FRAMES_TO_LOG.get().contains(frame); } }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { String clientIP = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SOURCE_ADDRESS).get(); if (IPS.get().contains(clientIP)) { ctx.channel().attr(DynamicHttp2FrameLogger.ATTR_ENABLE).set(Boolean.TRUE); ctx.pipeline().remove(this); } } finally { super.channelRead(ctx, msg); } } }
private boolean isGzippableContentType(HttpResponseMessage response) { String ct = response.getHeaders().getFirst(HttpHeaderNames.CONTENT_TYPE); if (ct != null) { int charsetIndex = ct.indexOf(';'); if (charsetIndex > 0) { ct = ct.substring(0, charsetIndex); } return GZIPPABLE_CONTENT_TYPES.get().contains(ct.toLowerCase()); } return false; }
private void setupClones() { for(String cloneApp : cloneWrite.get()) { manager.initEVCache(cloneApp); } }
protected boolean shouldLogFrame(String frame) { return FRAMES_TO_LOG.get().contains(frame); } }
public boolean shouldLogOperation(String key, String op) { if (!isLogEventEnabled()) return false; if (!logOperationCalls.get().contains(op)) return false; return key.hashCode() % 1000 <= logOperations.get(); }
public EVCacheClient[] getEVCacheClientForWrite() { try { if((cloneWrite.get().size() == 0)) { return getAllWriteClients(); } else { final List<EVCacheClient> evcacheClientList = new ArrayList<EVCacheClient>(); final EVCacheClient[] clientArr = getAllWriteClients(); for(EVCacheClient client : clientArr) { evcacheClientList.add(client); } for(String cloneApp : cloneWrite.get()) { final EVCacheClient[] cloneWriteArray = manager.getEVCacheClientPool(cloneApp).getAllWriteClients(); for(int j = 0; j < cloneWriteArray.length; j++) { evcacheClientList.add(cloneWriteArray[j]); } } return evcacheClientList.toArray(new EVCacheClient[0]); } } catch (Throwable t) { log.error("Exception trying to get an array of writable EVCache Instances", t); return new EVCacheClient[0]; } }
public EVCacheClient[] getWriteOnlyEVCacheClients() { try { if((cloneWrite.get().size() == 0)) { int size = memcachedWriteInstancesByServerGroup.size() - memcachedReadInstancesByServerGroup.size(); if (size == 0) return new EVCacheClient[0]; } else { final List<EVCacheClient> evcacheClientList = new ArrayList<EVCacheClient>(); for(String cloneApp : cloneWrite.get()) { final EVCacheClient[] clients = manager.getEVCacheClientPool(cloneApp).getWriteOnlyEVCacheClients(); if(clients == null || clients.length == 0) continue;
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { String clientIP = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SOURCE_ADDRESS).get(); if (IPS.get().contains(clientIP)) { ctx.channel().attr(DynamicHttp2FrameLogger.ATTR_ENABLE).set(Boolean.TRUE); ctx.pipeline().remove(this); } } finally { super.channelRead(ctx, msg); } } }
private boolean isGzippableContentType(HttpResponseMessage response) { String ct = response.getHeaders().getFirst(HttpHeaderNames.CONTENT_TYPE); if (ct != null) { int charsetIndex = ct.indexOf(';'); if (charsetIndex > 0) { ct = ct.substring(0, charsetIndex); } return GZIPPABLE_CONTENT_TYPES.get().contains(ct.toLowerCase()); } return false; }
final String localIp = amznInfo.get(AmazonInfo.MetaDataKey.localIpv4); if (log.isDebugEnabled()) log.debug("myZone - " + myZone + "; zone : " + zone + "; myRegion : " + myRegion + "; region : " + region + "; host : " + host + "; vpcId : " + vpcId); if(localIp != null && ignoreHosts.get().contains(localIp)) continue; if(host != null && ignoreHosts.get().contains(host)) continue;
@Override public Set<String> getRateLimiterPrivilegedClients() { return rateLimiterPrivilegedClients.get(); }
protected boolean shouldLogFrame(String frame) { return FRAMES_TO_LOG.get().contains(frame); } }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { String clientIP = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SOURCE_ADDRESS).get(); if (IPS.get().contains(clientIP)) { ctx.channel().attr(DynamicHttp2FrameLogger.ATTR_ENABLE).set(Boolean.TRUE); ctx.pipeline().remove(this); } } finally { super.channelRead(ctx, msg); } } }
private boolean isGzippableContentType(HttpResponseMessage response) { String ct = response.getHeaders().getFirst(HttpHeaderNames.CONTENT_TYPE); if (ct != null) { int charsetIndex = ct.indexOf(';'); if (charsetIndex > 0) { ct = ct.substring(0, charsetIndex); } return GZIPPABLE_CONTENT_TYPES.get().contains(ct.toLowerCase()); } return false; }