• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Setter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ManagedHystrixCommandFactory

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


示例2: toSetters

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
/**
 * Process all methods in the target so that appropriate setters are created.
 */
static Map<Method, Setter> toSetters(SetterFactory setterFactory, Target<?> target,
                                     Set<Method> methods) {
  Map<Method, Setter> result = new LinkedHashMap<Method, Setter>();
  for (Method method : methods) {
    method.setAccessible(true);
    result.put(method, setterFactory.create(target, method));
  }
  return result;
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:13,代码来源:HystrixInvocationHandler.java


示例3: defaultSetter

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
private static Setter defaultSetter(AmazonS3 s3) {
  return Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("s3"))
      .andCommandKey(HystrixCommandKey.Factory.asKey(s3.getRegionName()))
      .andCommandPropertiesDefaults(
          HystrixCommandProperties.defaultSetter()
              .withCircuitBreakerRequestVolumeThreshold(5)
              .withExecutionTimeoutEnabled(false))
      .andThreadPoolPropertiesDefaults(
          HystrixThreadPoolProperties.defaultSetter()
              .withMaxQueueSize(5)
              .withQueueSizeRejectionThreshold(5));
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:13,代码来源:HystrixS3Decorator.java


示例4: getAsHystrixCommand

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
@Override
public HystrixCommand<String> getAsHystrixCommand() {
	Setter hystrixMetadata = HystrixCommand.Setter
			.withGroupKey(HystrixCommandGroupKey.Factory.asKey("FallbackUnknownApi"));

	return new HystrixCommand<String>(hystrixMetadata) {
		@Override
		protected String run() throws Exception {
			return "this is BadApi (command) fallback!";
		}
	};
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:13,代码来源:FallbackBadApi.java


示例5: create

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
public Setter create(String groupName, String commandName) {
  HystrixCommandProperties.Setter properties =
      HystrixCommandProperties.Setter().withExecutionTimeoutEnabled(false);

  return Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupName))
      .andCommandKey(HystrixCommandKey.Factory.asKey(commandName))
      .andCommandPropertiesDefaults(properties);
}
 
开发者ID:Qorr,项目名称:Hvalspik,代码行数:9,代码来源:CommandPropertiesFactory.java


示例6: HystrixS3Decorator

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
private HystrixS3Decorator(AmazonS3 delegate, Setter setter) {
  this.delegate = checkNotNull(delegate, "delegate");
  this.setter = checkNotNull(setter, "setter");
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:5,代码来源:HystrixS3Decorator.java


示例7: decorate

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
public static HystrixS3Decorator decorate(AmazonS3 s3, Setter setter) {
  return new HystrixS3Decorator(s3, setter);
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:4,代码来源:HystrixS3Decorator.java


示例8: S3Command

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
private S3Command(Setter setter, Supplier<T> callable) {
  super(setter);
  this.callable = callable;
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:5,代码来源:HystrixS3Decorator.java


示例9: HystrixCommandEndpointCallExecutableFactory

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
public HystrixCommandEndpointCallExecutableFactory(Setter hystrixMetadata) {
	super(hystrixMetadata);
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:4,代码来源:HystrixCommandEndpointCallExecutableFactory.java


示例10: initSetter

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
private Setter initSetter(HystrixCommandKey commandKey, Method method, FaultToleranceOperation operation) {
    HystrixCommandProperties.Setter propertiesSetter = HystrixCommandProperties.Setter();

    if (operation.isAsync()) {
        propertiesSetter.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD);
    } else {
        propertiesSetter.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE);
    }

    if (nonFallBackEnable && operation.hasTimeout()) {
        Long value = Duration.of(operation.getTimeout().get(TimeoutConfig.VALUE), operation.getTimeout().get(TimeoutConfig.UNIT)).toMillis();
        if (value > Integer.MAX_VALUE) {
            LOGGER.warnf("Max supported value for @Timeout.value() is %s", Integer.MAX_VALUE);
            value = Long.valueOf(Integer.MAX_VALUE);
        }
        propertiesSetter.withExecutionTimeoutInMilliseconds(value.intValue());
    } else {
        propertiesSetter.withExecutionTimeoutEnabled(false);
    }

    if (nonFallBackEnable && operation.hasCircuitBreaker()) {
        propertiesSetter.withCircuitBreakerEnabled(true)
                .withCircuitBreakerRequestVolumeThreshold(operation.getCircuitBreaker().get(CircuitBreakerConfig.REQUEST_VOLUME_THRESHOLD))
                .withCircuitBreakerErrorThresholdPercentage(
                        new Double((Double) operation.getCircuitBreaker().get(CircuitBreakerConfig.FAILURE_RATIO) * 100).intValue())
                .withCircuitBreakerSleepWindowInMilliseconds((int) Duration
                        .of(operation.getCircuitBreaker().get(CircuitBreakerConfig.DELAY), operation.getCircuitBreaker().get(CircuitBreakerConfig.DELAY_UNIT)).toMillis());
    } else {
        propertiesSetter.withCircuitBreakerEnabled(false);
    }

    Setter setter = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("DefaultCommandGroup"))
            // Each method must have a unique command key
            .andCommandKey(commandKey).andCommandPropertiesDefaults(propertiesSetter);

    if (nonFallBackEnable && operation.hasBulkhead()) {
        // TODO: these options need further review
        BulkheadConfig bulkhead = operation.getBulkhead();
        propertiesSetter.withExecutionIsolationSemaphoreMaxConcurrentRequests(bulkhead.get(BulkheadConfig.VALUE));
        propertiesSetter.withExecutionIsolationThreadInterruptOnFutureCancel(true);
        // Each bulkhead policy needs a dedicated thread pool
        setter.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(commandKey.name()));
        HystrixThreadPoolProperties.Setter threadPoolSetter = HystrixThreadPoolProperties.Setter();
        threadPoolSetter.withAllowMaximumSizeToDivergeFromCoreSize(true);
        threadPoolSetter.withCoreSize(bulkhead.get(BulkheadConfig.VALUE));
        threadPoolSetter.withMaximumSize(bulkhead.get(BulkheadConfig.VALUE));
        threadPoolSetter.withMaxQueueSize(bulkhead.get(BulkheadConfig.WAITING_TASK_QUEUE));
        threadPoolSetter.withQueueSizeRejectionThreshold(bulkhead.get(BulkheadConfig.WAITING_TASK_QUEUE));
        setter.andThreadPoolPropertiesDefaults(threadPoolSetter);
    }
    return setter;
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:53,代码来源:HystrixCommandInterceptor.java


示例11: MethodInfo

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
public MethodInfo(final Method method,
        final RestAdapterConfig restAdapterConfig) {

    // GET HTTP ANNOTATION
    http = Arrays
            .stream(method.getAnnotations())
            .filter(a -> Http.class.equals(a.annotationType()))
            .map(a -> (Http) a)
            .findFirst()
            .orElseThrow(
                    () -> new IllegalStateException(
                            "No Http annotation present."));

    cookiesAnnotation = Arrays.stream(method.getAnnotations())
            .filter(a -> Cookies.class.equals(a.annotationType()))
            .map(a -> (Cookies) a).findFirst();

    responseType = Arrays.stream(method.getAnnotations())
            .filter(a -> ResponseType.class.equals(a.annotationType()))
            .map(a -> (ResponseType) a).findFirst();

    // GET HYSTRIX ANNOTATION
    hystrix = Arrays
            .stream(method.getAnnotations())
            .filter(a -> HystrixGroup.class.equals(a.annotationType()))
            .map(a -> (HystrixGroup) a)
            .findFirst()
            .orElseThrow(
                    () -> new IllegalStateException(
                            "No Hystrix annotation present."));

    cacheKeyGroup = Arrays.stream(method.getAnnotations())
            .filter(a -> CacheKeyGroup.class.equals(a.annotationType()))
            .map(a -> a == null ? null : ((CacheKeyGroup) a).value())
            .findFirst().orElse(null);

    this.setter = Setter.withGroupKey(
            HystrixCommandGroupKey.Factory.asKey(hystrix.groupKey()))
            .andCommandKey(
                    HystrixCommandKey.Factory.asKey(hystrix.commandKey()));

    this.parameters = method.getParameters();

    this.headers = Arrays.stream(http.headers()).collect(
            Collectors.toMap(t -> t.name(), t -> t.value()));

    if (headers.containsKey("Cookie")) {
        cookies.add(this.headers.remove("Cookie"));
    }
    if (cookiesAnnotation.isPresent()) {
        cookies.addAll(Arrays.stream(cookiesAnnotation.get().cookies())
                .map(cookie -> cookie.name() + "=" + cookie.value())
                .collect(Collectors.toList()));
    }

    @SuppressWarnings("rawtypes")
    final Class returnType = method.getReturnType();
    @SuppressWarnings("rawtypes")
    final Class httpClass;
    if (responseType.isPresent()) {
        httpClass = responseType.get().responseClass();
    } else {
        httpClass = null;
    }

    this.isObservable = Observable.class.equals(returnType);
    if (this.isObservable) {
        this.responseClass = Optional.ofNullable(httpClass).orElseThrow(
                () -> new IllegalStateException(
                        "Http responseClass is required for observables"));
    } else {
        this.responseClass = Optional.ofNullable(httpClass).orElse(
                returnType);
    }

    this.restAdapterConfig = restAdapterConfig;

}
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:79,代码来源:MethodInfo.java


示例12: HystrixCommandFacade

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
private HystrixCommandFacade(CheckedCommand<T> command, Setter hystrixConfiguration) {
	this.command = command;
	this.hystrixConfiguration = hystrixConfiguration;
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:5,代码来源:HystrixCommandFacade.java


示例13: execute

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
public static <T> T execute(CheckedCommand<T> command, Setter settings) throws Throwable {
	return new HystrixCommandFacade<>(command, settings).execute();
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:4,代码来源:HystrixCommandFacade.java


示例14: getSetter

import com.netflix.hystrix.HystrixCommand.Setter; //导入依赖的package包/类
public Setter getSetter() {

        return setter;
    }
 
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:5,代码来源:MethodInfo.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClientConfig类代码示例发布时间:2022-05-22
下一篇:
Java DefaultUriTemplateHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap