我面临一个独特的问题。我们使用bojo方法将属性设置为节点。设置属性后,我们将创建与创建的Node的关系。第一次创建节点和关系时,当我保存另一个节点时,它挂起在CreateRelationShipTo线上,而以前保存的节点也从Neo4j中丢失了?任何人都可以指导我们为什么会这样吗?很抱歉没有提供正确的信息。 Java代码如下:
Transaction trx = DataSource.getGraphDBAPI().beginTx();
try{
Node apiDetailsNode = DataSource.getGraphDB().createNode();
apiDetailsNode.setId("1");
apiDetailsNode.setName("Test API");
apiDetailsNode.setURL("www.test.com");
parentNode.createRelationshipTo(apiDetailsNode,
KnoxxiRelationshipType.API);
apiDetailsNode.setStatus("1");
trx.success();
}catch (Exception e) {
trx.failure();
log.error("Strange API Failed To Create");
} finally {trx.finish();}
neo4j配置如下:
node_auto_indexing=true
cache_type=gcr
nodestore_propertystore_mapped_memory_size=150M
nodestore_mapped_memory_size=100M
relationshipstore_mapped_memory_size=500M
strings_mapped_memory_size=150M
nodestore_mapped_memory_size=150M
relationship_auto_indexing=true
我们的数据存储区现在有2M节点和800万个关系。
我们正在使用 1.9.8 Neo4j版本
message.log文件中的最后20行如下:
2015-03-20 09:25:08.030+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 385ms [total block time: 5.365s]
2015-03-20 09:25:25.766+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 395ms [total block time: 5.76s]
2015-03-20 09:25:44.909+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 415ms [total block time: 6.175s]
2015-03-20 09:28:46.736+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 377ms [total block time: 6.552s]
2015-03-20 09:28:50.147+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 395ms [total block time: 6.947s]
2015-03-20 09:31:17.876+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 525ms [total block time: 7.472s]
2015-03-20 09:32:50.150+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 424ms [total block time: 7.896s]
2015-03-20 09:35:03.267+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 498ms [total block time: 8.394s]
2015-03-20 09:35:14.967+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 417ms [total block time: 8.811s]
2015-03-20 09:35:20.184+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 402ms [total block time: 9.213s]
2015-03-20 09:37:03.175+0000 INFO [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 415ms [total block time: 9.628s]
答案 0 :(得分:0)
我找到了问题的根本原因并修复了它。挂起的原因是由于Open Transaction连接。(可以通过JMX Console找到)。
由于在排除密码查询后没有关闭执行结果,因此发生了打开的连接。示例代码如下,
public static Node executeCypherQuerySingleResult(String strCypherQuery, String strResultColumnName) {
ExecutionResult result = null;
Iterator<Node> n_column = null;
ExecutionEngine engine = null;
try {
engine = NeoDbConnection.getExecutionEngine(); // This will return the Execution Engine Instance from Neo DB Connection Singleton Class
result = engine.execute(strCypherQuery);
n_column = result.columnAs(strResultColumnName);
while (n_column.hasNext()) {
Node node = n_column.next();
return node;
}
} catch (Exception e) {
log.warn("Exception on Executing Cypher Query : " + strCypherQuery + ".. Error is : " + e.getLocalizedMessage());
} finally {
//
if (null != result) {
result.close(); // After I add this the issue was solved
}
result = null;
n_column = null;
engine = null;
}
return null;
}
感谢所有指导解决问题的人。