當前位置: 首頁>>代碼示例>>Java>>正文


Java ThreadPoolConfiguration類代碼示例

本文整理匯總了Java中com.yammer.tenacity.core.config.ThreadPoolConfiguration的典型用法代碼示例。如果您正苦於以下問題:Java ThreadPoolConfiguration類的具體用法?Java ThreadPoolConfiguration怎麽用?Java ThreadPoolConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ThreadPoolConfiguration類屬於com.yammer.tenacity.core.config包,在下文中一共展示了ThreadPoolConfiguration類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCanReplace

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
/**
 * Replacing isn't actually used at time of test writing, but it's a good one to keep in the client API, so testing it here.
 */
@Test
public void testCanReplace() throws Exception {
    final DependencyEntity originalEntity = DependencyEntity.build(dependencyId, testTimeStamp, user,
            new TenacityConfiguration(
                    new ThreadPoolConfiguration(),
                    new CircuitBreakerConfiguration(1234, 5678, 910, 20000, 10),
                    3000),
            serviceId);

    assertTrue(tableClient.insertOrReplace(originalEntity));

    final TenacityConfiguration updatedConfiguration = new TenacityConfiguration(
            new ThreadPoolConfiguration(),
            new CircuitBreakerConfiguration(987, 6543, 321, 1000, 20),
            4000);
    final DependencyEntity updatedEntity = DependencyEntity.build(dependencyId, testTimeStamp, user,
            updatedConfiguration, serviceId);

    assertTrue(tableClient.insertOrReplace(updatedEntity));
    final Optional<DependencyEntity> retrievedEntity = tableClient.retrieve(originalEntity);
    assertTrue(retrievedEntity.isPresent());
    assertThat(retrievedEntity.get().getConfiguration()).isEqualTo(Optional.of(updatedConfiguration));
}
 
開發者ID:guggens,項目名稱:log-dropwizard-eureka-mongo-sample,代碼行數:27,代碼來源:DependencyEntityTest.java

示例2: testCanReplace

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
/**
 * Replacing isn't actually used at time of test writing, but it's a good one to keep in the client API, so testing it here.
 */
@Test
public void testCanReplace() throws Exception {
    final DependencyEntity originalEntity = DependencyEntity.build(dependencyId, testTimeStamp, user,
            new TenacityConfiguration(
                    new ThreadPoolConfiguration(),
                    new CircuitBreakerConfiguration(1234, 5678, 910, 20000, 10),
                    new SemaphoreConfiguration(),
                    3000),
            serviceId);

    assertTrue(tableClient.insertOrReplace(originalEntity));

    final TenacityConfiguration updatedConfiguration = new TenacityConfiguration(
            new ThreadPoolConfiguration(),
            new CircuitBreakerConfiguration(987, 6543, 321, 1000, 20),
            new SemaphoreConfiguration(),
            4000);
    final DependencyEntity updatedEntity = DependencyEntity.build(dependencyId, testTimeStamp, user,
            updatedConfiguration, serviceId);

    assertTrue(tableClient.insertOrReplace(updatedEntity));
    final Optional<DependencyEntity> retrievedEntity = tableClient.retrieve(originalEntity);
    assertTrue(retrievedEntity.isPresent());
    assertThat(retrievedEntity.get().getConfiguration()).isEqualTo(Optional.of(updatedConfiguration));
}
 
開發者ID:yammer,項目名稱:breakerbox,代碼行數:29,代碼來源:DependencyEntityTest.java

示例3: setup

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
@Before
public void setup() throws Exception {
    tableClient = new TableClientFactory(azureTableConfiguration).create();
    breakerboxStore = new AzureStore(azureTableConfiguration, environment());
    testServiceId = ServiceId.from(UUID.randomUUID().toString());
    testDependencyId = DependencyId.from(UUID.randomUUID().toString());
    timestamp = 1345938944000L;
    dependencyConfiguration = new TenacityConfiguration(
            new ThreadPoolConfiguration(12, 23, 34, 45, 56, 67),
            new CircuitBreakerConfiguration(1, 2, 3, 4, 5),
            new SemaphoreConfiguration(1, 2),
            6789);
    user = "USER";
    assumeTrue(validAzureAccount());
    assertTrue(breakerboxStore.initialize());
}
 
開發者ID:yammer,項目名稱:breakerbox,代碼行數:17,代碼來源:AzureStoreTest.java

示例4: getTenacityConfiguration

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
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(),
                    threadPoolProperties.metricsRollingStatisticalWindowBuckets().get()),
            new CircuitBreakerConfiguration(
                    commandProperties.circuitBreakerRequestVolumeThreshold().get(),
                    commandProperties.circuitBreakerSleepWindowInMilliseconds().get(),
                    commandProperties.circuitBreakerErrorThresholdPercentage().get(),
                    commandProperties.metricsRollingStatisticalWindowInMilliseconds().get(),
                    commandProperties.metricsRollingStatisticalWindowBuckets().get()),
            new SemaphoreConfiguration(
                    commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get(),
                    commandProperties.fallbackIsolationSemaphoreMaxConcurrentRequests().get()),
            commandProperties.executionTimeoutInMilliseconds().get(),
            commandProperties.executionIsolationStrategy().get());
}
 
開發者ID:yammer,項目名稱:tenacity,代碼行數:24,代碼來源:TenacityPropertyStore.java

示例5: testSerializationAndDeserializationOfConfig

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
@Test
public void testSerializationAndDeserializationOfConfig() throws Exception {
    final TenacityConfiguration dependencyConfiguration = new TenacityConfiguration(new ThreadPoolConfiguration(12, 23, 34, 45, 56, 67), new CircuitBreakerConfiguration(1, 2, 3, 4, 5), 6789);//numbers totally arbitrary
    final DependencyEntity entry = DependencyEntity.build(dependencyId, testTimeStamp, user, dependencyConfiguration, serviceId);

    final TenacityConfiguration recomposedConfiguration = entry.getConfiguration().get();
    assertThat(recomposedConfiguration).isEqualsToByComparingFields(dependencyConfiguration);

}
 
開發者ID:guggens,項目名稱:log-dropwizard-eureka-mongo-sample,代碼行數:10,代碼來源:DependencyEntityTest.java

示例6: setup

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
@Before
public void setup() throws Exception {
    tableClient = new TableClientFactory(azureTableConfiguration).create();
    breakerboxStore = new AzureStore(azureTableConfiguration, environment());
    testServiceId = ServiceId.from(UUID.randomUUID().toString());
    testDependencyId = DependencyId.from(UUID.randomUUID().toString());
    timestamp = 1345938944000l;
    dependencyConfiguration = new TenacityConfiguration(new ThreadPoolConfiguration(12, 23, 34, 45, 56, 67), new CircuitBreakerConfiguration(1, 2, 3, 4, 5), 6789);
    user = "USER";
    assumeTrue(validAzureAccount());
    assertTrue(breakerboxStore.initialize());
}
 
開發者ID:guggens,項目名稱:log-dropwizard-eureka-mongo-sample,代碼行數:13,代碼來源:AzureStoreTest.java

示例7: testSerializationAndDeserializationOfConfig

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
@Test
public void testSerializationAndDeserializationOfConfig() throws Exception {
    final TenacityConfiguration dependencyConfiguration = new TenacityConfiguration(new ThreadPoolConfiguration(12, 23, 34, 45, 56, 67), new CircuitBreakerConfiguration(1, 2, 3, 4, 5), new SemaphoreConfiguration(3, 4), 6789);//numbers totally arbitrary
    final DependencyEntity entry = DependencyEntity.build(dependencyId, testTimeStamp, user, dependencyConfiguration, serviceId);

    final TenacityConfiguration recomposedConfiguration = entry.getConfiguration().get();
    assertThat(recomposedConfiguration).isEqualToComparingFieldByField(dependencyConfiguration);

}
 
開發者ID:yammer,項目名稱:breakerbox,代碼行數:10,代碼來源:DependencyEntityTest.java

示例8: configure

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
@POST @Timed @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/{dependency}")
public Response configure(@Auth BasicCredentials creds,
                          @PathParam("service") String serviceName,
                          @PathParam("dependency") String dependencyName,
                          @FormParam("executionTimeout") Integer executionTimeout,
                          @FormParam("requestVolumeThreshold") Integer requestVolumeThreshold,
                          @FormParam("errorThresholdPercentage") Integer errorThresholdPercentage,
                          @FormParam("sleepWindow") Integer sleepWindow,
                          @FormParam("circuitBreakerstatisticalWindow") Integer circuitBreakerstatisticalWindow,
                          @FormParam("circuitBreakerStatisticalWindowBuckets") Integer circuitBreakerStatisticalWindowBuckets,
                          @FormParam("threadPoolCoreSize") Integer threadPoolCoreSize,
                          @FormParam("keepAliveMinutes") Integer keepAliveMinutes,
                          @FormParam("maxQueueSize") Integer maxQueueSize,
                          @FormParam("queueSizeRejectionThreshold") Integer queueSizeRejectionThreshold,
                          @FormParam("threadpoolStatisticalWindow") Integer threadpoolStatisticalWindow,
                          @FormParam("threadpoolStatisticalWindowBuckets") Integer threadpoolStatisticalWindowBuckets) {
    final TenacityConfiguration tenacityConfiguration = new TenacityConfiguration(
            new ThreadPoolConfiguration(
                    threadPoolCoreSize,
                    keepAliveMinutes,
                    maxQueueSize,
                    queueSizeRejectionThreshold,
                    threadpoolStatisticalWindow,
                    threadpoolStatisticalWindowBuckets),
            new CircuitBreakerConfiguration(
                    requestVolumeThreshold,
                    sleepWindow,
                    errorThresholdPercentage,
                    circuitBreakerstatisticalWindow,
                    circuitBreakerStatisticalWindowBuckets),
            executionTimeout);
    final ServiceId serviceId = ServiceId.from(serviceName);
    final DependencyId dependencyId = DependencyId.from(dependencyName);
    if (breakerboxStore.store(new ServiceModel(serviceId, dependencyId)) &&
        breakerboxStore.store(new DependencyModel(dependencyId, DateTime.now(), tenacityConfiguration, creds.getUsername(), serviceId))) {
        return Response
                .created(URI.create(String.format("/configuration/%s/%s", serviceName, dependencyName)))
                .build();
    } else {
        return Response.serverError().build();
    }
}
 
開發者ID:guggens,項目名稱:log-dropwizard-eureka-mongo-sample,代碼行數:44,代碼來源:ConfigureResource.java

示例9: configure

import com.yammer.tenacity.core.config.ThreadPoolConfiguration; //導入依賴的package包/類
@POST @Timed @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/{dependency}")
public Response configure(@Auth User user,
                          @PathParam("service") String serviceName,
                          @PathParam("dependency") String dependencyName,
                          @FormParam("executionTimeout") Integer executionTimeout,
                          @FormParam("requestVolumeThreshold") Integer requestVolumeThreshold,
                          @FormParam("errorThresholdPercentage") Integer errorThresholdPercentage,
                          @FormParam("sleepWindow") Integer sleepWindow,
                          @FormParam("circuitBreakerstatisticalWindow") Integer circuitBreakerstatisticalWindow,
                          @FormParam("circuitBreakerStatisticalWindowBuckets") Integer circuitBreakerStatisticalWindowBuckets,
                          @FormParam("threadPoolCoreSize") Integer threadPoolCoreSize,
                          @FormParam("keepAliveMinutes") Integer keepAliveMinutes,
                          @FormParam("maxQueueSize") Integer maxQueueSize,
                          @FormParam("queueSizeRejectionThreshold") Integer queueSizeRejectionThreshold,
                          @FormParam("threadpoolStatisticalWindow") Integer threadpoolStatisticalWindow,
                          @FormParam("threadpoolStatisticalWindowBuckets") Integer threadpoolStatisticalWindowBuckets,
                          @FormParam("semaphoreMaxConcurrentRequests") Integer semaphoreMaxConcurrentRequests,
                          @FormParam("semaphoreFallbackMaxConcurrentRequests") Integer semaphoreFallbackMaxConcurrentRequests,
                          @FormParam("executionIsolationStrategy") HystrixCommandProperties.ExecutionIsolationStrategy executionIsolationStrategy) {
    final TenacityConfiguration tenacityConfiguration = new TenacityConfiguration(
            new ThreadPoolConfiguration(
                    threadPoolCoreSize,
                    keepAliveMinutes,
                    maxQueueSize,
                    queueSizeRejectionThreshold,
                    threadpoolStatisticalWindow,
                    threadpoolStatisticalWindowBuckets),
            new CircuitBreakerConfiguration(
                    requestVolumeThreshold,
                    sleepWindow,
                    errorThresholdPercentage,
                    circuitBreakerstatisticalWindow,
                    circuitBreakerStatisticalWindowBuckets),
            new SemaphoreConfiguration(
                    semaphoreMaxConcurrentRequests,
                    semaphoreFallbackMaxConcurrentRequests),
            executionTimeout,
            executionIsolationStrategy);
    final ServiceId serviceId = ServiceId.from(serviceName);
    final DependencyId dependencyId = DependencyId.from(dependencyName);
    if (breakerboxStore.store(new ServiceModel(serviceId, dependencyId)) &&
        breakerboxStore.store(new DependencyModel(dependencyId, DateTime.now(), tenacityConfiguration, user.getName(), serviceId))) {
        return Response
                .created(URI.create(String.format("/configuration/%s/%s", serviceName, dependencyName)))
                .entity(tenacityConfiguration)
                .build();
    } else {
        return Response.serverError().build();
    }
}
 
開發者ID:yammer,項目名稱:breakerbox,代碼行數:52,代碼來源:ConfigureResource.java


注:本文中的com.yammer.tenacity.core.config.ThreadPoolConfiguration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。