/** * Calls {@link TitanFactory#open(String)}, passing the Titan configuration file path * which must be the sole element in the {@code args} array, then calls * {@link #load(com.thinkaurelius.titan.core.TitanGraph)} on the opened graph, * then calls {@link com.thinkaurelius.titan.core.TitanGraph#close()} * and returns. * <p/> * This method may call {@link System#exit(int)} if it encounters an error, such as * failure to parse its arguments. Only use this method when executing main from * a command line. Use one of the other methods on this class ({@link #create(String)} * or {@link #load(com.thinkaurelius.titan.core.TitanGraph)}) when calling from * an enclosing application. * * @param args a singleton array containing a path to a Titan config properties file */ public static void main(String args[]) { if (null == args || 1 != args.length) { System.err.println("Usage: GraphOfTheGodsFactory <titan-config-file>"); System.exit(1); } TitanGraph g = TitanFactory.open(args[0]); load(g); g.close(); } }
/** * Test {@link com.thinkaurelius.titan.example.GraphOfTheGodsFactory#create(String)}. */ @Test public void testGraphOfTheGodsFactoryCreate() { File bdbtmp = new File("target/gotgfactory"); IOUtils.deleteDirectory(bdbtmp, true); TitanGraph gotg = GraphOfTheGodsFactory.create(bdbtmp.getPath()); TitanIndexTest.assertGraphOfTheGods(gotg); gotg.close(); } }
@Test public void testTitanFactoryBuilder() { String baseDir = Joiner.on(File.separator).join("target", "es", "titanfactory_jvmlocal_ext"); TitanFactory.Builder builder = TitanFactory.build(); builder.set("storage.backend", "inmemory"); builder.set("index." + INDEX_NAME + ".elasticsearch.interface", "NODE"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs"); TitanGraph graph = builder.open(); // Must not throw an exception assertTrue(graph.isOpen()); graph.close(); }
@Override public void closeDatabase() { getTitanGraph().close(); }
@Override public void shutdown() { getGraph().close(); }
@Override public void cleanup() { try { getGraphInstance().close(); } catch (Throwable t) { LOG.warn("Could not close test TitanGraph", t); t.printStackTrace(); } try { TitanCleanup.clear(getGraphInstance()); } catch (Throwable t) { LOG.warn("Could not clear test TitanGraph", t); t.printStackTrace(); } }
@Override protected void clearGraph() { TitanGraph titanGraph = getTinkerPopGraph(); titanGraph.close(); TitanCleanup.clear(titanGraph); }
public static void unload() { synchronized (Titan1GraphDatabase.class) { if (graphInstance == null) { return; } graphInstance.tx().commit(); graphInstance.close(); graphInstance = null; } }
/** * Calls {@link TitanFactory#open(String)}, passing the Titan configuration file path * which must be the sole element in the {@code args} array, then calls * {@link #load(com.thinkaurelius.titan.core.TitanGraph)} on the opened graph, * then calls {@link com.thinkaurelius.titan.core.TitanGraph#close()} * and returns. * <p/> * This method may call {@link System#exit(int)} if it encounters an error, such as * failure to parse its arguments. Only use this method when executing main from * a command line. Use one of the other methods on this class ({@link #create(String)} * or {@link #load(com.thinkaurelius.titan.core.TitanGraph)}) when calling from * an enclosing application. * * @param args a singleton array containing a path to a Titan config properties file */ public static void main(String args[]) { if (null == args || 1 != args.length) { System.err.println("Usage: GraphOfTheGodsFactory <titan-config-file>"); System.exit(1); } TitanGraph g = TitanFactory.open(args[0]); load(g); g.close(); } }
@Override public void clear() { TitanGraph graph = getGraph(); if (graph.isOpen()) { // only a shut down graph can be cleared graph.close(); } TitanCleanup.clear(graph); }
@Override public void clear() { TitanGraph titanGraph = getTinkerPopGraph(); titanGraph.close(); TitanCleanup.clear(titanGraph); EngineCommunicator.contactEngine(getCommitLogEndPoint(), REST.HttpConn.DELETE_METHOD); }