graphaware / neo4j-timetree

Java and REST APIs for working with time-representing tree in Neo4j
206 stars 41 forks source link

Unexpected behaviour with the range rest api #38

Closed Bretto closed 9 years ago

Bretto commented 9 years ago

Here is my conf: graphaware-server-community-all-2.2.2.32.jar graphaware-timetree-2.2.2.32.22.jar

com.graphaware.runtime.enabled=true

# Module TTCREATED for creation logic
com.graphaware.module.TTCREATED.1=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
com.graphaware.module.TTCREATED.event=hasLabel('Item') && !hasProperty('modified')
com.graphaware.module.TTCREATED.relationship=Created
com.graphaware.module.TTCREATED.timestamp=created
com.graphaware.module.TTCREATED.timezone=GMT+11
com.graphaware.module.TTCREATED.resolution=SECOND
com.graphaware.module.TTCREATED.autoAttach=true

# Module TTMODIFIED for modification logic
com.graphaware.module.TTMODIFIED.2=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
com.graphaware.module.TTMODIFIED.event=hasLabel('Item') && hasProperty('modified')
com.graphaware.module.TTMODIFIED.relationship=Modified
com.graphaware.module.TTMODIFIED.timestamp=modified
com.graphaware.module.TTMODIFIED.timezone=GMT+11
com.graphaware.module.TTMODIFIED.resolution=SECOND
com.graphaware.module.TTMODIFIED.autoAttach=true

create new Item:

create (item:Item {uid:'${item.uid}' ,name:'${item.name}',content:'${item.content}', created:timestamp()})

then I'v got some updates

match (user:User)-[:Own]->(i:Item {uid:'${newItemUid}'})-[:ofType]->(c:Category) set i.modified=timestamp()

result: The timetree is showing the edges created and modified as expected.

Item  <id>:93 uid:cicpv995x00003k5kcghumlea name:test content:test modified:1438242754445 created:1438240496379 

but:

http://localhost:7474/graphaware/timetree/range/1438230296379/1438250296379/events?resolution=Second

return: [ ] nothing

start = moment(1438230296379)Thu Jul 30 2015 15:24:56 GMT+1100 (NCT)} end = moment(1438250296379)Thu Jul 30 2015 20:58:16 GMT+1100 (NCT)}

created = moment(1438240496379) Thu Jul 30 2015 18:14:56 GMT+1100 (NCT)} modified = moment(1438242754445) Thu Jul 30 2015 18:52:34 GMT+1100 (NCT)}

so the created and modified dates are with in the range, why am I not getting any result ?

ikwattro commented 9 years ago

Can you confirm you use neo4j 2.2.2 or lower ? I'll reproduce this now

ikwattro commented 9 years ago

Confirmed issue. We will investigate. Thanks for reporting.

ikwattro commented 9 years ago

@bachmanm First of all, with the same configuration, latest framework and latest timetree plugin on neo4j-enterprise 2.2.2

The second module definition does not seems to recognize the node for inclusion. Unless I change the configuration for eg by adding spaces around the && in the inclusion policy in neo4j.properties and restarting the server, then the modified timetree graph is created.

I created a failing test in the issue-38 branch.

https://github.com/graphaware/neo4j-timetree/blob/issue38/src/test/java/com/graphaware/module/timetree/Issue38Test.java

ikwattro commented 9 years ago

I also did some debug by logging when the TT modules are called.

The second module definition does not seem to be called at all either :

15:16:21.207 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - Setting startup timeout to: 120000ms based on 120000
15:16:23.346 [main] INFO  c.g.r.b.RuntimeKernelExtension - GraphAware Runtime enabled, bootstrapping...
15:16:23.361 [main] INFO  c.g.r.b.RuntimeKernelExtension - Bootstrapping module with order 1, ID TTCREATED, using com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
15:16:23.518 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Node Inclusion Strategy set to com.graphaware.common.policy.composite.CompositeNodeInclusionPolicy@16d8ea8a
15:16:23.520 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Timestamp Property set to created
15:16:23.520 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Resolution set to SECOND
15:16:23.535 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Time zone set to +11:00
15:16:23.536 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Relationship type set to Created
15:16:23.536 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - AutoAttach set to true
15:16:23.540 [main] INFO  c.g.runtime.BaseGraphAwareRuntime - Registering module TTCREATED with GraphAware Runtime.
15:16:23.541 [main] INFO  c.g.r.b.RuntimeKernelExtension - Bootstrapping module with order 2, ID TTMODIFIED, using com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
15:16:23.543 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Node Inclusion Strategy set to com.graphaware.common.policy.composite.CompositeNodeInclusionPolicy@e9c3726f
15:16:23.543 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Timestamp Property set to modified
15:16:23.544 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Resolution set to SECOND
15:16:23.544 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Time zone set to +11:00
15:16:23.544 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - Relationship type set to Modified
15:16:23.544 [main] INFO  c.g.m.t.m.TimeTreeModuleBootstrapper - AutoAttach set to true
15:16:23.545 [main] INFO  c.g.runtime.BaseGraphAwareRuntime - Registering module TTMODIFIED with GraphAware Runtime.
15:16:23.546 [main] INFO  c.g.r.b.RuntimeKernelExtension - GraphAware Runtime bootstrapped, starting the Runtime...
15:16:23.823 [Thread-4] INFO  c.g.runtime.BaseGraphAwareRuntime - Starting GraphAware...
15:16:23.824 [Thread-4] INFO  c.g.runtime.BaseGraphAwareRuntime - Loading module metadata...
15:16:23.826 [Thread-4] INFO  c.g.r.manager.BaseModuleManager - Loading metadata for module TTCREATED
15:16:23.827 [Thread-4] INFO  c.g.r.manager.BaseModuleManager - Module TTCREATED seems to have been registered for the first time.
15:16:23.828 [Thread-4] INFO  c.g.r.m.BaseTxDrivenModuleManager - Module TTCREATED seems to have been registered for the first time, will initialize...
15:16:23.915 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - Starting HTTP on port :7575 with 4 threads available
15:16:23.936 [Thread-4] INFO  c.g.r.manager.BaseModuleManager - Creating fresh metadata for module TTCREATED.
15:16:23.937 [Thread-4] INFO  c.g.r.m.BaseTxDrivenModuleManager - Module TTCREATED has not changed configuration since last run, already initialized.
15:16:23.971 [Thread-4] INFO  c.g.r.manager.BaseModuleManager - Loading metadata for module TTMODIFIED
15:16:23.973 [Thread-4] INFO  c.g.r.manager.BaseModuleManager - Module TTMODIFIED seems to have been registered for the first time.
15:16:23.974 [Thread-4] INFO  c.g.r.m.BaseTxDrivenModuleManager - Module TTMODIFIED seems to have been registered for the first time, will initialize...
15:16:24.079 [Thread-4] INFO  c.g.r.manager.BaseModuleManager - Creating fresh metadata for module TTMODIFIED.
15:16:24.079 [Thread-4] INFO  c.g.r.m.BaseTxDrivenModuleManager - Module TTMODIFIED has not changed configuration since last run, already initialized.
15:16:24.098 [Thread-4] INFO  c.g.runtime.BaseGraphAwareRuntime - Module metadata loaded.
15:16:24.099 [Thread-4] INFO  c.g.r.m.BaseTxDrivenModuleManager - Starting transaction-driven modules...
15:16:24.099 [Thread-4] INFO  c.g.r.m.BaseTxDrivenModuleManager - Transaction-driven modules started.
15:16:24.099 [Thread-4] INFO  c.g.r.schedule.RotatingTaskScheduler - There are no timer-driven runtime modules. Not scheduling any tasks.
15:16:24.100 [Thread-4] INFO  c.g.runtime.BaseGraphAwareRuntime - GraphAware started.
15:16:24.100 [Thread-4] INFO  c.g.r.b.RuntimeKernelExtension - GraphAware Runtime automatically started.
15:16:24.148 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - Enabling HTTPS on port :7573
15:16:24.148 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - No SSL certificate found, generating a self-signed certificate..
15:16:24.423 [main] INFO  org.eclipse.jetty.util.log - Logging initialized @5178ms
15:16:24.486 [main] INFO  c.g.s.web.GraphAwareJetty9WebServer - Mounting static content at [/webadmin] from [webadmin-html]
15:16:24.532 [main] INFO  c.g.s.web.GraphAwareJetty9WebServer - Mounting static content at [/browser] from [browser]
15:16:24.622 [main] INFO  c.g.s.web.GraphAwareJetty9WebServer - Mounting GraphAware Framework under /graphaware
15:16:24.648 [main] INFO  c.g.s.web.GraphAwareJetty9WebServer - Will try to scan the following packages: {com.**.graphaware.**,org.**.graphaware.**,net.**.graphaware.**}
15:16:24.652 [main] INFO  org.eclipse.jetty.server.Server - jetty-9.2.4.v20141103
15:16:24.711 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.h.MovedContextHandler@5dbfcc25{/,null,AVAILABLE}
15:16:24.804 [main] INFO  o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /webadmin, did not find org.apache.jasper.servlet.JspServlet
15:16:24.818 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@17cb25bc{/webadmin,jar:file:/Users/cw/.m2/repository/org/neo4j/app/neo4j-server/2.2.2/neo4j-server-2.2.2-static-web.jar!/webadmin-html,AVAILABLE}
juil. 30, 2015 3:16:24 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
15:16:25.267 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@19392832{/db/manage,null,AVAILABLE}
juil. 30, 2015 3:16:25 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
15:16:25.573 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@74736a03{/db/data,null,AVAILABLE}
15:16:25.589 [main] INFO  o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /browser, did not find org.apache.jasper.servlet.JspServlet
15:16:25.591 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@2c02dbfc{/browser,jar:file:/Users/cw/.m2/repository/org/neo4j/app/neo4j-browser/2.2.2/neo4j-browser-2.2.2.jar!/browser,AVAILABLE}
juil. 30, 2015 3:16:25 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
15:16:25.691 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@5fac7dc3{/,null,AVAILABLE}
15:16:25.720 [main] INFO  /graphaware - Initializing Spring FrameworkServlet 'graphaware'
15:16:27.284 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@27f22caf{/graphaware,null,AVAILABLE}
15:16:27.289 [main] INFO  o.e.jetty.server.ServerConnector - Started ServerConnector@7e4c56{HTTP/1.1}{0.0.0.0:7575}
15:16:27.685 [main] INFO  o.e.jetty.server.ServerConnector - Started ServerConnector@764dd1c8{SSL-HTTP/1.1}{0.0.0.0:7573}
15:16:27.686 [main] INFO  org.eclipse.jetty.server.Server - Started @8443ms
15:16:27.686 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - Server started on: http://0.0.0.0:7575/
15:16:27.687 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - Remote interface ready and available at [http://0.0.0.0:7575/]
15:16:29.606 [qtp871298772-47] WARN  c.g.m.timetree.module.TimeTreeModule - The node has not the modified property
15:16:29.624 [qtp871298772-47] INFO  c.g.module.timetree.SingleTimeTree - Creating time tree root
15:16:30.166 [qtp871298772-47] INFO  c.g.r.b.RuntimeKernelExtension - GraphAware Runtime disabled.
15:16:31.298 [main] INFO  o.e.jetty.server.ServerConnector - Stopped ServerConnector@7e4c56{HTTP/1.1}{0.0.0.0:7575}
15:16:31.299 [main] INFO  o.e.jetty.server.ServerConnector - Stopped ServerConnector@764dd1c8{SSL-HTTP/1.1}{0.0.0.0:7573}
15:16:31.299 [main] INFO  /graphaware - Destroying Spring FrameworkServlet 'graphaware'
15:16:31.302 [main] INFO  o.e.j.server.handler.ContextHandler - Stopped o.e.j.s.ServletContextHandler@27f22caf{/graphaware,null,UNAVAILABLE}
15:16:31.302 [main] INFO  o.e.j.server.handler.ContextHandler - Stopped o.e.j.s.ServletContextHandler@5fac7dc3{/,null,UNAVAILABLE}
15:16:31.303 [main] INFO  o.e.j.server.handler.ContextHandler - Stopped o.e.j.w.WebAppContext@2c02dbfc{/browser,jar:file:/Users/cw/.m2/repository/org/neo4j/app/neo4j-browser/2.2.2/neo4j-browser-2.2.2.jar!/browser,UNAVAILABLE}
15:16:31.304 [main] INFO  o.e.j.server.handler.ContextHandler - Stopped o.e.j.s.ServletContextHandler@74736a03{/db/data,null,UNAVAILABLE}
15:16:31.305 [main] INFO  o.e.j.server.handler.ContextHandler - Stopped o.e.j.s.ServletContextHandler@19392832{/db/manage,null,UNAVAILABLE}
15:16:31.306 [main] INFO  o.e.j.server.handler.ContextHandler - Stopped o.e.j.w.WebAppContext@17cb25bc{/webadmin,jar:file:/Users/cw/.m2/repository/org/neo4j/app/neo4j-server/2.2.2/neo4j-server-2.2.2-static-web.jar!/webadmin-html,UNAVAILABLE}
15:16:31.306 [main] INFO  o.e.j.server.handler.ContextHandler - Stopped o.e.j.s.h.MovedContextHandler@5dbfcc25{/,null,UNAVAILABLE}
15:16:31.316 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - Successfully shutdown Neo4j Server.
15:16:31.345 [main] INFO  c.g.runtime.BaseGraphAwareRuntime - Shutting down GraphAware Runtime... 
15:16:31.345 [main] INFO  c.g.r.manager.BaseModuleManager - Shutting down module TTCREATED
15:16:31.345 [main] INFO  c.g.r.manager.BaseModuleManager - Shutting down module TTMODIFIED
15:16:31.345 [main] INFO  c.g.r.schedule.RotatingTaskScheduler - Terminating task scheduler...
15:16:31.345 [main] INFO  c.g.r.schedule.RotatingTaskScheduler - Task scheduler terminated successfully.
15:16:31.346 [main] INFO  c.g.runtime.BaseGraphAwareRuntime - GraphAware Runtime shut down.
15:16:31.352 [main] INFO  c.g.s.GraphAwareCommunityNeoServer - Successfully shutdown database.
15:16:31.352 [main] INFO  c.g.s.GraphAwareCommunityBootstrapper - Successfully shutdown Neo Server on port [7575], database [unknown location]

java.lang.AssertionError: Expected and actual status codes don't match. Response body: There is no corresponding node to (:Hour {value: 23}) in existing database 
Expected :200
Actual   :417
 <Click to see difference>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:743)
    at org.junit.Assert.assertEquals(Assert.java:118)
    at org.junit.Assert.assertEquals(Assert.java:555)
    at com.graphaware.test.util.TestHttpClient$1.handleResponse(TestHttpClient.java:301)
    at com.graphaware.test.util.TestHttpClient$1.handleResponse(TestHttpClient.java:294)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:218)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:160)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:136)
    at com.graphaware.test.util.TestHttpClient.method(TestHttpClient.java:229)
    at com.graphaware.test.util.TestHttpClient.post(TestHttpClient.java:147)
    at com.graphaware.test.util.TestHttpClient.post(TestHttpClient.java:125)
    at com.graphaware.test.util.TestHttpClient.post(TestHttpClient.java:112)
    at com.graphaware.module.timetree.Issue38Test.verifyIssue38(Issue38Test.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
bachmanm commented 9 years ago

Fixed in master, will release next week. Thanks for reporting and for help!

ikwattro commented 9 years ago

@Bretto until the official release you can use the fixed plugin by compiling it yourself :

git clone git@github.com:graphaware/neo4j-timetree
mvn clean package
cp target/timetree-2.2.2.32.23-SNAPSHOT-jar-with-dependencies.jar /path/to/your/plugins/folder

If you have an error during the packaging about wrong java version

javac: invalid target release: 1.7

You need to set the JAVA_HOME env to the path of your java1.7 directory :

set -x JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/
Bretto commented 9 years ago

Great thanks for the feedback, will this #37 be part of the new version ?

bachmanm commented 9 years ago

We'll do our best to include that, too.

Bretto commented 9 years ago

I have updated to the latest build but it am still getting unexpected behaviours related to the query string prams. neo4j-community-2.2.2 graphaware-server-community-all-2.2.2.33.jar graphaware-timetree-2.2.2.33.23.jar

My config is the same as above.

Case 1 (relationshipType=Modified)

http://localhost:7474/graphaware/timetree/range/1338984541742/1438994621742/events?relationshipType=Modified

result:

[
    {
        "node":{
            "id":615,
            "properties":{
                "content":"New 4x4",
                "uid":"cid26b2vj00003k5kq477zkrg",
                "created":1438984651247,
                "name":"Dmax",
                "modified":1438999230987
            },
            "labels":[
                "Item"
            ]
        },
        "relationshipType":"Created"
    },
    {
        "node":{
            "id":118,
            "properties":{
                "content":"okokk",
                "uid":"cid2i00hv00003k5mgk2ad1bb",
                "created":1439004290353,
                "name":"Time Test",
                "modified":1439004290606
            },
            "labels":[
                "Item"
            ]
        },
        "relationshipType":"Modified"
    }
]

Expecting only the relationType "Modified" but I am seeing the relationType "Created" as-well.

Case 2 (resolution)

http://localhost:7474/graphaware/timetree/range/1338984541742/1439005420669/events?resolution=day

result:

[
    {
        "node":{
            "id":615,
            "properties":{
                "content":"New 4x4",
                "uid":"cid26b2vj00003k5kq477zkrg",
                "created":1438984651247,
                "name":"Dmax",
                "modified":1438999230987
            },
            "labels":[
                "Item"
            ]
        },
        "relationshipType":"Created"
    },
    {
        "node":{
            "id":118,
            "properties":{
                "content":"okokk",
                "uid":"cid2i00hv00003k5mgk2ad1bb",
                "created":1439004290353,
                "name":"Time Test",
                "modified":1439004290606
            },
            "labels":[
                "Item"
            ]
        },
        "relationshipType":"Modified"
    }
]

OK all Good.

http://localhost:7474/graphaware/timetree/range/1338984541742/1439005420669/events?resolution=hour

result: [ ]

Expecting same as above. And being able to filter on the granularity of the resolution passed. Every other resolution gives an empty array.

ikwattro commented 9 years ago

For the GET method of the TimedEvents API. The query parameter for the relationship type is in the plural form : relationshipTypes as described here : https://github.com/graphaware/neo4j-timetree#rest-api

Can you try out a GET request on this url then, thanks :

http://localhost:7474/graphaware/timetree/range/1338984541742/1438994621742/events?relationshipTypes=Modified

I'll try out your config again in the day.

Bretto commented 9 years ago

My mistake, "relationshipTypes" works thanks ! Maybe you should add a message error like you do with the Resolution

{"message":"No enum constant com.graphaware.module.timetree.domain.Resolution.HOURS"}
ikwattro commented 9 years ago

Glad to hear, you're welcome ;-)

Bretto commented 9 years ago

Did you get the "resolution" to work ?