/** * Server context shutdown hook. Override for custom logic */ protected void destroyEurekaServerContext() throws Exception { EurekaMonitors.shutdown(); if (awsBinder != null) { awsBinder.shutdown(); } if (serverContext != null) { serverContext.shutdown(); } }
/** * Increment the counter for the given statistic. */ public void increment() { increment(false); }
EurekaMonitors.registerAllStats();
@Test public void testCustomClientShedding() throws Exception { // Custom clients will go up to the window limit whenRequest(FULL_FETCH, CUSTOM_CLIENT); filter.doFilter(request, response, filterChain); filter.doFilter(request, response, filterChain); verify(filterChain, times(2)).doFilter(request, response); // Now we hit the limit long rateLimiterCounter = EurekaMonitors.RATE_LIMITED.getCount(); filter.doFilter(request, response, filterChain); assertEquals("Expected rate limiter counter increase", rateLimiterCounter + 1, EurekaMonitors.RATE_LIMITED.getCount()); verify(response, times(1)).setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); }
protected void initEurekaServerContext() throws Exception { // For backward compatibility JsonXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH); XmlXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH); if (isAws(this.applicationInfoManager.getInfo())) { this.awsBinder = new AwsBinderDelegate(this.eurekaServerConfig, this.eurekaClientConfig, this.registry, this.applicationInfoManager); this.awsBinder.start(); } EurekaServerContextHolder.initialize(this.serverContext); log.info("Initialized server context"); // Copy registry from neighboring eureka node int registryCount = this.registry.syncUp(); this.registry.openForTraffic(this.applicationInfoManager, registryCount); // Register all monitoring statistics. EurekaMonitors.registerAllStats(); }
@Test public void testStandardClientsThrottlingEnforceable() throws Exception { ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.throttleStandardClients", true); // Custom clients will go up to the window limit whenRequest(FULL_FETCH, EurekaClientIdentity.DEFAULT_CLIENT_NAME); filter.doFilter(request, response, filterChain); filter.doFilter(request, response, filterChain); verify(filterChain, times(2)).doFilter(request, response); // Now we hit the limit long rateLimiterCounter = EurekaMonitors.RATE_LIMITED.getCount(); filter.doFilter(request, response, filterChain); assertEquals("Expected rate limiter counter increase", rateLimiterCounter + 1, EurekaMonitors.RATE_LIMITED.getCount()); verify(response, times(1)).setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); }
private void incrementStats(Target target) { if (serverConfig.isRateLimiterEnabled()) { EurekaMonitors.RATE_LIMITED.increment(); if (target == Target.FullFetch) { EurekaMonitors.RATE_LIMITED_FULL_FETCH.increment(); } } else { EurekaMonitors.RATE_LIMITED_CANDIDATES.increment(); if (target == Target.FullFetch) { EurekaMonitors.RATE_LIMITED_FULL_FETCH_CANDIDATES.increment(); } } }
/** * Server context shutdown hook. Override for custom logic */ protected void destroyEurekaServerContext() throws Exception { EurekaMonitors.shutdown(); if (awsBinder != null) { awsBinder.shutdown(); } if (serverContext != null) { serverContext.shutdown(); } }
protected void initEurekaServerContext() throws Exception { // For backward compatibility JsonXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH); XmlXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH); if (isAws(this.applicationInfoManager.getInfo())) { this.awsBinder = new AwsBinderDelegate(this.eurekaServerConfig, this.eurekaClientConfig, this.registry, this.applicationInfoManager); this.awsBinder.start(); } EurekaServerContextHolder.initialize(this.serverContext); log.info("Initialized server context"); // Copy registry from neighboring eureka node int registryCount = this.registry.syncUp(); this.registry.openForTraffic(this.applicationInfoManager, registryCount); // Register all monitoring statistics. EurekaMonitors.registerAllStats(); }
@Test public void testCustomClientThrottlingCandidatesCounter() throws Exception { ConfigurationManager.getConfigInstance().setProperty("eureka.rateLimiter.enabled", false); // Custom clients will go up to the window limit whenRequest(FULL_FETCH, CUSTOM_CLIENT); filter.doFilter(request, response, filterChain); filter.doFilter(request, response, filterChain); verify(filterChain, times(2)).doFilter(request, response); // Now we hit the limit long rateLimiterCounter = EurekaMonitors.RATE_LIMITED_CANDIDATES.getCount(); filter.doFilter(request, response, filterChain); assertEquals("Expected rate limiter counter increase", rateLimiterCounter + 1, EurekaMonitors.RATE_LIMITED_CANDIDATES.getCount()); // We just test the counter verify(response, times(0)).setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); }
/** * Server context shutdown hook. Override for custom logic */ protected void destroyEurekaServerContext() throws Exception { EurekaMonitors.shutdown(); if (this.awsBinder != null) { this.awsBinder.shutdown(); } if (this.serverContext != null) { this.serverContext.shutdown(); } }
EurekaMonitors.registerAllStats();
EurekaMonitors.GET_APPLICATION.increment();
/** * Server context shutdown hook. Override for custom logic */ protected void destroyEurekaServerContext() throws Exception { EurekaMonitors.shutdown(); if (this.awsBinder != null) { this.awsBinder.shutdown(); } if (this.serverContext != null) { this.serverContext.shutdown(); } }