Class MultiTaskSession
- java.lang.Object
- 
- org.apache.tinkerpop.gremlin.server.handler.AbstractSession
- 
- org.apache.tinkerpop.gremlin.server.handler.MultiTaskSession
 
 
- 
- All Implemented Interfaces:
- AutoCloseable,- Runnable,- Session
 
 public class MultiTaskSession extends AbstractSession ASessionimplementation that queues tasks given to it and executes them in a serial fashion within the same thread which thus allows multiple tasks to be executed in the same transaction. The firstSessionTaskto execute is supplied on the constructor and additional ones may be added as they arrive withsubmitTask(SessionTask)where they will be added to a queue where they will await execution in the thread bound to this session.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.apache.tinkerpop.gremlin.server.handler.AbstractSessionAbstractSession.CloseReason
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected BlockingQueue<SessionTask>queue- 
Fields inherited from class org.apache.tinkerpop.gremlin.server.handler.AbstractSessionaliasesUsedBySession, closeReason, graphManager, maintainStateAfterException, sessions, sessionTaskStarted, sessionThread
 - 
Fields inherited from interface org.apache.tinkerpop.gremlin.server.handler.SessionevalOpTimer, traversalOpTimer
 
- 
 - 
Constructor SummaryConstructors Constructor Description MultiTaskSession(SessionTask initialSessionTask, String sessionId, ConcurrentMap<String,Session> sessions)Creates a newMultiTaskSessionobject providing the initial startingSessionTaskthat gets executed by the session when it starts.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This method stops incoming requests from being added to the session queue.GremlinScriptEnginegetScriptEngine(SessionTask sessionTask, String language)Gets the script engine specific to this session which is dependent on theSettings.useCommonEngineForSessionsconfiguration.protected BindingsgetWorkerBindings()protected GremlinExecutorinitializeGremlinExecutor(SessionTask sessionTask)booleanisAcceptingTasks()Determines if this session can accept additional tasks or not.voidrun()voidsendTimeoutResponseForUncommencedTask()Respond to the client with the specific timeout response for this Session implementation.booleansubmitTask(SessionTask sessionTask)Adds a task for session to complete.StringtoString()- 
Methods inherited from class org.apache.tinkerpop.gremlin.server.handler.AbstractSessioncancel, closeTransaction, closeTransaction, closeTransactionSafely, closeTransactionSafely, determineIfSpecialException, fromBytecode, fromScript, generateResponseMetaData, generateStatusAttributes, getActualTimeoutLengthWhenClosed, getCloseReason, getSessionId, handleException, handleGraphOperation, handleIterator, isBoundTo, isTransactionManaged, iterateComplete, makeFrame, mergeBindingsFromRequest, process, setSessionCancelFuture, setSessionFuture, startTransaction, triggerTimeout
 
- 
 
- 
- 
- 
Field Detail- 
queueprotected final BlockingQueue<SessionTask> queue 
 
- 
 - 
Constructor Detail- 
MultiTaskSessionpublic MultiTaskSession(SessionTask initialSessionTask, String sessionId, ConcurrentMap<String,Session> sessions) Creates a newMultiTaskSessionobject providing the initial startingSessionTaskthat gets executed by the session when it starts.- Parameters:
- initialSessionTask- The tasks that starts the session.
- sessionId- The id of the session
- sessions- The session id to- Sessioninstances mapping
 
 
- 
 - 
Method Detail- 
getScriptEnginepublic GremlinScriptEngine getScriptEngine(SessionTask sessionTask, String language) Gets the script engine specific to this session which is dependent on theSettings.useCommonEngineForSessionsconfiguration.- Overrides:
- getScriptEnginein class- AbstractSession
 
 - 
isAcceptingTaskspublic boolean isAcceptingTasks() Description copied from interface:SessionDetermines if this session can accept additional tasks or not.
 - 
sendTimeoutResponseForUncommencedTaskpublic void sendTimeoutResponseForUncommencedTask() Description copied from class:AbstractSessionRespond to the client with the specific timeout response for this Session implementation. This is for situations where the Session hasn't started running.- Specified by:
- sendTimeoutResponseForUncommencedTaskin class- AbstractSession
 
 - 
submitTaskpublic boolean submitTask(SessionTask sessionTask) throws RejectedExecutionException Description copied from interface:SessionAdds a task for session to complete.- Throws:
- RejectedExecutionException- if the task cannot be queued
 
 - 
runpublic void run() 
 - 
closepublic void close() This method stops incoming requests from being added to the session queue. It then cancels the session lifetime timeout and then calls {@link super#close()} which will then interrupt thisrun()which will clear out remaining requests in the queue. This latter part of the close, where the interruption is concerned, is an asynchronous operation and will not block as it finishes its processing in the "gremlinPool" thread that was originally handling the work.- Specified by:
- closein interface- AutoCloseable
- Overrides:
- closein class- AbstractSession
 
 - 
getWorkerBindingsprotected Bindings getWorkerBindings() throws SessionException - Overrides:
- getWorkerBindingsin class- AbstractSession
- Throws:
- SessionException
 
 - 
initializeGremlinExecutorprotected GremlinExecutor initializeGremlinExecutor(SessionTask sessionTask) 
 
- 
 
-