当前位置: 首页>>代码示例>>Java>>正文


Java HystrixObservableCommand类代码示例

本文整理汇总了Java中com.netflix.hystrix.HystrixObservableCommand的典型用法代码示例。如果您正苦于以下问题:Java HystrixObservableCommand类的具体用法?Java HystrixObservableCommand怎么用?Java HystrixObservableCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HystrixObservableCommand类属于com.netflix.hystrix包,在下文中一共展示了HystrixObservableCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConstructProvider

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的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

示例2: testGetCacheKeyWithContextInitializedProvider

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的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

示例3: testResumeWithFallbackConsumer

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的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

示例4: testConstructConsumer

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的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

示例5: testGetCacheKeyWithContextInitializedConsumer

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的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

示例6: HttpResourceObservableCommand

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
public HttpResourceObservableCommand(HttpClient<ByteBuf, ByteBuf> httpClient,
                                     HttpClientRequest<ByteBuf> httpRequest, String hystrixCacheKey,
                                     Map<String, Object> requestProperties,
                                     FallbackHandler<T> fallbackHandler,
                                     ResponseValidator<HttpClientResponse<ByteBuf>> validator,
                                     Class<? extends T> classType,
                                     HystrixObservableCommand.Setter setter) {
    super(setter);
    this.httpClient = httpClient;
    this.fallbackHandler = fallbackHandler;
    this.validator = validator;
    this.httpRequest = httpRequest;
    this.hystrixCacheKey = hystrixCacheKey;
    this.classType = classType;
    this.requestProperties = requestProperties;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:HttpResourceObservableCommand.java

示例7: createBizkeeperCommand

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的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

示例8: createBizkeeperCommand

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的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

示例9: createBizkeeperCommand

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
@Override
protected BizkeeperCommand createBizkeeperCommand(Invocation invocation) {
  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));
  return bizkeeperCommand;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:14,代码来源:TestBizkeeperHandler.java

示例10: testGetCacheKeyProvider

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
@Test
public void testGetCacheKeyProvider() {

  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));

  String str = bizkeeperCommand.getCacheKey();
  Assert.assertNull(str);

  Response resp = Mockito.mock(Response.class);
  Mockito.when(resp.isFailed()).thenReturn(false);
  Assert.assertEquals(false, bizkeeperCommand.isFailedResponse(resp));
  Mockito.when(resp.isFailed()).thenReturn(true);
  InvocationException excp = Mockito.mock(InvocationException.class);
  Mockito.when(resp.getResult()).thenReturn(excp);
  Mockito.when(excp.getStatusCode()).thenReturn(400);
  Assert.assertEquals(false, bizkeeperCommand.isFailedResponse(resp));
  Mockito.when(resp.getResult()).thenReturn(excp);
  Mockito.when(excp.getStatusCode()).thenReturn(590);
  Assert.assertEquals(true, bizkeeperCommand.isFailedResponse(resp));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:33,代码来源:TestBizkeeperCommand.java

示例11: testResumeWithFallbackProvider

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
@Test
public void testResumeWithFallbackProvider() {

  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> observe = bizkeeperCommand.resumeWithFallback();
  Assert.assertNotNull(observe);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:TestBizkeeperCommand.java

示例12: testGetCacheKeyConsumer

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
@Test
public void testGetCacheKeyConsumer() {

  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));

  String str = bizkeeperCommand.getCacheKey();
  Assert.assertNull(str);

  Response resp = Mockito.mock(Response.class);
  Mockito.when(resp.isFailed()).thenReturn(false);
  Assert.assertEquals(false, bizkeeperCommand.isFailedResponse(resp));
  Mockito.when(resp.isFailed()).thenReturn(true);
  InvocationException excp = Mockito.mock(InvocationException.class);
  Mockito.when(resp.getResult()).thenReturn(excp);
  Mockito.when(excp.getStatusCode()).thenReturn(400);
  Assert.assertEquals(false, bizkeeperCommand.isFailedResponse(resp));
  Mockito.when(resp.getResult()).thenReturn(excp);
  Mockito.when(excp.getStatusCode()).thenReturn(490);
  Assert.assertEquals(true, bizkeeperCommand.isFailedResponse(resp));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:33,代码来源:TestBizkeeperCommand.java

示例13: build

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
protected ExchangeCommand build(ClientRequest<?> request){

        HystrixObservableCommand.Setter setter =  HystrixObservableCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKeyName))
                .andCommandKey(HystrixCommandKey.Factory.asKey(commandName))
                .andCommandPropertiesDefaults(commandProperties
                        .withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)
                        .withFallbackEnabled(false));

        return new ExchangeCommand(hystrixWebClient.getDelegate(),request,setter);
    }
 
开发者ID:noorulhaq,项目名称:reactive.loanbroker.system,代码行数:11,代码来源:ExchangeCommandBuilder.java

示例14: getObservableFunction

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
public Function<HystrixObservableCommand<T>, Observable<T>> getObservableFunction() {
	Function<HystrixObservableCommand<T>, Observable<T>> observableFunc;

	if (this.toObservable != null) {
		observableFunc = this.toObservable;
	} else if (this.eager) {
		observableFunc = cmd -> cmd.observe();
	} else { // apply a default onBackpressureBuffer if not eager
		observableFunc = cmd -> cmd.toObservable().onBackpressureBuffer();
	}
	return observableFunc;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:HystrixCommands.java

示例15: observe

import com.netflix.hystrix.HystrixObservableCommand; //导入依赖的package包/类
public void observe() throws Exception {
    final String name = "Pinpoint";
    final String expectedMessage = HystrixTestHelper.sayHello(name);
    HystrixObservableCommand<String> helloObservableCommand = SayHelloObservableCommand.create(commandGroup, name);
    String actualMessage = helloObservableCommand.observe()
            .toBlocking()
            .single();
    Assert.assertEquals(expectedMessage, actualMessage);

    HystrixTestHelper.waitForSpanDataFlush();
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:12,代码来源:HystrixObservableCommandTestRunner.java


注:本文中的com.netflix.hystrix.HystrixObservableCommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。