欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

janusgraph创建索引报错

程序员文章站 2024-01-19 13:17:46
...

创建名为byTelComposite的索引,installed转registered时报错:

janusgraph>GraphIndexStatusReport[success=false, indexName='byTelComposite', targetStatus=[REGISTERED], notConverged={tel=INSTALLED}, converged={}, elapsed=PT1M0.261S]

原因:
出现了多个事务或者实例

解决:
关闭实例过程

gremlin> mgmt = graph.openManagement()
==>[email protected]7c75
//查询实例
gremlin> mgmt.getOpenInstances()
==>c0a81433160396-s11(current)
==>c0a81433160854-s13
==>c0a81433160854-s11
==>c0a81433160854-s15
//出现多个则关闭
gremlin> mgmt.forceCloseInstance('c0a81433160854-s11')
==>null
gremlin> mgmt.commit()
==>null

关闭事务过程

//查询事务
graph.getOpenTransactions()//打开多个事务
//关闭事务
graph.getOpenTransactions().getAt(0).rollback()  //关闭
或者
int size = graph.getOpenTransactions().size();for(i=0;i<size;i++) {graph.getOpenTransactions().getAt(0).rollback()}  //size替换为事务的数量

最后查看实例事务是否都关闭

mgmt = graph.openManagement()
mgmt.getOpenInstances()
mgmt.commit()    
graph.getOpenTransactions()

INSTALLED转REGISTERED方法:
执行 REGISTER_INDEX ACTION,使索引状态INSTALLED 转为 REGISTERED

mgmt = graph.openManagement()
mgmt.updateIndex(m.getGraphIndex('byTelComposite'), SchemaAction.REGISTER_INDEX).get()
mgmt.commit()

或者

ManagementSystem.awaitGraphIndexStatus(graph, 'byTelComposite').call()

直接查看索引的状态

mgmt = graph.openManagement()
index = mgmt.getGraphIndex('byTelComposite')
index.getIndexStatus(mgmt.getPropertyKey('tel'))