Interface GraphManager
-
- All Known Implementing Classes:
CheckedGraphManager
,DefaultGraphManager
public interface GraphManager
TheGraphManager
interface allows for reference tracking of Graph references through aMap<String, Graph>
; the interface plugs into the lifeline of gremlin script executions, meaning that commit() and rollback() will be called on all graphs stored in the graph reference tracker at the end of the script executions; you may want to implement this interface if you want to define a custom graph instantiation/closing mechanism; note that the interface also defines similar features forTraversalSource
objects.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
beforeQueryStart(RequestMessage msg)
This method will be called before a script or query is processed by the gremlin-server.void
commit(Set<String> graphSourceNamesToCloseTxOn)
Selectively commit transactions on the specified graphs or the graphs of traversal sources.void
commitAll()
Commit transactions across allGraph
objects.Bindings
getAsBindings()
Get theGraph
andTraversalSource
list as a set of bindings.Graph
getGraph(String graphName)
GetGraph
instance whose name matchesgraphName
.Set<String>
getGraphNames()
TraversalSource
getTraversalSource(String traversalSourceName)
GetTraversalSource
instance whose name matchestraversalSourceName
Set<String>
getTraversalSourceNames()
Get aSet
of the names of the the storedTraversalSource
instances.default boolean
hasAnyOpenTransactions()
Determines if anyGraph
instances that support transactions have open transactions.default void
onQueryError(RequestMessage msg, Throwable error)
This method will be called before a script or query is processed by the gremlin-server.default void
onQuerySuccess(RequestMessage msg)
When a script or query successfully completes this method will be called.Graph
openGraph(String graphName, Function<String,Graph> supplier)
Implementation that allows for custom graph-opening implementations; if theMap
tracking graph references has aGraph
object corresponding to the graph name, then we return thatGraph
-- otherwise, we use the customFunction
to instantiate a newGraph
, add it to theMap
tracking graph references, and return saidGraph
.void
putGraph(String graphName, Graph g)
Add or update the specifiedGraph
with the specified name toMap<String, Graph>
.void
putTraversalSource(String tsName, TraversalSource ts)
Add or update the specifiedTraversalSource
with the specified name.Graph
removeGraph(String graphName)
Implementation that allows for custom graph closing implementations; this method should remove theGraph
from theGraphManager
.TraversalSource
removeTraversalSource(String tsName)
RemoveTraversalSource
by name.void
rollback(Set<String> graphSourceNamesToCloseTxOn)
Selectively rollback transactions on the specified graphs or the graphs of traversal sources.void
rollbackAll()
Rollback transactions across allGraph
objects.
-
-
-
Method Detail
-
getGraph
Graph getGraph(String graphName)
GetGraph
instance whose name matchesgraphName
.- Returns:
Graph
if exists, else null
-
putGraph
void putGraph(String graphName, Graph g)
Add or update the specifiedGraph
with the specified name toMap<String, Graph>
.
-
getTraversalSourceNames
Set<String> getTraversalSourceNames()
Get aSet
of the names of the the storedTraversalSource
instances.
-
getTraversalSource
TraversalSource getTraversalSource(String traversalSourceName)
GetTraversalSource
instance whose name matchestraversalSourceName
- Returns:
TraversalSource
if exists, else null
-
putTraversalSource
void putTraversalSource(String tsName, TraversalSource ts)
Add or update the specifiedTraversalSource
with the specified name.
-
removeTraversalSource
TraversalSource removeTraversalSource(String tsName)
RemoveTraversalSource
by name.
-
getAsBindings
Bindings getAsBindings()
Get theGraph
andTraversalSource
list as a set of bindings.
-
rollbackAll
void rollbackAll()
Rollback transactions across allGraph
objects.
-
rollback
void rollback(Set<String> graphSourceNamesToCloseTxOn)
Selectively rollback transactions on the specified graphs or the graphs of traversal sources.
-
commitAll
void commitAll()
Commit transactions across allGraph
objects.
-
commit
void commit(Set<String> graphSourceNamesToCloseTxOn)
Selectively commit transactions on the specified graphs or the graphs of traversal sources.
-
openGraph
Graph openGraph(String graphName, Function<String,Graph> supplier)
Implementation that allows for custom graph-opening implementations; if theMap
tracking graph references has aGraph
object corresponding to the graph name, then we return thatGraph
-- otherwise, we use the customFunction
to instantiate a newGraph
, add it to theMap
tracking graph references, and return saidGraph
.
-
removeGraph
Graph removeGraph(String graphName) throws Exception
Implementation that allows for custom graph closing implementations; this method should remove theGraph
from theGraphManager
.- Throws:
Exception
-
hasAnyOpenTransactions
default boolean hasAnyOpenTransactions()
Determines if anyGraph
instances that support transactions have open transactions.
-
beforeQueryStart
default void beforeQueryStart(RequestMessage msg)
This method will be called before a script or query is processed by the gremlin-server.- Parameters:
msg
- theRequestMessage
received by the gremlin-server.
-
onQueryError
default void onQueryError(RequestMessage msg, Throwable error)
This method will be called before a script or query is processed by the gremlin-server.- Parameters:
msg
- theRequestMessage
received by the gremlin-server.error
- the exception encountered during processing from the gremlin-server.
-
onQuerySuccess
default void onQuerySuccess(RequestMessage msg)
When a script or query successfully completes this method will be called.- Parameters:
msg
- theRequestMessage
received by the gremlin-server.
-
-