Package org.pipservices3.components.test
Class Shutdown
java.lang.Object
org.pipservices3.components.test.Shutdown
- All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable,org.pipservices3.commons.run.IClosable,org.pipservices3.commons.run.IOpenable
public class Shutdown
extends Object
implements org.pipservices3.commons.config.IConfigurable, org.pipservices3.commons.run.IOpenable
Random shutdown component that crashes the process
using various methods.
The component is usually used for testing, but brave developers can try to use it in production to randomly crash microservices. It follows the concept of "Chaos Monkey" popularized by Netflix.
### Configuration parameters ###
- - mode: null - crash by NullPointer excepiton, zero - crash by dividing by zero, excetion = crash by unhandled exception, exit - exit the process
- - min_timeout: minimum crash timeout in milliseconds (default: 5 mins)
- - max_timeout: maximum crash timeout in milliseconds (default: 15 minutes)
### Example ###
Shutdown shutdown = new Shutdown();
shutdown.configure(ConfigParams.fromTuples(
"mode", "exception"
));
shutdown.shutdown(); // Result: Bang!!! the process crashes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses the timer.voidconfigure(org.pipservices3.commons.config.ConfigParams config) Configures component by passing configuration parameters.booleanisOpen()Checks if the component is opened.voidOpens the component.voidshutdown()Crashes the process using the configured crash mode.
-
Constructor Details
-
Shutdown
public Shutdown()
-
-
Method Details
-
configure
public void configure(org.pipservices3.commons.config.ConfigParams config) throws org.pipservices3.commons.errors.ConfigException Configures component by passing configuration parameters.- Specified by:
configurein interfaceorg.pipservices3.commons.config.IConfigurable- Parameters:
config- configuration parameters to be set.- Throws:
org.pipservices3.commons.errors.ConfigException
-
isOpen
public boolean isOpen()Checks if the component is opened.- Specified by:
isOpenin interfaceorg.pipservices3.commons.run.IOpenable- Returns:
- true if the component has been opened and false otherwise.
-
open
Opens the component.- Specified by:
openin interfaceorg.pipservices3.commons.run.IOpenable- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.
-
shutdown
public void shutdown() throws org.pipservices3.commons.errors.ApplicationExceptionCrashes the process using the configured crash mode.- Throws:
org.pipservices3.commons.errors.ApplicationException
-
close
Closes the timer. This is required by ICloseable interface, but besides that it is identical to stop().- Specified by:
closein interfaceorg.pipservices3.commons.run.IClosable- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.
-