@Override
  protected void executeRuntimeStep(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    // Address is of the form:
    // /subsystem=infinispan/cache-container=*/*-cache=*/transaction=TRANSACTION
    PathAddress address = context.getCurrentAddress();
    String containerName = address.getElement(address.size() - 3).getValue();
    String cacheName = address.getElement(address.size() - 2).getValue();
    String name = operation.require(ModelDescriptionConstants.NAME).asString();

    TransactionMetric metric = TransactionMetric.forName(name);

    if (metric == null) {
      context.getFailureDescription().set(InfinispanLogger.ROOT_LOGGER.unknownMetric(name));
    } else {
      Cache<?, ?> cache =
          ServiceContainerHelper.findValue(
              context.getServiceRegistry(false),
              CacheServiceName.CACHE.getServiceName(containerName, cacheName));
      if (cache != null) {
        TxInterceptor interceptor = CacheMetric.findInterceptor(cache, TxInterceptor.class);
        context
            .getResult()
            .set((interceptor != null) ? metric.getValue(interceptor) : new ModelNode(0));
      }
    }
    context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
  }
示例#2
0
  @Override
  protected void executeRuntimeStep(OperationContext context, ModelNode operation) {
    // Address is of the form: /subsystem=infinispan/cache-container=*/*-cache=*
    PathAddress address = context.getCurrentAddress();
    String containerName = address.getElement(address.size() - 2).getValue();
    String cacheName = address.getElement(address.size() - 1).getValue();
    String name = Operations.getAttributeName(operation);

    CacheMetric metric = CacheMetric.forName(name);

    if (metric == null) {
      context.getFailureDescription().set(InfinispanLogger.ROOT_LOGGER.unknownMetric(name));
    } else {
      Cache<?, ?> cache =
          ServiceContainerHelper.findValue(
              context.getServiceRegistry(false),
              CacheServiceName.CACHE.getServiceName(containerName, cacheName));
      if (cache != null) {
        context.getResult().set(metric.getValue(cache));
      }
    }
    context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
  }