Examples of ThreadPoolConfiguration


Examples of com.yammer.tenacity.core.config.ThreadPoolConfiguration

    public static TenacityConfiguration getTenacityConfiguration(TenacityPropertyKey key) {
        final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(key);
        final HystrixThreadPoolProperties threadPoolProperties = TenacityCommand.getThreadpoolProperties(key);
        return new TenacityConfiguration(
                new ThreadPoolConfiguration(
                        threadPoolProperties.coreSize().get(),
                        threadPoolProperties.keepAliveTimeMinutes().get(),
                        threadPoolProperties.maxQueueSize().get(),
                        threadPoolProperties.queueSizeRejectionThreshold().get(),
                        threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get(),
View Full Code Here

Examples of com.yammer.tenacity.core.config.ThreadPoolConfiguration

    }

    @Test
    public void overriddenProperties() throws Exception {
        final TenacityConfiguration overrideConfiguration = new TenacityConfiguration(
                new ThreadPoolConfiguration(50, 3, 27, 57, 2000, 20),
                new CircuitBreakerConfiguration(1, 2, 3, 2000, 20),
                982);

        final TenacityPropertyRegister tenacityPropertyRegister = new TenacityPropertyRegister(
                ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(DependencyKey.OVERRIDE, overrideConfiguration),
                new BreakerboxConfiguration(),
                mock(ArchaiusPropertyRegister.class));

        tenacityPropertyRegister.register();

        assertEquals(new TenacitySuccessCommand(DependencyKey.OVERRIDE).execute(), "value");
        assertEquals(new TenacitySuccessCommand(DependencyKey.OVERRIDE).queue().get(), "value");

        final TenacitySuccessCommand successCommand = new TenacitySuccessCommand(DependencyKey.OVERRIDE);

        assertNotEquals(new TenacitySuccessCommand().getCommandProperties().executionIsolationThreadTimeoutInMilliseconds(), overrideConfiguration.getExecutionIsolationThreadTimeoutInMillis());

        final HystrixCommandProperties commandProperties = successCommand.getCommandProperties();
        assertEquals(commandProperties.executionIsolationThreadTimeoutInMilliseconds().get().intValue(), overrideConfiguration.getExecutionIsolationThreadTimeoutInMillis());
        assertEquals(commandProperties.circuitBreakerErrorThresholdPercentage().get().intValue(), overrideConfiguration.getCircuitBreaker().getErrorThresholdPercentage());
        assertEquals(commandProperties.circuitBreakerRequestVolumeThreshold().get().intValue(), overrideConfiguration.getCircuitBreaker().getRequestVolumeThreshold());
        assertEquals(commandProperties.circuitBreakerSleepWindowInMilliseconds().get().intValue(), overrideConfiguration.getCircuitBreaker().getSleepWindowInMillis());
        assertEquals(commandProperties.metricsRollingStatisticalWindowBuckets().get().intValue(), overrideConfiguration.getCircuitBreaker().getMetricsRollingStatisticalWindowBuckets());
        assertEquals(commandProperties.metricsRollingStatisticalWindowInMilliseconds().get().intValue(), overrideConfiguration.getCircuitBreaker().getMetricsRollingStatisticalWindowInMilliseconds());


        final HystrixThreadPoolProperties threadPoolProperties = successCommand.getThreadpoolProperties();
        final ThreadPoolConfiguration threadPoolConfiguration = overrideConfiguration.getThreadpool();
        assertEquals(threadPoolProperties.coreSize().get().intValue(), threadPoolConfiguration.getThreadPoolCoreSize());
        assertEquals(threadPoolProperties.keepAliveTimeMinutes().get().intValue(), threadPoolConfiguration.getKeepAliveTimeMinutes());
        assertEquals(threadPoolProperties.maxQueueSize().get().intValue(), threadPoolConfiguration.getMaxQueueSize());
        assertEquals(threadPoolProperties.metricsRollingStatisticalWindowBuckets().get().intValue(), threadPoolConfiguration.getMetricsRollingStatisticalWindowBuckets());
        assertEquals(threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get().intValue(), threadPoolConfiguration.getMetricsRollingStatisticalWindowInMilliseconds());
        assertEquals(threadPoolProperties.queueSizeRejectionThreshold().get().intValue(), threadPoolConfiguration.getQueueSizeRejectionThreshold());

        assertEquals(TenacityPropertyStore.getTenacityConfiguration(DependencyKey.OVERRIDE), overrideConfiguration);
    }
View Full Code Here

Examples of com.yammer.tenacity.core.config.ThreadPoolConfiguration

    @Test
    public void queueRejectionWithBlockingQueue() throws Exception {
        final int queueMaxSize = 5;
        final TenacityConfiguration exampleConfiguration = new TenacityConfiguration(
                new ThreadPoolConfiguration(1, 1, 10, queueMaxSize, 10000, 10),
                new CircuitBreakerConfiguration(20, 5000, 50, 10000, 10),
                5000);

        final TenacityPropertyRegister tenacityPropertyRegister = new TenacityPropertyRegister(
                ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(DependencyKey.SLEEP, exampleConfiguration),
                new BreakerboxConfiguration(),
                mock(ArchaiusPropertyRegister.class));

        tenacityPropertyRegister.register();

        final ImmutableList.Builder<Future<Optional<String>>> sleepCommands = ImmutableList.builder();
        for (int i = 0; i < queueMaxSize * 2; i++) {
            sleepCommands.add(new SleepCommand(DependencyKey.SLEEP).queue());
        }

        for (Future<Optional<String>> future : sleepCommands.build()) {
            assertFalse(future.isCancelled());
            final Optional<String> result = future.get();
            if (result.isPresent()) {
                assertThat(result.get()).isEqualTo("sleep");
            } else {
                assertThat(result).isEqualTo(Optional.<String>absent());
            }
        }

        final HystrixCommandMetrics sleepCommandMetrics = new SleepCommand(DependencyKey.SLEEP).getCommandMetrics();
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED))
                .isEqualTo(4);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.TIMEOUT))
                .isEqualTo(0);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS))
                .isEqualTo(4);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.SHORT_CIRCUITED))
                .isEqualTo(0);

        final HystrixThreadPoolProperties threadPoolProperties = new SleepCommand(DependencyKey.SLEEP).getThreadpoolProperties();

        final ThreadPoolConfiguration threadPoolConfiguration = exampleConfiguration.getThreadpool();
        assertEquals(threadPoolProperties.queueSizeRejectionThreshold().get().intValue(), threadPoolConfiguration.getQueueSizeRejectionThreshold());
        assertEquals(threadPoolProperties.maxQueueSize().get().intValue(), threadPoolConfiguration.getMaxQueueSize());

        assertEquals(TenacityPropertyStore.getTenacityConfiguration(DependencyKey.SLEEP), exampleConfiguration);
    }
View Full Code Here

Examples of com.yammer.tenacity.core.config.ThreadPoolConfiguration

            }
        };
    }

    private void setUpTenacityCommand(int poolSize, int timeout) {
        final ThreadPoolConfiguration poolConfig = new ThreadPoolConfiguration();
        poolConfig.setThreadPoolCoreSize(poolSize);
        final CircuitBreakerConfiguration circuitConfig = new CircuitBreakerConfiguration();
        circuitConfig.setErrorThresholdPercentage(1);
        circuitConfig.setRequestVolumeThreshold(1);
        new TenacityPropertyRegister(
                ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(
View Full Code Here

Examples of org.infinispan.configuration.global.ThreadPoolConfiguration

   private ThreadPoolConfiguration createThreadPoolConfiguration(String threadPoolName, String componentName) {
      ThreadPoolConfigurationBuilder threadPool = threadPools.get(threadPoolName);
      if (threadPool == null)
         throw log.undefinedThreadPoolName(threadPoolName);

      ThreadPoolConfiguration threadPoolConfiguration = threadPool.create();
      DefaultThreadFactory threadFactory = threadPoolConfiguration.threadFactory();
      threadFactory.setComponent(shortened(componentName));
      return threadPoolConfiguration;
   }
View Full Code Here

Examples of org.infinispan.configuration.global.ThreadPoolConfiguration

   private ThreadPoolConfiguration createThreadPoolConfiguration(String threadPoolName, String componentName) {
      ThreadPoolConfigurationBuilder threadPool = threadPools.get(threadPoolName);
      if (threadPool == null)
         throw log.undefinedThreadPoolName(threadPoolName);

      ThreadPoolConfiguration threadPoolConfiguration = threadPool.create();
      DefaultThreadFactory threadFactory = threadPoolConfiguration.threadFactory();
      threadFactory.setComponent(shortened(componentName));
      return threadPoolConfiguration;
   }
View Full Code Here

Examples of org.infinispan.configuration.global.ThreadPoolConfiguration

   private ThreadPoolConfiguration createThreadPoolConfiguration(String threadPoolName, String componentName) {
      ThreadPoolConfigurationBuilder threadPool = threadPools.get(threadPoolName);
      if (threadPool == null)
         throw log.undefinedThreadPoolName(threadPoolName);

      ThreadPoolConfiguration threadPoolConfiguration = threadPool.create();
      DefaultThreadFactory threadFactory = threadPoolConfiguration.threadFactory();
      threadFactory.setComponent(shortened(componentName));
      return threadPoolConfiguration;
   }
View Full Code Here

Examples of org.infinispan.configuration.global.ThreadPoolConfiguration

   private ThreadPoolConfiguration createThreadPoolConfiguration(String threadPoolName, String componentName) {
      ThreadPoolConfigurationBuilder threadPool = threadPools.get(threadPoolName);
      if (threadPool == null)
         throw log.undefinedThreadPoolName(threadPoolName);

      ThreadPoolConfiguration threadPoolConfiguration = threadPool.create();
      DefaultThreadFactory threadFactory = threadPoolConfiguration.threadFactory();
      threadFactory.setComponent(shortened(componentName));
      return threadPoolConfiguration;
   }
View Full Code Here

Examples of org.infinispan.configuration.global.ThreadPoolConfiguration

   private ThreadPoolConfiguration createThreadPoolConfiguration(String threadPoolName, String componentName) {
      ThreadPoolConfigurationBuilder threadPool = threadPools.get(threadPoolName);
      if (threadPool == null)
         throw log.undefinedThreadPoolName(threadPoolName);

      ThreadPoolConfiguration threadPoolConfiguration = threadPool.create();
      DefaultThreadFactory threadFactory = threadPoolConfiguration.threadFactory();
      threadFactory.setComponent(shortened(componentName));
      return threadPoolConfiguration;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.