I am creating a vertices in Titan with multiple threads. Here's my code
Trying to connect to Titan, Specifying the schema and then Adding vertices.
g = TitanFactory.open("/conf/titan-cassandra.properties");
TitanManagement mgmt = g.getManagementSystem();
final PropertyKey userid = mgmt.makePropertyKey("userid").dataType(Integer.class).make();
TitanGraphIndex namei = mgmt.buildIndex("userid",Vertex.class).addKey(userid).unique().buildCompositeIndex();
mgmt.setConsistency(namei, ConsistencyModifier.LOCK);
mgmt.commit();
Then I'm calling a function to Add Vertex
Multiple threads accessing function Add Vertex which takes input parameter - randomly generated unique numbers (entityPK)
tx1 = g.newTransaction();
Vertex user_ver = tx1.addVertexWithLabel("user");
user_ver.setProperty("userid",entityPK);
//Adding other properties for vertex
tx1.commit();`
I read that the exception that is thrown is because of not specifying the LOCK. But even after specifying LOCK, exception is thrown.
com.thinkaurelius.titan.core.TitanException: Could not commit transaction due to exception during persistence