本文整理汇总了Java中com.yammer.tenacity.core.properties.TenacityPropertyKey类的典型用法代码示例。如果您正苦于以下问题:Java TenacityPropertyKey类的具体用法?Java TenacityPropertyKey怎么用?Java TenacityPropertyKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TenacityPropertyKey类属于com.yammer.tenacity.core.properties包,在下文中一共展示了TenacityPropertyKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: with
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
public ArchaiusFormatBuilder with(TenacityPropertyKey key,
TenacityConfiguration configuration) {
executionIsolationThreadTimeoutInMilliseconds(key, configuration);
threadpoolCoreSize(key, configuration);
threadpoolMaxQueueSize(key, configuration);
threadpoolKeepAliveTimeMinutes(key, configuration);
threadpoolQueueSizeRejectionThreshold(key, configuration);
threadpoolMetricsRollingStatsNumBuckets(key, configuration);
threadpoolMetricsRollingStatsTimeInMilliseconds(key, configuration);
circuitBreakerRequestVolumeThreshold(key, configuration);
circuitBreakerErrorThresholdPercentage(key, configuration);
circuitBreakerSleepWindowInMilliseconds(key, configuration);
circuitBreakermetricsRollingStatsNumBuckets(key, configuration);
circuitBreakermetricsRollingStatsTimeInMilliseconds(key, configuration);
return this;
}
示例2: differentBreakerboxConfiguration
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void differentBreakerboxConfiguration() {
final SyncComparator syncComparator = new SyncComparator(mockFactory, mockTenacityStory);
final TenacityConfiguration differentConfiguration = new TenacityConfiguration();
differentConfiguration.setExecutionIsolationThreadTimeoutInMillis(9);
when(mockTenacityStory.retrieve(serviceId, dependencyId))
.thenReturn(Optional.of(new ServiceModel(serviceId, dependencyId)));
when(mockTenacityStory.retrieveLatest(dependencyId, serviceId))
.thenReturn(Optional.of(new DependencyModel(dependencyId, new DateTime(testTimestamp), differentConfiguration, "fooUser", serviceId)));
when(mockFactory.create(any(URI.class), any(TenacityPropertyKey.class))).thenReturn(mockFetcher);
when(mockFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(new TenacityConfiguration())));
assertThat(syncComparator.inSync(serviceId, dependencyId))
.isEqualTo(unsynchronized());
}
示例3: oneIsDifferent
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void oneIsDifferent() {
final SyncComparator syncComparator = new SyncComparator(mockFactory, mockTenacityStory);
final TenacityConfigurationFetcher differentFetcher = mock(TenacityConfigurationFetcher.class);
final TenacityConfiguration differentConfiguration = new TenacityConfiguration();
differentConfiguration.setExecutionIsolationThreadTimeoutInMillis(9);
final URI differentURI = URI.create("http://deploy-001.sjc1.yammer.com:9090");
when(mockTenacityStory.retrieve(serviceId, dependencyId))
.thenReturn(Optional.of(new ServiceModel(serviceId, dependencyId)));
when(mockTenacityStory.retrieveLatest(dependencyId, serviceId))
.thenReturn(Optional.of(new DependencyModel(dependencyId, new DateTime(testTimestamp), DependencyEntity.defaultConfiguration(), "fooUser", serviceId)));
when(mockFactory.create(any(URI.class), any(TenacityPropertyKey.class))).thenReturn(mockFetcher);
when(mockFactory.create(eq(differentURI), any(TenacityPropertyKey.class)))
.thenReturn(differentFetcher);
when(mockFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(new TenacityConfiguration())));
when(differentFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(differentConfiguration)));
assertThat(syncComparator.inSync(serviceId, dependencyId))
.isEqualTo(allSynchronizedExcept(differentURI));
}
示例4: oneFailedFetching
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void oneFailedFetching() {
final SyncComparator syncComparator = new SyncComparator(mockFactory, mockTenacityStory);
final TenacityConfigurationFetcher differentFetcher = mock(TenacityConfigurationFetcher.class);
final TenacityConfiguration differentConfiguration = new TenacityConfiguration();
differentConfiguration.setExecutionIsolationThreadTimeoutInMillis(9);
final URI differentURI = URI.create("http://deploy-001.sjc1.yammer.com:9090");
when(mockTenacityStory.retrieve(serviceId, dependencyId))
.thenReturn(Optional.of(new ServiceModel(serviceId, dependencyId)));
when(mockTenacityStory.retrieveLatest(dependencyId, serviceId))
.thenReturn(Optional.of(new DependencyModel(dependencyId, new DateTime(testTimestamp), DependencyEntity.defaultConfiguration(), "fooUser", serviceId)));
when(mockFactory.create(any(URI.class), any(TenacityPropertyKey.class))).thenReturn(mockFetcher);
when(mockFactory.create(eq(differentURI), any(TenacityPropertyKey.class)))
.thenReturn(differentFetcher);
when(mockFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(new TenacityConfiguration())));
when(differentFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.<TenacityConfiguration>absent()));
assertThat(syncComparator.inSync(serviceId, dependencyId))
.isEqualTo(allSynchronizedExceptUnknown(differentURI));
}
示例5: with
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
public ArchaiusFormatBuilder with(TenacityPropertyKey key,
TenacityConfiguration configuration) {
executionIsolationThreadTimeoutInMilliseconds(key, configuration);
threadpoolCoreSize(key, configuration);
threadpoolMaxQueueSize(key, configuration);
threadpoolKeepAliveTimeMinutes(key, configuration);
threadpoolQueueSizeRejectionThreshold(key, configuration);
threadpoolMetricsRollingStatsNumBuckets(key, configuration);
threadpoolMetricsRollingStatsTimeInMilliseconds(key, configuration);
circuitBreakerRequestVolumeThreshold(key, configuration);
circuitBreakerErrorThresholdPercentage(key, configuration);
circuitBreakerSleepWindowInMilliseconds(key, configuration);
circuitBreakermetricsRollingStatsNumBuckets(key, configuration);
circuitBreakermetricsRollingStatsTimeInMilliseconds(key, configuration);
semaphoreMaxConcurrentRequests(key, configuration);
semaphoreFallbackMaxConcurrentRequests(key, configuration);
if (configuration.hasExecutionIsolationStrategy()) {
executionIsolationStrategy(key, configuration);
}
return this;
}
示例6: differentBreakerboxConfiguration
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void differentBreakerboxConfiguration() {
final SyncComparator syncComparator = new SyncComparator(mockFactory, mockTenacityStory);
final TenacityConfiguration differentConfiguration = new TenacityConfiguration();
differentConfiguration.setExecutionIsolationThreadTimeoutInMillis(9);
when(mockTenacityStory.retrieve(serviceId, dependencyId))
.thenReturn(Optional.of(new ServiceModel(serviceId, dependencyId)));
when(mockTenacityStory.retrieveLatest(dependencyId, serviceId))
.thenReturn(Optional.of(new DependencyModel(dependencyId, new DateTime(testTimestamp), differentConfiguration, "fooUser", serviceId)));
when(mockFactory.create(any(Instance.class), any(TenacityPropertyKey.class))).thenReturn(mockFetcher);
when(mockFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(new TenacityConfiguration())));
assertThat(syncComparator.inSync(serviceId, dependencyId))
.isEqualTo(unsynchronized());
}
示例7: oneIsDifferent
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void oneIsDifferent() {
final SyncComparator syncComparator = new SyncComparator(mockFactory, mockTenacityStory);
final TenacityConfigurationFetcher differentFetcher = mock(TenacityConfigurationFetcher.class);
final TenacityConfiguration differentConfiguration = new TenacityConfiguration();
differentConfiguration.setExecutionIsolationThreadTimeoutInMillis(9);
final Instance differentInstance = new Instance("http://deploy-001.sjc1.yammer.com:9090", "ignored", true);
when(mockTenacityStory.retrieve(serviceId, dependencyId))
.thenReturn(Optional.of(new ServiceModel(serviceId, dependencyId)));
when(mockTenacityStory.retrieveLatest(dependencyId, serviceId))
.thenReturn(Optional.of(new DependencyModel(dependencyId, new DateTime(testTimestamp), DependencyEntity.defaultConfiguration(), "fooUser", serviceId)));
when(mockFactory.create(any(Instance.class), any(TenacityPropertyKey.class))).thenReturn(mockFetcher);
when(mockFactory.create(eq(differentInstance), any(TenacityPropertyKey.class)))
.thenReturn(differentFetcher);
when(mockFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(new TenacityConfiguration())));
when(differentFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(differentConfiguration)));
assertThat(syncComparator.inSync(serviceId, dependencyId))
.isEqualTo(allSynchronizedExcept(differentInstance));
}
示例8: oneFailedFetching
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void oneFailedFetching() {
final SyncComparator syncComparator = new SyncComparator(mockFactory, mockTenacityStory);
final TenacityConfigurationFetcher differentFetcher = mock(TenacityConfigurationFetcher.class);
final TenacityConfiguration differentConfiguration = new TenacityConfiguration();
differentConfiguration.setExecutionIsolationThreadTimeoutInMillis(9);
final Instance differentInstance = new Instance("http://deploy-001.sjc1.yammer.com:9090", "ignored", true);
when(mockTenacityStory.retrieve(serviceId, dependencyId))
.thenReturn(Optional.of(new ServiceModel(serviceId, dependencyId)));
when(mockTenacityStory.retrieveLatest(dependencyId, serviceId))
.thenReturn(Optional.of(new DependencyModel(dependencyId, new DateTime(testTimestamp), DependencyEntity.defaultConfiguration(), "fooUser", serviceId)));
when(mockFactory.create(any(Instance.class), any(TenacityPropertyKey.class))).thenReturn(mockFetcher);
when(mockFactory.create(eq(differentInstance), any(TenacityPropertyKey.class)))
.thenReturn(differentFetcher);
when(mockFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.of(new TenacityConfiguration())));
when(differentFetcher.queue()).thenReturn(Futures.immediateFuture(Optional.empty()));
assertThat(syncComparator.inSync(serviceId, dependencyId))
.isEqualTo(allSynchronizedExceptUnknown(differentInstance));
}
示例9: modifyCircuitBreaker
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@SuppressWarnings("unused")
public Optional<CircuitBreaker> modifyCircuitBreaker(URI root,
TenacityPropertyKey key,
CircuitBreaker.State state) {
try (Timer.Context timerContext = fetchCircuitBreakers.time()) {
return Optional.of(client
.target(root)
.path(TenacityCircuitBreakersResource.PATH)
.path(key.name())
.request(MediaType.APPLICATION_JSON_TYPE)
.put(Entity.text(state.toString()), CircuitBreaker.class));
} catch (Exception err) {
LOGGER.warn("Unable to retrieve tenacity configuration for {} and key {}", root, err);
}
return Optional.empty();
}
示例10: run
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Override
public void run(T configuration, Environment environment) throws Exception {
Map<TenacityPropertyKey, TenacityConfiguration> tenacityPropertyKeyConfigurations =
tenacityBundleConfigurationFactory.getTenacityConfigurations(configuration);
configureHystrix(configuration, environment);
addExceptionMappers(environment);
addHealthChecks(tenacityPropertyKeyConfigurations.keySet(), environment);
addTenacityResources(
environment,
tenacityBundleConfigurationFactory.getTenacityPropertyKeyFactory(configuration),
tenacityPropertyKeyConfigurations.keySet()
);
registerTenacityProperties(tenacityPropertyKeyConfigurations, configuration);
}
示例11: usingHystrix
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
public static Optional<CircuitBreaker> usingHystrix(TenacityPropertyKey id) {
final HystrixCircuitBreaker circuitBreaker = TenacityCommand.getCircuitBreaker(id);
if (circuitBreaker == null) {
return Optional.empty();
}
final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(id);
if (commandProperties.circuitBreakerForceOpen().get()) {
return Optional.of(CircuitBreaker.forcedOpen(id));
} else if (commandProperties.circuitBreakerForceClosed().get()) {
return Optional.of(CircuitBreaker.forcedClosed(id));
} else if (circuitBreaker.allowRequest()) {
return Optional.of(CircuitBreaker.closed(id));
} else {
return Optional.of(CircuitBreaker.open(id));
}
}
示例12: executionIsolationStrategyCanBeChangedAtAnyTime
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void executionIsolationStrategyCanBeChangedAtAnyTime() {
final RandomTenacityKey randomTenacityKey = new RandomTenacityKey(UUID.randomUUID().toString());
assertThat(TenacityObservableCommand.getCommandProperties(randomTenacityKey).executionIsolationStrategy().get())
.isEqualTo(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD);
new TenacityPropertyRegister(ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(
randomTenacityKey, new TenacityConfiguration()), new BreakerboxConfiguration()).register();
assertThat(TenacityObservableCommand.getCommandProperties(randomTenacityKey).executionIsolationStrategy().get())
.isEqualTo(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD);
final TenacityConfiguration semaphoreConfiguration = new TenacityConfiguration();
semaphoreConfiguration.setExecutionIsolationThreadTimeoutInMillis(912);
semaphoreConfiguration.setExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE);
new TenacityPropertyRegister(ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(
randomTenacityKey, semaphoreConfiguration), new BreakerboxConfiguration()).register();
assertThat(TenacityObservableCommand.getCommandProperties(randomTenacityKey).executionTimeoutInMilliseconds().get())
.isEqualTo(semaphoreConfiguration.getExecutionIsolationThreadTimeoutInMillis());
assertThat(TenacityObservableCommand.getCommandProperties(randomTenacityKey).executionIsolationStrategy().get())
.isEqualTo(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE);
}
示例13: registerTenacityConfigurationFirst
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void registerTenacityConfigurationFirst() {
new TenacityPropertyRegister(ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(
DependencyKey.EXAMPLE, new TenacityConfiguration()), breakerboxConfiguration).register();
assertThat(ConfigurationManager.getConfigInstance()).isInstanceOf(AggregatedConfiguration.class);
assertThat(DynamicPropertyFactory.getInstance()
.getLongProperty(TenacityPropertyRegister.executionIsolationThreadTimeoutInMilliseconds(DependencyKey.EXAMPLE),
0).get())
.isEqualTo(1000);
final ConcurrentCompositeConfiguration overrideConfig = new ConcurrentCompositeConfiguration();
overrideConfig.setProperty(TenacityPropertyRegister.executionIsolationThreadTimeoutInMilliseconds(DependencyKey.EXAMPLE), 2000);
ConfigurationManager.loadPropertiesFromConfiguration(overrideConfig);
assertThat(DynamicPropertyFactory.getInstance()
.getLongProperty(TenacityPropertyRegister.executionIsolationThreadTimeoutInMilliseconds(DependencyKey.EXAMPLE),
1000).get())
.isEqualTo(2000);
assertThat(DynamicPropertyFactory.getInstance()
.getLongProperty(TenacityPropertyRegister.threadpoolCoreSize(DependencyKey.EXAMPLE),
1000).get())
.isEqualTo(10);
}
示例14: registerTwoSources
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
@Test
public void registerTwoSources() throws Exception {
new TenacityPropertyRegister(ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(
DependencyKey.EXAMPLE, new TenacityConfiguration()), breakerboxConfiguration).register();
assertThat(ConfigurationManager.getConfigInstance()).isInstanceOf(AggregatedConfiguration.class);
final AbstractPollingScheduler mockPollingSchedulerOne = mock(AbstractPollingScheduler.class);
final DynamicConfiguration dynConfig = new DynamicConfiguration(
new URLConfigurationSource("http://localhost"),
mockPollingSchedulerOne);
ConfigurationManager.loadPropertiesFromConfiguration(dynConfig);
final AbstractPollingScheduler mockPollingSchedulerTwo = mock(AbstractPollingScheduler.class);
final DynamicConfiguration dynConfig2 = new DynamicConfiguration(
new URLConfigurationSource("http://localhost2"),
mockPollingSchedulerTwo);
ConfigurationManager.loadPropertiesFromConfiguration(dynConfig2);
verify(mockPollingSchedulerOne, atLeastOnce()).startPolling(any(PolledConfigurationSource.class), any(Configuration.class));
verify(mockPollingSchedulerTwo, atLeastOnce()).startPolling(any(PolledConfigurationSource.class), any(Configuration.class));
}
示例15: setUpTenacityCommand
import com.yammer.tenacity.core.properties.TenacityPropertyKey; //导入依赖的package包/类
private void setUpTenacityCommand(int poolSize, int timeout) {
final ThreadPoolConfiguration poolConfig = new ThreadPoolConfiguration();
poolConfig.setThreadPoolCoreSize(poolSize);
final SemaphoreConfiguration semaphoreConfiguration = new SemaphoreConfiguration();
semaphoreConfiguration.setMaxConcurrentRequests(poolSize);
final CircuitBreakerConfiguration circuitConfig = new CircuitBreakerConfiguration();
circuitConfig.setErrorThresholdPercentage(1);
circuitConfig.setRequestVolumeThreshold(1);
new TenacityPropertyRegister(
ImmutableMap.<TenacityPropertyKey, TenacityConfiguration>of(
DependencyKey.EXAMPLE, new TenacityConfiguration(
poolConfig, circuitConfig, semaphoreConfiguration, timeout
)
),
new BreakerboxConfiguration()
).register();
}