org.apache.tinkerpop.gremlin.server.op.session

## Class SessionOpProcessor

- java.lang.Object
- - org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor
  - - org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor
    - - org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor

- All Implemented Interfaces:
    AutoCloseable, OpProcessor

      public class SessionOpProcessor
      extends AbstractEvalOpProcessor

  Simple `OpProcessor` implementation that handles `ScriptEngine` script evaluation in the context of a session. Note that this processor will also take a "close" op to kill the session and rollback any incomplete transactions.
  Author:
    Stephen Mallette (http://stephen.genoprime.com)

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor

      `AbstractEvalOpProcessor.BindingSupplier`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONFIG_GLOBAL_FUNCTION_CACHE_ENABLED` Configuration setting that behaves as an override to the global script engine setting of the same name that is provided to the `GroovyCompilerGremlinPlugin`.
    `static String` | `CONFIG_PER_GRAPH_CLOSE_TIMEOUT` Configuration setting for how long to wait in milliseconds for each configured graph to close any open transactions when the session is killed.
    `static String` | `CONFIG_SESSION_TIMEOUT` Configuration setting for how long a session will be available before it times out.
    `static long` | `DEFAULT_PER_GRAPH_CLOSE_TIMEOUT` Default amount of time to wait in milliseconds for each configured graph to close any open transactions when the session is killed.
    `static long` | `DEFAULT_SESSION_TIMEOUT` Default timeout for a session is eight hours.
    `static String` | `OP_PROCESSOR_NAME`
    `protected static ConcurrentHashMap<String,Session>` | `sessions` Script engines are evaluated in a per session context where imports/scripts are isolated per session.

    - ### Fields inherited from class org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor

      `CONFIG_MAX_PARAMETERS, DEFAULT_MAX_PARAMETERS, evalOpTimer, INVALID_BINDINGS_KEYS, maxParameters`

    - ### Fields inherited from class org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor

      `manageTransactions`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SessionOpProcessor()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected void` | `evalOp(Context context)`
    `protected Function<Context,AbstractEvalOpProcessor.BindingSupplier>` | `getBindingMaker(Session session)` A useful method for those extending this class, where the means for binding construction can be supplied to this class.
    `ThrowingConsumer<Context>` | `getEvalOp()` Provides an operation for evaluating a Gremlin script.
    `String` | `getName()` The name of the processor which requests must refer to "processor" field on a request.
    `protected static Session` | `getSession(Context context, RequestMessage msg)` Examines the `RequestMessage` and extracts the session token.
    `void` | `init(Settings settings)` Initialize the `OpProcessor` with settings from the server.
    `Optional<ThrowingConsumer<Context>>` | `selectOther(RequestMessage requestMessage)` Session based requests accept a "close" operator in addition to "eval".
    `protected Optional<ThrowingConsumer<Context>>` | `validateEvalMessage(RequestMessage message)`

    - ### Methods inherited from class org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor

      `evalOpInternal, evalOpInternal, select`

    - ### Methods inherited from class org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor

      `attemptCommit, attemptRollback, generateMetaData, generateResultMetaData, generateStatusAttributes, handleIterator, handleIterator, isForceFlushed, iterateComplete, makeFrame, makeFrame, makeFrame`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### OP_PROCESSOR_NAME

          public static final String OP_PROCESSOR_NAME

      See Also:
        Constant Field Values

    - #### sessions

          protected static ConcurrentHashMap<String,Session> sessions

      Script engines are evaluated in a per session context where imports/scripts are isolated per session.

    - #### CONFIG_SESSION_TIMEOUT

          public static final String CONFIG_SESSION_TIMEOUT

      Configuration setting for how long a session will be available before it times out.
      See Also:
        Constant Field Values

    - #### CONFIG_PER_GRAPH_CLOSE_TIMEOUT

          public static final String CONFIG_PER_GRAPH_CLOSE_TIMEOUT

      Configuration setting for how long to wait in milliseconds for each configured graph to close any open transactions when the session is killed.
      See Also:
        Constant Field Values

    - #### CONFIG_GLOBAL_FUNCTION_CACHE_ENABLED

          public static final String CONFIG_GLOBAL_FUNCTION_CACHE_ENABLED

      Configuration setting that behaves as an override to the global script engine setting of the same name that is provided to the `GroovyCompilerGremlinPlugin`.
      See Also:
        Constant Field Values

    - #### DEFAULT_SESSION_TIMEOUT

          public static final long DEFAULT_SESSION_TIMEOUT

      Default timeout for a session is eight hours.
      See Also:
        Constant Field Values

    - #### DEFAULT_PER_GRAPH_CLOSE_TIMEOUT

          public static final long DEFAULT_PER_GRAPH_CLOSE_TIMEOUT

      Default amount of time to wait in milliseconds for each configured graph to close any open transactions when the session is killed.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SessionOpProcessor

          public SessionOpProcessor()

  - ### Method Detail

    - #### getName

          public String getName()

      Description copied from interface: `OpProcessor`
      The name of the processor which requests must refer to "processor" field on a request.

    - #### init

          public void init(Settings settings)

      Description copied from interface: `OpProcessor`
      Initialize the `OpProcessor` with settings from the server. This method should only be called once at server startup by a single thread.

    - #### selectOther

          public Optional<ThrowingConsumer<Context>> selectOther(RequestMessage requestMessage)
                                                          throws OpProcessorException

      Session based requests accept a "close" operator in addition to "eval". A close will trigger the session to be killed and any uncommitted transaction to be rolled-back.
      Specified by:
        `selectOther` in class `AbstractEvalOpProcessor`
      Returns:
      Throws:
        `OpProcessorException`

    - #### getEvalOp

          public ThrowingConsumer<Context> getEvalOp()

      Description copied from class: `AbstractEvalOpProcessor`
      Provides an operation for evaluating a Gremlin script.
      Specified by:
        `getEvalOp` in class `AbstractEvalOpProcessor`
      Returns:

    - #### validateEvalMessage

          protected Optional<ThrowingConsumer<Context>> validateEvalMessage(RequestMessage message)
                                                                     throws OpProcessorException

      Overrides:
        `validateEvalMessage` in class `AbstractEvalOpProcessor`
      Throws:
        `OpProcessorException`

    - #### close

          public void close()
                     throws Exception

      Throws:
        `Exception`

    - #### evalOp

          protected void evalOp(Context context)
                         throws OpProcessorException

      Throws:
        `OpProcessorException`

    - #### getSession

          protected static Session getSession(Context context,
                                              RequestMessage msg)

      Examines the `RequestMessage` and extracts the session token. The session is then either found or a new one is created.

    - #### getBindingMaker

          protected Function<Context,AbstractEvalOpProcessor.BindingSupplier> getBindingMaker(Session session)

      A useful method for those extending this class, where the means for binding construction can be supplied to this class. This function is used in `evalOp(Context)` to create the final argument to `AbstractEvalOpProcessor.evalOpInternal(Context, Supplier, BindingSupplier)`. In this way an extending class can use the default `AbstractEvalOpProcessor.BindingSupplier` which carries a lot of re-usable functionality or provide a new one to override the existing approach.

Copyright © 2013–2019 Apache Software Foundation. All rights reserved.