@HystrixCommand(commandKey = "GetUserCommand", groupKey = "UserGroupKey", threadPoolKey = "Test", commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "110"), @HystrixProperty(name = "execution.isolation.thread.interruptOnTimeout", value = "false") }, threadPoolProperties = { @HystrixProperty(name = "coreSize", value = "30"), @HystrixProperty(name = "maximumSize", value = "35"), @HystrixProperty(name = "allowMaximumSizeToDivergeFromCoreSize", value = "true"), @HystrixProperty(name = "maxQueueSize", value = "101"), @HystrixProperty(name = "keepAliveTimeMinutes", value = "2"), @HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"), @HystrixProperty(name = "queueSizeRejectionThreshold", value = "15"), @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "1440") }) public User getUser(String id, String name) { return new User(id, name + id); // it should be network call }
private static <S> S initializeProperties(S setter, List<HystrixProperty> properties, Map<String, PropSetter<S, String>> propMap, String type) { if (properties != null && properties.size() > 0) { for (HystrixProperty property : properties) { validate(property); if (!propMap.containsKey(property.name())) { throw new IllegalArgumentException("unknown " + type + " property: " + property.name()); } propMap.get(property.name()).set(setter, property.value()); } } return setter; }
private static void validate(HystrixProperty hystrixProperty) throws IllegalArgumentException { Validate.notBlank(hystrixProperty.name(), "hystrix property name cannot be null or blank"); }
private static void validate(HystrixProperty hystrixProperty) throws IllegalArgumentException { Validate.notBlank(hystrixProperty.name(), "hystrix property name cannot be null or blank"); }
@HystrixCommand(groupKey = "FallbackGroupKey", threadPoolKey = "FallbackThreadPoolKey", commandProperties = { @HystrixProperty(name = EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS, value = "654") }, threadPoolProperties = { @HystrixProperty(name = "maxQueueSize", value = "321") }) private Object fallbackOverridesDefaultProperties() { return null; } }
private static <S> S initializeProperties(S setter, List<HystrixProperty> properties, Map<String, PropSetter<S, String>> propMap, String type) { if (properties != null && properties.size() > 0) { for (HystrixProperty property : properties) { validate(property); if (!propMap.containsKey(property.name())) { throw new IllegalArgumentException("unknown " + type + " property: " + property.name()); } propMap.get(property.name()).set(setter, property.value()); } } return setter; }
@HystrixCollapser( batchMethod = "getUsers", collapserKey = "GetUserCollapser", collapserProperties = { @HystrixProperty(name = TIMER_DELAY_IN_MILLISECONDS, value = "200"), @HystrixProperty(name = MAX_REQUESTS_IN_BATCH, value = "1"), }) public User getUser(String id) { return null; }
@HystrixCommand( commandProperties = { @HystrixProperty(name = EXECUTION_ISOLATION_STRATEGY, value = "SEMAPHORE"), @HystrixProperty(name = EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS, value = "500"), @HystrixProperty(name = EXECUTION_TIMEOUT_ENABLED, value = "true"), @HystrixProperty(name = EXECUTION_ISOLATION_THREAD_INTERRUPT_ON_TIMEOUT, value = "false"), @HystrixProperty(name = EXECUTION_ISOLATION_SEMAPHORE_MAX_CONCURRENT_REQUESTS, value = "10"), @HystrixProperty(name = FALLBACK_ISOLATION_SEMAPHORE_MAX_CONCURRENT_REQUESTS, value = "15"), @HystrixProperty(name = FALLBACK_ENABLED, value = "false"), @HystrixProperty(name = CIRCUIT_BREAKER_ENABLED, value = "false"), @HystrixProperty(name = CIRCUIT_BREAKER_REQUEST_VOLUME_THRESHOLD, value = "30"), @HystrixProperty(name = CIRCUIT_BREAKER_SLEEP_WINDOW_IN_MILLISECONDS, value = "250"), @HystrixProperty(name = CIRCUIT_BREAKER_ERROR_THRESHOLD_PERCENTAGE, value = "60"), @HystrixProperty(name = CIRCUIT_BREAKER_FORCE_OPEN, value = "false"), @HystrixProperty(name = CIRCUIT_BREAKER_FORCE_CLOSED, value = "true"), @HystrixProperty(name = METRICS_ROLLING_PERCENTILE_ENABLED, value = "false"), @HystrixProperty(name = METRICS_ROLLING_PERCENTILE_TIME_IN_MILLISECONDS, value = "400"), @HystrixProperty(name = METRICS_ROLLING_STATS_TIME_IN_MILLISECONDS, value = "500"), @HystrixProperty(name = METRICS_ROLLING_STATS_NUM_BUCKETS, value = "10"), @HystrixProperty(name = METRICS_ROLLING_PERCENTILE_NUM_BUCKETS, value = "5"), @HystrixProperty(name = METRICS_ROLLING_PERCENTILE_BUCKET_SIZE, value = "6"), @HystrixProperty(name = METRICS_HEALTH_SNAPSHOT_INTERVAL_IN_MILLISECONDS, value = "312"), @HystrixProperty(name = REQUEST_CACHE_ENABLED, value = "false"), @HystrixProperty(name = REQUEST_LOG_ENABLED, value = "true") } ) public User getUsingAllCommandProperties(String id, String name) { return new User(id, name + id); // it should be network call }
@HystrixCommand(groupKey = "CommandGroupKey", threadPoolKey = "CommandThreadPoolKey", commandProperties = { @HystrixProperty(name = EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS, value = "654") }, threadPoolProperties = { @HystrixProperty(name = "maxQueueSize", value = "321") }, fallbackMethod = "fallbackInheritsDefaultProperties") public Object commandOverridesDefaultPropertiesWithFallbackInheritsDefaultProperties() { throw new RuntimeException(); }
@HystrixCommand(commandProperties = {@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1")}) String commandWithFallbackThatFailsByTimeOut_f_0() { return ""; } }
@HystrixCollapser(batchMethod = "getUserByIdsWithFallback", collapserProperties = {@HystrixProperty(name = "timerDelayInMilliseconds", value = "200")}) public Future<User> getUserByIdWithFallback(String id) { return null; }
@HystrixCommand(threadPoolProperties = { @HystrixProperty(name = "maxQueueSize", value = "321") }) public Object commandOverridesDefaultThreadPoolProperties() { return null; } }
@HystrixCommand(fallbackMethod = "getUserByIdsFallback", commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "10000")// for debug }) public List<User> getUserByIdsWithFallback(List<String> ids) { throw new RuntimeException("not found"); }
@HystrixCommand(commandProperties = { @HystrixProperty(name = EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS, value = "654") }) public Object commandOverridesDefaultCommandProperties() { return null; }
@HystrixCommand( fallbackMethod = "getUserByIdsFallbackWithThrowableParam1", commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "10000")// for debug }) public List<User> getUserByIdsThrowsException(List<String> ids) { throw new RuntimeException("getUserByIdsFails failed"); }
@HystrixCollapser(batchMethod = "getUserByIds", collapserProperties = {@HystrixProperty(name = "timerDelayInMilliseconds", value = "200")}) public Observable<User> getUserByIdReactive(String id) { return null; }
@HystrixCommand(fallbackMethod = "asyncFallbackCommand", commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "100000") }) public Future<User> asyncCommandWithAsyncFallbackCommand(final String id, final String name) { return new AsyncResult<User>() { @Override public User invoke() { validate(id, name); return new User(id, name + id); // it should be network call } }; }
@HystrixCollapser(batchMethod = "getUserByIds", collapserProperties = {@HystrixProperty(name = "timerDelayInMilliseconds", value = "200")}) public Future<User> getUserById(String id) { return null; }
@HystrixCollapser(batchMethod = "getUserByIdsThrowsException", collapserProperties = {@HystrixProperty(name = "timerDelayInMilliseconds", value = "200")}) public Future<User> getUserByIdWithFallbackWithThrowableParam(String id) { return null; }
@HystrixCommand(commandProperties = {@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1")}) String timedOutWithoutFallback() { return ""; }