Ejemplo n.º 1
0
  @Override
  public ConfigurationBuilder createConfigurationBuilder() {
    ConfigurationBuilder builder = super.createConfigurationBuilder();
    builder.clustering().cacheMode(CacheMode.LOCAL);

    TransactionConfiguration transaction = this.transaction.getValue();
    LockingConfiguration locking = this.locking.getValue();
    PersistenceConfiguration persistence = this.persistence.getValue();

    // Auto-enable simple cache optimization if cache is non-transactional and non-persistent
    builder.simpleCache(
        !transaction.transactionMode().isTransactional() && !persistence.usingStores());
    if (InfinispanLogger.ROOT_LOGGER.isTraceEnabled() && builder.simpleCache()) {
      InfinispanLogger.ROOT_LOGGER.tracef(
          "Configuration for container '%s', cache '%s' will use simple cache optimization",
          this.containerName, this.cacheName);
    }
    if ((transaction.lockingMode() == LockingMode.OPTIMISTIC)
        && (locking.isolationLevel() == IsolationLevel.REPEATABLE_READ)) {
      builder.locking().writeSkewCheck(true);
      builder.versioning().enable().scheme(VersioningScheme.SIMPLE);
    }

    return builder;
  }
Ejemplo n.º 2
0
 LocalCacheBuilder(String containerName, String cacheName) {
   super(containerName, cacheName);
   this.containerName = containerName;
   this.cacheName = cacheName;
   if (InfinispanLogger.ROOT_LOGGER.isTraceEnabled()) {
     InfinispanLogger.ROOT_LOGGER.tracef(
         "LocalCacheBuilder will be configured for container '%s', cache '%s'",
         containerName, cacheName);
   }
 }
  @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);
  }
 static String findPoolName(OperationContext context, String jndiName)
     throws OperationFailedException {
   PathAddress address = context.getCurrentAddress();
   PathAddress rootAddress = address.subAddress(0, address.size() - 4);
   PathAddress subsystemAddress =
       rootAddress.append(
           PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources"));
   Resource subsystem = context.readResourceFromRoot(subsystemAddress);
   for (String type : Arrays.asList("data-source", "xa-data-source")) {
     if (subsystem.hasChildren(type)) {
       for (Resource.ResourceEntry entry : subsystem.getChildren(type)) {
         ModelNode model = entry.getModel();
         if (model.get("jndi-name").asString().equals(jndiName)) {
           return entry.getName();
         }
       }
     }
   }
   throw InfinispanLogger.ROOT_LOGGER.dataSourceJndiNameNotFound(jndiName);
 }
Ejemplo n.º 5
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);
  }