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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(String correlationId)
    Closes the timer.
    void
    configure(org.pipservices3.commons.config.ConfigParams config)
    Configures component by passing configuration parameters.
    boolean
    Checks if the component is opened.
    void
    open(String correlationId)
    Opens the component.
    void
    Crashes the process using the configured crash mode.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      configure in interface org.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:
      isOpen in interface org.pipservices3.commons.run.IOpenable
      Returns:
      true if the component has been opened and false otherwise.
    • open

      public void open(String correlationId)
      Opens the component.
      Specified by:
      open in interface org.pipservices3.commons.run.IOpenable
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
    • shutdown

      public void shutdown() throws org.pipservices3.commons.errors.ApplicationException
      Crashes the process using the configured crash mode.
      Throws:
      org.pipservices3.commons.errors.ApplicationException
    • close

      public void close(String correlationId)
      Closes the timer. This is required by ICloseable interface, but besides that it is identical to stop().
      Specified by:
      close in interface org.pipservices3.commons.run.IClosable
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.