} else if (cache == null) {
context.getFailureDescription().set(String.format("Unavailable cache %s", attrName));
} else {
AdvancedCache<?, ?> aCache = cache.getAdvancedCache();
LockManagerImpl lockManager = (LockManagerImpl) SecurityActions.getLockManager(aCache);
RpcManagerImpl rpcManager = (RpcManagerImpl) SecurityActions.getRpcManager(aCache);
List<CommandInterceptor> interceptors = SecurityActions.getInterceptorChain(aCache);
ComponentRegistry registry = SecurityActions.getComponentRegistry(aCache);
ComponentStatus status = SecurityActions.getCacheStatus(aCache);
switch (metric) {
case CACHE_STATUS:
result.set(status.toString());
break;
case CONCURRENCY_LEVEL:
result.set(lockManager.getConcurrencyLevel());
break;
case NUMBER_OF_LOCKS_AVAILABLE:
result.set(lockManager.getNumberOfLocksAvailable());
break;
case NUMBER_OF_LOCKS_HELD:
result.set(lockManager.getNumberOfLocksHeld());
break;
case AVERAGE_READ_TIME: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageReadTime() : 0);
break;
}
case AVERAGE_WRITE_TIME: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageWriteTime() : 0);
break;
}
case AVERAGE_REMOVE_TIME: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageRemoveTime() : 0);
break;
}
case ELAPSED_TIME: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getElapsedTime() : 0);
break;
}
case EVICTIONS: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getEvictions() : 0);
break;
}
case HIT_RATIO: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getHitRatio() : 0);
break;
}
case HITS: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getHits() : 0);
break;
}
case MISSES: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getMisses() : 0);
break;
}
case NUMBER_OF_ENTRIES: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getNumberOfEntries() : 0);
break;
}
case READ_WRITE_RATIO: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getReadWriteRatio() : 0);
break;
}
case REMOVE_HITS: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getRemoveHits() : 0);
break;
}
case REMOVE_MISSES: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getRemoveMisses() : 0);
break;
}
case STORES: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getStores() : 0);
break;
}
case TIME_SINCE_RESET: {
CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getTimeSinceReset() : 0);
break;
}
case AVERAGE_REPLICATION_TIME: {
result.set(rpcManager.getAverageReplicationTime());
break;
}
case REPLICATION_COUNT:
result.set(rpcManager.getReplicationCount());
break;
case REPLICATION_FAILURES:
result.set(rpcManager.getReplicationFailures());
break;
case SUCCESS_RATIO:
result.set(rpcManager.getSuccessRatioFloatingPoint());
break;
case COMMITS: {
TxInterceptor txInterceptor = getFirstInterceptorWhichExtends(interceptors, TxInterceptor.class);
result.set(txInterceptor != null ? txInterceptor.getCommits() : 0);
break;