public Configuration getConfiguration() { Configuration cfg = (cache == null ? config : cache.getConfiguration()); if (cfg == null) { cfg = config = new Configuration(); } return cfg; }
private void processBaseName(ObjectName baseName) { if (baseName != null) { this.objectNameBase = baseName.getCanonicalName(); return; } if (cacheSpi.getConfiguration().getCacheMode().equals(Configuration.CacheMode.LOCAL)) { // CurrentTimeMillis is not good enaugh as an unique id generator. I am constantly // getting conflicts in several parallel tests on my box. Maybe some more sofisticated // unique id generator should be provided? // For example: use identity hashcode in hex format. objectNameBase = LOCAL_CACHE_PREFIX + Integer.toHexString(System.identityHashCode(cacheSpi)); } else //the cache is clustered { objectNameBase = REPLICATED_CACHE_PREFIX + cacheSpi.getConfiguration().getClusterName(); } }
public Configuration getCacheConfiguration() { if (regionManager != null && regionManager.getCache() != null) return regionManager.getCache().getConfiguration(); else return null; }
public PessimisticUnversionedNode(Object name, Fqn fqn, Map<K, V> data, CacheSPI<K, V> cache) { super(fqn, cache, false); if (!fqn.isRoot() && !name.equals(fqn.getLastElement())) throw new IllegalArgumentException("Child " + name + " must be last part of " + fqn); if (data != null && !data.isEmpty()) setInternalState(data); else this.data = new FastCopyHashMap<K, V>(); setLockForChildInsertRemove(cache != null && cache.getConfiguration() != null && cache.getConfiguration().isLockParentForChildInsertRemove()); }
/** * Here is where the registration is being performed. */ @Start(priority = 14) public void registerToPlatformMBeanServer() { if (cache == null) throw new IllegalStateException("The cache should had been injected before a call to this method"); Configuration config = cache.getConfiguration(); if (config.getExposeManagementStatistics()) { jmxRegistrationManager = new JmxRegistrationManager(cache); jmxRegistrationManager.registerAllMBeans(); log.info("JBossCache MBeans were successfully registered to the platform mbean server."); } }
/** * Unregister when the cache is being stoped. */ @Stop public void unregisterMBeans() { //this method might get called several times. // After the first call the cache will become null, so we guard this if (cache == null) return; Configuration config = cache.getConfiguration(); if (config.getExposeManagementStatistics()) { jmxRegistrationManager.unregisterAllMBeans(); log.trace("JBossCache MBeans were successfully unregistered from the platform mbean server."); } cache = null; } }
@Override public void loadEntireState(ObjectOutputStream os) throws Exception { try { // // We use the lock acquisition timeout rather than the // // state transfer timeout, otherwise we'd never try // // to break locks before the requesting node gives up // return cache._getState(Fqn.fromString(SEPARATOR), // cache.getLockAcquisitionTimeout(), // true, // false); // Until flush is in place, use the old mechanism // where we wait the full state retrieval timeout delegate.getStateTransferManager().getState(os, Fqn.ROOT, delegate.getConfiguration().getStateRetrievalTimeout(), true, false); } catch (Exception e) { throw e; } catch (Throwable t) { throw new RuntimeException("Caught exception getting state from delegate", t); } }
else if (!cache.getConfiguration().isUseRegionBasedMarshalling())
envConfig.setAllowCreate(true); envConfig.setTransactional(true); envConfig.setLockTimeout(1000 * cache.getConfiguration().getLockAcquisitionTimeout()); // these are in nanos if (log.isTraceEnabled()) log.trace("Creating JE environment with home dir " + location); env = new Environment(location, envConfig);
if (cache.getConfiguration().isFetchInMemoryState()) region.setActive(false); if (cache.getConfiguration().isFetchInMemoryState())
long stateFetchTimeout = cache.getConfiguration().getLockAcquisitionTimeout() + 5000;
ctx.getOptionOverrides().setLockAcquisitionTimeout((int) (cache.getConfiguration().getLockAcquisitionTimeout() + 5000));