private synchronized void removeEndPoint(ServiceEndPoint endPoint) { // Mark this end point as recently removed. We do this in order to keep a positive set of removed // end points so that we avoid a potential race condition where someone was using this end point while // we noticed it disappeared from host discovery. In that case there is the potential that they // would add it to the bad end points set after we've already processed the removal, thus leading to a // memory leak in the bad end points set. Having this time-limited view of the recently removed // end points ensures that this memory leak doesn't happen. _recentlyRemovedEndPoints.add(endPoint); _badEndPoints.remove(endPoint); _serviceCache.evict(endPoint); LOG.debug("End point removed from service pool. End point: {}", endPoint); }
@Override public int getNumActiveInstances(ServiceEndPoint endPoint) { return _serviceCache.getNumActiveInstances(endPoint); } };
@Override public int getNumIdleCachedInstances(ServiceEndPoint endPoint) { return _serviceCache.getNumIdleInstances(endPoint); }
@Override public void close() { for (HealthCheck healthCheck : _badEndPoints.values()) { healthCheck.cancel(true); } _hostDiscovery.removeListener(_hostDiscoveryListener); if (_cleanupHostDiscoveryOnClose) { try { _hostDiscovery.close(); } catch (IOException e) { // NOP } } _serviceCache.close(); _metrics.close(); if (_shutdownHealthCheckExecutorOnClose) { _healthCheckExecutor.shutdownNow(); } }
@Override public void close() { for (HealthCheck healthCheck : _badEndPoints.values()) { healthCheck.cancel(true); } _hostDiscovery.removeListener(_hostDiscoveryListener); if (_cleanupHostDiscoveryOnClose) { try { _hostDiscovery.close(); } catch (IOException e) { // NOP } } _serviceCache.close(); _metrics.close(); if (_shutdownHealthCheckExecutorOnClose) { _healthCheckExecutor.shutdownNow(); } }
private synchronized void removeEndPoint(ServiceEndPoint endPoint) { // Mark this end point as recently removed. We do this in order to keep a positive set of removed // end points so that we avoid a potential race condition where someone was using this end point while // we noticed it disappeared from host discovery. In that case there is the potential that they // would add it to the bad end points set after we've already processed the removal, thus leading to a // memory leak in the bad end points set. Having this time-limited view of the recently removed // end points ensures that this memory leak doesn't happen. _recentlyRemovedEndPoints.add(endPoint); _badEndPoints.remove(endPoint); _serviceCache.evict(endPoint); LOG.debug("End point removed from service pool. End point: {}", endPoint); }
@Override public int getNumActiveInstances(ServiceEndPoint endPoint) { return _serviceCache.getNumActiveInstances(endPoint); } };
@Override public int getNumIdleCachedInstances(ServiceEndPoint endPoint) { return _serviceCache.getNumIdleInstances(endPoint); }
private synchronized void markEndPointAsBad(ServiceEndPoint endPoint) { if (_recentlyRemovedEndPoints.contains(endPoint)) { // Nothing to do, we've already removed this end point return; } _serviceCache.evict(endPoint); // Only schedule a health check if this is the first time we've seen this end point as bad... HealthCheck healthCheck = new HealthCheck(endPoint); if (_badEndPoints.putIfAbsent(endPoint, healthCheck) == null) { healthCheck.start(); } }
private synchronized void markEndPointAsBad(ServiceEndPoint endPoint) { if (_recentlyRemovedEndPoints.contains(endPoint)) { // Nothing to do, we've already removed this end point return; } _serviceCache.evict(endPoint); // Only schedule a health check if this is the first time we've seen this end point as bad... HealthCheck healthCheck = new HealthCheck(endPoint); if (_badEndPoints.putIfAbsent(endPoint, healthCheck) == null) { healthCheck.start(); } }