Search in sources :

Example 1 with RemoteCacheContainer

use of org.wildfly.clustering.infinispan.client.RemoteCacheContainer in project wildfly by wildfly.

the class RemoteCacheMetricExecutor method execute.

@Override
public ModelNode execute(OperationContext context, Metric<RemoteCacheClientStatisticsMXBean> metric) throws OperationFailedException {
    ServiceName name = InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.PARENT);
    FunctionExecutor<RemoteCacheContainer> executor = this.executors.get(name);
    return (executor != null) ? executor.execute(new MetricFunction<>(new RemoteCacheClientStatisticsFactory(context.getCurrentAddressValue()), metric)) : null;
}
Also used : RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) ServiceName(org.jboss.msc.service.ServiceName) MetricFunction(org.jboss.as.clustering.controller.MetricFunction)

Example 2 with RemoteCacheContainer

use of org.wildfly.clustering.infinispan.client.RemoteCacheContainer in project wildfly by wildfly.

the class RemoteClusterOperationExecutor method execute.

@Override
public ModelNode execute(OperationContext context, ModelNode op, Operation<Map.Entry<String, RemoteCacheManagerMXBean>> operation) throws OperationFailedException {
    ServiceName name = InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.PARENT);
    FunctionExecutor<RemoteCacheContainer> executor = this.executors.get(name);
    Function<RemoteCacheContainer, Map.Entry<String, RemoteCacheManagerMXBean>> mapper = new Function<RemoteCacheContainer, Map.Entry<String, RemoteCacheManagerMXBean>>() {

        @Override
        public Map.Entry<String, RemoteCacheManagerMXBean> apply(RemoteCacheContainer container) {
            String cluster = context.getCurrentAddressValue();
            return new AbstractMap.SimpleImmutableEntry<>(cluster, container);
        }
    };
    return (executor != null) ? executor.execute(new OperationFunction<>(context, op, mapper, operation)) : null;
}
Also used : OperationFunction(org.jboss.as.clustering.controller.OperationFunction) Function(java.util.function.Function) RemoteCacheManagerMXBean(org.infinispan.client.hotrod.jmx.RemoteCacheManagerMXBean) RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) OperationFunction(org.jboss.as.clustering.controller.OperationFunction) ServiceName(org.jboss.msc.service.ServiceName) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Example 3 with RemoteCacheContainer

use of org.wildfly.clustering.infinispan.client.RemoteCacheContainer in project wildfly by wildfly.

the class RemoteCacheContainerServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceBuilder<?> builder = new AsyncServiceConfigurator(this.getServiceName()).build(target);
    Consumer<RemoteCacheContainer> container = this.configuration.register(builder).provides(this.getServiceName());
    Service service = new FunctionalService<>(container, this, this, this);
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) FunctionalService(org.wildfly.clustering.service.FunctionalService) AsyncServiceConfigurator(org.wildfly.clustering.service.AsyncServiceConfigurator) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service)

Example 4 with RemoteCacheContainer

use of org.wildfly.clustering.infinispan.client.RemoteCacheContainer in project wildfly by wildfly.

the class RemoteCacheServiceConfigurator method get.

@Override
public RemoteCache<K, V> get() {
    String templateName = (this.configurationName != null) ? this.configurationName : DefaultTemplate.DIST_SYNC.getTemplateName();
    NearCacheMode mode = this.nearCacheFactory.getMode();
    Consumer<RemoteCacheConfigurationBuilder> configurator = new Consumer<RemoteCacheConfigurationBuilder>() {

        @Override
        public void accept(RemoteCacheConfigurationBuilder builder) {
            builder.forceReturnValues(false).nearCacheMode(mode).transactionMode(TransactionMode.NONE).templateName(templateName);
        }
    };
    this.container.get().getConfiguration().addRemoteCache(this.cacheName, configurator);
    RemoteCacheContainer container = this.container.get();
    try (RemoteCacheContainer.NearCacheRegistration registration = (this.nearCacheFactory != null) ? container.registerNearCacheFactory(this.cacheName, this.nearCacheFactory) : null) {
        RemoteCache<K, V> cache = container.getCache(this.cacheName);
        cache.start();
        return cache;
    }
}
Also used : RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) NearCacheMode(org.infinispan.client.hotrod.configuration.NearCacheMode) Consumer(java.util.function.Consumer) RemoteCacheConfigurationBuilder(org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder)

Example 5 with RemoteCacheContainer

use of org.wildfly.clustering.infinispan.client.RemoteCacheContainer in project wildfly by wildfly.

the class RemoteCacheContainerMetricExecutor method execute.

@Override
public ModelNode execute(OperationContext context, Metric<RemoteCacheManagerMXBean> metric) throws OperationFailedException {
    ServiceName name = InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, UnaryCapabilityNameResolver.DEFAULT);
    FunctionExecutor<RemoteCacheContainer> executor = this.executors.get(name);
    return (executor != null) ? executor.execute(new MetricFunction<>(Functions.identity(), metric)) : null;
}
Also used : RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) ServiceName(org.jboss.msc.service.ServiceName) MetricFunction(org.jboss.as.clustering.controller.MetricFunction)

Aggregations

RemoteCacheContainer (org.wildfly.clustering.infinispan.client.RemoteCacheContainer)8 ServiceName (org.jboss.msc.service.ServiceName)4 Consumer (java.util.function.Consumer)2 RemoteCacheConfigurationBuilder (org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder)2 MetricFunction (org.jboss.as.clustering.controller.MetricFunction)2 OperationFunction (org.jboss.as.clustering.controller.OperationFunction)2 AbstractMap (java.util.AbstractMap)1 Map (java.util.Map)1 Function (java.util.function.Function)1 NearCacheMode (org.infinispan.client.hotrod.configuration.NearCacheMode)1 HotRodClientException (org.infinispan.client.hotrod.exceptions.HotRodClientException)1 RemoteCacheManagerMXBean (org.infinispan.client.hotrod.jmx.RemoteCacheManagerMXBean)1 PersistenceException (org.infinispan.persistence.spi.PersistenceException)1 ListAttributeTranslation (org.jboss.as.clustering.controller.ListAttributeTranslation)1 ManagementResourceRegistration (org.jboss.as.clustering.controller.ManagementResourceRegistration)1 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)1 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)1 ServiceValueExecutorRegistry (org.jboss.as.clustering.controller.ServiceValueExecutorRegistry)1 SimpleResourceRegistration (org.jboss.as.clustering.controller.SimpleResourceRegistration)1 UnaryRequirementCapability (org.jboss.as.clustering.controller.UnaryRequirementCapability)1