本文整理了Java中org.janusgraph.core.JanusGraph.openManagement()
方法的一些代码示例,展示了JanusGraph.openManagement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JanusGraph.openManagement()
方法的具体详情如下:
包路径:org.janusgraph.core.JanusGraph
类名称:JanusGraph
方法名:openManagement
[英]Returns the management system for this graph instance. The management system provides functionality to change global configuration options, install indexes and inspect the graph schema.
The management system operates in its own transactional context which must be explicitly closed.
[中]返回此图形实例的管理系统。管理系统提供更改全局配置选项、安装索引和检查图形模式的功能。
管理系统在自己的事务上下文中运行,必须显式关闭。
代码示例来源:origin: JanusGraph/janusgraph
JanusGraphManagement management = null;
try {
management = g.openManagement();
idx = management.getGraphIndex(graphIndexName);
for (PropertyKey pk : idx.getFieldKeys()) {
代码示例来源:origin: JanusGraph/janusgraph
private static void removeGraphFromCache(final JanusGraph graph) {
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
Preconditions.checkState(jgm != null, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
jgm.removeGraph(((StandardJanusGraph) graph).getGraphName());
final ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
mgmt.evictGraphFromCache();
mgmt.commit();
}
代码示例来源:origin: JanusGraph/janusgraph
public Consumer<ScanMetrics> getIndexJobFinisher(final JanusGraph graph, final SchemaAction action) {
Preconditions.checkArgument((graph != null && action != null) || (graph == null && action == null));
return metrics -> {
try {
if (metrics.get(ScanMetrics.Metric.FAILURE) == 0) {
if (action != null) {
ManagementSystem management = (ManagementSystem) graph.openManagement();
try {
Index index = retrieve(management);
management.updateIndex(index, action);
} finally {
management.commit();
}
}
LOGGER.info("Index update job successful for [{}]", IndexIdentifier.this.toString());
} else {
LOGGER.error("Index update job unsuccessful for [{}]. Check logs", IndexIdentifier.this.toString());
}
} catch (Throwable e) {
LOGGER.error("Error encountered when updating index after job finished [" + IndexIdentifier.this.toString() + "]: ", e);
}
};
}
}
代码示例来源:origin: JanusGraph/janusgraph
public SchemaContainer(JanusGraph graph) {
vertexLabels = Maps.newHashMap();
relationTypes = Maps.newHashMap();
JanusGraphManagement management = graph.openManagement();
try {
for (VertexLabel vl : management.getVertexLabels()) {
VertexLabelDefinition vld = new VertexLabelDefinition(vl);
vertexLabels.put(vld.getName(),vld);
}
for (EdgeLabel el : management.getRelationTypes(EdgeLabel.class)) {
EdgeLabelDefinition eld = new EdgeLabelDefinition(el);
relationTypes.put(eld.getName(),eld);
}
for (PropertyKey pk : management.getRelationTypes(PropertyKey.class)) {
PropertyKeyDefinition pkd = new PropertyKeyDefinition(pk);
relationTypes.put(pkd.getName(), pkd);
}
} finally {
management.rollback();
}
}
代码示例来源:origin: JanusGraph/janusgraph
JanusGraphManagement management = null;
try {
management = g.openManagement();
idx = management.getRelationIndex(management.getRelationType(relationTypeName), relationIndexName);
actualStatus = idx.getIndexStatus();
代码示例来源:origin: JanusGraph/janusgraph
this.managementSystem = (ManagementSystem)graph.openManagement();
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void loadGraphData(final Graph g, final LoadGraphWith loadGraphWith, final Class testClass,
final String testName) {
if (loadGraphWith != null) {
this.createIndices((JanusGraph) g, loadGraphWith.value());
} else {
if (TransactionTest.class.equals(testClass)
&& testName.equalsIgnoreCase("shouldExecuteWithCompetingThreads")) {
JanusGraphManagement management = ((JanusGraph) g).openManagement();
management.makePropertyKey("blah").dataType(Double.class).make();
management.makePropertyKey("bloop").dataType(Integer.class).make();
management.makePropertyKey("test").dataType(Object.class).make();
management.makeEdgeLabel("friend").make();
management.commit();
}
}
super.loadGraphData(g, loadGraphWith, testClass, testName);
}
代码示例来源:origin: JanusGraph/janusgraph
JanusGraphManagement m2 = g2.openManagement();
assertEquals(secondValue.toString(), m2.get(path));
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testOrForceIndexUniqueMixedIndex() throws Exception {
JanusGraph customGraph = null;
try {
customGraph = this.getForceIndexGraph();
final JanusGraphManagement management = customGraph.openManagement();
final PropertyKey nameProperty = management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
final PropertyKey ageProperty = management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
final PropertyKey lengthProperty = management.makePropertyKey("length").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
management.buildIndex("oridx", Vertex.class).addKey(nameProperty, getStringMapping()).addKey(ageProperty).addKey(lengthProperty).buildMixedIndex(INDEX);
management.commit();
customGraph.tx().commit();
testOr(customGraph);
} finally {
if (customGraph != null) {
JanusGraphFactory.close(customGraph);
}
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testOrForceIndexPartialIndex() throws Exception {
JanusGraph customGraph = null;
try {
customGraph = this.getForceIndexGraph();
final JanusGraphManagement management = customGraph.openManagement();
final PropertyKey stringProperty = management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
management.buildIndex("oridx", Vertex.class).addKey(stringProperty, getStringMapping()).buildMixedIndex(INDEX);
management.commit();
customGraph.tx().commit();
final GraphTraversalSource g = customGraph.traversal();
g.addV().property("name", "Hiro").property("age", 2).next();
g.addV().property("name", "Totoro").property("age", 1).next();
customGraph.tx().commit();
g.V().or(__.has("name", "Totoro"),__.has("age", 2)).hasNext();
fail("should fail");
} catch (final JanusGraphException e){
assertTrue(e.getMessage().contains("Could not find a suitable index to answer graph query and graph scans are disabled"));
} finally {
if (customGraph != null) {
JanusGraphFactory.close(customGraph);
}
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testOrForceIndexMixedAndCompositeIndex() throws Exception {
JanusGraph customGraph = null;
try {
customGraph = this.getForceIndexGraph();
final JanusGraphManagement management = customGraph.openManagement();
final PropertyKey nameProperty = management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
final PropertyKey ageProperty = management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
final PropertyKey lengthProperty = management.makePropertyKey("length").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
management.buildIndex("nameidx", Vertex.class).addKey(nameProperty, getStringMapping()).buildMixedIndex(INDEX);
management.buildIndex("ageridx", Vertex.class).addKey(ageProperty).buildCompositeIndex();
management.buildIndex("lengthidx", Vertex.class).addKey(lengthProperty).buildMixedIndex(INDEX);
management.commit();
customGraph.tx().commit();
testOr(customGraph);
} finally {
if (customGraph != null) {
JanusGraphFactory.close(customGraph);
}
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testOrForceIndexComposite() throws Exception {
JanusGraph customGraph = null;
try {
customGraph = this.getForceIndexGraph();
final JanusGraphManagement management = customGraph.openManagement();
management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
final PropertyKey ageProperty = management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
management.buildIndex("ageridx", Vertex.class).addKey(ageProperty).buildCompositeIndex();
management.commit();
customGraph.tx().commit();
final GraphTraversalSource g = customGraph.traversal();
g.addV().property("name", "Hiro").property("age", 2).next();
g.addV().property("name", "Totoro").property("age", 1).next();
customGraph.tx().commit();
g.V().has("age", P.gte(4).or(P.lt(2))).hasNext();
fail("should fail");
} catch (final JanusGraphException e){
assertTrue(e.getMessage().contains("Could not find a suitable index to answer graph query and graph scans are disabled"));
} finally {
if (customGraph != null) {
JanusGraphFactory.close(customGraph);
}
}
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Test
public void testAndForceIndex() throws Exception {
JanusGraph customGraph = null;
try {
customGraph = this.getForceIndexGraph();
final JanusGraphManagement management = customGraph.openManagement();
final PropertyKey nameProperty = management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
final PropertyKey ageProperty = management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
management.buildIndex("oridx", Vertex.class).addKey(nameProperty, getStringMapping()).addKey(ageProperty).buildMixedIndex(INDEX);
management.commit();
customGraph.tx().commit();
final GraphTraversalSource g = customGraph.traversal();
g.addV().property("name", "Hiro").property("age", 2).next();
g.addV().property("name", "Totoro").property("age", 1).next();
customGraph.tx().commit();
assertCount(1, g.V().has("name", "Totoro"));
assertCount(1, g.V().has("age", 2));
assertCount(1, g.V().and(__.has("name", "Hiro"),__.has("age", 2)));
assertCount(0, g.V().and(__.has("name", "Totoro"),__.has("age", 2)));
} finally {
if (customGraph != null) {
JanusGraphFactory.close(customGraph);
}
}
}
代码示例来源:origin: JanusGraph/janusgraph
JanusGraphManagement management = graph.openManagement();
final PropertyKey name = management.makePropertyKey("name").dataType(String.class).make();
JanusGraphManagement.IndexBuilder nameIndexBuilder = management.buildIndex("name", Vertex.class).addKey(name);
代码示例来源:origin: JanusGraph/janusgraph
private void createIndices(final JanusGraph g, final LoadGraphWith.GraphData graphData) {
JanusGraphManagement management = g.openManagement();
if (graphData.equals(LoadGraphWith.GraphData.GRATEFUL)) {
VertexLabel artist = management.makeVertexLabel("artist").make();
代码示例来源:origin: apache/atlas
static void validateIndexBackend(Configuration config) {
String configuredIndexBackend = config.getString(INDEX_BACKEND_CONF);
JanusGraphManagement managementSystem = getGraphInstance().openManagement();
String currentIndexBackend = managementSystem.get(INDEX_BACKEND_CONF);
managementSystem.commit();
if (!configuredIndexBackend.equals(currentIndexBackend)) {
throw new RuntimeException("Configured Index Backend " + configuredIndexBackend
+ " differs from earlier configured Index Backend " + currentIndexBackend + ". Aborting!");
}
}
代码示例来源:origin: apache/atlas
@Override
public AtlasGraphManagement getManagementSystem() {
return new AtlasJanusGraphManagement(this, getGraph().openManagement());
}
代码示例来源:origin: apache/atlas
private Set<String> getIndexKeys(Class<? extends Element> janusGraphElementClass) {
JanusGraphManagement mgmt = getGraph().openManagement();
Iterable<JanusGraphIndex> indices = mgmt.getGraphIndexes(janusGraphElementClass);
Set<String> result = new HashSet<String>();
for (JanusGraphIndex index : indices) {
result.add(index.name());
}
mgmt.commit();
return result;
}
代码示例来源:origin: ai.grakn/janus-factory
private static void buildJanusIndexes(JanusGraph graph) {
JanusGraphManagement management = graph.openManagement();
makeVertexLabels(management);
makeEdgeLabels(management);
makePropertyKeys(management);
makeIndicesVertexCentric(management);
makeIndicesComposite(management);
management.commit();
}
代码示例来源:origin: Netflix/ndbench
protected void createSchema(JanusGraph graph) {
JanusGraphManagement mgmt = graph.openManagement();
if (!mgmt.containsGraphIndex(COMPOSITE_INDEX_NAME)) {
final PropertyKey customId = mgmt.makePropertyKey(PROP_CUSTOM_ID_KEY).dataType(String.class).make();
JanusGraphManagement.IndexBuilder customIdIndexBuilder = mgmt.buildIndex(COMPOSITE_INDEX_NAME, Vertex.class).addKey(customId);
customIdIndexBuilder.buildCompositeIndex();
mgmt.makeVertexLabel(VERTEX_LABEL_LEVEL_1).make();
mgmt.commit();
}
}
内容来源于网络,如有侵权,请联系作者删除!