Search in sources :

Example 1 with RemoteCacheConfigurationBuilder

use of org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder 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 2 with RemoteCacheConfigurationBuilder

use of org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder 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)

Aggregations

Consumer (java.util.function.Consumer)2 RemoteCacheConfigurationBuilder (org.infinispan.client.hotrod.configuration.RemoteCacheConfigurationBuilder)2 RemoteCacheContainer (org.wildfly.clustering.infinispan.client.RemoteCacheContainer)2 NearCacheMode (org.infinispan.client.hotrod.configuration.NearCacheMode)1 HotRodClientException (org.infinispan.client.hotrod.exceptions.HotRodClientException)1 PersistenceException (org.infinispan.persistence.spi.PersistenceException)1