Interface LifeCycleHook

All Known Implementing Classes:
TinkerFactoryDataLoader

public interface LifeCycleHook
Provides a method in which users can hook into the startup and shutdown lifecycle of Gremlin Server. Creating an instance of this interface in a Gremlin Server initialization script enables the ability to get a callback when the server starts and stops. The hook is guaranteed to execute once at in both cases.
Author:
Stephen Mallette (http://stephen.genoprime.com)
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Contains objects from the server that might be useful to scripting during the startup and shutdown process.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    init(Map<String,Object> config)
    Called once after instantiation to pass configuration from the lifecycleHooks YAML section.
    void
    Called when the server is shutdown.
    void
    Called when the server starts up.
  • Method Details

    • init

      default void init(Map<String,Object> config)
      Called once after instantiation to pass configuration from the lifecycleHooks YAML section. Implementations that require configuration should override this method. The default implementation is a no-op so that existing hooks are not forced to implement it.

      If this method throws an exception, the hook is skipped and the server continues to start without it.

      Parameters:
      config - the key/value pairs from the config block in the YAML entry
    • onStartUp

      void onStartUp(LifeCycleHook.Context c)
      Called when the server starts up. The graph collection will have been initialized at this point and all initialization scripts will have been executed when this callback is called.

      If this method throws an exception (other than UnsupportedOperationException), the server will fail to start.

    • onShutDown

      void onShutDown(LifeCycleHook.Context c)
      Called when the server is shutdown.

      If this method throws an exception, remaining shutdown hooks and graph cleanup may be skipped.