com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy Java Examples

The following examples show how to use com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy. 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: 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 #2
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 #3
Source File: SeataHystrixConcurrencyStrategy.java    From spring-cloud-alibaba with Apache License 2.0 6 votes vote down vote up
public SeataHystrixConcurrencyStrategy() {
	try {
		this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
		if (this.delegate instanceof SeataHystrixConcurrencyStrategy) {
			return;
		}
		HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
		HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
		HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
		HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
		logCurrentStateOfHystrixPlugins(eventNotifier, metricsPublisher, propertiesStrategy);
		HystrixPlugins.reset();
		HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
		HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
		HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
		HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
		HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
	} catch (Exception ex) {
		logger.error("Failed to register Seata Hystrix Concurrency Strategy", ex);
	}
}
 
Example #4
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 #5
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 #6
Source File: ThreadLocalConfiguration.java    From spring-microservices-in-action with Apache License 2.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();

       HystrixPlugins.getInstance().registerConcurrencyStrategy(new ThreadLocalAwareStrategy(existingConcurrencyStrategy));  // Register your customized strategy ({@code ThreadLocalAwareStrategy})
       HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
       HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
       HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
       HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #7
Source File: ThreadLocalConfiguration.java    From spring-microservices-in-action with Apache License 2.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();

       HystrixPlugins.getInstance().registerConcurrencyStrategy(new ThreadLocalAwareStrategy(existingConcurrencyStrategy));  // Register your customized strategy ({@code ThreadLocalAwareStrategy})
       HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
       HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
       HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
       HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #8
Source File: ThreadLocalConfiguration.java    From spring-microservices-in-action with Apache License 2.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();

       HystrixPlugins.getInstance().registerConcurrencyStrategy(new ThreadLocalAwareStrategy(existingConcurrencyStrategy));  // Register your customized strategy ({@code ThreadLocalAwareStrategy})
       HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
       HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
       HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
       HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #9
Source File: ThreadLocalConfiguration.java    From spring-microservices-in-action with Apache License 2.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();

       HystrixPlugins.getInstance().registerConcurrencyStrategy(new ThreadLocalAwareStrategy(existingConcurrencyStrategy));  // Register your customized strategy ({@code ThreadLocalAwareStrategy})
       HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
       HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
       HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
       HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #10
Source File: GrayHystrixContextConcurrencyStrategy.java    From spring-cloud-gray with Apache License 2.0 6 votes vote down vote up
public GrayHystrixContextConcurrencyStrategy() {
    this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
    if (this.delegate instanceof GrayHystrixContextConcurrencyStrategy) {
        return;
    }
    // Keeps references of existing Hystrix plugins.
    HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
    HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
    HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
    HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();

    HystrixPlugins.reset();

    // Registers existing plugins excepts the Concurrent Strategy plugin.
    HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
}
 
Example #11
Source File: SofaTracerHystrixConcurrencyStrategy.java    From sofa-tracer with Apache License 2.0 6 votes vote down vote up
public SofaTracerHystrixConcurrencyStrategy() {
    try {
        this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
        if (this.delegate instanceof SofaTracerHystrixConcurrencyStrategy) {
            // Welcome to singleton hell...
            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);
    } catch (Exception ex) {
        SelfLog.error("Failed to register Sleuth Hystrix Concurrency Strategy", ex);
    }
}
 
Example #12
Source File: ThreadLocalProcessHystrixConcurrencyStrategy.java    From Aooms with Apache License 2.0 6 votes vote down vote up
public ThreadLocalProcessHystrixConcurrencyStrategy() {
	try {

		this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
		if (this.delegate instanceof ThreadLocalProcessHystrixConcurrencyStrategy) {
			// Welcome to singleton hell...
			return;
		}
		HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
		HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
		HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
		HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();

		this.logCurrentStateOfHystrixPlugins(eventNotifier, metricsPublisher, propertiesStrategy);

		HystrixPlugins.reset();
		HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
		HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
		HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
		HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
		HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
	}
	catch (Exception e) {
		log.error("Failed to register Sleuth Hystrix Concurrency Strategy", e);
	}
}
 
Example #13
Source File: RequestAttributeHystrixAutoConfiguration.java    From summerframework with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {

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

    HystrixPlugins.reset();

    HystrixPlugins.getInstance()
        .registerConcurrencyStrategy(new RequestAttributeHystrixConcurrencyStrategy(existingConcurrencyStrategy));
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
 
Example #14
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 #15
Source File: CustomFeignHystrixConcurrencyStrategy.java    From spring-microservice-exam with MIT License 6 votes vote down vote up
public CustomFeignHystrixConcurrencyStrategy() {
    try {
        this.hystrixConcurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
        if (this.hystrixConcurrencyStrategy instanceof CustomFeignHystrixConcurrencyStrategy) {
            // Welcome to singleton hell...
            return;
        }
        HystrixCommandExecutionHook commandExecutionHook =
                HystrixPlugins.getInstance().getCommandExecutionHook();
        HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
        HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance().getMetricsPublisher();
        HystrixPropertiesStrategy propertiesStrategy =
                HystrixPlugins.getInstance().getPropertiesStrategy();
        this.logCurrentStateOfHystrixPlugins(eventNotifier, metricsPublisher, propertiesStrategy);
        HystrixPlugins.reset();
        HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
        HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
        HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
        HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
        HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    } catch (Exception e) {
        log.error("Failed to register Sleuth Hystrix Concurrency Strategy", e);
    }
}
 
Example #16
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 #17
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 #18
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 #19
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 #20
Source File: TracingHystrixConcurrencyStrategy.java    From tx-lcn with Apache License 2.0 5 votes vote down vote up
public TracingHystrixConcurrencyStrategy() {
    try {
        this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
        if (this.delegate instanceof TracingHystrixConcurrencyStrategy) {
            log.debug("Non another HystrixConcurrencyStrategy.");
            return;
        }
        HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins
                .getInstance().getCommandExecutionHook();
        HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance()
                .getEventNotifier();
        HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance()
                .getMetricsPublisher();
        HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance()
                .getPropertiesStrategy();
        log.debug("HystrixEventNotifier:{}, HystrixMetricsPublisher:{}, HystrixPropertiesStrategy:{}",
                eventNotifier, metricsPublisher, propertiesStrategy);
        HystrixPlugins.reset();
        HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
        HystrixPlugins.getInstance()
                .registerCommandExecutionHook(commandExecutionHook);
        HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
        HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
        HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    } catch (Exception e) {
        log.error("Failed to register Tracing Hystrix Concurrency Strategy", e);
    }
}
 
Example #21
Source File: MythHystrixConcurrencyStrategy.java    From myth with Apache License 2.0 5 votes vote down vote up
public MythHystrixConcurrencyStrategy() {
    try {
        this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
        if (this.delegate instanceof MythHystrixConcurrencyStrategy) {
            return;
        }
        HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins
                .getInstance().getCommandExecutionHook();
        HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance()
                .getEventNotifier();
        HystrixMetricsPublisher metricsPublisher = HystrixPlugins.getInstance()
                .getMetricsPublisher();
        HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance()
                .getPropertiesStrategy();
        LOGGER.debug("HystrixEventNotifier:{}, HystrixMetricsPublisher:{}, HystrixPropertiesStrategy:{}",
                eventNotifier, metricsPublisher, propertiesStrategy);
        HystrixPlugins.reset();
        HystrixPlugins.getInstance().registerConcurrencyStrategy(this);
        HystrixPlugins.getInstance()
                .registerCommandExecutionHook(commandExecutionHook);
        HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
        HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
        HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
    } catch (Exception e) {
        LOGGER.error("Failed to register Tracing Hystrix Concurrency Strategy", e);
    }
}
 
Example #22
Source File: HystrixConcurrencyStrategyInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
private void registerSWHystrixConcurrencyStrategyWrapper(SWHystrixConcurrencyStrategyWrapper wrapper) {
    // Copy from Spring Cloud Sleuth
    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(wrapper);
    HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
    HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
    HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
    HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
}
 
Example #23
Source File: HystrixCommandConfigurationTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
private static HystrixThreadPoolProperties getThreadPoolProperties(HystrixFaultToleranceFactory hystrixFaultTolerance,
		Class<?> api) {
	HystrixPropertiesStrategy hystrixPropertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
	HystrixCommandGroupKey groupKey = hystrixFaultTolerance.getGroupKey(AstrixBeanKey.create(api));
	return hystrixPropertiesStrategy.getThreadPoolProperties(HystrixThreadPoolKey.Factory.asKey(groupKey.name()), 
			  HystrixThreadPoolProperties.Setter());
}
 
Example #24
Source File: MultiPropertiesStrategyDispatcherTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
@Test
public void delegatesToUnderlyingCollapserKeys() {
	HystrixPropertiesStrategy mock = Mockito.mock(HystrixPropertiesStrategy.class);

	dispatcher.setUnderlying(mock);
	dispatcher.getCollapserProperties(HystrixCollapserKey.Factory.asKey("com.avanza.test.TestApi.TestService"), defaultCollapserSetter);

	Mockito.verify(mock).getCollapserProperties(HystrixCollapserKey.Factory.asKey("com.avanza.test.TestApi.TestService"), defaultCollapserSetter);
}
 
Example #25
Source File: MultiPropertiesStrategyDispatcherTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
@Test
public void decodesIncomingCollapserKeys() throws Exception {
	HystrixPropertiesStrategy mock = Mockito.mock(HystrixPropertiesStrategy.class);
	MultiConfigId configId = MultiConfigId.create("t1");
	
	dispatcher.register(configId.toString(), mock);
	dispatcher.getCollapserProperties(configId.createCollapserKey("com.avanza.test.TestApi.TestService"), defaultCollapserSetter);
	
	Mockito.verify(mock).getCollapserProperties(HystrixCollapserKey.Factory.asKey("com.avanza.test.TestApi.TestService"), defaultCollapserSetter);
}
 
Example #26
Source File: TracingConcurrencyStrategy.java    From feign-opentracing with Apache License 2.0 5 votes vote down vote up
private TracingConcurrencyStrategy(Tracer tracer) {
    this.tracer = tracer;
    try {
        this.delegateStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
        if (this.delegateStrategy instanceof TracingConcurrencyStrategy) {
            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);
    } catch (Exception ex) {
        log.log(Level.SEVERE, "Failed to register " + TracingConcurrencyStrategy.class +
            ", to HystrixPlugins", ex);
    }
}
 
Example #27
Source File: ArqHystrixTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigurationThroughArchaius() {
    HystrixPropertiesStrategy strategy = HystrixPlugins.getInstance().getPropertiesStrategy();

    HystrixCommandProperties defaultProps = strategy.getCommandProperties(HystrixCommandKey.Factory.asKey("default"), HystrixCommandProperties.Setter());

    assertFalse( defaultProps.circuitBreakerEnabled().get());
    assertEquals(77, (int) defaultProps.circuitBreakerErrorThresholdPercentage().get());

    HystrixCommandProperties gooberProps = strategy.getCommandProperties(HystrixCommandKey.Factory.asKey("goober"), HystrixCommandProperties.Setter());
    assertTrue( gooberProps.circuitBreakerEnabled().get());
    assertEquals(44, (int) gooberProps.circuitBreakerErrorThresholdPercentage().get());
}
 
Example #28
Source File: MultiPropertiesStrategyDispatcherTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
@Test
public void decodesIncomingThreadPoolKeys() throws Exception {
	HystrixPropertiesStrategy mock = Mockito.mock(HystrixPropertiesStrategy.class);
	MultiConfigId configId = MultiConfigId.create("t1");
	
	dispatcher.register(configId.toString(), mock);
	dispatcher.getThreadPoolProperties(configId.createThreadPoolKey("com.avanza.test.TestApi.TestService"), defaultThreadPoolSetter);
	
	Mockito.verify(mock).getThreadPoolProperties(HystrixThreadPoolKey.Factory.asKey("com.avanza.test.TestApi.TestService"), defaultThreadPoolSetter);
}
 
Example #29
Source File: SpringCloudDtsContextHystrixConcurrencyStrategy.java    From dts with Apache License 2.0 5 votes vote down vote up
public SpringCloudDtsContextHystrixConcurrencyStrategy() {
    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 #30
Source File: MultiPropertiesStrategyDispatcherTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
@Test
public void decodesIncomingCommandKeys() throws Exception {
	HystrixPropertiesStrategy mock = Mockito.mock(HystrixPropertiesStrategy.class);
	MultiConfigId configId = MultiConfigId.create("t1");
	
	dispatcher.register(configId.toString(), mock);
	dispatcher.getCommandProperties(configId.createCommandKey("com.avanza.test.TestApi.TestService"), defaultCommandSetter);
	
	Mockito.verify(mock).getCommandProperties(HystrixCommandKey.Factory.asKey("com.avanza.test.TestApi.TestService"), defaultCommandSetter);
}