com.tinkerpop.rexster.gremlin
Class GremlinSession

java.lang.Object
  extended by com.tinkerpop.rexster.gremlin.GremlinSession
All Implemented Interfaces:
Runnable

public class GremlinSession
extends Object
implements Runnable

A wrapper thread for a given gremlin instance. Webadmin spawns one of these threads for each client that uses the gremlin console.

Credit to Neo Technology (http://neotechnology.com/) for most of the code related to the Gremlin in Rexster. Specifically, this code was borrowed from https://github.com/neo4j/webadmin and re-purposed for Rexster's needs.

Original author Jacob Hansson


Field Summary
protected  BlockingQueue<GremlinEvaluationJob> jobQueue
          Commands waiting to be executed.
protected  Date lastTimeUsed
          Keep track of the last time this was used.
static int MAX_COMMANDS_WAITING
           
protected  Thread runner
          Mama thread.
protected  ScriptEngine scriptEngine
          The gremlin evaluator instance beeing wrapped.
protected  boolean sepukko
          Should I shut down?
 
Constructor Summary
GremlinSession(String graphName, RexsterApplication ra)
           
 
Method Summary
 void die()
           
 GremlinEvaluationJob evaluate(String script)
          Take some gremlin script, evaluate it in the context of this gremlin session, and return the result.
 long getIdleTime()
          Get the number of milliseconds this worker has been idle.
protected  Object performEvaluation(GremlinEvaluationJob job)
          Internal evaluate implementation.
 void reset()
          Destroy the internal gremlin evaluator and replace it with a clean slate.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_COMMANDS_WAITING

public static final int MAX_COMMANDS_WAITING
See Also:
Constant Field Values

lastTimeUsed

protected Date lastTimeUsed
Keep track of the last time this was used.


scriptEngine

protected ScriptEngine scriptEngine
The gremlin evaluator instance beeing wrapped.


jobQueue

protected BlockingQueue<GremlinEvaluationJob> jobQueue
Commands waiting to be executed. Number of waiting commands is capped, since this is meant to be used by a single client.


sepukko

protected boolean sepukko
Should I shut down?


runner

protected Thread runner
Mama thread.

Constructor Detail

GremlinSession

public GremlinSession(String graphName,
                      RexsterApplication ra)
Method Detail

run

public void run()
Specified by:
run in interface Runnable

evaluate

public GremlinEvaluationJob evaluate(String script)
Take some gremlin script, evaluate it in the context of this gremlin session, and return the result.

Parameters:
script -
Returns:

reset

public void reset()
Destroy the internal gremlin evaluator and replace it with a clean slate.


getIdleTime

public long getIdleTime()
Get the number of milliseconds this worker has been idle.


die

public void die()

performEvaluation

protected Object performEvaluation(GremlinEvaluationJob job)
Internal evaluate implementation. This actually interprets a gremlin statement.



Copyright © 2009-2012. All Rights Reserved.