Search in sources :

Example 1 with ConfigurationProperties

use of org.infinispan.client.hotrod.impl.ConfigurationProperties in project infinispan by infinispan.

the class DefaultAsyncExecutorFactory method getExecutor.

@Override
public ThreadPoolExecutor getExecutor(Properties p) {
    ConfigurationProperties cp = new ConfigurationProperties(p);
    int factoryIndex = DefaultAsyncExecutorFactory.factoryCounter.incrementAndGet();
    String threadNamePrefix = cp.getDefaultExecutorFactoryThreadNamePrefix();
    String threadNameSuffix = cp.getDefaultExecutorFactoryThreadNameSuffix();
    ISPNNonBlockingThreadGroup nonBlockingThreadGroup = new ISPNNonBlockingThreadGroup(threadNamePrefix + "-group");
    ThreadFactory tf = r -> {
        int threadIndex = threadCounter.incrementAndGet();
        Thread th = new Thread(nonBlockingThreadGroup, r, threadNamePrefix + "-" + factoryIndex + "-" + threadIndex + threadNameSuffix);
        th.setDaemon(true);
        return th;
    };
    log.debugf("Creating executor %s-%d", threadNamePrefix, factoryIndex);
    return new ThreadPoolExecutor(cp.getDefaultExecutorFactoryPoolSize(), cp.getDefaultExecutorFactoryPoolSize(), 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<>(), tf, (r, executor) -> {
        int poolSize = cp.getDefaultExecutorFactoryPoolSize();
        HOTROD.cannotCreateAsyncThread(poolSize);
        throw new RejectedExecutionException("Too few threads: " + poolSize);
    });
}
Also used : Properties(java.util.Properties) SynchronousQueue(java.util.concurrent.SynchronousQueue) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ConfigurationProperties(org.infinispan.client.hotrod.impl.ConfigurationProperties) Log(org.infinispan.client.hotrod.logging.Log) ExecutorFactory(org.infinispan.commons.executors.ExecutorFactory) TimeUnit(java.util.concurrent.TimeUnit) LogFactory(org.infinispan.client.hotrod.logging.LogFactory) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) NonBlockingResource(org.infinispan.commons.executors.NonBlockingResource) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ThreadFactory(java.util.concurrent.ThreadFactory) HOTROD(org.infinispan.client.hotrod.logging.Log.HOTROD) ThreadFactory(java.util.concurrent.ThreadFactory) ConfigurationProperties(org.infinispan.client.hotrod.impl.ConfigurationProperties) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with ConfigurationProperties

use of org.infinispan.client.hotrod.impl.ConfigurationProperties in project infinispan by infinispan.

the class AbstractRemoteCacheManagerFactory method configurationProperties.

protected Properties configurationProperties() throws IOException {
    final Properties answer;
    if (this.configurationProperties != null) {
        answer = this.configurationPropertiesOverrides.override(this.configurationProperties);
        logger.debug("Using user-defined properties [" + this.configurationProperties + "] for configuring RemoteCacheManager");
    } else if (this.configurationPropertiesFileLocation != null) {
        answer = loadPropertiesFromFile(this.configurationPropertiesFileLocation);
        logger.debug("Loading properties from file [" + this.configurationProperties + "] for configuring RemoteCacheManager");
    } else if (!this.configurationPropertiesOverrides.isEmpty()) {
        answer = this.configurationPropertiesOverrides.override(new Properties());
        logger.debug("Using explicitly set configuration settings [" + answer + "] for configuring RemoteCacheManager");
    } else {
        logger.debug("No configuration properties. RemoteCacheManager will use default configuration.");
        RemoteCacheManager remoteCacheManager = new RemoteCacheManager(false);
        try {
            answer = remoteCacheManager.getConfiguration().properties();
        } finally {
            remoteCacheManager.stop();
        }
    }
    initializeMarshallingProperties(answer);
    return answer;
}
Also used : RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) Properties(java.util.Properties) ConfigurationProperties(org.infinispan.client.hotrod.impl.ConfigurationProperties)

Aggregations

Properties (java.util.Properties)2 ConfigurationProperties (org.infinispan.client.hotrod.impl.ConfigurationProperties)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 SynchronousQueue (java.util.concurrent.SynchronousQueue)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RemoteCacheManager (org.infinispan.client.hotrod.RemoteCacheManager)1 Log (org.infinispan.client.hotrod.logging.Log)1 HOTROD (org.infinispan.client.hotrod.logging.Log.HOTROD)1 LogFactory (org.infinispan.client.hotrod.logging.LogFactory)1 ExecutorFactory (org.infinispan.commons.executors.ExecutorFactory)1 NonBlockingResource (org.infinispan.commons.executors.NonBlockingResource)1