@Override public void commit() { if (!active) { throw new XOException("There is no active transaction."); } active = false; titanGraph.commit(); }
@Override public void cleanup(final Reducer<LongWritable, FaunusVertex, NullWritable, FaunusVertex>.Context context) throws IOException, InterruptedException { this.graph.commit(); this.graph.shutdown(); } }
public static void unload() { synchronized (Titan0GraphDatabase.class) { if (graphInstance == null) { return; } graphInstance.commit(); //shutdown invalidates the graph instance graphInstance.shutdown(); graphInstance = null; } }
@Override public void commit() { getGraph().commit(); }
@Override public void run() { LOG.info("Performing final commit for archive vertex: " + archiveModelID); context.getGraph().getBaseGraph().commit(); } });
@Override public void relateNodes(Vertex src, Vertex dest) { try { titanGraph.addEdge(null, src, dest, "similar"); titanGraph.commit(); } catch (Exception e) { titanGraph.rollback(); //TODO(amcp) why can this happen? doesn't this indicate illegal state? } } }
public static void assertGraphOfTheGods(TitanGraph gotg) { assertEquals(12,Iterables.size(gotg.getVertices())); assertEquals(3,Iterables.size(gotg.getVertices("label","god"))); Vertex h = Iterables.getOnlyElement(gotg.getVertices("name","hercules")); assertEquals(30,h.getProperty("age")); assertEquals("demigod",((TitanVertex)h).getLabel()); assertEquals(5,Iterables.size(h.getEdges(Direction.BOTH))); gotg.commit(); }
@Override public Vertex getOrCreate(String value) { Integer intValue = Integer.valueOf(value); final Vertex v; if (titanGraph.query().has("nodeId", Compare.EQUAL, intValue).vertices().iterator().hasNext()) { v = (Vertex) titanGraph.query().has("nodeId", Compare.EQUAL, intValue).vertices().iterator().next(); } else { final long titanVertexId = TitanId.toVertexId(intValue); v = titanGraph.addVertex(titanVertexId); v.setProperty("nodeId", intValue); titanGraph.commit(); } return v; }
@Override public void init(Map<Class<?>, TypeMetadata> registeredMetadata) { logger.info("Initializing eXtended Objects for Titan on Cassandra..."); Configuration configuration = new BaseConfiguration(); configuration.setProperty("storage.backend", "cassandra"); configuration.setProperty("storage.hostname", host); if (port > 0) { configuration.setProperty("storage.port", port); } if (keyspace != null) { configuration.setProperty("storage.cassandra.keyspace", keyspace); } titanGraph = TitanFactory.open(configuration); try { checkAndInitializeDiscriminatorProperties(registeredMetadata); checkAndInitializePropertyIndizes(registeredMetadata); } finally { titanGraph.commit(); } }
context.getGraph().getBaseGraph().commit();