HystrixCommandKey commandKey = HystrixCommandKey.Factory.asKey(config.name); config.setter = Setter.withGroupKey(groupKey) .andCommandKey(commandKey);
public void testSynchronousExecutionTimeoutValueViaExecute() { HystrixObservableCommand.Setter properties = HystrixObservableCommand.Setter .withGroupKey(HystrixCommandGroupKey.Factory.asKey("TestKey")) .andCommandPropertiesDefaults(HystrixCommandProperties.Setter() .withExecutionIsolationStrategy(ExecutionIsolationStrategy.THREAD) .withExecutionTimeoutInMilliseconds(50));
cacheSetter = HystrixObservableCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(cacheName)) .andCommandKey(HystrixCommandKey.Factory.asKey(cacheName)); HystrixCommandProperties.Setter cacheCommandProps = HystrixCommandProperties.Setter(); cacheCommandProps.withExecutionIsolationThreadTimeoutInMilliseconds(DEFAULT_CACHE_TIMEOUT); cacheSetter.andCommandPropertiesDefaults(cacheCommandProps); if (setter != null) { this.setter = setter; } else { this.setter = HystrixObservableCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(client.name())) .andCommandKey(HystrixCommandKey.Factory.asKey(name())); HystrixCommandProperties.Setter commandProps = HystrixCommandProperties.Setter(); if (maxResponseTime > 0) { commandProps.withExecutionIsolationSemaphoreMaxConcurrentRequests(concurrentRequestLimit); this.setter.andCommandPropertiesDefaults(commandProps);
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; }
@Override public HystrixObservableCommand.Setter createObservableSetter(FilterInvoker invoker, SofaRequest request) { Method clientMethod = request.getMethod(); if (!OBSERVABLE_SETTER_CACHE.containsKey(clientMethod)) { synchronized (DefaultSetterFactory.class) { if (!OBSERVABLE_SETTER_CACHE.containsKey(clientMethod)) { String groupKey = invoker.getConfig().getInterfaceId(); String commandKey = request.getMethodName(); HystrixObservableCommand.Setter setter = HystrixObservableCommand.Setter .withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey)) .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)); OBSERVABLE_SETTER_CACHE.put(clientMethod, setter); } } } return OBSERVABLE_SETTER_CACHE.get(clientMethod); } }
/** * Setter factory method containing required values. * <p> * All optional arguments can be set via the chained methods. * * @param groupKey * {@link HystrixCommandGroupKey} used to group together multiple {@link HystrixObservableCommand} objects. * <p> * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interace * with, * common business purpose etc. */ protected Setter(HystrixCommandGroupKey groupKey) { this.groupKey = groupKey; // default to using SEMAPHORE for ObservableCommand commandPropertiesDefaults = setDefaults(HystrixCommandProperties.Setter()); }
/** * @param request the request to execute * @param observable the observable that emits the response for this request (created with one of the * CaravanHttpClient implementations) * @param fallback the fallback response to emit if the original request fails */ public HttpHystrixCommand(CaravanHttpRequest request, Observable<CaravanHttpResponse> observable, Observable<CaravanHttpResponse> fallback) { super(Setter .withGroupKey(HystrixCommandGroupKey.Factory.asKey(GROUP_KEY)) .andCommandKey(HystrixCommandKey.Factory.asKey(StringUtils.defaultString(request.getServiceId(), "UNKNOWN"))) .andCommandPropertiesDefaults(HystrixCommandProperties.Setter() .withExecutionIsolationStrategy(getIsolationStrategy(request)) .withExecutionIsolationSemaphoreMaxConcurrentRequests(10000))); this.request = request; this.observable = observable; this.fallback = fallback; }
/** * Setter factory method with required values. * <p> * All optional arguments can be set via the chained methods. * * @param groupKey * {@link HystrixCommandGroupKey} used to group together multiple {@link HystrixObservableCommand} objects. * <p> * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interace * with, * common business purpose etc. */ public static Setter withGroupKey(HystrixCommandGroupKey groupKey) { return new Setter(groupKey); }
/** * Construct a {@link HystrixObservableCommand} with defined {@link HystrixCommandGroupKey}. * <p> * The {@link HystrixCommandKey} will be derived from the implementing class name. * * @param group * {@link HystrixCommandGroupKey} used to group together multiple {@link HystrixObservableCommand} objects. * <p> * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interace with, * common business purpose etc. */ protected HystrixObservableCommand(HystrixCommandGroupKey group) { // use 'null' to specify use the default this(new Setter(group)); }
public ObservableCommandHelloFailure(String name) { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"))); this.name = name; }
@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; } }
@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; } }
@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; } }
@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; } }
protected TenacityObservableCommand(TenacityPropertyKey tenacityPropertyKey) { super(HystrixObservableCommand.Setter.withGroupKey(TenacityCommand.tenacityGroupKey()) .andCommandKey(tenacityPropertyKey)); }
/** * Optional * * @param commandPropertiesDefaults * {@link HystrixCommandProperties.Setter} with property overrides for this specific instance of {@link HystrixObservableCommand}. * <p> * See the {@link HystrixPropertiesStrategy} JavaDocs for more information on properties and order of precedence. * @return Setter for fluent interface via method chaining */ public Setter andCommandPropertiesDefaults(HystrixCommandProperties.Setter commandPropertiesDefaults) { this.commandPropertiesDefaults = setDefaults(commandPropertiesDefaults); return this; }
protected TenacityObservableCommand(TenacityPropertyKey tenacityPropertyKey) { super(HystrixObservableCommand.Setter.withGroupKey(TenacityCommand.tenacityGroupKey()) .andCommandKey(tenacityPropertyKey)); }
public HystrixBeanFaultTolerance(HystrixCommandKey commandKey, HystrixCommandGroupKey groupKey) { observableSettings = Setter.withGroupKey(groupKey) .andCommandKey(commandKey) .andCommandPropertiesDefaults( HystrixCommandProperties.Setter().withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE)); commandSettings = com.netflix.hystrix.HystrixCommand.Setter.withGroupKey(groupKey) .andCommandKey(commandKey) .andCommandPropertiesDefaults( HystrixCommandProperties.Setter().withExecutionIsolationStrategy(ExecutionIsolationStrategy.THREAD)); }
@Override public HystrixObservableCommand.Setter create(Target<?> target, MethodMetadata methodMetadata) { String groupKey = target.name(); String commandKey = methodMetadata.configKey(); return HystrixObservableCommand.Setter .withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey)) .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)); } }
@Override public HystrixObservableCommand.Setter create(Target<?> target, MethodMetadata methodMetadata) { String groupKey = target.name(); String commandKey = methodMetadata.configKey(); return HystrixObservableCommand.Setter .withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey)) .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)); } }