neo4j创建多个节点json

时间:2014-04-08 12:14:00

标签: json neo4j

请让我知道我哪里出错了 我正在使用neo4j来存储我的路由器接口和链接信息。该链接将在2个接口之间创建。 我已成功创建节点和接口,但在创建链接时遇到了问题。

这是我用来创建链接的查询

MATCH (I:Interface), (I2:Interface) 
FOREACH(p in FILTER(z in {props} WHERE z.OrigIPAddress = I.IfIPAddress or z.TermIPAddress = I.IfIPAddress) | 
MERGE (I {IfIPAddress:p.OrigIPAddress})-[r:link]->(I2 {IfIPAddress:p.TermIPAddress}) 
ON CREATE SET r = p 
ON MATCH SET r = p) 

我有一个名为props的地图数组,我在json中传递为包含链接属性的params,即OrigIPAddress(Originating interface IP),TermIPAddress(Terminating interface ip)。 在foreach中,我首先过滤所有已经存在源或目标接口的链接。现在我这样做后,我正在创建道具链接。

当我运行它时它运行正常但没有创建链接。存在源和目标接口。

编辑1: 我修改了查询,当我运行此查询时

MATCH (I:Interface), (I2:Interface) 
FOREACH(p in FILTER(z in {props} WHERE z.OrigIPAddress = I.IfIPAddress and z.TermIPAddress = I2.IfIPAddress) | 
MERGE (I {IfIPAddress:p.OrigIPAddress})-[r:link]->(I {IfIPAddress:p.TermIPAddress}) 
ON CREATE SET r = p 
ON MATCH SET r = p)

我没有从neo4j和neo4j web控制台得到ant响应我可以看到这个meesage “Neo4j断开了,检查你的插座......”

以下是日志 2014年4月9日上午11:06:46 org.neo4j.server.logging.Logger日志 警告:您使用的是不受支持的Java运行时。请使用Oracle(R)Java(TM)Runtime Environment 7。

SEVERE: The response of the WebApplicationException cannot be utilized as the response is already committed. Re-throwing to the HTTP container
javax.ws.rs.WebApplicationException: javax.ws.rs.WebApplicationException: org.eclipse.jetty.io.EofException
    at org.neo4j.server.rest.repr.OutputFormat$1.write(OutputFormat.java:174)
    at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:71)
    at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:57)
    at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1437)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1506)
    at org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1477)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:211)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1096)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:432)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1030)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
    at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:445)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:268)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
    at java.lang.Thread.run(Thread.java:744)
Caused by: javax.ws.rs.WebApplicationException: org.eclipse.jetty.io.EofException
    at org.neo4j.server.rest.repr.formats.StreamingJsonFormat$StreamingRepresentationFormat.flush(StreamingJsonFormat.java:401)
    at org.neo4j.server.rest.repr.formats.StreamingJsonFormat$StreamingRepresentationFormat.complete(StreamingJsonFormat.java:389)
    at org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:43)
    at org.neo4j.server.rest.repr.OutputFormat$1.write(OutputFormat.java:160)
    ... 30 more
Caused by: org.eclipse.jetty.io.EofException
    at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:186)
    at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:335)
    at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:125)
    at org.eclipse.jetty.server.HttpConnection$ContentCallback.process(HttpConnection.java:784)
    at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:79)
    at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:356)
    at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:631)
    at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:661)
    at org.eclipse.jetty.server.HttpOutput.flush(HttpOutput.java:151)
    at com.sun.jersey.spi.container.servlet.WebComponent$Writer.flush(WebComponent.java:315)
    at com.sun.jersey.spi.container.ContainerResponse$CommittingOutputStream.flush(ContainerResponse.java:145)
    at org.codehaus.jackson.impl.Utf8Generator.flush(Utf8Generator.java:1091)
    at org.neo4j.server.rest.repr.formats.StreamingJsonFormat$StreamingRepresentationFormat.flush(StreamingJsonFormat.java:397)
    ... 33 more
Caused by: java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcherImpl.writev0(Native Method)
    at sun.nio.ch.SocketDispatcher.writev(SocketDispatcher.java:51)
    at sun.nio.ch.IOUtil.write(IOUtil.java:148)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:524)
    at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:167)
    ... 45 more

Apr 09, 2014 11:10:17 AM com.sun.jersey.server.impl.application.WebApplicationImpl _handleRequest
SEVERE: The response of the WebApplicationException cannot be utilized as the response is already committed. Re-throwing to the HTTP container
javax.ws.rs.WebApplicationException: javax.ws.rs.WebApplicationException: org.eclipse.jetty.io.EofException
    at org.neo4j.server.rest.repr.OutputFormat$1.write(OutputFormat.java:174)
    at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:71)
    at com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:57)
    at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1437)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1506)
    at org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1477)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:211)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1096)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:432)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1030)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
    at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:445)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:268)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
    at java.lang.Thread.run(Thread.java:744)
Caused by: javax.ws.rs.WebApplicationException: org.eclipse.jetty.io.EofException
    at org.neo4j.server.rest.repr.formats.StreamingJsonFormat$StreamingRepresentationFormat.flush(StreamingJsonFormat.java:401)
    at org.neo4j.server.rest.repr.formats.StreamingJsonFormat$StreamingRepresentationFormat.complete(StreamingJsonFormat.java:389)
    at org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:43)
    at org.neo4j.server.rest.repr.OutputFormat$1.write(OutputFormat.java:160)
    ... 30 more
Caused by: org.eclipse.jetty.io.EofException
    at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:186)
    at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:335)
    at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:125)
    at org.eclipse.jetty.server.HttpConnection$ContentCallback.process(HttpConnection.java:784)
    at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:79)
    at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:356)
    at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:631)
    at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:661)
    at org.eclipse.jetty.server.HttpOutput.flush(HttpOutput.java:151)
    at 

让我知道我在哪里出错。

2 个答案:

答案 0 :(得分:1)

这更接近你想要做的事情吗?

MATCH (I:Interface)
FOREACH(
  p in FILTER(z in {props}
    WHERE z.OrigIPAddress = I.IfIPAddress or z.TermIPAddress = I.IfIPAddress) | 
  MERGE (I)-[r:link]->(:Interface {IfIPAddress:p.TermIPAddress})
  SET I.IfIPAddress = p.OrigIPAddress, r = p
);

答案 1 :(得分:1)

最后在谷歌搜索后我发现了这个问题。 它的服务器超时。由于查询需要一些时间来执行,因此服务器会超时并发送响应。

我增加了超时并且它有效 以下是如何增加它的参考。 http://docs.neo4j.org/chunked/stable/server-configuration.html