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


Java HystrixCommandProperties.Setter方法代碼示例

本文整理匯總了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);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:21,代碼來源:TestBizkeeperCommand.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:22,代碼來源:TestBizkeeperCommand.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:21,代碼來源:TestBizkeeperCommand.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:21,代碼來源:TestBizkeeperCommand.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:22,代碼來源:TestBizkeeperCommand.java

示例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);
}
 
開發者ID:lemonJun,項目名稱:TakinRPC,代碼行數:18,代碼來源:HelloDegrade.java

示例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);
}
 
開發者ID:lemonJun,項目名稱:TakinRPC,代碼行數:17,代碼來源:HelloBreaker.java

示例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);
}
 
開發者ID:xiaomin0322,項目名稱:spring-integration-hystrix,代碼行數:25,代碼來源:HystrixCommandAspect.java

示例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;
}
 
開發者ID:nickman,項目名稱:HeliosStreams,代碼行數:31,代碼來源:ManagedHystrixCommandFactory.java

示例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);
}
 
開發者ID:ahus1,項目名稱:prometheus-hystrix,代碼行數:27,代碼來源:HystrixCommandTest.java

示例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
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-netflix,代碼行數:23,代碼來源:AbstractRibbonCommand.java

示例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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-netflix,代碼行數:23,代碼來源:HystrixCommands.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:15,代碼來源:ProviderBizkeeperHanlder.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:15,代碼來源:ConsumerBizkeeperHandler.java


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