com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy Java Examples

The following examples show how to use com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegisterCommandExcutionHook.java    From jframework with Apache License 2.0 6 votes vote down vote up
public RegisterCommandExcutionHook() {
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
    HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
    HystrixMetricsPublisher hystrixMetricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();

    HystrixPlugins.reset();
    HystrixPlugins.getInstance().registerMetricsPublisher(hystrixMetricsPublisher);
    HystrixPlugins.getInstance().registerConcurrencyStrategy(concurrencyStrategy);
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(new HystrixCommandExecutionHook() {
        @Override
        public <T> void onFallbackStart(HystrixInvokable<T> commandInstance) {
            HystrixCommand hystrixCommand = (HystrixCommand) commandInstance;
            String commandKey = hystrixCommand.getCommandKey().toString();
            log.error("Hystrix: {} 接口开始降级", commandKey);
            super.onFallbackStart(commandInstance);
        }
    });
}
 
Example #2
Source File: HystrixConcurrencyStrategyInterceptorTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Test
public void testInterceptorWithCustomHystrixConcurrencyStrategy() throws Throwable {
    Object wrapperResult = getConcurrencyStrategyByInterceptor();
    assertTrue(wrapperResult instanceof SWHystrixConcurrencyStrategyWrapper);
    assertSame(HystrixPlugins.getInstance().getConcurrencyStrategy(), wrapperResult);

    // register custom HystrixConcurrencyStrategy
    final HystrixConcurrencyStrategy delegate = getConcurrencyStrategyByInterceptor();
    HystrixConcurrencyStrategy customConcurrencyStrategy = new CustomConcurrencyStrategy(delegate);
    HystrixPlugins.reset();
    HystrixPlugins.getInstance().registerConcurrencyStrategy(customConcurrencyStrategy);

    // custom HystrixConcurrencyStrategy can be consumed
    wrapperResult = getConcurrencyStrategyByInterceptor();
    assertSame(customConcurrencyStrategy, wrapperResult);
    assertSame(HystrixPlugins.getInstance().getConcurrencyStrategy(), wrapperResult);
}
 
Example #3
Source File: HystrixConcurrencyStrategyInterceptor.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    Object ret) throws Throwable {
    SWHystrixPluginsWrapperCache wrapperCache = (SWHystrixPluginsWrapperCache) objInst.getSkyWalkingDynamicField();
    if (wrapperCache == null || wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) {
        synchronized (objInst) {
            if (wrapperCache == null) {
                wrapperCache = new SWHystrixPluginsWrapperCache();
                objInst.setSkyWalkingDynamicField(wrapperCache);
            }
            if (wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) {
                // Return and register wrapper only for the first time
                // Try to believe that all other strategies will use the their delegates
                SWHystrixConcurrencyStrategyWrapper wrapper = new SWHystrixConcurrencyStrategyWrapper((HystrixConcurrencyStrategy) ret);
                wrapperCache.setSwHystrixConcurrencyStrategyWrapper(wrapper);

                registerSWHystrixConcurrencyStrategyWrapper(wrapper);

                return wrapper;
            }
        }
    }
    return ret;
}
 
Example #4
Source File: HystrixPluginsInterceptor.java    From skywalking with Apache License 2.0 6 votes vote down vote up
private static void registerSWExecutionHookWrapper(SWExecutionHookWrapper wrapper) {
    HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
    HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
    HystrixPlugins.reset();
    HystrixPlugins.getInstance().registerConcurrencyStrategy(concurrencyStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(wrapper);
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
}
 
Example #5
Source File: MultiConfigs.java    From astrix with Apache License 2.0 6 votes vote down vote up
private static void registerWithHystrix() {

        final HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
        final HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
        final HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
        final HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
        final HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();

        HystrixPlugins.reset();

        reRegister(eventNotifier, multiEventNotifierDispatcher, notifier -> HystrixPlugins.getInstance().registerEventNotifier(notifier));
        reRegister(concurrencyStrategy, multiConcurrencyStrategyDispatcher, strategy -> HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy));
        HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
        reRegister(propertiesStrategy, multiPropertiesStrategyDispatcher, strategy -> HystrixPlugins.getInstance().registerPropertiesStrategy(strategy));
        HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);

        LOGGER.info(MultiPropertiesStrategyDispatcher.class.getName() + " registered with Hystrix!");
    }
 
Example #6
Source File: BladeHystrixAutoConfiguration.java    From blade-tool with GNU Lesser General Public License v3.0 6 votes vote down vote up
@PostConstruct
public void init() {
	// Keeps references of existing Hystrix plugins.
	HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
	HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
	HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
	HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();

	HystrixPlugins.reset();

	// Registers existing plugins excepts the Concurrent Strategy plugin.
	HystrixConcurrencyStrategy strategy = new BladeHystrixConcurrencyStrategy(existingConcurrencyStrategy, accountGetter, properties);
	HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy);
	HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
	HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
	HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
	HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #7
Source File: PreservesExecutionContextHystrixStrategy.java    From spring-cloud-ribbon-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * registers the {@link ExecutionContextAwareHystrixStrategy}
 */
public static void init() {
    // keeps references of existing Hystrix plugins.
    HystrixConcurrencyStrategy existingConcurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
    HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
    HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
    // reset the Hystrix plugin
    HystrixPlugins.reset();
    // configure the  plugin
    HystrixPlugins.getInstance().registerConcurrencyStrategy(new ExecutionContextAwareHystrixStrategy(existingConcurrencyStrategy));
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
    log.info("Context propagation enabled for Hystrix.");
}
 
Example #8
Source File: AbstractContextConcurrencyStrategy.java    From onetwo with Apache License 2.0 6 votes vote down vote up
public AbstractContextConcurrencyStrategy(HystrixConcurrencyStrategy existingConcurrencyStrategy) {
	if (getClass().isInstance(existingConcurrencyStrategy)) {
		System.out.println("Welcome to singleton hell...");
		return;
	}
	
	this.existingConcurrencyStrategy = existingConcurrencyStrategy;
	
	HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance()
			.getEventNotifier();
	HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance()
			.getMetricsPublisher();
	HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance()
			.getPropertiesStrategy();
	HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance()
			.getCommandExecutionHook();

	HystrixPlugins.reset();

	// Registers existing plugins excepts the Concurrent Strategy plugin.
	HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
	HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
	HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
	HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
	HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #9
Source File: RouterHystrixConcurrencyStrategy.java    From spring-cloud-huawei with Apache License 2.0 6 votes vote down vote up
public RouterHystrixConcurrencyStrategy() {
  HystrixConcurrencyStrategy strategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
  if (strategy instanceof RouterHystrixConcurrencyStrategy) {
    return;
  }
  HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance()
      .getCommandExecutionHook();
  HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
  HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
  HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance()
      .getPropertiesStrategy();
  HystrixPlugins.reset();
  HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
  HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
  HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
  HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
  HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
}
 
Example #10
Source File: HystrixMetricsBinder.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Override
public void bindTo(MeterRegistry registry) {
    // Keeps references of existing Hystrix plugins.
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
    HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
    HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
    HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();

    HystrixPlugins.reset();

    // Registers existing plugins except the new MicroMeter Strategy plugin.
    HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(registry, metricsPublisher));
    HystrixPlugins.getInstance().registerConcurrencyStrategy(concurrencyStrategy);
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #11
Source File: HystrixConcurrencyStrategyTests.java    From servicecomb-pack with Apache License 2.0 5 votes vote down vote up
@Test
public void testConcurrencyStrategyInstalled() {

  HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance()
      .getConcurrencyStrategy();
  assertThat(concurrencyStrategy)
      .isInstanceOf(ServiceCombConcurrencyStrategy.class);
}
 
Example #12
Source File: HystrixStrategies.java    From astrix with Apache License 2.0 5 votes vote down vote up
public HystrixStrategies(HystrixPropertiesStrategy hystrixPropertiesStrategy,
						 HystrixConcurrencyStrategy concurrencyStrategy,
						 HystrixEventNotifier eventNotifier,
						 String id) {
	this.hystrixPropertiesStrategy = hystrixPropertiesStrategy;
	this.hystrixConcurrencyStrategy = concurrencyStrategy;
	this.hystrixEventNotifier = eventNotifier;
	this.id = id;
}
 
Example #13
Source File: ServiceCombConcurrencyStrategy.java    From servicecomb-pack with Apache License 2.0 5 votes vote down vote up
public ServiceCombConcurrencyStrategy(
    HystrixConcurrencyStrategy existingConcurrencyStrategy,
    List<HystrixCallableWrapper> optionalHystrixCallableWrappers) {
  this.existingConcurrencyStrategy = existingConcurrencyStrategy;
  this.hystrixCallableWrappers =
      optionalHystrixCallableWrappers == null ? Collections.<HystrixCallableWrapper>emptyList()
          : optionalHystrixCallableWrappers;
}
 
Example #14
Source File: MultiConcurrencyStrategyDispatcher.java    From astrix with Apache License 2.0 4 votes vote down vote up
@Override
public HystrixConcurrencyStrategy instance() {
    return this;
}
 
Example #15
Source File: HystrixPrometheusMetricsPublisher.java    From prometheus-hystrix with Apache License 2.0 4 votes vote down vote up
public void buildAndRegister() {
    HystrixPlugins plugins = HystrixPlugins.getInstance();

    // memorize the registered plugins
    HystrixCommandExecutionHook commandExecutionHook = plugins.getCommandExecutionHook();
    HystrixEventNotifier eventNotifier = plugins.getEventNotifier();
    HystrixMetricsPublisher metricsPublisher = plugins.getMetricsPublisher();
    HystrixPropertiesStrategy propertiesStrategy = plugins.getPropertiesStrategy();
    HystrixConcurrencyStrategy concurrencyStrategy = plugins.getConcurrencyStrategy();

    HystrixMetricsCollector collector = new HystrixMetricsCollector(namespace,
            new Consumer<Histogram.Builder>() {
                @Override
                public void accept(Histogram.Builder builder) {
                    if (metrics == MetricsType.EXPONENTIAL) {
                        builder.exponentialBuckets(exponentialStart, exponentialFactor, exponentialCount);
                    } else if (metrics == MetricsType.LINEAR) {
                        builder.linearBuckets(linearStart, linearWidth, linearCount);
                    } else if (metrics == MetricsType.DISTINCT) {
                        builder.buckets(distinctBuckets);
                    } else if (metrics == MetricsType.DEFAULT) {
                        // nothing to do
                    } else {
                        throw new IllegalStateException("unknown enum state " + metrics);
                    }
                }
            }).register(registry);

    // wrap the metrics publisher plugin
    HystrixPrometheusMetricsPublisher wrappedMetricsPublisher =
            new HystrixPrometheusMetricsPublisher(exportProperties,
                    exportDeprecatedMetrics, collector, metricsPublisher);

    // reset all plugins
    HystrixPlugins.reset();
    // the following statement wouldn't be necessary, but I'm paranoid that reset might
    // change the plugin instance.
    plugins = HystrixPlugins.getInstance();

    // set previous values for all plugins, but not if they would use the default implementation,
    // as this would block the slot for plugins to be registered.

    // REASON: if there was no previous setting, Hystrix would have returned the default implementation
    // and not all other plugin use the reset-and-wrap approach we do here.

    // ASSUMPTION: the default strategies/hooks can't wrap a different strategy/hook

    // CAVEAT: instead of a default implementation there is a sophisticated Archaius configuration mechanism
    // to determine a class from property settings. There is a corner case where someone would register a
    // default implementation manually overriding an Archaius configuration. Therefore this is configurable
    // using "registerDefaultPlugins".

    if (registerDefaultPlugins || concurrencyStrategy.getClass() != HystrixConcurrencyStrategyDefault.class) {
        plugins.registerConcurrencyStrategy(concurrencyStrategy);
    }
    if (registerDefaultPlugins || commandExecutionHook.getClass() != HystrixCommandExecutionHookDefault.class) {
        plugins.registerCommandExecutionHook(commandExecutionHook);
    }
    if (registerDefaultPlugins || eventNotifier.getClass() != HystrixEventNotifierDefault.class) {
        plugins.registerEventNotifier(eventNotifier);
    }
    if (registerDefaultPlugins || propertiesStrategy.getClass() != HystrixPropertiesStrategyDefault.class) {
        plugins.registerPropertiesStrategy(propertiesStrategy);
    }

    // ... except for the metrics publisher that will now be wrapped
    plugins.registerMetricsPublisher(wrappedMetricsPublisher);
}
 
Example #16
Source File: HystrixConcurrencyStrategyInterceptorTest.java    From skywalking with Apache License 2.0 4 votes vote down vote up
public CustomConcurrencyStrategy(HystrixConcurrencyStrategy delegate) {
    this.delegate = delegate;
}
 
Example #17
Source File: HystrixConcurrencyStrategyInterceptorTest.java    From skywalking with Apache License 2.0 4 votes vote down vote up
private HystrixConcurrencyStrategy getConcurrencyStrategyByInterceptor() throws Throwable {
    return (HystrixConcurrencyStrategy) hystrixConcurrencyStrategyInterceptor.afterMethod(enhancedInstance, null, null, null, HystrixPlugins
        .getInstance()
        .getConcurrencyStrategy());
}
 
Example #18
Source File: RequestAttributeHystrixConcurrencyStrategy.java    From summerframework with Apache License 2.0 4 votes vote down vote up
public RequestAttributeHystrixConcurrencyStrategy(HystrixConcurrencyStrategy existingConcurrencyStrategy) {
    this.existingConcurrencyStrategy = existingConcurrencyStrategy;
}
 
Example #19
Source File: SWHystrixConcurrencyStrategyWrapper.java    From skywalking with Apache License 2.0 4 votes vote down vote up
public SWHystrixConcurrencyStrategyWrapper(HystrixConcurrencyStrategy delegate) {
    this.delegate = delegate;
}
 
Example #20
Source File: HystrixStrategies.java    From astrix with Apache License 2.0 4 votes vote down vote up
public HystrixConcurrencyStrategy getHystrixConcurrencyStrategy() {
	return this.hystrixConcurrencyStrategy;
}
 
Example #21
Source File: HystrixServiceCombAutoConfiguration.java    From servicecomb-pack with Apache License 2.0 4 votes vote down vote up
@PostConstruct
public void init() {
  try {
    if (CollectionUtils.isEmpty(hystrixCallableWrappers)) {
      log.info(
          "no hystrixCallableWrapper find ,ServiceCombConcurrencyStrategy ignore Configuration");
      return;
    }
    HystrixConcurrencyStrategy concurrencyStrategy = detectRegisteredConcurrencyStrategy();
    if (concurrencyStrategy instanceof ServiceCombConcurrencyStrategy) {
      log.info(
          "Current Hystrix plugins concurrencyStrategy is ServiceCombConcurrencyStrategy ignore Configuration");
      return;
    }

    // Keeps references of existing Hystrix plugins.
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance()
        .getEventNotifier();
    HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance()
        .getMetricsPublisher();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance()
        .getPropertiesStrategy();
    HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance()
        .getCommandExecutionHook();

    log.info("Current Hystrix plugins configuration is ["
        + "concurrencyStrategy [" + concurrencyStrategy + "]," + "eventNotifier ["
        + eventNotifier + "]," + "metricPublisher [" + metricsPublisher + "],"
        + "propertiesStrategy [" + propertiesStrategy + "]," + "]");
    HystrixPlugins.reset();

    // Registers existing plugins excepts the Concurrent Strategy plugin.
    HystrixPlugins.getInstance().registerConcurrencyStrategy(
        new ServiceCombConcurrencyStrategy(concurrencyStrategy, hystrixCallableWrappers));
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);

    log.info("Succeeded to register ServiceComb Hystrix Concurrency Strategy");

  } catch (Exception e) {
    log.error("Failed to register ServiceComb Hystrix Concurrency Strategy", e);
  }

}
 
Example #22
Source File: MultiConcurrencyStrategyDispatcher.java    From astrix with Apache License 2.0 4 votes vote down vote up
@Override
public void setUnderlying(final HystrixConcurrencyStrategy underlying) {
    this.underlying.set(underlying);
}
 
Example #23
Source File: MultiConcurrencyStrategyDispatcher.java    From astrix with Apache License 2.0 4 votes vote down vote up
private Optional<HystrixConcurrencyStrategy> underlying() {
    return Optional.ofNullable(underlying.get());
}
 
Example #24
Source File: MultiConcurrencyStrategyDispatcher.java    From astrix with Apache License 2.0 4 votes vote down vote up
public void register(String id, HystrixConcurrencyStrategy strategy) {
    this.strategies.put(MultiConfigId.create(id), strategy);
}
 
Example #25
Source File: MultiConfigs.java    From astrix with Apache License 2.0 4 votes vote down vote up
public static void register(String id, HystrixConcurrencyStrategy strategy) {
    multiConcurrencyStrategyDispatcher.register(id, strategy);
    verifyRegistered();
}
 
Example #26
Source File: RaincatFeignConfiguration.java    From Raincat with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Hystrix concurrency strategy hystrix concurrency strategy.
 *
 * @return the hystrix concurrency strategy
 */
@Bean
@ConditionalOnProperty(name = "feign.hystrix.enabled")
public HystrixConcurrencyStrategy hystrixConcurrencyStrategy() {
    return new RaincatHystrixConcurrencyStrategy();
}
 
Example #27
Source File: MythFeignConfiguration.java    From myth with Apache License 2.0 4 votes vote down vote up
/**
 * Hystrix concurrency strategy hystrix concurrency strategy.
 *
 * @return the hystrix concurrency strategy
 */
@Bean
@ConditionalOnProperty(name = "feign.hystrix.enabled")
public HystrixConcurrencyStrategy hystrixConcurrencyStrategy() {
    return new MythHystrixConcurrencyStrategy();
}
 
Example #28
Source File: HystrixServiceCombAutoConfiguration.java    From servicecomb-pack with Apache License 2.0 4 votes vote down vote up
private HystrixConcurrencyStrategy detectRegisteredConcurrencyStrategy() {
  return HystrixPlugins.getInstance()
      .getConcurrencyStrategy();
}
 
Example #29
Source File: ThreadLocalAwareStrategy.java    From spring-microservices-in-action with Apache License 2.0 2 votes vote down vote up
/**
 * Construct a {@code ThreadLocalAwareStrategy}.
 * 
 * @param  existingConcurrencyStrategy
 *         The existing {@code HystrixConcurrencyStrategy} defined by 
 *         Spring Cloud.
 */
public ThreadLocalAwareStrategy(HystrixConcurrencyStrategy existingConcurrencyStrategy) {
    this.existingConcurrencyStrategy = existingConcurrencyStrategy;
}
 
Example #30
Source File: ThreadLocalAwareStrategy.java    From spring-microservices-in-action with Apache License 2.0 2 votes vote down vote up
/**
 * Construct a {@code ThreadLocalAwareStrategy}.
 * 
 * @param  existingConcurrencyStrategy
 *         The existing {@code HystrixConcurrencyStrategy} defined by 
 *         Spring Cloud.
 */
public ThreadLocalAwareStrategy(HystrixConcurrencyStrategy existingConcurrencyStrategy) {
    this.existingConcurrencyStrategy = existingConcurrencyStrategy;
}