public class MultiTaskSession extends AbstractSession
Session
implementation 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 first SessionTask
to execute is supplied on the constructor and additional ones may be added as they arrive with
submitTask(SessionTask)
where they will be added to a queue where they will await execution in the thread
bound to this session.AbstractSession.CloseReason
Modifier and Type | Field and Description |
---|---|
protected BlockingQueue<SessionTask> |
queue |
aliasesUsedBySession, closeReason, graphManager, maintainStateAfterException, sessions, sessionThread
evalOpTimer, traversalOpTimer
Constructor and Description |
---|
MultiTaskSession(SessionTask initialSessionTask,
String sessionId,
ConcurrentMap<String,Session> sessions)
Creates a new
MultiTaskSession object providing the initial starting SessionTask that gets
executed by the session when it starts. |
Modifier and Type | Method and Description |
---|---|
void |
close()
This method stops incoming requests from being added to the session queue.
|
GremlinScriptEngine |
getScriptEngine(SessionTask sessionTask,
String language)
Gets the script engine specific to this session which is dependent on the
Settings.useCommonEngineForSessions configuration. |
protected Bindings |
getWorkerBindings() |
protected GremlinExecutor |
initializeGremlinExecutor(SessionTask sessionTask) |
boolean |
isAcceptingTasks()
Determines if this session can accept additional tasks or not.
|
void |
run() |
boolean |
submitTask(SessionTask sessionTask)
Adds a task for session to complete.
|
String |
toString() |
cancel, closeTransaction, closeTransaction, closeTransactionSafely, closeTransactionSafely, determineIfTemporaryException, fromBytecode, fromScript, generateResponseMetaData, generateStatusAttributes, getActualTimeoutLengthWhenClosed, getCloseReason, getSessionId, handleException, handleGraphOperation, handleIterator, isBoundTo, isTransactionManaged, iterateComplete, makeFrame, mergeBindingsFromRequest, process, setSessionCancelFuture, setSessionFuture, startTransaction, triggerTimeout
protected final BlockingQueue<SessionTask> queue
public MultiTaskSession(SessionTask initialSessionTask, String sessionId, ConcurrentMap<String,Session> sessions)
MultiTaskSession
object providing the initial starting SessionTask
that gets
executed by the session when it starts.initialSessionTask
- The tasks that starts the session.sessionId
- The id of the sessionsessions
- The session id to Session
instances mappingpublic GremlinScriptEngine getScriptEngine(SessionTask sessionTask, String language)
Settings.useCommonEngineForSessions
configuration.getScriptEngine
in class AbstractSession
public boolean isAcceptingTasks()
Session
public boolean submitTask(SessionTask sessionTask) throws RejectedExecutionException
Session
RejectedExecutionException
- if the task cannot be queuedpublic void run()
public void close()
super#close()
which will then interrupt this run()
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.close
in interface AutoCloseable
close
in class AbstractSession
protected Bindings getWorkerBindings() throws SessionException
getWorkerBindings
in class AbstractSession
SessionException
protected GremlinExecutor initializeGremlinExecutor(SessionTask sessionTask)
Copyright © 2013–2021 Apache Software Foundation. All rights reserved.