Search in sources :

Example 1 with HealthInfoElement

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

the class CacheMXBeanImpl method getAlert.

@Override
public int getAlert() {
    Iterator<HealthInfoElement> it = getInfo().getHealth().iterator();
    if (!it.hasNext()) {
        return 0;
    }
    HealthInfoElement hi = it.next();
    if (HealthInfoElement.FAILURE.equals(hi.getLevel())) {
        return 2;
    }
    return 1;
}
Also used : HealthInfoElement(org.cache2k.core.HealthInfoElement)

Example 2 with HealthInfoElement

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

the class ManagerMXBeanImpl method constructHealthString.

static String constructHealthString(final List<HealthInfoElement> _sortedList) {
    if (_sortedList.isEmpty()) {
        return "ok";
    }
    boolean _comma = false;
    StringBuilder sb = new StringBuilder();
    for (HealthInfoElement hi : _sortedList) {
        if (_comma) {
            sb.append("; ");
        }
        sb.append(hi.getLevel()).append(": ").append("[").append(hi.getCache().getName() + "] ").append(hi.getMessage());
        _comma = true;
    }
    return sb.toString();
}
Also used : HealthInfoElement(org.cache2k.core.HealthInfoElement)

Example 3 with HealthInfoElement

use of org.cache2k.core.HealthInfoElement 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

HealthInfoElement (org.cache2k.core.HealthInfoElement)3 ArrayList (java.util.ArrayList)1 Cache (org.cache2k.Cache)1 InternalCache (org.cache2k.core.InternalCache)1