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

Following code examples demonstrate how to use com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy from netflix-hystrix. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy and various code implementation of this class.
Example 1
Project : netflix-hystrix Source File : RegisterCommandExcutionHook.java View Source Code on GitHub

    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
Project : netflix-hystrix Source File : HystrixConfiguration.java View Source Code on GitHub

    public void init() {
        HystrixPlugins plugins = HystrixPlugins.getInstance();
        HystrixEventNotifier eventNotifier = plugins.getEventNotifier();
        HystrixMetricsPublisher metricsPublisher = plugins.getMetricsPublisher();
        HystrixPropertiesStrategy propertiesStrategy = plugins.getPropertiesStrategy();
        HystrixCommandExecutionHook commandExecutionHook = plugins.getCommandExecutionHook();

        HystrixPlugins.reset();

        HystrixPlugins.getInstance().registerConcurrencyStrategy(new ThreadLocalAwareStrategy(existingConcurrencyStrategy));
        HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
        HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
        HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
        HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
    }
			
Example 3
Project : netflix-hystrix Source File : ThreadLocalConfiguration.java View Source Code on GitHub

    public void init() {
        LOG.debug("existingConcurrencyStrategy = " + (existingConcurrencyStrategy != null));
        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));
        HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
        HystrixPlugins.getInstance().registerMetricsPublisher(metricsPublisher);
        HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
        HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
    }
			
Example 4
Project : netflix-hystrix Source File : DemoApplicationConfiguration.java View Source Code on GitHub

  public void registerHystrixServo(){
    final HystrixPlugins hystrixPlugins = HystrixPlugins.getInstance();
    if (hystrixPlugins.getMetricsPublisher() == null) {
      hystrixPlugins.registerMetricsPublisher(HystrixServoMetricsPublisher.getInstance());
    }
    else {
      final HystrixEventNotifier hystrixEventNotifier = hystrixPlugins.getEventNotifier();
      final HystrixConcurrencyStrategy hystrixConcurrencyStrategy = hystrixPlugins.getConcurrencyStrategy();
      final HystrixPropertiesStrategy hystrixPropertiesStrategy = hystrixPlugins.getPropertiesStrategy();
      final HystrixCommandExecutionHook hystrixCommandExecutionHook = hystrixPlugins.getCommandExecutionHook();
      HystrixPlugins.reset();
      hystrixPlugins.registerEventNotifier(hystrixEventNotifier);
      hystrixPlugins.registerConcurrencyStrategy(hystrixConcurrencyStrategy);
      hystrixPlugins.registerPropertiesStrategy(hystrixPropertiesStrategy);
      hystrixPlugins.registerCommandExecutionHook(hystrixCommandExecutionHook);
      hystrixPlugins.registerMetricsPublisher(HystrixServoMetricsPublisher.getInstance());
    }
  }