@Override public Map<String, Object> asJson() { LinkedHashMap<String, Object> json = new LinkedHashMap<>(); for (CacheManager cacheManager : CacheManager.ALL_CACHE_MANAGERS) { LinkedHashMap<String, Object> jsonForManager = new LinkedHashMap<>(); json.put(cacheManager.getName(), jsonForManager); for (String cacheName : cacheManager.getCacheNames()) { Cache cache = cacheManager.getCache(cacheName); LinkedHashMap<String, Object> cacheJson = new LinkedHashMap<>(); jsonForManager.put(cacheName, cacheJson); cacheJson.put("Cache configuration information", getCacheConfigurationInformationAsJson(cache)); cacheJson.put("Cache runtime information", getCacheRuntimeInformationAsJson(cache)); } } return json; }
/** * @return either the name of this CacheManager, or if unset, Object.toString() */ @Override public String toString() { return getName(); }
/** * Gets the name of the CacheManager * * @return The cache manager name, which may not be set */ public String getName() { return cacheManager.getName(); }
/** * {@inheritDoc} */ public String getName() { return cacheManager.getName(); }
/** * Basically does the same as CacheManager.getCache() except that this method is lock free. */ private static CacheManager getCacheManager(String cacheManagerName) { for (CacheManager cacheManager : CacheManager.ALL_CACHE_MANAGERS) { if (cacheManager.getName().equals(cacheManagerName)) { return cacheManager; } } return null; }
@Override public Thread newThread(Runnable r) { Thread t = new Thread(r, "Statistics Thread-" + getName() + "-" + cnt.incrementAndGet()); t.setDaemon(true); return t; } });
void register(CacheManager cacheManager, String clientUUID) throws Exception { Method registerMethod = MANAGEMENT_SERVER_CLASS.getMethod("register", CacheManager.class); registerMethod.invoke(managementServer, cacheManager); if (clientUUID != null) { Method registerClusterRemoteEndpoint = MANAGEMENT_SERVER_CLASS.getMethod("registerClusterRemoteEndpoint", String.class); registerClusterRemoteEndpoint.invoke(managementServer, clientUUID); clientUUIDs.put(cacheManager.getName(), clientUUID); } }
void unregister(CacheManager cacheManager) throws Exception { Method unregisterMethod = MANAGEMENT_SERVER_CLASS.getMethod("unregister", CacheManager.class); unregisterMethod.invoke(managementServer, cacheManager); String unregisteredClientUUID = clientUUIDs.remove(cacheManager.getName()); if (unregisteredClientUUID != null) { Method unregisterClusterRemoteEndpoint = MANAGEMENT_SERVER_CLASS.getMethod("unregisterClusterRemoteEndpoint", String.class); unregisterClusterRemoteEndpoint.invoke(managementServer, unregisteredClientUUID); } }
/** * {@inheritDoc} */ public synchronized void registerMBeanForCacheManager(final CacheManager manager, final Properties properties) throws Exception { String sessionFactoryName = properties.getProperty(Environment.SESSION_FACTORY_NAME); String name = null; if (sessionFactoryName == null) { name = manager.getName(); } else { name = "".equals(sessionFactoryName.trim()) ? manager.getName() : sessionFactoryName; } registerBean(name, manager); }
/** * Get or create a TransactionIDFactory * * @return a TransactionIDFactory */ public TransactionIDFactory getOrCreateTransactionIDFactory() { if (transactionIDFactory == null) { transactionIDFactory = new DelegatingTransactionIDFactory(featuresManager, terracottaClient, getName()); } return transactionIDFactory; }
private String getCacheManagerName() { if (cacheManager.isNamed()) { return "'" + cacheManager.getName() + "'"; } else { return "no name"; } }
/** * Divine the name. * * @param cache the cache * @return the string */ public static String divineName(Ehcache cache) { return cache.getCacheManager().getName() + "." + cache.getName(); } }
private JobDetail makeOverseerJob() throws SchedulerException { JobDataMap jdm = new JobDataMap(); jdm.put(PROP_CACHE_MGR_NAME, underlyingCache.getCacheManager().getName()); jdm.put(PROP_CACHE_NAME, underlyingCache.getName()); jdm.put(PROP_CONFIG_OBJECT, config); JobDetail seed = JobBuilder.newJob(OverseerJob.class).storeDurably() .withIdentity(OVERSEER_JOB_NAME, groupName) .usingJobData(jdm).build(); return seed; }
private static String getCacheManagerName(Ehcache cache) { final String cacheMgrName; if (cache.getCacheManager().isNamed()) { cacheMgrName = cache.getCacheManager().getName(); } else { cacheMgrName = TerracottaClusteredInstanceFactory.DEFAULT_CACHE_MANAGER_NAME; } return cacheMgrName; }
@Override public synchronized AsyncCoordinator getOrCreateAsyncCoordinator(final Ehcache cache, final AsyncConfig config) { return getOrCreateAsyncCoordinator(cache.getCacheManager().getName(), cache.getName(), config); }
/** * Constructs an object from an ehcache statistics object * * @param ehcache the backing ehcache */ public CacheStatistics(Ehcache ehcache) { this.ehcache = ehcache; this.statistics = ehcache.getStatistics(); objectName = createObjectName(ehcache.getCacheManager().getName(), ehcache.getName()); }
@Override public ToolkitNotifier<CacheDisposalNotification> getOrCreateCacheDisposalNotifier(Ehcache cache) { return toolkit.getNotifier(EhcacheEntitiesNaming.getToolkitCacheNameFor(cache.getCacheManager().getName(), cache.getName()) + DELIMITER + DISPOSAL_NOTIFIER_SUFFIX, CacheDisposalNotification.class); }
private Store(Ehcache ehcache, Object storeBean) throws NotCompliantMBeanException { this.objectName = createObjectName(ehcache.getCacheManager().getName(), ehcache.getName()); if (storeBean instanceof DynamicMBean) { this.storeBean = (DynamicMBean) storeBean; } else { this.storeBean = new StandardMBean(storeBean, null); } }
void setUpWanConfig() { if (!cache.getCacheManager().getConfiguration().getTerracottaConfiguration().isWanEnabledTSA()) { toolkitInstanceFactory.markCacheWanDisabled(cache.getCacheManager().getName(), cache.getName()); } }