public interface JanusGraphManagement extends JanusGraphConfiguration, SchemaManager
JanusGraphTransaction
and therefore copies many of its methods as they relate to schema inspection
and definition.
JanusGraphManagement behaves like a transaction in that it opens a transactional scope for reading the schema and making
changes to it. As such, it needs to be explicitly closed via its commit()
or rollback()
methods.
A JanusGraphManagement transaction is opened on a graph via JanusGraph.openManagement()
.
JanusGraphManagement provides methods to:
Modifier and Type | Interface and Description |
---|---|
static interface |
JanusGraphManagement.IndexBuilder
Builder for
JanusGraphIndex . |
Modifier and Type | Method and Description |
---|---|
void |
addIndexKey(JanusGraphIndex index,
PropertyKey key,
Parameter... parameters) |
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
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 |
containsGraphIndex(String name)
Whether the graph has a graph index defined with the given name.
|
boolean |
containsRelationIndex(RelationType type,
String name)
Whether a
RelationTypeIndex with the given name has been defined for the provided RelationType |
void |
forceCloseInstance(String instanceId)
Forcefully removes a JanusGraph instance from this graph cluster as identified by its name.
|
ConsistencyModifier |
getConsistency(JanusGraphSchemaElement element)
Retrieves the consistency modifier for the given
JanusGraphSchemaElement . |
JanusGraphIndex |
getGraphIndex(String name)
Returns the graph index with the given name or null if it does not exist
|
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
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.
|
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)
|
<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). |
Duration |
getTTL(JanusGraphSchemaType type)
Retrieves the time-to-live for the given
JanusGraphSchemaType as a Duration . |
Iterable<VertexLabel> |
getVertexLabels()
Returns an
Iterable over all defined VertexLabel s. |
boolean |
isOpen()
Whether this management transaction is open or has been closed (i.e.
|
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.
|
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.
|
void |
setConsistency(JanusGraphSchemaElement element,
ConsistencyModifier consistency)
Sets the consistency modifier for the given
JanusGraphSchemaElement . |
void |
setTTL(JanusGraphSchemaType type,
Duration duration)
Sets the time-to-live for the given
JanusGraphSchemaType . |
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). |
get, remove, set
addConnection, addProperties, addProperties, makeEdgeLabel, makePropertyKey, makeVertexLabel
containsEdgeLabel, containsPropertyKey, containsRelationType, containsVertexLabel, getEdgeLabel, getOrCreateEdgeLabel, getOrCreatePropertyKey, getOrCreatePropertyKey, getOrCreatePropertyKey, getOrCreateVertexLabel, getPropertyKey, getRelationType, getVertexLabel
RelationTypeIndex buildEdgeIndex(EdgeLabel label, String name, org.apache.tinkerpop.gremlin.structure.Direction direction, PropertyKey... sortKeys)
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
.label
- name
- direction
- sortKeys
- RelationTypeIndex
RelationTypeIndex buildEdgeIndex(EdgeLabel label, String name, org.apache.tinkerpop.gremlin.structure.Direction direction, org.apache.tinkerpop.gremlin.process.traversal.Order sortOrder, PropertyKey... sortKeys)
RelationTypeIndex
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.
label
- name
- direction
- sortOrder
- sortKeys
- RelationTypeIndex
RelationTypeIndex buildPropertyIndex(PropertyKey key, String name, PropertyKey... sortKeys)
buildPropertyIndex(org.janusgraph.core.PropertyKey, String, org.apache.tinkerpop.gremlin.process.traversal.Order, org.janusgraph.core.PropertyKey...)
with default sort order Order.asc
.key
- name
- sortKeys
- RelationTypeIndex
RelationTypeIndex buildPropertyIndex(PropertyKey key, String name, org.apache.tinkerpop.gremlin.process.traversal.Order sortOrder, PropertyKey... sortKeys)
RelationTypeIndex
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.
key
- name
- sortOrder
- sortKeys
- RelationTypeIndex
boolean containsRelationIndex(RelationType type, String name)
RelationTypeIndex
with the given name has been defined for the provided RelationType
type
- name
- RelationTypeIndex getRelationIndex(RelationType type, String name)
RelationTypeIndex
with the given name for the provided RelationType
or null
if it does not existtype
- name
- Iterable<RelationTypeIndex> getRelationIndexes(RelationType type)
type
- boolean containsGraphIndex(String name)
name
- JanusGraphIndex getGraphIndex(String name)
name
- Iterable<JanusGraphIndex> getGraphIndexes(Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementType)
elementType
- JanusGraphSchemaType getIndexOnlyConstraint(String indexName)
indexName
- IllegalArgumentException
- if there is no index with given nameJanusGraphManagement.IndexBuilder buildIndex(String indexName, Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementType)
JanusGraphManagement.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.indexName
- elementType
- void addIndexKey(JanusGraphIndex index, PropertyKey key, Parameter... parameters)
ConsistencyModifier getConsistency(JanusGraphSchemaElement element)
JanusGraphSchemaElement
. If none has been explicitly
defined, ConsistencyModifier.DEFAULT
is returned.element
- void setConsistency(JanusGraphSchemaElement element, ConsistencyModifier consistency)
JanusGraphSchemaElement
. Note, that only RelationType
s
and composite graph indexes allow changing of the consistency level.element
- consistency
- Duration getTTL(JanusGraphSchemaType type)
JanusGraphSchemaType
as a Duration
.
If no TTL has been defined, the returned Duration will be zero-length ("lives forever").type
- void setTTL(JanusGraphSchemaType type, Duration duration)
JanusGraphSchemaType
. The most granular time unit used for TTL values
is seconds. Any argument will be rounded to seconds if it is more granular than that.
The ttl
must be non-negative. When ttl
is zero, any existing TTL on type
is removed
("lives forever"). Positive ttl
values are interpreted literally.type
- the affected typeduration
- time-to-liveScanJobFuture removeGhostVertices()
ScanJobFuture removeGhostVertices(int numOfThreads)
void changeName(JanusGraphSchemaElement element, String newName)
JanusGraphSchemaElement
to the provided new name.
The new name must be valid and not already in use, otherwise an IllegalArgumentException
is thrown.element
- newName
- ScanJobFuture updateIndex(Index index, SchemaAction updateAction)
SchemaAction
.
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.index
- updateAction
- ScanJobFuture updateIndex(Index index, SchemaAction updateAction, int numOfThreads)
SchemaAction
, using
given number of threads if applicable (REINDEX and DISCARD_INDEX).index
- updateAction
- numOfThreads
- ScanJobFuture getIndexJobStatus(Index index)
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.index
- Set<String> getOpenInstances()
void forceCloseInstance(String instanceId)
This 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.
instanceId
- <T extends RelationType> Iterable<T> getRelationTypes(Class<T> clazz)
EdgeLabel
which returns all labels,
PropertyKey
which returns all keys, or RelationType
which returns all types).T
- clazz
- RelationType
or sub-interfaceIterable<VertexLabel> getVertexLabels()
Iterable
over all defined VertexLabel
s.boolean isOpen()
void commit()
JanusGraphTransaction.commit()
void rollback()
JanusGraphTransaction.rollback()
String printSchema()
String printVertexLabels()
String printEdgeLabels()
String printPropertyKeys()
String printIndexes()
Copyright © 2012–2024. All rights reserved.