Java Code Examples for com.netflix.hystrix.Hystrix#reset()

The following examples show how to use com.netflix.hystrix.Hystrix#reset() . 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: ExampleServiceGetApiTest.java    From gradle-archetype-plugin with Apache License 2.0 5 votes vote down vote up
@After
public void reset() {
  ConfigurationManager.getConfigInstance()
    .setProperty("hystrix.command.default.circuitBreaker.forceOpen",
      false);

  Hystrix.reset();
}
 
Example 2
Source File: HystrixStrategyDispatcher.java    From astrix with Apache License 2.0 5 votes vote down vote up
private static void initHystrixPlugins() {
	try {
		registerDispatcherStrategies();
	} catch (Exception e) {
		log.warn("Failed to init Hystrix with custom Astrix strategies. Hystrix configuration will be reset and one more registreation attempt will be performed", e);
		Hystrix.reset();
		registerDispatcherStrategies();
	}
}
 
Example 3
Source File: HystrixCommandFacadeTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
@Before
public void before() throws InterruptedException {
	Hystrix.reset();
	context = new TestAstrixConfigurer().enableFaultTolerance(true)
										.registerApiProvider(PingApi.class)
										.set(AstrixBeanSettings.TIMEOUT, AstrixBeanKey.create(Ping.class), 250)
										.set(AstrixBeanSettings.CORE_SIZE, AstrixBeanKey.create(Ping.class), 1)
										.set(AstrixThreadPoolProperties.MAX_QUEUE_SIZE, AstrixBeanKey.create(Ping.class), -1) // NO QUEUE
										.set("pingUri", DirectComponent.registerAndGetUri(Ping.class, pingServer))
										.configure();
	ping = context.getBean(Ping.class);
	initMetrics(ping);
}
 
Example 4
Source File: HystrixObservableCommandFacadeTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
@Before
public void before() throws InterruptedException {
	Hystrix.reset();
	context = new TestAstrixConfigurer().enableFaultTolerance(true)
										.registerApiProvider(PingApi.class)
										.set(AstrixBeanSettings.TIMEOUT, AstrixBeanKey.create(Ping.class), 25)
										.set(AstrixBeanSettings.MAX_CONCURRENT_REQUESTS, AstrixBeanKey.create(Ping.class), 1)
										.set("pingUri", DirectComponent.registerAndGetUri(Ping.class, pingServer))
										.configure();
	ping = context.getBean(Ping.class);
	initMetrics(ping);
}
 
Example 5
Source File: HystrixFaulttoleranceIntegrationTest.java    From astrix with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws InterruptedException {
	Hystrix.reset();
	counter.incrementAndGet();
	astrixConfigurer.registerApiProvider(PingApiProvider.class);
	astrixConfigurer.registerApiProvider(CorruptPingApiProvider.class);
	astrixConfigurer.enableFaultTolerance(true);
	context = (AstrixApplicationContext) astrixConfigurer.configure();
	ping = context.getBean(Ping.class);
	initMetrics(ping);
}
 
Example 6
Source File: Application.java    From data-prep with Apache License 2.0 5 votes vote down vote up
@Override
public void destroy() throws Exception {
    LOG.info("Shutting down Hystrix...");
    // shutdown all thread pools; waiting a little time for shutdown
    Hystrix.reset(1, TimeUnit.SECONDS);
    LOG.info("Shut down Hystrix done.");
}
 
Example 7
Source File: MetricsPublisherRegistrationTest.java    From prometheus-hystrix with Apache License 2.0 4 votes vote down vote up
@After
public void teardown() {
    Hystrix.reset();
    CollectorRegistry.defaultRegistry.clear();
}
 
Example 8
Source File: GroovyModuleLoaderExample.java    From Nicobar with Apache License 2.0 4 votes vote down vote up
public void runExample() throws Exception {

        // create the loader with the groovy plugin
        ScriptModuleLoader moduleLoader = new ScriptModuleLoader.Builder()
            .addPluginSpec(new ScriptCompilerPluginSpec.Builder(GROOVY2_PLUGIN_ID) // configure Groovy plugin
                .addRuntimeResource(ExampleResourceLocator.getGroovyRuntime())
                .addRuntimeResource(ExampleResourceLocator.getGroovyPluginLocation())
                .withPluginClassName(GROOVY2_COMPILER_PLUGIN_CLASS)
                .build())
            .addListener(new BaseScriptModuleListener() {                // add an example listener for module updates
                public void moduleUpdated(ScriptModule newScriptModule, ScriptModule oldScriptModule) {
                    System.out.printf("Received module update event. newModule: %s,  oldModule: %s%n", newScriptModule, oldScriptModule);
                }
            })
            .build();

        // create an archive repository and wrap a poller around it to feed updates to the module loader
        Path baseArchiveDir = Files.createTempDirectory(GroovyModuleLoaderExample.class.getSimpleName());
        JarArchiveRepository repository = new JarArchiveRepository.Builder(baseArchiveDir).build();
        deployTestArchive(repository);
        ArchiveRepositoryPoller poller = new ArchiveRepositoryPoller.Builder(moduleLoader).build();
        poller.addRepository(repository, 30, TimeUnit.SECONDS, true);

        // the test module has now been compiled and is ready for execution.
        // create a closure which knows how to bind any request time inputs (if any) and execute the module.
        ScriptModuleExecutable<String> executable = new ScriptModuleExecutable<String>() {
            @Override
            public String execute(ScriptModule scriptModule) throws Exception {
                // the script doesn't necessarily have to implement any specific interfaces, but it does need to
                // be compilable to a class.
                Class<?> callable = ScriptModuleUtils.findAssignableClass(scriptModule, Callable.class);
                @SuppressWarnings("unchecked")
                Callable<String> instance = (Callable<String>) callable.newInstance();
                String result = instance.call();
                return result;
            }
        };

        // Execute it in a Hystrix command.
        HystrixScriptModuleExecutor<String> executor = new HystrixScriptModuleExecutor<String>("TestModuleExecutor");
        List<String> results = executor.executeModules(Collections.singletonList(SCRIPT_MODULE_ID), executable, moduleLoader);
        System.out.println("Module(s) have been executed. Output: " + results);

        // release the Hystrix resources
        Hystrix.reset();
    }
 
Example 9
Source File: TenacityTestRule.java    From tenacity with Apache License 2.0 4 votes vote down vote up
public void teardown() {
    Hystrix.reset(1, TimeUnit.SECONDS);
    ConfigurationManager.getConfigInstance().clear();
}
 
Example 10
Source File: TenacityTestRule.java    From tenacity with Apache License 2.0 4 votes vote down vote up
private void setup() {
    resetStreams();
    Hystrix.reset();
    final AbstractConfiguration configuration = ConfigurationManager.getConfigInstance();
    configuration.setProperty("hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds", "100");
}
 
Example 11
Source File: ManagedHystrix.java    From tenacity with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() throws Exception {
    Hystrix.reset(shutdownGracePeriod.getQuantity(), shutdownGracePeriod.getUnit());
}
 
Example 12
Source File: HystrixTestHelper.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
public static void reset() {
    Hystrix.reset(60, TimeUnit.MILLISECONDS);
}
 
Example 13
Source File: HystrixCommandTest.java    From prometheus-hystrix with Apache License 2.0 4 votes vote down vote up
@After
public void teardown() {
    CollectorRegistry.defaultRegistry.clear();
    Hystrix.reset();
}
 
Example 14
Source File: MetricsListTest.java    From prometheus-hystrix with Apache License 2.0 4 votes vote down vote up
@After
public void teardown() {
    Hystrix.reset();
    CollectorRegistry.defaultRegistry.clear();
}
 
Example 15
Source File: MicrometerMetricsPublisherThreadPoolTest.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@BeforeEach
void init() {
    Hystrix.reset();
}
 
Example 16
Source File: FaultToleranceMetricsTest.java    From astrix with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
	Hystrix.reset();
}
 
Example 17
Source File: MicrometerMetricsPublisherThreadPoolTest.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@AfterEach
void teardown() {
    Hystrix.reset();
}