本文整理匯總了Java中com.netflix.hystrix.HystrixCommandProperties.Setter方法的典型用法代碼示例。如果您正苦於以下問題:Java HystrixCommandProperties.Setter方法的具體用法?Java HystrixCommandProperties.Setter怎麽用?Java HystrixCommandProperties.Setter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.netflix.hystrix.HystrixCommandProperties
的用法示例。
在下文中一共展示了HystrixCommandProperties.Setter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetCommandPropertiesCacheKey
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Test
public void testGetCommandPropertiesCacheKey() {
assertNotNull(HystrixPropertiesStrategyExt.getInstance());
HystrixPropertiesStrategyExt hps = HystrixPropertiesStrategyExt.getInstance();
HystrixCommandKey commandKey = Mockito.mock(HystrixCommandKey.class);
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceName()).thenReturn("testqualify");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)
.withRequestLogEnabled(false)
.withFallbackIsolationSemaphoreMaxConcurrentRequests(
Configuration.INSTANCE.getFallbackMaxConcurrentRequests("groupname",
"testing",
invocation.getOperationMeta().getMicroserviceQualifiedName()));
String str1 = hps.getCommandPropertiesCacheKey(commandKey, setter);
Assert.assertNull(str1);
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:24,代碼來源:TestHystrixPropertiesStrategyExt.java
示例2: testConstructProvider
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Test
public void testConstructProvider() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)
.withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ProviderBizkeeperCommand("groupname", invocation,
HystrixObservableCommand.Setter
.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
.andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
.andCommandPropertiesDefaults(setter));
Observable<Response> response = bizkeeperCommand.construct();
Assert.assertNotNull(response);
}
示例3: testGetCacheKeyWithContextInitializedProvider
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Test
public void testGetCacheKeyWithContextInitializedProvider() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)
.withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ProviderBizkeeperCommand("groupname", invocation,
HystrixObservableCommand.Setter
.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
.andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
.andCommandPropertiesDefaults(setter));
HystrixRequestContext.initializeContext();
String cacheKey = bizkeeperCommand.getCacheKey();
Assert.assertNotNull(cacheKey);
}
示例4: testResumeWithFallbackConsumer
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Test
public void testResumeWithFallbackConsumer() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)
.withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation,
HystrixObservableCommand.Setter
.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
.andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
.andCommandPropertiesDefaults(setter));
Observable<Response> observe = bizkeeperCommand.resumeWithFallback();
Assert.assertNotNull(observe);
}
示例5: testConstructConsumer
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Test
public void testConstructConsumer() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)
.withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation,
HystrixObservableCommand.Setter
.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
.andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
.andCommandPropertiesDefaults(setter));
Observable<Response> response = bizkeeperCommand.construct();
Assert.assertNotNull(response);
}
示例6: testGetCacheKeyWithContextInitializedConsumer
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Test
public void testGetCacheKeyWithContextInitializedConsumer() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)
.withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation,
HystrixObservableCommand.Setter
.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
.andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
.andCommandPropertiesDefaults(setter));
HystrixRequestContext.initializeContext();
String cacheKey = bizkeeperCommand.getCacheKey();
Assert.assertNotNull(cacheKey);
}
示例7: setter
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
private static Setter setter() {
HystrixCommandGroupKey groupkey = HystrixCommandGroupKey.Factory.asKey("rpc");
HystrixCommandKey commandkey = HystrixCommandKey.Factory.asKey("say");
HystrixThreadPoolKey threadpoolkey = HystrixThreadPoolKey.Factory.asKey("hello-1");
HystrixThreadPoolProperties.Setter threadproperties = HystrixThreadPoolProperties.Setter()//
.withCoreSize(20).withKeepAliveTimeMinutes(5).withMaxQueueSize(1000).withQueueSizeRejectionThreshold(100);
HystrixCommandProperties.Setter commandproperty = HystrixCommandProperties.Setter()//
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD)//
.withFallbackEnabled(true).withFallbackIsolationSemaphoreMaxConcurrentRequests(100)//
.withExecutionIsolationThreadInterruptOnFutureCancel(true)//
.withExecutionIsolationThreadInterruptOnTimeout(true)//
.withExecutionTimeoutEnabled(true).withExecutionTimeoutInMilliseconds(1000);
return HystrixCommand.Setter.withGroupKey(groupkey).andCommandKey(commandkey)//
.andThreadPoolKey(threadpoolkey).andThreadPoolPropertiesDefaults(threadproperties)//
.andCommandPropertiesDefaults(commandproperty);
}
示例8: setter
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
private static Setter setter() {
HystrixCommandGroupKey groupkey = HystrixCommandGroupKey.Factory.asKey("rpc");
HystrixCommandKey commandkey = HystrixCommandKey.Factory.asKey("say");
HystrixThreadPoolKey threadpoolkey = HystrixThreadPoolKey.Factory.asKey("hello-1");
HystrixThreadPoolProperties.Setter threadproperties = HystrixThreadPoolProperties.Setter()//
.withCoreSize(20).withKeepAliveTimeMinutes(5).withMaxQueueSize(1000).withQueueSizeRejectionThreshold(100);
HystrixCommandProperties.Setter commandproperty = HystrixCommandProperties.Setter()//
.withCircuitBreakerEnabled(true).withCircuitBreakerForceClosed(false)//
.withCircuitBreakerForceOpen(false).withCircuitBreakerErrorThresholdPercentage(50)//
.withCircuitBreakerRequestVolumeThreshold(20)//
.withCircuitBreakerSleepWindowInMilliseconds(5000);
return HystrixCommand.Setter.withGroupKey(groupkey).andCommandKey(commandkey)//
.andThreadPoolKey(threadpoolkey).andThreadPoolPropertiesDefaults(threadproperties)//
.andCommandPropertiesDefaults(commandproperty);
}
示例9: getCommandSetter
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
/**
* ��·������ �ο� http://hot66hot.iteye.com/blog/2155036
*
* @param joinPoint
* @param cb
* @return
*/
private HystrixCommand.Setter getCommandSetter(ProceedingJoinPoint joinPoint,
com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand cb) {
String name = getHystrixGroupName(joinPoint, cb);
String groupKey = StringUtils.isEmpty(cb.groupKey()) ? name : cb.groupKey();
String commandKey = StringUtils.isEmpty(cb.commandKey()) ? name : cb.commandKey();
HystrixThreadPoolKey hystrixThreadPoolKey = StringUtils.isEmpty(cb.threadPoolKey()) ? null
: HystrixThreadPoolKey.Factory.asKey(cb.threadPoolKey());
HystrixCommandProperties.Setter commandPropertiesDefaults = getHystrixCommandPropertiesSetter(cb);
HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults = getHystrixThreadPoolPropertiesSetter(cb);
return HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)).andThreadPoolKey(hystrixThreadPoolKey)
.andCommandPropertiesDefaults(commandPropertiesDefaults)
.andThreadPoolPropertiesDefaults(threadPoolPropertiesDefaults);
}
示例10: ManagedHystrixCommandFactory
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
/**
* Creates a new ManagedHystrixCommandFactory
* @param setter the command setter
* @param key The command key
* @param commandPropertySetter the command property setter
* @param threadPoolPropertySetter the thread pool property setter
*/
public ManagedHystrixCommandFactory(final Setter setter, final String key, final HystrixCommandProperties.Setter commandPropertySetter, final HystrixThreadPoolProperties.Setter threadPoolPropertySetter) {
this.setter = setter;
this.key = key;
this.commandPropertySetter = commandPropertySetter;
this.threadPoolPropertySetter = threadPoolPropertySetter;
final HystrixCommand<Object> sampleCommand = new HystrixCommand<Object>(setter) {
@Override
protected Object run() throws Exception {
return null;
}
};
ObjectName tmp = null;
try {
tmp = JMXHelper.objectName(String.format(OBJECT_NAME_TEMPLATE, sampleCommand.getCommandGroup().name(), sampleCommand.getCommandKey().name(), sampleCommand.getThreadPoolKey().name()));
} catch (Exception ex) {
tmp = JMXHelper.objectName(String.format(OBJECT_NAME_TEMPLATE,
ObjectName.quote(sampleCommand.getCommandGroup().name()),
ObjectName.quote(sampleCommand.getCommandKey().name()),
ObjectName.quote(sampleCommand.getThreadPoolKey().name())
));
}
objectName = tmp;
}
示例11: shouldIncrementCounterHistogramForExecuteButNotLatencyOnCancelledCommand
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Test
public void shouldIncrementCounterHistogramForExecuteButNotLatencyOnCancelledCommand() {
// given
HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.defaultSetter();
TestHystrixCommand command = new TestHystrixCommand("cancelledCommand",
commandProperties).willWait(10);
command.queue().cancel(true);
// then
assertThat(CollectorRegistry.defaultRegistry.getSampleValue(
"exampleapp_hystrix_command_latency_execute_seconds_count",
new String[]{"command_group", "command_name"},
new String[]{"group_cancelledCommand", "command_cancelledCommand"}
))
.describedAs("counter of all executions in the histogram")
.isEqualTo(1);
assertThat(CollectorRegistry.defaultRegistry.getSampleValue(
"exampleapp_hystrix_command_latency_total_seconds_count",
new String[]{"command_group", "command_name"},
new String[]{"group_cancelledCommand", "command_cancelledCommand"}
))
.describedAs("counter of all executions in the histogram")
.isEqualTo(0);
}
示例12: getSetter
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
protected static Setter getSetter(final String commandKey,
ZuulProperties zuulProperties, IClientConfig config) {
// @formatter:off
Setter commandSetter = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RibbonCommand"))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
final HystrixCommandProperties.Setter setter = createSetter(config, commandKey, zuulProperties);
if (zuulProperties.getRibbonIsolationStrategy() == ExecutionIsolationStrategy.SEMAPHORE){
final String name = ZuulConstants.ZUUL_EUREKA + commandKey + ".semaphore.maxSemaphores";
// we want to default to semaphore-isolation since this wraps
// 2 others commands that are already thread isolated
final DynamicIntProperty value = DynamicPropertyFactory.getInstance()
.getIntProperty(name, zuulProperties.getSemaphore().getMaxSemaphores());
setter.withExecutionIsolationSemaphoreMaxConcurrentRequests(value.get());
} else if (zuulProperties.getThreadPool().isUseSeparateThreadPools()) {
final String threadPoolKey = zuulProperties.getThreadPool().getThreadPoolKeyPrefix() + commandKey;
commandSetter.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(threadPoolKey));
}
return commandSetter.andCommandPropertiesDefaults(setter);
// @formatter:on
}
示例13: getSetter
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
public Setter getSetter() {
Setter setterToUse;
if (this.setter != null) {
setterToUse = this.setter;
} else {
String groupNameToUse;
if (StringUtils.hasText(this.groupName)) {
groupNameToUse = this.groupName;
} else {
groupNameToUse = commandName + "group";
}
HystrixCommandGroupKey groupKey = HystrixCommandGroupKey.Factory.asKey(groupNameToUse);
HystrixCommandKey commandKey = HystrixCommandKey.Factory.asKey(this.commandName);
HystrixCommandProperties.Setter commandProperties = this.commandProperties != null
? this.commandProperties
: HystrixCommandProperties.Setter();
setterToUse = Setter.withGroupKey(groupKey).andCommandKey(commandKey)
.andCommandPropertiesDefaults(commandProperties);
}
return setterToUse;
}
示例14: createBizkeeperCommand
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Override
protected BizkeeperCommand createBizkeeperCommand(Invocation invocation) {
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(false)
.withRequestLogEnabled(false);
setCommonProperties(invocation, setter);
BizkeeperCommand command = new ProviderBizkeeperCommand(groupname, invocation,
HystrixObservableCommand.Setter
.withGroupKey(CommandKey.toHystrixCommandGroupKey(groupname, invocation))
.andCommandKey(CommandKey.toHystrixCommandKey(groupname, invocation))
.andCommandPropertiesDefaults(setter));
return command;
}
示例15: createBizkeeperCommand
import com.netflix.hystrix.HystrixCommandProperties; //導入方法依賴的package包/類
@Override
protected BizkeeperCommand createBizkeeperCommand(Invocation invocation) {
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)
.withRequestLogEnabled(false);
setCommonProperties(invocation, setter);
BizkeeperCommand command = new ConsumerBizkeeperCommand(groupname, invocation,
HystrixObservableCommand.Setter
.withGroupKey(CommandKey.toHystrixCommandGroupKey(groupname, invocation))
.andCommandKey(CommandKey.toHystrixCommandKey(groupname, invocation))
.andCommandPropertiesDefaults(setter));
return command;
}