4

Instead of using AWS, I am using its local available DynamoDB database and creating a graph in the Gremlin console.

My PC is using Gremlin-version=3.0.1.incubating and Titan-version=1.0.0

My question: How to save a graph in my local DynamoDB so that I can retrieve it back whenever I wish? (E.g. after computer restart).

I have tried a lot, using save() or commit() graph. But I always got an error:

g.commit()
No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph
  .GraphTraversalSource.commit() is applicable for argument types: () values: []
Possible solutions: wait(), computer(), collect(), wait(long), computer(java.lang.Class), collect(groovy.lang.Closure)

I am using Tinkerpop 3.

Ondra Žižka
  • 36,997
  • 35
  • 184
  • 250
Mustaffa
  • 71
  • 9

2 Answers2

4

Relevant documentation links:

As Filipe mentioned, g.commit() throws an exception because there is no commit() method on g which is a GraphTraversalSource. I suggested that you use graph.tx().commit(), where graph.tx() gets the Transaction from the Graph. In the comments we found out that you were trying to commit() a transaction on a TinkerGraph, which does not support transactions.

You need to instantiate a TitanGraph, not a TinkerGraph. This commonly done with a properties file, and there is a DynamoDB Local example properties file in the dynamodb-titan-storage-backend repository. Make sure to update the storage.dynamodb.client.endpoint to match your configuration. If you are using the Titan Server directions from the DynamoDB-Titan link, the port is 4567. If you are using the directions from the DynamoDB local link above, the default port is 8000.

gremlin> graph = TitanFactory.open('conf/gremlin-server/dynamodb-local.properties')
==>standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]]
gremlin> v0 = graph.addVertex('name', 'jason'); v1 = graph.addVertex('name', 'mustaffa'); v0.addEdge('helps', v1)
==>e[175-39k-1lh-374][4232-helps->4144]
gremlin> graph.tx().commit()
==>null

Also note, the DynamoDB-Titan directions end up starting an in-memory DynamoDB Local instance. This behavior can be changed by commenting out the -inMemory argument the pom.xml.

Jason Plurad
  • 6,422
  • 2
  • 15
  • 37
  • Might be helpful I will surely notice it and get back BTW thanks for the wonderful suggestion..! :) – Mustaffa Nov 30 '16 at 04:53
0

You are attempting to commit your traversal g. You should be attempting to commit your graph like so: graph.commit().

g is the traversal which is initialised as such: g = graph.traversal() and it cannot be committed.

Filipe Teixeira
  • 3,465
  • 22
  • 42
  • hey, i have tried it using the above command but it shows the following error : graph.commit() No signature of method: org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.commit() is applicable for argument types: () values: [] Possible solutions: compute(), compute(java.lang.Class), wait(), collect(), wait(long), collect(groovy.lang.Closure) Display stack trace? [yN] Can u solve the problem..... – Mustaffa Nov 28 '16 at 13:16
  • 1
    [TinkerGra‌ph](http://tinkerpop.apache.org/docs/current/reference/#tinkergraph-gremlin) is an in-memory graph only so it cannot be commited. Check how you are initialising your graph. Since it looks like you are trying to use titan on top of dynamo you should probable take a look [here](http://s3.thinkaurelius.com/docs/titan/1.0.0/getting-started.html) – Filipe Teixeira Nov 28 '16 at 13:20
  • absolutely right as i am using titan on top of it. but i have not not know how could this be save the graph and retrieve it – Mustaffa Nov 28 '16 at 13:28
  • 1
    You are incorrectly initialising a TinkerGraph. You should be initialising a titan graph as detailed [here](http://s3.thinkaurelius.com/docs/titan/1.0.0/getting-started.html) – Filipe Teixeira Nov 28 '16 at 13:29
  • 2
    `graph.tx().commit()` – Jason Plurad Nov 28 '16 at 15:10
  • I have a problem actually i have installed dynamodb local at one place from http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html – Mustaffa Nov 29 '16 at 05:33