Frames + remote graph

97 views
Skip to first unread message

Alina Arm

unread,
Feb 26, 2015, 4:06:34 AM2/26/15
to gremli...@googlegroups.com
Hi 

I need to write a java program that can read/insert to Titan database that is running on remote server (Titan 
+cassandra+Rexster installation)

Currently I am doing this by running code below

  RexsterClient client = RexsterClientFactory.open("192.168.30.62");
        String gremlin = "g = rexster.getGraph(\"graph\");"
        + "v1 = g.addVertex([type:'Conduit',name:'Test_c']);"
        + "v2 = g.addVertex([type:'MicroConduit',name:'Test_cm']);"
        + "g.addEdge(v2, v1, 'IN');"
        + "g.commit();"
        + "g.E.map();";
        
        List<Map<String, Object>> results = client.execute(gremlin);
        System.out.println("TEST "+results);
        client.close();


which is not the best way of doing this, I believe

I am wondering if it possible to use Tinkerpop Frames to read/write to existing Titan database running on remote server?

Stephen Mallette

unread,
Feb 26, 2015, 9:06:33 AM2/26/15
to gremli...@googlegroups.com
No - Frames does not work that way.  The approach you are taking with RexsterClient isn't really "wrong", but tons of fat, embedded strings in your code isn't especially easy to manage.  If you have a large body of Gremlin code, you should consider putting it on the server, i.e. build a DSL hosted remotely, and then calling it from RexsterClient.  You can read more about DSLs with Gremlin here:


This is a good approach to organizing your Gremlin code with or without remoting, as the code becomes more re-usable for different contexts.

Stephen



--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/cd2cd4d4-9bf5-4efb-9aa5-0bf1d00321a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alina Arm

unread,
Mar 2, 2015, 9:28:44 AM3/2/15
to gremli...@googlegroups.com
OK, but if java application and Titan are running on the same host. I need to get FramedGraph object. I could find a lot of example how to make a new graph 

Configuration c = new BaseConfiguration(); 
c.setProperty("blueprints.graph", "com.tinkerpop.blueprints.impls.tg.TinkerGraph"); 
Graph g = GraphFactory.open(c);
FramedGraphFactory factory = new FramedGraphFactory(new GremlinGroovyModule());
FramedGraph framedGraph = factory.create(g);

but how do I access graph I have already created?

четверг, 26 февраля 2015 г., 15:06:33 UTC+1 пользователь Stephen Mallette написал:

Stephen Mallette

unread,
Mar 2, 2015, 9:34:16 AM3/2/15
to gremli...@googlegroups.com
i'm not sure i follow your problem...perhaps you are confused about the nature of "create"

FramedGraph framedGraph = factory.create(g);

"create" doesn't mean "create a new graph and delete an old one".  it simply means "create a FramedGraph from the Graph instance in 'g'".

Alina Arm

unread,
Mar 2, 2015, 9:42:56 AM3/2/15
to gremli...@googlegroups.com
Doesnt it make a new graph?

Configuration c = new BaseConfiguration(); 
c.setProperty("blueprints.graph", "com.tinkerpop.blueprints.impls.tg.TinkerGraph"); 
Graph g = GraphFactory.open(c);

When I was using RexsterClient I was passing location and name of the graph?

RexsterClient client = RexsterClientFactory.open("192.168.30.62");
String grimlin = "g = rexster.getGraph(\"graph\");"

How does it know where the graph is located when I use FramedGraph?


понедельник, 2 марта 2015 г., 15:34:16 UTC+1 пользователь Stephen Mallette написал:

Stephen Mallette

unread,
Mar 2, 2015, 9:48:26 AM3/2/15
to gremli...@googlegroups.com
Well - TinkerGraph is an in-memory graph so it will always create a new Graph that is empty.  If you want the data persisted, then you need to choose a Graph implementation like Neo4j, Titan, OrientDB, etc.  In those cases, you will specify the location of the Graph (i.e. where the data is) and thus allow for your FramedGraph to connect to the same one between JVM shutdowns.

Alina Arm

unread,
Mar 2, 2015, 9:53:08 AM3/2/15
to gremli...@googlegroups.com
yes, that is what i want to do. I want to access existing Titan graph, but I cannot find any tutorial how to do that. 

понедельник, 2 марта 2015 г., 15:48:26 UTC+1 пользователь Stephen Mallette написал:

Stephen Mallette

unread,
Mar 2, 2015, 10:05:18 AM3/2/15
to gremli...@googlegroups.com
again, i'm not following your problem....


g = TitanFactory.open(‘berkeleyje:/tmp/graph’)
factory = new FramedGraphFactory(new GremlinGroovyModule());
framedGraph = factory.create(g);

The GraphFactory from Blueprints should be capable of opening a TitanGraph too as well.....



Javid Ahammed

unread,
Oct 18, 2015, 2:25:10 PM10/18/15
to Gremlin-users
Hello Alina,

Were you able to figure out the best way to achieve the remote titan connection from Java application?

Regards
Javid 
Reply all
Reply to author
Forward
0 new messages