public class DefaultGraphManager extends Object implements GraphManager
Graph
and TraversalSource
instances configured for the server to be passed to script
engine bindings. The Graph
instances are read from the Settings
for Gremlin Server as defined in
the configuration file. The TraversalSource
instances are rebound to the GraphManager
once
initialization scripts construct them.Constructor and Description |
---|
DefaultGraphManager(Settings settings)
Create a new instance using the
Settings from Gremlin Server. |
Modifier and Type | Method and Description |
---|---|
protected void |
addGraph(String name,
String configurationFile) |
void |
commit(Set<String> graphSourceNamesToCloseTxOn)
Selectively commit transactions on the specified graphs or the graphs of traversal sources.
|
void |
commitAll()
Commit transactions across all
Graph objects. |
Bindings |
getAsBindings()
Get the
Graph and TraversalSource list as a set of bindings. |
Graph |
getGraph(String graphName)
Get
Graph instance whose name matches graphName . |
Set<String> |
getGraphNames()
|
TraversalSource |
getTraversalSource(String traversalSourceName)
Get
TraversalSource instance whose name matches traversalSourceName |
Set<String> |
getTraversalSourceNames()
Get a
Set of the names of the the stored TraversalSource instances. |
Graph |
openGraph(String graphName,
Function<String,Graph> supplier)
Implementation that allows for custom graph-opening implementations; if the
Map
tracking graph references has a Graph object corresponding to the graph name, then we return that
Graph -- otherwise, we use the custom Function to instantiate a new Graph , add it to
the Map tracking graph references, and return said Graph . |
void |
putGraph(String graphName,
Graph g)
Add or update the specified
Graph with the specified name to Map<String, Graph> . |
void |
putTraversalSource(String tsName,
TraversalSource ts)
Add or update the specified
TraversalSource with the specified name. |
Graph |
removeGraph(String graphName)
Implementation that allows for custom graph closing implementations; this method should remove the
Graph
from the GraphManager . |
TraversalSource |
removeTraversalSource(String tsName)
Remove
TraversalSource 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 all
Graph objects. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hasAnyOpenTransactions
public final Set<String> getGraphNames()
GraphManager
getGraphNames
in interface GraphManager
public final Graph getGraph(String graphName)
GraphManager
Graph
instance whose name matches graphName
.getGraph
in interface GraphManager
Graph
if exists, else nullpublic final void putGraph(String graphName, Graph g)
GraphManager
Graph
with the specified name to Map<String, Graph>
.putGraph
in interface GraphManager
public final Set<String> getTraversalSourceNames()
GraphManager
Set
of the names of the the stored TraversalSource
instances.getTraversalSourceNames
in interface GraphManager
public final TraversalSource getTraversalSource(String traversalSourceName)
GraphManager
TraversalSource
instance whose name matches traversalSourceName
getTraversalSource
in interface GraphManager
TraversalSource
if exists, else nullpublic final void putTraversalSource(String tsName, TraversalSource ts)
GraphManager
TraversalSource
with the specified name.putTraversalSource
in interface GraphManager
public final TraversalSource removeTraversalSource(String tsName)
GraphManager
TraversalSource
by name.removeTraversalSource
in interface GraphManager
public final Bindings getAsBindings()
Graph
and TraversalSource
list as a set of bindings.getAsBindings
in interface GraphManager
public final void rollbackAll()
Graph
objects.rollbackAll
in interface GraphManager
public final void rollback(Set<String> graphSourceNamesToCloseTxOn)
rollback
in interface GraphManager
public final void commitAll()
Graph
objects.commitAll
in interface GraphManager
public final void commit(Set<String> graphSourceNamesToCloseTxOn)
commit
in interface GraphManager
public final Graph openGraph(String graphName, Function<String,Graph> supplier)
Map
tracking graph references has a Graph
object corresponding to the graph name, then we return that
Graph
-- otherwise, we use the custom Function
to instantiate a new Graph
, add it to
the Map
tracking graph references, and return said Graph
.openGraph
in interface GraphManager
public final Graph removeGraph(String graphName) throws Exception
Graph
from the GraphManager
.removeGraph
in interface GraphManager
Exception
Copyright © 2013–2022 Apache Software Foundation. All rights reserved.