Search in sources :

Example 1 with InternalCache

use of org.cache2k.core.InternalCache in project cache2k by cache2k.

the class JmxSupport method cacheCreated.

@Override
public void cacheCreated(Cache c) {
    InternalCache ic = (InternalCache) c;
    if (!ic.getCommonMetrics().isDisabled()) {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        String _name = standardName(c.getCacheManager(), c);
        try {
            mbs.registerMBean(new CacheMXBeanImpl(ic), new ObjectName(_name));
        } catch (InstanceAlreadyExistsException ignore) {
            log.debug("register failure, cache: " + c.getName(), ignore);
        } catch (Exception e) {
            throw new CacheException("register JMX bean, ObjectName: " + _name, e);
        }
    }
}
Also used : CacheException(org.cache2k.CacheException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InternalCache(org.cache2k.core.InternalCache) CacheException(org.cache2k.CacheException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 2 with InternalCache

use of org.cache2k.core.InternalCache in project cache2k by cache2k.

the class BasicCacheOperationsTest method getEntryState.

@Test
public void getEntryState() {
    if (!(cache instanceof InternalCache)) {
        return;
    }
    InternalCache c = (InternalCache) cache;
    String s = c.getEntryState(KEY);
    assertNull(s);
    cache.put(KEY, VALUE);
    s = c.getEntryState(KEY);
    assertNotNull(s);
}
Also used : InternalCache(org.cache2k.core.InternalCache)

Example 3 with InternalCache

use of org.cache2k.core.InternalCache in project cache2k by cache2k.

the class BasicCacheOperationsTest method getEntryState_Exception.

@Test
public void getEntryState_Exception() {
    if (!(cache instanceof InternalCache)) {
        return;
    }
    ((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
    InternalCache c = (InternalCache) cache;
    String s = c.getEntryState(KEY);
    assertTrue(s.contains("exception="));
}
Also used : InternalCache(org.cache2k.core.InternalCache) ExceptionWrapper(org.cache2k.core.ExceptionWrapper) InternalCache(org.cache2k.core.InternalCache) Cache(org.cache2k.Cache)

Example 4 with InternalCache

use of org.cache2k.core.InternalCache in project cache2k by cache2k.

the class ManagerMXBeanImpl method getHealthStatus.

@Override
public String getHealthStatus() {
    List<HealthInfoElement> li = new ArrayList<HealthInfoElement>();
    for (Cache c : manager.getActiveCaches()) {
        InternalCache ic = (InternalCache) c;
        li.addAll(ic.getInfo().getHealth());
    }
    sortHealthInfoList(li);
    return constructHealthString(li);
}
Also used : ArrayList(java.util.ArrayList) InternalCache(org.cache2k.core.InternalCache) HealthInfoElement(org.cache2k.core.HealthInfoElement) Cache(org.cache2k.Cache) InternalCache(org.cache2k.core.InternalCache)

Aggregations

InternalCache (org.cache2k.core.InternalCache)4 Cache (org.cache2k.Cache)2 ArrayList (java.util.ArrayList)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 CacheException (org.cache2k.CacheException)1 ExceptionWrapper (org.cache2k.core.ExceptionWrapper)1 HealthInfoElement (org.cache2k.core.HealthInfoElement)1