Getting error While querying sample Graph in Titan

162 views
Skip to first unread message

Vasu kothapalli

unread,
Jun 21, 2016, 8:05:26 AM6/21/16
to Aurelius
Hi All,

I have been started working on a sample Graph POC, Using Titan 1.0 and embedded Cassandra as backend storage.

Config file(titan-cassandra-embedded-es.properties) properties are set as below


storage.backend=embeddedcassandra
index.search.directory=../db/es
index.search.backend=elasticsearch
index.search.hostname=127.0.0.1
index.search.elasticsearch.client-only=true
storage.index.search.backend=elasticsearch


Created a sample employee graph using below java code,

package pkg;
import com.thinkaurelius.titan.core.EdgeLabel;
import com.thinkaurelius.titan.core.Multiplicity;
import com.thinkaurelius.titan.core.PropertyKey;
import com.thinkaurelius.titan.core.TitanFactory;
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanTransaction;
import com.thinkaurelius.titan.core.attribute.Geoshape;
import com.thinkaurelius.titan.core.schema.ConsistencyModifier;
import com.thinkaurelius.titan.core.schema.TitanGraphIndex;
import com.thinkaurelius.titan.core.schema.TitanManagement;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;

import java.io.File;
public class empgraph{

public static void main(String[] args) {
// TODO Auto-generated method stub
        
String uniqueNameCompositeIndex = null;
TitanGraph gh = TitanFactory.open("Documents/myproject/titan-1.0-2.0-hadoop1/conf/titan-cassandra-embedded-es.properties");
TitanManagement mgmt = gh.openManagement();
final PropertyKey empname = mgmt.makePropertyKey("empname").dataType(String.class).make();
final PropertyKey empRole = mgmt.makePropertyKey("empRole").dataType(String.class).make();
final PropertyKey empExperience = mgmt.makePropertyKey("empExperience").dataType(Integer.class).make();
mgmt.buildIndex("empname", Vertex.class).addKey(empname).buildCompositeIndex();
System.out.println("property key generated");
mgmt.makeVertexLabel("employee").make();
//Edge labels  
mgmt.buildIndex("edges", Edge.class).addKey(empname).buildCompositeIndex();
mgmt.makeEdgeLabel("workswith").multiplicity(Multiplicity.MULTI).make();
                mgmt.makeEdgeLabel("reportTo").multiplicity(Multiplicity.MANY2ONE).make();
mgmt.commit();
        System.out.println("Edge lables generated");
        TitanTransaction tx = gh.newTransaction();
        
     // vertices
        Vertex scott = gh.addVertex(T.label, "employee", "empname", "scott", "empRole", "Engineer", "empExperience", 6);
        Vertex rich = gh.addVertex(T.label, "employee","empname", "rich", "empRole", "architect", "empExperience", 13);
        Vertex david = gh.addVertex(T.label, "employee","empname", "david", "empRole", "teamlead", "empExperience", 10);
        Vertex tommy = gh.addVertex(T.label,"employee", "empname", "tommy", "empRole", "consultant", "empExperience", 9);
        Vertex santo = gh.addVertex(T.label, "employee","empname", "santo ", "empRole", "manager", "empExperience", 15);
        
        System.out.println("vertex genearated*******");
     // edges
        
        scott.addEdge("workswith", rich);
        scott.addEdge("workswith", david);
        scott.addEdge("workswith", tommy);
        scott.addEdge("reportTo", santo);
        
        rich.addEdge("workswith", scott);
        rich.addEdge("workswith", david);
        rich.addEdge("workswith", tommy);
        rich.addEdge("workswith", santo);
        
        david.addEdge("workswith", rich);
        david.addEdge("workswith", scott);
        david.addEdge("workswith", tommy);
        david.addEdge("reportTo", santo);
        
        tommy.addEdge("workswith", rich);
        tommy.addEdge("workswith", david);
        tommy.addEdge("workswith", scott);
        tommy.addEdge("reportTo", santo);
        
        santo.addEdge("workswith", rich);
        santo.addEdge("workswith", david);
        santo.addEdge("workswith", scott);
        santo.addEdge("workswith", tommy);
        
        System.out.println("Graph Generated****");
     
        tx.commit();
}

}


I have run the code with out any errors but I am not getting any data while querying the graph in gremlin console,

gremlin> gh  = TitanFactory.open("conf/titan-cassandra-embedded-es.properties")

15:42:32 WARN  org.apache.cassandra.utils.CLibrary  - JNA link failure, one or more native method will be unavailable.

15:42:32 WARN  org.apache.cassandra.service.CassandraDaemon  - JMX is not enabled to receive remote connections. Please see cassandra-env.sh for more info.

15:42:32 ERROR org.apache.cassandra.service.CassandraDaemon  - cassandra.jmx.local.port missing from cassandra-env.sh, unable to start local JMX service.null

==>standardtitangraph[embeddedcassandra:[127.0.0.1]]

gremlin> g = gh.traversal()

==>graphtraversalsource[standardtitangraph[embeddedcassandra:[127.0.0.1]], standard]

gremlin> g

==>graphtraversalsource[standardtitangraph[embeddedcassandra:[127.0.0.1]], standard]

gremlin> g.V()

15:43:13 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

gremlin> g.V().has('name','srinivas')

gremlin> g.V().has('name','rich')

gremlin> g.V.hasNext()

No such property: V for class: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource

Display stack trace? [yN] y

groovy.lang.MissingPropertyException: No such property: V for class: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:51)

at org.codehaus.groovy.runtime.callsite.PojoMetaClassGetPropertySite.getProperty(PojoMetaClassGetPropertySite.java:35)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:293)

at groovysh_evaluate.run(groovysh_evaluate:3)



gremlin> g.V().hasNext()

17:11:15 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

==>false




Also did not find any errors in log, related to Index generation. 

INFO StorageService:1665 - Node /127.0.0.1 state jump to normal

15:52:56,010  INFO CompactionTask:274 - Compacted 4 sstables to [db/cassandra/data/system/local-7ad54392bcdd35a684174e047860b377/system-local-ka-567,].  1,498 bytes to 905 (~60% of original) in 15ms = 0.057538MB/s.  4 total partitions merged to 1.  Partition merge counts were {4:1, }

15:52:56,156  INFO Server:156 - Netty using Java NIO event loop

15:52:56,196  INFO Server:181 - Using Netty Version: [netty-buffer=netty-buffer-4.0.25.Final.087db82, netty-codec=netty-codec-4.0.25.Final.087db82, netty-codec-http=netty-codec-http-4.0.25.Final.087db82, netty-codec-socks=netty-codec-socks-4.0.25.Final.087db82, netty-common=netty-common-4.0.25.Final.087db82, netty-handler=netty-handler-4.0.25.Final.087db82, netty-tcnative=netty-tcnative-1.1.32.Fork1.9e735d2, netty-transport=netty-transport-4.0.25.Final.087db82, netty-transport-native-epoll=netty-transport-native-epoll-4.0.25.Final.087db82, netty-transport-rxtx=netty-transport-rxtx-4.0.25.Final.087db82, netty-transport-sctp=netty-transport-sctp-4.0.25.Final.087db82, netty-transport-udt=netty-transport-udt-4.0.25.Final.087db82]

15:52:56,197  INFO Server:182 - Starting listening for CQL clients on localhost/127.0.0.1:9042...

15:52:56,404  INFO ThriftServer:119 - Binding thrift service to localhost/127.0.0.1:9160

15:52:56,411  INFO ThriftServer:136 - Listening for thrift clients...

15:52:56,484  INFO ReflectiveConfigOptionLoader:159 - Loaded and initialized config classes: 12 OK out of 12 attempts in PT0.05S

15:52:56,617  INFO Reflections:224 - Reflections took 106 ms to scan 1 urls, producing 0 keys and 0 values 

15:52:56,694  INFO GraphDatabaseConfiguration:1358 - Set default timestamp provider MICRO

15:52:56,705  INFO GraphDatabaseConfiguration:1518 - Generated unique-instance-id=0a481c0e62690-BLRJPT311650D1

15:52:56,719  INFO Backend:459 - Configuring index [search]

15:52:56,831  INFO node:141 - [Quicksilver] version[1.5.1], pid[62690], build[5e38401/2015-04-09T13:41:35Z]

15:52:56,831  INFO node:143 - [Quicksilver] initializing ...

15:52:56,835  INFO plugins:151 - [Quicksilver] loaded [], sites []

15:52:58,518  INFO node:213 - [Quicksilver] initialized

15:52:58,518  INFO node:232 - [Quicksilver] starting ...

15:52:58,521  INFO transport:155 - [Quicksilver] bound_address {local[1]}, publish_address {local[1]}

15:52:58,530  INFO discovery:85 - [Quicksilver] elasticsearch/cbnKkjcxRJSp_qvLW0tgvQ

15:52:58,532  INFO service:437 - [Quicksilver] master {new [Quicksilver][cbnKkjcxRJSp_qvLW0tgvQ][BLRJPT311650D][local[1]]{local=true}}, removed {[Quicksilver][qF0Nb8F5QiGhWWwN13Xs_g][BLRJPT311650D][local[1]]{local=true},}, reason: local-disco-initial_connect(master)

15:52:58,561  INFO gateway:272 - [Quicksilver] recovered [0] indices into cluster_state

15:52:58,588  INFO http:91 - [Quicksilver] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/10.72.28.14:9200]}

15:52:58,589  INFO node:267 - [Quicksilver] started

15:52:58,790  INFO metadata:453 - [Quicksilver] [titan] creating index, cause [api], templates [], shards [5]/[1], mappings []

15:52:59,150  INFO Backend:176 - Initiated backend operations thread pool of size 16

15:52:59,164  INFO Backend:254 - Configuring total store cache size: 390576550

15:52:59,236  INFO KCVSLog:730 - Loaded unidentified ReadMarker start time 2016-06-21T10:22:59.221Z into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller@5c125a0a




I have gone thru different forum post, tried different ways(build index code in java) but the problem still persist.


Please help.


TIA,

Vasu



Daniel Kuppitz

unread,
Jun 21, 2016, 9:55:49 AM6/21/16
to aureliu...@googlegroups.com
Don't create an explicit transaction (TitanTransaction tx = gh.newTransaction()), if you don't use it. Remove this line and replace the last line (tx.commit()) with gh.tx().commit().

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/15fa6e2b-4d90-4892-ae25-6b737815d7aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vasu kothapalli

unread,
Jun 22, 2016, 8:27:50 AM6/22/16
to Aurelius
HI Daniel,

Thanks for quick response, Removed Transaction related steps and re-ran with updated code. but still getting the same issue with same error message. 

when I run below query, getting  "false" response. does this mean graph exist in Titan? Is there any problem with the java code? Even I am facing same issue with the GraphofTheGodsFactory sample code  in Github. 

gremlin> g.V().hasNext()

17:15:44 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

==>false


When I create graph manually thru gremlin console, when run the following query, getting "true" response. and I was able to query other vertices in graph.

gremlin> g.V().hasNext()

17:22:02 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

==>true 


Thank you,
Srinivas.

Daniel Kuppitz

unread,
Jun 22, 2016, 9:28:24 AM6/22/16
to aureliu...@googlegroups.com
The code looks proper to me. Are you 100% sure that your Java app and the Gremlin console are using the same graph? I see that there are at least two relative paths involved: Maybe try to use absolute paths (in your app code and in the config files).

Cheers,
Daniel


Vasu kothapalli

unread,
Jun 23, 2016, 10:19:15 AM6/23/16
to Aurelius
Hi Daniel,

I am using same config file path(URI) for both gremlin console and Java app. Also I am querying the graph from the Java app using same config file path which i used for graph creation, but data not being retrieved.

Below sample code snippet used for graph querying..


TitanGraph gh = TitanFactory.open("/Users/scottarao_k09/Documents/myproject/titan-1.0-2.0-hadoop1/conf/titan-cassandra-embedded-es.properties");
GraphTraversalSource g = gh.traversal();
gh.query().vertices();
g.V("empname", "scott");
g.E();
System.out.println("traversal"+g.V().has("empname", "scott"));
g.V().has("empname", "scott").value();
System.out.println("vertex value-------"+g.V().has("empname", "scott").value());


Also attached Log details generated for Graph generation and for graph querying, can you check.

Thank you
vasu
titanlog_graphGeneration.txt
titanlog.txt

Daniel Kuppitz

unread,
Jun 23, 2016, 11:08:37 AM6/23/16
to aureliu...@googlegroups.com
The Java code to read stuff from the graph and print it doesn't look good. Try something more like this:

g.V("empname", "scott").forEachRemaining(System.out::println);

Cheers,
Daniel


Vasu kothapalli

unread,
Jun 27, 2016, 9:16:27 AM6/27/16
to Aurelius
Hi Daniel,


Now I am able see the data, I removed existing Titan pkg and re installed fresh one. Initially while testing I manually deleted the few folders(data, db) to clear the existing graph. May be that caused the issue.

Thank you,
Vasu
Reply all
Reply to author
Forward
0 new messages