/** * Start the CachedDirectoryLookupService. * * <p>It is thread safe. */ @Override public void start() { if (isStarted.compareAndSet(false, true)) { super.start(); initCacheSyncTask(); } }
/** * Stop the CachedDirectoryLookupService. * * <p>It is thread safe. */ @Override public void stop() { if (isStarted.compareAndSet(true, false)) { // if you shutdown it, it can not be use anymore super.stop(); ScheduledExecutorService service = this.syncService.getAndSet(newSyncService()); service.shutdown(); LOGGER.info("Cache sync Service is shutdown"); for (Entry<String, ModelServiceClientCache> entry : cache.entrySet()) { removeInstanceChangeListener(entry.getKey(), entry.getValue()); } getCache().clear(); } }