Store Gremlin graph in local DynamoDB - titan

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.

Relevant documentation links:
Amazon DynamoDB Storage Backend for Titan
Running DynamoDB on Your Computer
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.

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.

Related

OrientDB: Creating Graph-database through HTTP-API

It seems it is only possible to create document-type databases via the HTTP-api. The documentation omit's information about whether the database will be created as a graph or a documentdatabase, but when creating a vertext, i get the error:
Super-class V not exists
...which, as i understand, means that the database is a document-type.
Is there any way around this? The /command/ action makes it pretty easy for me to do what I want from C#, if I could only generate a graph-database via HTTP-api...
Is there any way to create a graph-database through the HTTP-API?
Alternatively: Is there another way to create a graph-database from c#? I've tried creating a database via the console, but here i get IllegalArgumentException:
Error: java.lang.IllegalArgumentException: Storage type 'plocal' is different by storage type in URL
..which i cannot find any explenation for
Any help is much appreciated :)
I managed to have that using POST http://localhost:2480/database/<db name>/plocal/graph
I did found it experimentally. Did not found that in documentation which is a bit strange.
Tested on version 2.1.7
I got the same error message when I typed in the following command:
create database REMOTE:localhost/petshop root aaaa plocal document
Solution:
I had to write it in lower case:
create database remote:localhost/petshop root aaaa plocal document

Make Orion fetch data from Cosmos and publish

I have set up a subscription between Orion ContextBroker and Cosmos BigData using Cygnus, and data is properly persisted in Cosmos when an update is made to Orion.
But I want to analyze the data in Cosmos and return the results to Orion, and finally access the result data in Orion from "outside".
How would one do this? Of course, I would like the solution I build to be as "automated" as possible, but mostly I just want to solve this problem.
Any advise is much appreciated!
As general response (as also the question is very general ;), what you need is a process that access to information stored in Cosmos (either using HDFS APIs -such as WebHDFS or HttpFs-, Hive queries, general MapReduce jobs on top of Hadoop, etc.), then implement the client side of the NGSI API that Orion implements in order to inject context elements into Orion based in the information you retrieved from Cosmos. The key operation to do so in the Orion API is updateContext.
The automation degree would depend on how you implement that process. It can be as automated as you want.
EDIT: considering this answer comments, I will try to add more detail.
What I mean is to develop a piece of software (let's call it APOS -A Piece Of Software) implementing the following behaviour:
APOS will grab data from Cosmos any of the interfaces provided by Cosmos, i.e. WebHDFS/HttpFs, Hive, MapReduce jobs, etc.
APOS will process the data to produce some result
APOS will inject that result in Orion, using the Orion REST API described in the Orion user manual. It is particularly useful for that task the updateContext operation. From a client-server point of view, Orion is a server exposing a REST API and APOS is the client interacting with that server.
It is completely up to you how to implement this APOS and how orchestrate the flow from 1 to 3 (e.g. it can run in batch mode all midnights, be triggered by user interaction on a web portal, etc.).
At the present moment, FI-WARE doesn't provide any generic enabler to convert from Cosmos data to NGSI given that each particular realization of the steps 1 to 3 above is different and depends on the use case. However, note that there is software component named Cygnus which implements the other way: from NGIS to Cosmos.

Loading data into Titan

I am currently running Titan Server (0.4) [via bin/titan.sh -c cassandra-es start] and load the sample data using rexster-console:
rexster[groovy]> g = rexster.getGraph("graph")
rexster[groovy]> GraphOfTheGodsFactory.load(g)
How can I do the same thing above using a RexsterClient in java? Essentially, Is it possible to get access to graph without me having to embed all this in client.execute()?
Thanks for your help.
Once you've created the graph you can access it with RexsterClient. You shouldn't need to recreate the graph again with it as the data is already in Cassandra. Just specify the graph name when constructing your RexsterClient instance (in the case of Titan Server the graph name is just "graph"):
RexsterClient client = RexsterClientFactory.open("localhost", "graph");
List<Map<String, Object>> results = client.execute("g.v(4).map");
That will initialize "g" and allow you to just issue some Gremlin against the Graph of the Gods sample data set. You can read more about the options for RexsterClient here.

Create\Add a graph Titan server using default rexster

when i run
rexster.getGraphNames()
my only result is graph, when i ran a gremlin instance directly over titan i had
tmp
and created a graph called
mygraph
i have been loooking around and havent found anything
Titan Server will only host a single instance of a graph. Therefore, rexster.getGraphNames() will always only return one graph and it will always be called graph.
Creating a graph called mygraph with the Gremlin REPL won't connect Titan Server to the graph unless you've configured it to do so and even then, it will still be referred to by Titan Server as just graph.

Is there a way to wipe an entire Neo4j database via the REST API?

I'm using the Neography gem to interact with a Neo4j database through the REST API. I don't see any way in Neography itself (though if it's there, I'd love to use it!), nor have I been able to find by searching on Google whether this is possible directly through the REST API itself. Does anyone out there with Neo4j experience happen to know?
With Neography, you can send this Gremlin script:
#neo = Neography::Rest.new
#neo.execute_script("g.clear()")
to remove all the nodes and relationships.
To clear all nodes and relationships except the root node, use the solution provided in neography wiki
#neo = Neography::Rest.new
#neo.execute_query("START n0=node(0),nx=node(*) MATCH n0-[r0?]-(),nx-[rx?]-() WHERE nx <> n0 DELETE r0,rx,nx")