protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String cacheContainerName = address.getLastElement().getValue();
final String attrName = operation.require(ModelDescriptionConstants.NAME).asString();
final ServiceController<?> controller = context.getServiceRegistry(false).getService(EmbeddedCacheManagerService.getServiceName(cacheContainerName));
DefaultEmbeddedCacheManager cacheManager = (DefaultEmbeddedCacheManager) controller.getValue();
CacheManagerMetrics metric = CacheManagerMetrics.getStat(attrName);
ModelNode result = new ModelNode();
if (metric == null) {
context.getFailureDescription().set(String.format("Unknown metric %s", attrName));
} else if (cacheManager == null) {
context.getFailureDescription().set(String.format("Unavailable cache container %s", attrName));
} else {
switch (metric) {
case CACHE_MANAGER_STATUS:
result.set(cacheManager.getStatus().toString());
break;
case IS_COORDINATOR:
result.set(cacheManager.isCoordinator());
break;
case LOCAL_ADDRESS:
result.set(cacheManager.getAddress() != null ? cacheManager.getAddress().toString() : "N/A");
break;
case COORDINATOR_ADDRESS:
result.set(cacheManager.getCoordinator() != null ? cacheManager.getCoordinator().toString() : "N/A");
break;
case CLUSTER_NAME:
result.set(cacheManager.getClusterName() != null ? cacheManager.getClusterName() : "N/A");
}
context.getResult().set(result);
}
context.completeStep();
}