本文整理汇总了Java中com.yammer.tenacity.core.config.CircuitBreakerConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java CircuitBreakerConfiguration类的具体用法?Java CircuitBreakerConfiguration怎么用?Java CircuitBreakerConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CircuitBreakerConfiguration类属于com.yammer.tenacity.core.config包,在下文中一共展示了CircuitBreakerConfiguration类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCanReplace
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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));
}
示例2: testCanReplace
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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));
}
示例3: setup
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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());
}
示例4: getTenacityConfiguration
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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());
}
示例5: testSerializationAndDeserializationOfConfig
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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);
}
示例6: setup
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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());
}
示例7: testSerializationAndDeserializationOfConfig
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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);
}
示例8: configure
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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();
}
}
示例9: configure
import com.yammer.tenacity.core.config.CircuitBreakerConfiguration; //导入依赖的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();
}
}