当前位置: 首页>>代码示例>>Java>>正文


Java TitanGraph.close方法代码示例

本文整理汇总了Java中com.thinkaurelius.titan.core.TitanGraph.close方法的典型用法代码示例。如果您正苦于以下问题:Java TitanGraph.close方法的具体用法?Java TitanGraph.close怎么用?Java TitanGraph.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thinkaurelius.titan.core.TitanGraph的用法示例。


在下文中一共展示了TitanGraph.close方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTitanFactoryBuilder

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
@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();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:18,代码来源:ElasticSearchConfigTest.java

示例2: doWork

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
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();
    }
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:21,代码来源:Driver.java

示例3: testGraphOfTheGodsFactoryCreate

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:13,代码来源:BerkeleyElasticsearchTest.java

示例4: clear

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
@Override
public void clear() {
    TitanGraph graph = getGraph();
    if (graph.isOpen()) {
        // only a shut down graph can be cleared
        graph.close();
    }
    TitanCleanup.clear(graph);
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:10,代码来源:Titan1Graph.java

示例5: main

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		Configuration conf = new PropertiesConfiguration( getRelativeResourcePath( "titan-cassandra-es.properties" ) );
		// start elastic search on startup
		Node node = new NodeBuilder().node();
		
		TitanGraph graph = TitanFactory.open(conf);
		/* Comment if you do not want to reload the graph every time */
		graph.close();
		TitanCleanup.clear(graph);
		graph = TitanFactory.open(conf);
		GraphOfTheGodsFactory.load(graph);
		/* graph loaded  */
		
		// create own indexes
		TitanManagement mgmt = graph.openManagement();
		PropertyKey name = mgmt.getPropertyKey("name");
		PropertyKey age = mgmt.getPropertyKey("age");
		mgmt.buildIndex( "byNameComposite", Vertex.class ).addKey(name).buildCompositeIndex();
		// index consisting of multiple properties
		mgmt.buildIndex( "byNameAndAgeComposite", Vertex.class ).addKey(name).addKey(age).buildCompositeIndex();
		mgmt.commit();
		
		// wait for the index to become available
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameComposite").call();
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameAndAgeComposite").call();
		
		// create new vertex
		Vertex me = graph.addVertex("theOneAndOnly");
		me.property( "name", "me" );
		me.property( "age", 1 );
		graph.tx().commit();
		System.out.println("Created the one and only!");
		
		// re index the existing data (not required, just for demo purposes)
		mgmt = graph.openManagement();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameComposite"), SchemaAction.REINDEX ).get();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameAndAgeComposite"), SchemaAction.REINDEX ).get();
		mgmt.commit();
		
		GraphTraversalSource g = graph.traversal();
		GremlinPipeline<GraphTraversal<?, ?>, ?> pipe = new GremlinPipeline();
		
		// read our new vertex
		pipe.start( g.V().has( "name", "me" ) );	
		Vertex v = (Vertex)pipe.next();
		System.out.println();
		System.out.println( "Label: " + v.label() );
		System.out.println( "Name: " + v.property("name").value() );
		System.out.println( "Age: " + v.property("age").value() );
		System.out.println();
		
		// read different vertex
		pipe.start( g.V().has( "name", "hercules" ) );	
		Vertex herclues = (Vertex)pipe.next();
		System.out.println( "Label: " + herclues.label() );
		System.out.println( "Name: " + herclues.property("name").value() );
		System.out.println( "Age: " + herclues.property("age").value() );
		
		// print some edges
		Iterator<Edge> it = herclues.edges( Direction.OUT );
		while( it.hasNext() ) {
			Edge e = it.next();
			System.out.println( "Out: " + e.label()  + " --> " + e.inVertex().property("name").value() );
		}
		System.out.println();
		
		// close graph
		graph.close();
		// close elastic search on shutdown
		node.close();
		
		System.exit(0);
	}
 
开发者ID:maltesander,项目名称:titan-cassandra-elasticsearch-index,代码行数:75,代码来源:TitanStart.java

示例6: setAndCheckGraphOption

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
private <T> void setAndCheckGraphOption(ConfigOption<T> opt, ConfigOption.Type requiredType, T firstValue, T secondValue) {
    // Sanity check: make sure the Type of the configoption is what we expect
    Preconditions.checkState(opt.getType().equals(requiredType));
    final EnumSet<ConfigOption.Type> allowedTypes =
            EnumSet.of(ConfigOption.Type.GLOBAL,
                    ConfigOption.Type.GLOBAL_OFFLINE,
                    ConfigOption.Type.MASKABLE);
    Preconditions.checkState(allowedTypes.contains(opt.getType()));

    // Sanity check: it's kind of pointless for the first and second values to be identical
    Preconditions.checkArgument(!firstValue.equals(secondValue));

    // Get full string path of config option
    final String path = ConfigElement.getPath(opt);

    // Set and check initial value before and after database restart
    mgmt.set(path, firstValue);
    assertEquals(firstValue.toString(), mgmt.get(path));
    // Close open tx first.  This is specific to BDB + GLOBAL_OFFLINE.
    // Basically: the BDB store manager throws a fit if shutdown is called
    // with one or more transactions still open, and GLOBAL_OFFLINE calls
    // shutdown on our behalf when we commit this change.
    tx.rollback();
    mgmt.commit();
    clopen();
    // Close tx again following clopen
    tx.rollback();
    assertEquals(firstValue.toString(), mgmt.get(path));

    // Set and check updated value before and after database restart
    mgmt.set(path, secondValue);
    assertEquals(secondValue.toString(), mgmt.get(path));
    mgmt.commit();
    clopen();
    tx.rollback();
    assertEquals(secondValue.toString(), mgmt.get(path));

    // Open a separate graph "g2"
    TitanGraph g2 = TitanFactory.open(config);
    TitanManagement m2 = g2.openManagement();
    assertEquals(secondValue.toString(), m2.get(path));

    // GLOBAL_OFFLINE options should be unmodifiable with g2 open
    if (opt.getType().equals(ConfigOption.Type.GLOBAL_OFFLINE)) {
        try {
            mgmt.set(path, firstValue);
            mgmt.commit();
            fail("Option " + path + " with type " + ConfigOption.Type.GLOBAL_OFFLINE + " should not be modifiable with concurrent instances");
        } catch (RuntimeException e) {
            log.debug("Caught expected exception", e);
        }
        assertEquals(secondValue.toString(), mgmt.get(path));
        // GLOBAL and MASKABLE should be modifiable even with g2 open
    } else {
        mgmt.set(path, firstValue);
        assertEquals(firstValue.toString(), mgmt.get(path));
        mgmt.commit();
        clopen();
        assertEquals(firstValue.toString(), mgmt.get(path));
    }

    m2.rollback();
    g2.close();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:65,代码来源:TitanGraphTest.java

示例7: testLists

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
@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();

}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:45,代码来源:VertexListTest.java

示例8: testTitanFactoryShorthand

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
@Test
public void testTitanFactoryShorthand() {
    TitanGraph g = TitanFactory.open("inmemory");
    g.close();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:6,代码来源:TitanFactoryShorthandTest.java

示例9: main

import com.thinkaurelius.titan.core.TitanGraph; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:26,代码来源:GraphOfTheGodsFactory.java


注:本文中的com.thinkaurelius.titan.core.TitanGraph.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。