public class ManagementSystem extends Object implements JanusGraphManagement
| Modifier and Type | Class and Description |
|---|---|
static class |
ManagementSystem.IndexJobStatus |
| Modifier and Type | Field and Description |
|---|---|
static String |
CURRENT_INSTANCE_SUFFIX |
| Constructor and Description |
|---|
ManagementSystem(StandardJanusGraph graph,
KCVSConfiguration config,
Log sysLog,
ManagementLogger managementLogger,
SchemaCache schemaCache) |
| Modifier and Type | Method and Description |
|---|---|
EdgeLabel |
addConnection(EdgeLabel edgeLabel,
VertexLabel outVLabel,
VertexLabel inVLabel)
Add a constraint on which vertices the given edge label can connect.
|
void |
addIndexKey(JanusGraphIndex index,
PropertyKey key,
Parameter... parameters) |
EdgeLabel |
addProperties(EdgeLabel edgeLabel,
PropertyKey... keys)
Add property constraints for a given edge label.
|
VertexLabel |
addProperties(VertexLabel vertexLabel,
PropertyKey... keys)
Add property constraints for a given vertex label.
|
static GraphIndexStatusWatcher |
awaitGraphIndexStatus(JanusGraph g,
String graphIndexName)
|
static RelationIndexStatusWatcher |
awaitRelationIndexStatus(JanusGraph g,
String relationIndexName,
String relationTypeName)
Returns a
RelationIndexStatusWatcher configured to watch the index specified by
relationIndexName and relationIndexType through graph g. |
RelationTypeIndex |
buildEdgeIndex(EdgeLabel label,
String name,
org.apache.tinkerpop.gremlin.structure.Direction direction,
org.apache.tinkerpop.gremlin.process.traversal.Order sortOrder,
PropertyKey... sortKeys)
Creates a
RelationTypeIndex for the provided edge label. |
RelationTypeIndex |
buildEdgeIndex(EdgeLabel label,
String name,
org.apache.tinkerpop.gremlin.structure.Direction direction,
PropertyKey... sortKeys)
|
JanusGraphManagement.IndexBuilder |
buildIndex(String indexName,
Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementType)
Returns an
JanusGraphManagement.IndexBuilder to add a graph index to this JanusGraph graph. |
RelationTypeIndex |
buildPropertyIndex(PropertyKey key,
String name,
org.apache.tinkerpop.gremlin.process.traversal.Order sortOrder,
PropertyKey... sortKeys)
Creates a
RelationTypeIndex for the provided property key. |
RelationTypeIndex |
buildPropertyIndex(PropertyKey key,
String name,
PropertyKey... sortKeys)
Identical to
JanusGraphManagement.buildPropertyIndex(org.janusgraph.core.PropertyKey, String, org.apache.tinkerpop.gremlin.process.traversal.Order, org.janusgraph.core.PropertyKey...)
with default sort order Order.asc. |
void |
changeName(JanusGraphSchemaElement element,
String newName)
Changes the name of a
JanusGraphSchemaElement to the provided new name. |
void |
commit()
Commits this management transaction and persists all schema changes.
|
boolean |
containsEdgeLabel(String name)
Checks whether an edge label of the given name has been defined in the JanusGraph schema.
|
boolean |
containsGraphIndex(String name)
Whether the graph has a graph index defined with the given name.
|
boolean |
containsPropertyKey(String name)
Checks whether a property key of the given name has been defined in the JanusGraph schema.
|
boolean |
containsRelationIndex(RelationType type,
String name)
Whether a
RelationTypeIndex with the given name has been defined for the provided RelationType |
boolean |
containsRelationType(String name)
Checks whether a type with the specified name exists.
|
boolean |
containsVertexLabel(String name)
Whether a vertex label with the given name exists in the graph.
|
void |
evictGraphFromCache()
Upon the open managementsystem's commit, this graph will be asynchronously evicted from the cache on all JanusGraph nodes in your
cluster, once there are no open transactions on this graph on each respective JanusGraph node
and assuming each node is correctly configured to use the
JanusGraphManager. |
void |
evictGraphFromCache(Callable<Boolean> trigger)
Upon the open managementsystem's commit, this graph will be asynchronously evicted from the cache on all JanusGraph nodes in your
cluster, once there are no open transactions on this graph on each respective JanusGraph node
and assuming each node is correctly configured to use the
JanusGraphManager. |
void |
forceCloseInstance(String instanceId)
Forcefully removes a JanusGraph instance from this graph cluster as identified by its name.
|
String |
get(String path)
Returns a string representation of the provided configuration option or namespace for inspection.
|
ConsistencyModifier |
getConsistency(JanusGraphSchemaElement element)
Retrieves the consistency level for a schema element (types and internal indexes)
|
EdgeLabel |
getEdgeLabel(String name)
Returns the edge label with the given name.
|
JanusGraphIndex |
getGraphIndex(String name)
Returns the graph index with the given name or null if it does not exist
|
static IndexType |
getGraphIndexDirect(String name,
StandardJanusGraphTx transaction) |
Iterable<JanusGraphIndex> |
getGraphIndexes(Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementType)
Returns all graph indexes that index the given element type.
|
ScanJobFuture |
getIndexJobStatus(Index index)
If an index update job was triggered through
JanusGraphManagement.updateIndex(Index, SchemaAction) with schema actions
SchemaAction.REINDEX or SchemaAction.DISCARD_INDEX
then this method can be used to track the status of this asynchronous process. |
JanusGraphSchemaType |
getIndexOnlyConstraint(String indexName)
Returns the indexOnly constraint for the index with given name or null if such constraint does not exist
|
Set<String> |
getOpenInstances()
Returns a set of unique instance ids for all JanusGraph instances that are currently
part of this graph cluster.
|
Set<String> |
getOpenInstancesInternal() |
EdgeLabel |
getOrCreateEdgeLabel(String name)
Returns the edge label with the given name.
|
PropertyKey |
getOrCreatePropertyKey(String name)
Returns the property key with the given name.
|
VertexLabel |
getOrCreateVertexLabel(String name)
Returns the vertex label with the given name.
|
PropertyKey |
getPropertyKey(String name)
Returns the property key with the given name.
|
RelationTypeIndex |
getRelationIndex(RelationType type,
String name)
Returns the
RelationTypeIndex with the given name for the provided RelationType or null
if it does not exist |
Iterable<RelationTypeIndex> |
getRelationIndexes(RelationType type)
|
RelationType |
getRelationType(String name)
Returns the type with the given name.
|
<T extends RelationType> |
getRelationTypes(Class<T> clazz)
Returns an iterable over all defined types that have the given clazz (either
EdgeLabel which returns all labels,
PropertyKey which returns all keys, or RelationType which returns all types). |
JanusGraphSchemaElement |
getSchemaElement(long id) |
JanusGraphSchemaVertex |
getSchemaVertex(JanusGraphSchemaElement element) |
Duration |
getTTL(JanusGraphSchemaType type)
Retrieves the time-to-live for the given
JanusGraphSchemaType as a Duration. |
VertexLabel |
getVertexLabel(String name)
Returns the vertex label with the given name.
|
Iterable<VertexLabel> |
getVertexLabels()
Returns an
Iterable over all defined VertexLabels. |
StandardJanusGraphTx |
getWrappedTx() |
boolean |
isOpen()
Whether this management transaction is open or has been closed (i.e.
|
EdgeLabelMaker |
makeEdgeLabel(String name)
Returns a
EdgeLabelMaker instance to define a new EdgeLabel with the given name. |
PropertyKeyMaker |
makePropertyKey(String name)
Returns a
PropertyKeyMaker instance to define a new PropertyKey with the given name. |
VertexLabelMaker |
makeVertexLabel(String name)
Returns a
VertexLabelMaker to define a new vertex label with the given name. |
String |
printEdgeLabels()
Prints out schema information related to edge labels.
|
String |
printIndexes()
Prints out schema information related to indexes
|
String |
printPropertyKeys()
Prints out schema information related to property keys.
|
String |
printSchema()
Prints out schema information related to vertex and edge labels, indexes, and property keys.
|
String |
printVertexLabels()
Prints out schema information related to vertex labels.
|
JanusGraphConfiguration |
remove(String path)
Remove the configuration option identified by the provided path.
|
ScanJobFuture |
removeGhostVertices()
Remove all ghost vertices (a.k.a.
|
ScanJobFuture |
removeGhostVertices(int numOfThreads)
Remove all ghost vertices (a.k.a.
|
void |
rollback()
Closes this management transaction and discards all changes.
|
JanusGraphConfiguration |
set(String path,
Object value)
Sets the configuration option identified by the provided path to the given value.
|
void |
setConsistency(JanusGraphSchemaElement element,
ConsistencyModifier consistency)
Sets the consistency level for those schema elements that support it (types and internal indexes)
|
void |
setTTL(JanusGraphSchemaType type,
Duration duration)
Sets time-to-live for those schema types that support it
|
ScanJobFuture |
updateIndex(Index index,
SchemaAction updateAction)
Updates the provided index according to the given
SchemaAction. |
ScanJobFuture |
updateIndex(Index index,
SchemaAction updateAction,
int numOfThreads)
Updates the provided index according to the given
SchemaAction, using
given number of threads if applicable (REINDEX and DISCARD_INDEX). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetOrCreatePropertyKey, getOrCreatePropertyKeypublic static final String CURRENT_INSTANCE_SUFFIX
public ManagementSystem(StandardJanusGraph graph, KCVSConfiguration config, Log sysLog, ManagementLogger managementLogger, SchemaCache schemaCache)
public Set<String> getOpenInstances()
JanusGraphManagementgetOpenInstances in interface JanusGraphManagementpublic void forceCloseInstance(String instanceId)
JanusGraphManagementThis method should be used with great care and only in cases where a JanusGraph instance has been abnormally terminated (i.e. killed instead of properly shut-down). If this happens, the instance will continue to be listed as an open instance which means that 1) a new instance with the same id cannot be started and 2) schema updates will fail because the killed instance cannot acknowledge the schema update.
Throws an exception if the instance is not part of this cluster or if the instance has been started after the start of this management transaction which is indicative of the instance having been restarted successfully.
forceCloseInstance in interface JanusGraphManagementpublic void commit()
JanusGraphManagementcommit in interface JanusGraphManagementJanusGraphTransaction.commit()public void rollback()
JanusGraphManagementrollback in interface JanusGraphManagementJanusGraphTransaction.rollback()public boolean isOpen()
JanusGraphManagementisOpen in interface JanusGraphManagementpublic StandardJanusGraphTx getWrappedTx()
public JanusGraphSchemaElement getSchemaElement(long id)
public RelationTypeIndex buildEdgeIndex(EdgeLabel label, String name, org.apache.tinkerpop.gremlin.structure.Direction direction, PropertyKey... sortKeys)
JanusGraphManagementJanusGraphManagement.buildEdgeIndex(org.janusgraph.core.EdgeLabel, String, org.apache.tinkerpop.gremlin.structure.Direction, org.apache.tinkerpop.gremlin.process.traversal.Order, org.janusgraph.core.PropertyKey...)
with default sort order Order.asc.buildEdgeIndex in interface JanusGraphManagementRelationTypeIndexpublic RelationTypeIndex buildEdgeIndex(EdgeLabel label, String name, org.apache.tinkerpop.gremlin.structure.Direction direction, org.apache.tinkerpop.gremlin.process.traversal.Order sortOrder, PropertyKey... sortKeys)
JanusGraphManagementRelationTypeIndex for the provided edge label. That means, that all edges of that label will be
indexed according to this index definition which will speed up certain vertex-centric queries.
An indexed is defined by its name, the direction in which the index should be created (can be restricted to one direction or both), the sort order and - most importantly - the sort keys which define the index key.
buildEdgeIndex in interface JanusGraphManagementRelationTypeIndexpublic RelationTypeIndex buildPropertyIndex(PropertyKey key, String name, PropertyKey... sortKeys)
JanusGraphManagementJanusGraphManagement.buildPropertyIndex(org.janusgraph.core.PropertyKey, String, org.apache.tinkerpop.gremlin.process.traversal.Order, org.janusgraph.core.PropertyKey...)
with default sort order Order.asc.buildPropertyIndex in interface JanusGraphManagementRelationTypeIndexpublic RelationTypeIndex buildPropertyIndex(PropertyKey key, String name, org.apache.tinkerpop.gremlin.process.traversal.Order sortOrder, PropertyKey... sortKeys)
JanusGraphManagementRelationTypeIndex for the provided property key. That means, that all properties of that key will be
indexed according to this index definition which will speed up certain vertex-centric queries.
An indexed is defined by its name, the sort order and - most importantly - the sort keys which define the index key.
buildPropertyIndex in interface JanusGraphManagementRelationTypeIndexpublic boolean containsRelationIndex(RelationType type, String name)
JanusGraphManagementRelationTypeIndex with the given name has been defined for the provided RelationTypecontainsRelationIndex in interface JanusGraphManagementpublic RelationTypeIndex getRelationIndex(RelationType type, String name)
JanusGraphManagementRelationTypeIndex with the given name for the provided RelationType or null
if it does not existgetRelationIndex in interface JanusGraphManagementpublic Iterable<RelationTypeIndex> getRelationIndexes(RelationType type)
JanusGraphManagementgetRelationIndexes in interface JanusGraphManagementpublic static IndexType getGraphIndexDirect(String name, StandardJanusGraphTx transaction)
public boolean containsGraphIndex(String name)
JanusGraphManagementcontainsGraphIndex in interface JanusGraphManagementpublic JanusGraphIndex getGraphIndex(String name)
JanusGraphManagementgetGraphIndex in interface JanusGraphManagementpublic Iterable<JanusGraphIndex> getGraphIndexes(Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementType)
JanusGraphManagementgetGraphIndexes in interface JanusGraphManagementpublic JanusGraphSchemaType getIndexOnlyConstraint(String indexName)
JanusGraphManagementgetIndexOnlyConstraint in interface JanusGraphManagementpublic String printSchema()
JanusGraphManagementprintSchema in interface JanusGraphManagementpublic String printVertexLabels()
JanusGraphManagementprintVertexLabels in interface JanusGraphManagementpublic String printEdgeLabels()
JanusGraphManagementprintEdgeLabels in interface JanusGraphManagementpublic String printPropertyKeys()
JanusGraphManagementprintPropertyKeys in interface JanusGraphManagementpublic String printIndexes()
JanusGraphManagementprintIndexes in interface JanusGraphManagementpublic static GraphIndexStatusWatcher awaitGraphIndexStatus(JanusGraph g, String graphIndexName)
GraphIndexStatusWatcher configured to watch
graphIndexName through graph g.
This method just instantiates an object.
Invoke GraphIndexStatusWatcher.call() to wait.
g - the graph through which to read index informationgraphIndexName - the name of a graph index to watchpublic static RelationIndexStatusWatcher awaitRelationIndexStatus(JanusGraph g, String relationIndexName, String relationTypeName)
RelationIndexStatusWatcher configured to watch the index specified by
relationIndexName and relationIndexType through graph g.
This method just instantiates an object.
Invoke RelationIndexStatusWatcher.call() to wait.
g - the graph through which to read index informationrelationIndexName - the name of the relation index to watchrelationTypeName - the type on the relation index to watchpublic void addIndexKey(JanusGraphIndex index, PropertyKey key, Parameter... parameters)
addIndexKey in interface JanusGraphManagementpublic JanusGraphManagement.IndexBuilder buildIndex(String indexName, Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementType)
JanusGraphManagementJanusGraphManagement.IndexBuilder to add a graph index to this JanusGraph graph. The index to-be-created
has the provided name and indexes elements of the given type.buildIndex in interface JanusGraphManagementpublic ScanJobFuture updateIndex(Index index, SchemaAction updateAction)
JanusGraphManagementSchemaAction.
If action is REINDEX or DISCARD_INDEX, then number of threads running the
action will be the number of available processors running on current JVM.updateIndex in interface JanusGraphManagementpublic ScanJobFuture updateIndex(Index index, SchemaAction updateAction, int numOfThreads)
JanusGraphManagementSchemaAction, using
given number of threads if applicable (REINDEX and DISCARD_INDEX).updateIndex in interface JanusGraphManagementpublic void evictGraphFromCache()
JanusGraphManager.public void evictGraphFromCache(Callable<Boolean> trigger)
JanusGraphManager.trigger - A Callable that will be called once the eviction is complete in the cluster. Return
boolean value indicating trigger status.public ScanJobFuture getIndexJobStatus(Index index)
JanusGraphManagementJanusGraphManagement.updateIndex(Index, SchemaAction) with schema actions
SchemaAction.REINDEX or SchemaAction.DISCARD_INDEX
then this method can be used to track the status of this asynchronous process.getIndexJobStatus in interface JanusGraphManagementpublic void changeName(JanusGraphSchemaElement element, String newName)
JanusGraphManagementJanusGraphSchemaElement to the provided new name.
The new name must be valid and not already in use, otherwise an IllegalArgumentException is thrown.changeName in interface JanusGraphManagementpublic JanusGraphSchemaVertex getSchemaVertex(JanusGraphSchemaElement element)
public ConsistencyModifier getConsistency(JanusGraphSchemaElement element)
getConsistency in interface JanusGraphManagementelement - public void setConsistency(JanusGraphSchemaElement element, ConsistencyModifier consistency)
Note, that it is possible to have a race condition here if two threads simultaneously try to change the consistency level. However, this is resolved when the consistency level is being read by taking the first one and deleting all existing attached consistency levels upon modification.
setConsistency in interface JanusGraphManagementelement - consistency - public Duration getTTL(JanusGraphSchemaType type)
JanusGraphManagementJanusGraphSchemaType as a Duration.
If no TTL has been defined, the returned Duration will be zero-length ("lives forever").getTTL in interface JanusGraphManagementpublic void setTTL(JanusGraphSchemaType type, Duration duration)
setTTL in interface JanusGraphManagementtype - duration - Note that only 'seconds' granularity is supportedpublic ScanJobFuture removeGhostVertices(int numOfThreads)
JanusGraphManagementremoveGhostVertices in interface JanusGraphManagementpublic ScanJobFuture removeGhostVertices()
JanusGraphManagementremoveGhostVertices in interface JanusGraphManagementpublic boolean containsRelationType(String name)
SchemaInspectorcontainsRelationType in interface SchemaInspectorname - name of the typepublic RelationType getRelationType(String name)
SchemaInspectorgetRelationType in interface SchemaInspectorname - name of the type to returnRelationTypepublic boolean containsPropertyKey(String name)
SchemaInspectorcontainsPropertyKey in interface SchemaInspectorname - name of the property keypublic PropertyKey getPropertyKey(String name)
SchemaInspectorgetPropertyKey in interface SchemaInspectorpublic boolean containsEdgeLabel(String name)
SchemaInspectorcontainsEdgeLabel in interface SchemaInspectorname - name of the edge labelpublic EdgeLabel getOrCreateEdgeLabel(String name)
SchemaInspectorgetOrCreateEdgeLabel in interface SchemaInspectorname - name of the edge label to returnEdgeLabelpublic PropertyKey getOrCreatePropertyKey(String name)
SchemaInspectorgetOrCreatePropertyKey in interface SchemaInspectorname - name of the property key to returnPropertyKeypublic EdgeLabel getEdgeLabel(String name)
SchemaInspectorgetEdgeLabel in interface SchemaInspectorpublic PropertyKeyMaker makePropertyKey(String name)
SchemaManagerPropertyKeyMaker instance to define a new PropertyKey with the given name.
By defining types explicitly (rather than implicitly through usage) one can control various
aspects of the key and associated consistency constraints.
The key constructed with this maker will be created in the context of this transaction.
makePropertyKey in interface SchemaManagerPropertyKeyMaker linked to this transaction.PropertyKeyMaker,
PropertyKeypublic EdgeLabelMaker makeEdgeLabel(String name)
SchemaManagerEdgeLabelMaker instance to define a new EdgeLabel with the given name.
By defining types explicitly (rather than implicitly through usage) one can control various
aspects of the label and associated consistency constraints.
The label constructed with this maker will be created in the context of this transaction.
makeEdgeLabel in interface SchemaManagerEdgeLabelMaker linked to this transaction.EdgeLabelMaker,
EdgeLabelpublic <T extends RelationType> Iterable<T> getRelationTypes(Class<T> clazz)
JanusGraphManagementEdgeLabel which returns all labels,
PropertyKey which returns all keys, or RelationType which returns all types).getRelationTypes in interface JanusGraphManagementclazz - RelationType or sub-interfacepublic boolean containsVertexLabel(String name)
SchemaInspectorcontainsVertexLabel in interface SchemaInspectorpublic VertexLabel getVertexLabel(String name)
SchemaInspectorgetVertexLabel in interface SchemaInspectorpublic VertexLabel getOrCreateVertexLabel(String name)
SchemaInspectorDefaultSchemaMaker.
Attempting to automatically create a vertex label might cause an exception depending on the configuration.
getOrCreateVertexLabel in interface SchemaInspectorpublic VertexLabelMaker makeVertexLabel(String name)
SchemaManagerVertexLabelMaker to define a new vertex label with the given name. Note, that the name must
be unique.makeVertexLabel in interface SchemaManagerpublic VertexLabel addProperties(VertexLabel vertexLabel, PropertyKey... keys)
SchemaManageraddProperties in interface SchemaManagervertexLabel - to which the constraints applies.keys - defines the properties which should be added to the VertexLabel as constraints.VertexLabel edited which contains the added constraints.public EdgeLabel addProperties(EdgeLabel edgeLabel, PropertyKey... keys)
SchemaManageraddProperties in interface SchemaManageredgeLabel - to which the constraints applies.keys - defines the properties which should be added to the EdgeLabel as constraints.EdgeLabel edited which contains the added constraints.public EdgeLabel addConnection(EdgeLabel edgeLabel, VertexLabel outVLabel, VertexLabel inVLabel)
SchemaManageraddConnection in interface SchemaManageredgeLabel - to which the constraint applies.outVLabel - specifies the outgoing vertex for this connection.inVLabel - specifies the incoming vertex for this connection.EdgeLabel edited which contains the added constraint.public Iterable<VertexLabel> getVertexLabels()
JanusGraphManagementIterable over all defined VertexLabels.getVertexLabels in interface JanusGraphManagementpublic String get(String path)
JanusGraphConfigurationAn exception is thrown if the path is invalid.
get in interface JanusGraphConfigurationpublic JanusGraphConfiguration set(String path, Object value)
JanusGraphConfigurationset in interface JanusGraphConfigurationpublic JanusGraphConfiguration remove(String path)
JanusGraphConfigurationremove in interface JanusGraphConfigurationCopyright © 2012–2023. All rights reserved.