use of javax.cache.CacheException in project hazelcast by hazelcast.
the class MXBeanUtil method unregisterCacheObject.
/**
* UnRegisters the mxbean if registered already.
* @param cacheManagerName name generated by URI and classloader.
* @param name cache name.
* @param stats is mxbean, a statistics mxbean.
*/
public static void unregisterCacheObject(String cacheManagerName, String name, boolean stats) {
synchronized (mBeanServer) {
ObjectName objectName = calculateObjectName(cacheManagerName, name, stats);
Set<ObjectName> registeredObjectNames = mBeanServer.queryNames(objectName, null);
if (isRegistered(cacheManagerName, name, stats)) {
//should just be one
for (ObjectName registeredObjectName : registeredObjectNames) {
try {
mBeanServer.unregisterMBean(registeredObjectName);
} catch (Exception e) {
throw new CacheException("Error unregistering object instance " + registeredObjectName + " . Error was " + e.getMessage(), e);
}
}
}
}
}
use of javax.cache.CacheException in project hazelcast by hazelcast.
the class AbstractHazelcastCachingProvider method getCacheManager.
@Override
public CacheManager getCacheManager(URI uri, ClassLoader classLoader, Properties properties) {
final URI managerURI = getManagerUri(uri);
final ClassLoader managerClassLoader = getManagerClassLoader(classLoader);
final Properties managerProperties = properties == null ? new Properties() : properties;
synchronized (cacheManagers) {
Map<URI, AbstractHazelcastCacheManager> cacheManagersByURI = cacheManagers.get(managerClassLoader);
if (cacheManagersByURI == null) {
cacheManagersByURI = new HashMap<URI, AbstractHazelcastCacheManager>();
cacheManagers.put(managerClassLoader, cacheManagersByURI);
}
AbstractHazelcastCacheManager cacheManager = cacheManagersByURI.get(managerURI);
if (cacheManager == null || cacheManager.isClosed()) {
try {
cacheManager = createHazelcastCacheManager(uri, classLoader, managerProperties);
cacheManagersByURI.put(managerURI, cacheManager);
} catch (Exception e) {
throw new CacheException("Error opening URI [" + managerURI.toString() + ']', e);
}
}
return cacheManager;
}
}
use of javax.cache.CacheException in project hazelcast by hazelcast.
the class CacheClearMessageTask method reduce.
@Override
protected Object reduce(Map<Integer, Object> map) {
for (Map.Entry<Integer, Object> entry : map.entrySet()) {
if (entry.getValue() == null) {
continue;
}
final CacheClearResponse cacheClearResponse = (CacheClearResponse) nodeEngine.toObject(entry.getValue());
final Object response = cacheClearResponse.getResponse();
if (response instanceof CacheException) {
throw (CacheException) response;
}
}
return null;
}
use of javax.cache.CacheException in project hazelcast by hazelcast.
the class CacheLoadAllMessageTask method reduce.
@Override
protected Object reduce(Map<Integer, Object> map) {
for (Map.Entry<Integer, Object> entry : map.entrySet()) {
if (entry.getValue() == null) {
continue;
}
final CacheClearResponse cacheClearResponse = (CacheClearResponse) nodeEngine.toObject(entry.getValue());
final Object response = cacheClearResponse.getResponse();
if (response instanceof CacheException) {
throw (CacheException) response;
}
}
return null;
}
use of javax.cache.CacheException in project pratilipi by Pratilipi.
the class MemcacheGaeImpl method flush.
@Override
public void flush() {
try {
Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
cache.clear();
} catch (CacheException ex) {
logger.log(Level.SEVERE, "Failed to create cache instance.", ex);
}
}
Aggregations