Class Context

  • Direct Known Subclasses:
    SessionTask

    public class Context
    extends Object
    The context of Gremlin Server within which a particular request is made.
    Author:
    Stephen Mallette (http://stephen.genoprime.com)
    • Method Detail

      • getRequestTimeout

        public long getRequestTimeout()
        The timeout for the request. If the request is a script it examines the script for a timeout setting using with(). If that is not found then it examines the request itself to see if the timeout is provided by Tokens.ARGS_EVAL_TIMEOUT. If that is not provided then the Settings.evaluationTimeout is utilized as the default.
      • isFinalResponseWritten

        public boolean isFinalResponseWritten()
      • getGremlinArgument

        public Object getGremlinArgument()
      • getRequestMessage

        public RequestMessage getRequestMessage()
        Gets the current request to Gremlin Server.
      • getChannelHandlerContext

        public io.netty.channel.ChannelHandlerContext getChannelHandlerContext()
        Gets the Netty context.
      • getSettings

        public Settings getSettings()
        Gets the current configuration of Gremlin Server.
      • getGraphManager

        public GraphManager getGraphManager()
        Gets the set of Graph objects configured in Gremlin Server.
      • getGremlinExecutor

        public GremlinExecutor getGremlinExecutor()
        Gets the executor chosen to evaluate incoming Gremlin scripts based on the request.
      • getUserAgent

        public String getUserAgent()
        Returns the user agent (if any) which was sent from the client during the web socket handshake. Returns empty string if no user agent exists
      • getStartedResponse

        public boolean getStartedResponse()
        Gets whether the server has started processing the response for this request.
      • setStartedResponse

        public void setStartedResponse()
        Signal that the server has started processing the response.
      • sendTimeoutResponse

        public void sendTimeoutResponse()
        Writes a default timeout error response message to the underlying channel.
      • sendTimeoutResponse

        public void sendTimeoutResponse​(String message)
        Writes a specific timeout error response message to the underlying channel.
      • writeAndFlush

        public void writeAndFlush​(ResponseMessage message)
        Writes a response message to the underlying channel while ensuring that at most one final response is written.

        Note: this method should be used instead of writing to the channel directly when multiple threads are expected to produce response messages concurrently.

        Attempts to write more than one final response message will be ignored.

        See Also:
        writeAndFlush(ResponseStatusCode, Object)
      • writeAndFlush

        public void writeAndFlush​(ResponseStatusCode code,
                                  Object responseMessage)
        Writes a response message to the underlying channel while ensuring that at most one final response is written.

        The caller must make sure that the provided response status code matches the content of the message.

        Note: this method should be used instead of writing to the channel directly when multiple threads are expected to produce response messages concurrently.

        Attempts to write more than one final response message will be ignored.

        See Also:
        writeAndFlush(ResponseMessage)
      • flush

        public void flush()
        Flushes messages to the underlying transport.