public static void assertGraphOfTheGods(TitanGraph gotg) { assertCount(12, gotg.query().vertices()); assertCount(3, gotg.query().has(LABEL_NAME, "god").vertices()); TitanVertex h = getOnlyVertex(gotg.query().has("name", "hercules")); assertEquals(30, h.<Integer>value("age").intValue()); assertEquals("demigod", h.label()); assertCount(5, h.query().direction(Direction.BOTH).edges()); gotg.tx().commit(); }
@Override protected void closeGraphTransaction() throws Exception { getTinkerPopGraph().tx().close(); } }
@Override public void rollback() { getGraph().tx().rollback(); }
public static void unload() { synchronized (Titan1GraphDatabase.class) { if (graphInstance == null) { return; } graphInstance.tx().commit(); graphInstance.close(); graphInstance = null; } }
@Override public void commit() { getGraph().tx().commit(); }
@Override public void run() { int i = 0; Runnable command = null; while ((command = commands.poll()) != null) { try { command.run(); } catch (Throwable e) { Throwable rootCause = ExceptionUtils.getRootCause(e); String rootCauseMessage = null == rootCause ? "" : rootCause.getMessage(); LOG.error("Error processing comic book {} {}", e.getMessage(), rootCauseMessage, e); } if (i++ % BATCH_SIZE == 0) { try { graph.tx().commit(); } catch (Throwable e) { LOG.error("error processing commit {} {}", e.getMessage(), ExceptionUtils.getRootCause(e).getMessage()); } } } try { graph.tx().commit(); } catch (Throwable e) { LOG.error("error processing commit {} {}", e.getMessage(), ExceptionUtils.getRootCause(e).getMessage()); } }
@Override public void commitTx(){ try { super.commitTx(); } catch (TitanException e){ throw new GraknBackendException(e); } if(!getTinkerPopGraph().tx().isOpen()){ getTinkerPopGraph().tx().open(); //Until we sort out the transaction handling properly commits have to result in transactions being auto opened } }
private synchronized TitanGraph newTitanGraph(String name, String address, String pathToConfig){ TitanGraph titanGraph = configureGraph(name, address, pathToConfig); buildTitanIndexes(titanGraph); titanGraph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK); return titanGraph; }
private synchronized TitanGraph newTitanGraph(String name, String address, Properties properties, boolean batchLoading){ TitanGraph titanGraph = configureGraph(name, address, properties, batchLoading); buildTitanIndexes(titanGraph); titanGraph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK); return titanGraph; }
private static Graph openTuplGraph() { final Configuration conf = new BaseConfiguration(); conf.addProperty("storage.backend", "jp.classmethod.titan.diskstorage.tupl.TuplStoreManager"); final TitanGraph g = TitanFactory.open(conf); final TitanManagement mgmt = g.openManagement(); final PropertyKey nameKey = mgmt.makePropertyKey(NAME).cardinality(Cardinality.SINGLE).dataType(String.class).make(); mgmt.buildIndex("nameKeyIndex", Vertex.class).addKey(nameKey).unique().buildCompositeIndex(); mgmt.commit(); g.tx().commit(); return g; }
public static Graph createTheCrew() { final Configuration conf = new BaseConfiguration(); conf.addProperty("storage.backend", "jp.classmethod.titan.diskstorage.tupl.TuplStoreManager"); final TitanGraph g = TitanFactory.open(conf); final TitanManagement mgmt = g.openManagement(); mgmt.makePropertyKey(LOCATION).cardinality(Cardinality.LIST).dataType(String.class).make(); mgmt.makePropertyKey(START_TIME).cardinality(Cardinality.LIST).dataType(Integer.class).make(); mgmt.makePropertyKey(END_TIME).cardinality(Cardinality.LIST).dataType(Integer.class).make(); mgmt.commit(); g.tx().commit(); generateTheCrew(g); return g; }