Search in sources :

Example 6 with RemoteCacheContainer

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

the class RemoteCacheContainerResourceDefinition method register.

@SuppressWarnings("deprecation")
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(ListAttribute.class).addIgnoredAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MODULE))).addAttributeTranslation(DeprecatedAttribute.MODULE, new ListAttributeTranslation(ListAttribute.MODULES)).addCapabilities(Capability.class).addRequiredChildren(ConnectionPoolResourceDefinition.PATH, ThreadPoolResourceDefinition.CLIENT.getPathElement(), SecurityResourceDefinition.PATH, RemoteTransactionResourceDefinition.PATH).addRequiredSingletonChildren(NoNearCacheResourceDefinition.PATH).setResourceTransformation(RemoteCacheContainerResource::new);
    ServiceValueExecutorRegistry<RemoteCacheContainer> executors = new ServiceValueExecutorRegistry<>();
    ResourceServiceHandler handler = new RemoteCacheContainerServiceHandler(this, executors);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    new ConnectionPoolResourceDefinition().register(registration);
    new RemoteClusterResourceDefinition(this, executors).register(registration);
    new SecurityResourceDefinition().register(registration);
    new RemoteTransactionResourceDefinition().register(registration);
    new InvalidationNearCacheResourceDefinition().register(registration);
    new NoNearCacheResourceDefinition().register(registration);
    ThreadPoolResourceDefinition.CLIENT.register(registration);
    if (registration.isRuntimeOnlyRegistrationValid()) {
        new MetricHandler<>(new RemoteCacheContainerMetricExecutor(executors), RemoteCacheContainerMetric.class).register(registration);
        new RemoteCacheResourceDefinition(executors).register(registration);
    }
    return registration;
}
Also used : UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) ListAttributeTranslation(org.jboss.as.clustering.controller.ListAttributeTranslation) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ServiceValueExecutorRegistry(org.jboss.as.clustering.controller.ServiceValueExecutorRegistry) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 7 with RemoteCacheContainer

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

the class HotRodStore method start.

@Override
public CompletionStage<Void> start(InitializationContext context) {
    this.blockingManager = context.getBlockingManager();
    HotRodStoreConfiguration configuration = context.getConfiguration();
    RemoteCacheContainer container = configuration.remoteCacheContainer();
    String cacheConfiguration = configuration.cacheConfiguration();
    String cacheName = context.getCache().getName();
    this.batchSize = configuration.maxBatchSize();
    this.marshaller = context.getPersistenceMarshaller();
    this.entryFactory = context.getMarshallableEntryFactory();
    String templateName = (cacheConfiguration != null) ? cacheConfiguration : DefaultTemplate.DIST_SYNC.getTemplateName();
    Consumer<RemoteCacheConfigurationBuilder> configurator = new Consumer<RemoteCacheConfigurationBuilder>() {

        @Override
        public void accept(RemoteCacheConfigurationBuilder builder) {
            builder.forceReturnValues(false).transactionMode(TransactionMode.NONE).nearCacheMode(NearCacheMode.DISABLED).templateName(templateName);
        }
    };
    container.getConfiguration().addRemoteCache(cacheName, configurator);
    Runnable task = new Runnable() {

        @Override
        public void run() {
            try {
                HotRodStore.this.setRemoteCache(container, cacheName);
            } catch (HotRodClientException ex) {
                throw new PersistenceException(ex);
            }
        }
    };
    return this.blockingManager.runBlocking(task, "hotrod-store-start");
}
Also used : RemoteCacheContainer(org.wildfly.clustering.infinispan.client.RemoteCacheContainer) Consumer(java.util.function.Consumer) PersistenceException(org.infinispan.persistence.spi.PersistenceException) RemoteCacheConfigurationBuilder(org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder) HotRodClientException(org.infinispan.client.hotrod.exceptions.HotRodClientException)

Example 8 with RemoteCacheContainer

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

the class RemoteCacheOperationExecutor method execute.

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

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