Java Code Examples for com.thinkaurelius.titan.core.TitanGraph#close()
The following examples show how to use
com.thinkaurelius.titan.core.TitanGraph#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticSearchConfigTest.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@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(); }
Example 2
Source File: Driver.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
private void doWork() { TitanGraph graph = TitanFactory.build().set("storage.backend", "inmemory").open(); // do "auto" transaction work graph.addVertex("type", "human"); graph.tx().commit(); // do "named" transaction work // TitanTransaction tx = graph.buildTransaction().logIdentifier("david1").start(); // Vertex v = tx.addVertex("type", "dog"); // Long id = (Long)v.id(); // tx.commit(); // GraphTraversalSource g = graph.traversal(); // Vertex v1 = g.V(id.longValue()).next(); // v1.remove(); graph.close(); }
Example 3
Source File: PopulateDB.java From titan-web-example with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { Configuration conf = new PropertiesConfiguration(TitanGraphFactory.PROPS_PATH); TitanGraph g = TitanFactory.open(conf); // Uncomment the following if your graph is already populated and you want to clear it out first. // g.close(); // TitanCleanup.clear(g); // g = TitanFactory.open(conf); // Interested in the source? // https://github.com/thinkaurelius/titan/blob/titan05/titan-core/src/main/java/com/thinkaurelius/titan/example/GraphOfTheGodsFactory.java GraphOfTheGodsFactory.load(g); g.close(); System.out.println("Success."); }
Example 4
Source File: BerkeleyElasticsearchTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
/** * 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(); }
Example 5
Source File: Titan1Graph.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public void clear() { TitanGraph graph = getGraph(); if (graph.isOpen()) { // only a shut down graph can be cleared graph.close(); } TitanCleanup.clear(graph); }
Example 6
Source File: VertexListTest.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@Test public void testLists() { int num = 13; TitanGraph g = TitanFactory.open("inmemory"); StandardTitanTx tx = (StandardTitanTx) g.newTransaction(); VertexLongList vll = new VertexLongList(tx); VertexArrayList val = new VertexArrayList(tx); for (int i=0; i<num; i++) { TitanVertex v = tx.addVertex(); vll.add(v); val.add(v); } assertEquals(num, Iterables.size(vll)); assertEquals(num, Iterables.size(val)); vll.sort(); val.sort(); assertTrue(vll.isSorted()); assertTrue(val.isSorted()); for (Iterable<TitanVertex> iterable : new Iterable[]{val,vll}) { Iterator<TitanVertex> iter = iterable.iterator(); TitanVertex previous = null; for (int i = 0; i < num; i++) { TitanVertex next = iter.next(); if (previous!=null) assertTrue(previous.longId()<next.longId()); previous = next; } try { iter.next(); fail(); } catch (NoSuchElementException ex) { } } tx.commit(); g.close(); }
Example 7
Source File: TitanFactoryShorthandTest.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@Test public void testTitanFactoryShorthand() { TitanGraph g = TitanFactory.open("inmemory"); g.close(); }
Example 8
Source File: GraphOfTheGodsFactory.java From titan1withtp3.1 with Apache License 2.0 | 3 votes |
/** * 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(); }