當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphDatabaseService.shutdown方法代碼示例

本文整理匯總了Java中org.neo4j.graphdb.GraphDatabaseService.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphDatabaseService.shutdown方法的具體用法?Java GraphDatabaseService.shutdown怎麽用?Java GraphDatabaseService.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.neo4j.graphdb.GraphDatabaseService的用法示例。


在下文中一共展示了GraphDatabaseService.shutdown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldNotIndexNodesWithWrongLabel

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void shouldNotIndexNodesWithWrongLabel() throws Exception
{
    // Given
    BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );

    inserter.createNode( map("name", "Bob"), label( "User" ), label("Admin"));

    inserter.createDeferredSchemaIndex( label( "Banana" ) ).on( "name" ).create();

    // When
    inserter.shutdown();

    // Then
    GraphDatabaseService db = dbRule.getGraphDatabaseService();
    try(Transaction tx = db.beginTx())
    {
        assertThat( count( db.findNodes( label( "Banana" ), "name", "Bob" ) ), equalTo(0) );
    }
    finally
    {
        db.shutdown();
    }

}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-lucene5-index,代碼行數:26,代碼來源:BatchInsertionIT.java

示例2: shouldBeAbleToMakeRepeatedCallsToSetNodeProperty

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void shouldBeAbleToMakeRepeatedCallsToSetNodeProperty() throws Exception
{
    BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );
    long nodeId = inserter.createNode( Collections.<String, Object>emptyMap() );

    final Object finalValue = 87;
    inserter.setNodeProperty( nodeId, "a", "some property value" );
    inserter.setNodeProperty( nodeId, "a", 42 );
    inserter.setNodeProperty( nodeId, "a", 3.14 );
    inserter.setNodeProperty( nodeId, "a", true );
    inserter.setNodeProperty( nodeId, "a", finalValue );
    inserter.shutdown();

    GraphDatabaseService db = dbRule.getGraphDatabaseService();
    try(Transaction ignored = db.beginTx())
    {
        assertThat( db.getNodeById( nodeId ).getProperty( "a" ), equalTo( finalValue ) );
    }
    finally
    {
        db.shutdown();
    }
}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-lucene5-index,代碼行數:25,代碼來源:BatchInsertionIT.java

示例3: insert_node_should_succeed_with_populated_index

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void insert_node_should_succeed_with_populated_index() throws Exception {
    Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);

    // populate the db
    List<String> columns = DummyTalendPojo.getColumnList();
    for (int i = 0; i < 100; i++) {
        DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo();
        nodeInserter.create(pojo, columns);
    }
    nodeInserter.finish();

    // check if index size
    Assert.assertEquals(100, batchDb.batchInserterIndexes.get(INDEX_NAME).query("*:*").size());

    // check the database data
    batchDb.shutdown();
    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        String result = graphDb.execute("MATCH (n:" + LABEL_NAME + ") RETURN count(n) AS count").resultAsString();
        Assert.assertEquals("+-------+\n| count |\n+-------+\n| 100   |\n+-------+\n1 row\n", result);
    }
    graphDb.shutdown();
}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:26,代碼來源:Neo4jBatchInserterNodeTest.java

示例4: update_node_should_succeed

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void update_node_should_succeed() throws Exception {
    // populate the db
    Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);
    List<String> columns = DummyTalendPojo.getColumnList();
    DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo();
    nodeInserter.create(pojo, columns);
    nodeInserter.finish();

    // By indexing the import id, I update the last node
    pojo.propString = "A new String";
    nodeInserter = getNeo4jBatchInserterNode(true);
    nodeInserter.create(pojo, columns);
    nodeInserter.finish();

    // check the result into the database
    batchDb.shutdown();
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        String result = graphDb.execute("MATCH (n:" + LABEL_NAME + ") WHERE exists(n.id) RETURN n.propString AS string").resultAsString();
        Assert.assertEquals("+----------------+\n| string         |\n+----------------+\n| \"A new String\" |\n+----------------+\n1 row\n", result);
    }
    graphDb.shutdown();
}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:25,代碼來源:Neo4jBatchInserterNodeTest.java

示例5: create_node_uniqueness_constraint_should_work

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void create_node_uniqueness_constraint_should_work() {
    // Test const.
    String label = "Test";
    String property = "myProp";

    // crete the schema
    batchDb.createSchema("NODE_PROPERTY_UNIQUE", label, property);
    batchDb.shutdown();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        Assert.assertTrue(graphDb.schema().getConstraints(DynamicLabel.label(label)).iterator().hasNext());
    }
    graphDb.shutdown();
}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:18,代碼來源:Neo4jBatchDatabaseTest.java

示例6: create_node_index_should_work

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void create_node_index_should_work() {
    // Test const.
    String label = "Test";
    String property = "myProp";

    // crete the schema
    batchDb.createSchema("NODE_PROPERTY_INDEX", label, property);
    batchDb.shutdown();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        Assert.assertTrue(graphDb.schema().getIndexes(DynamicLabel.label(label)).iterator().hasNext());
    }
    graphDb.shutdown();

}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:19,代碼來源:Neo4jBatchDatabaseTest.java

示例7: testRelReader

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void testRelReader() throws IOException{
  
  RelReader reader = new RelReader(neo4jLocation);
  reader.batchBuildGraph(new File("my_test_umls/"), "CtakesAllTuis.txt", "SNOMEDCT_US");
  GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(new File(neo4jLocation));
  
  try ( Transaction tx = db.beginTx() ){
    TraversalDescription td = db.traversalDescription()
        .breadthFirst()
        .relationships(RelReader.RelTypes.ISA, Direction.INCOMING)
        .evaluator(Evaluators.excludeStartPosition());

    Node cuiNode = db.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, "C0007102");
    Assert.assertNotNull(cuiNode);
    Traverser traverser = td.traverse(cuiNode);
    for(Path path : traverser){
      System.out.println("At depth " + path.length() + " => " + path.endNode().getProperty("cui"));
    }
  }
  db.shutdown();
}
 
開發者ID:tmills,項目名稱:umls-graph-api,代碼行數:23,代碼來源:TestRelReader.java

示例8: executeBreadthFirstSearch

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
private BreadthFirstSearchOutput executeBreadthFirstSearch(GraphStructure graph,
		BreadthFirstSearchParameters parameters, boolean directed) {
	GraphDatabaseService database = ValidationGraphLoader.loadValidationGraphToDatabase(graph);
	new BreadthFirstSearchComputation(database, parameters.getSourceVertex(), directed).run();

	Map<Long, Long> output = new HashMap<>();
	try (Transaction ignored = database.beginTx()) {
		for (Node node : GlobalGraphOperations.at(database).getAllNodes()) {
			if (node.hasProperty(DISTANCE)) {
				output.put((long)node.getProperty(ID_PROPERTY), (long)node.getProperty(DISTANCE));
			} else {
				output.put((long)node.getProperty(ID_PROPERTY), Long.MAX_VALUE);
			}
		}
	}
	database.shutdown();
	return new BreadthFirstSearchOutput(output);
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-neo4j,代碼行數:19,代碼來源:BreadthFirstSearchComputationTest.java

示例9: deleteIndex

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void deleteIndex()
{
    GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
    try ( Transaction tx = graphDb.beginTx() )
    {
        // START SNIPPET: delete
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes( "actors" );
        actors.delete();
        // END SNIPPET: delete
        tx.success();
    }
    assertFalse( indexExists( graphDb ) );
    graphDb.shutdown();
}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-lucene5-index,代碼行數:17,代碼來源:ImdbDocTest.java

示例10: dbWithConstraint

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
private void dbWithConstraint()
{
    GraphDatabaseService db = startDatabase();
    try
    {
        try ( Transaction tx = db.beginTx() )
        {
            db.schema().constraintFor( label( "Label1" ) ).assertPropertyIsUnique( "key1" ).create();

            tx.success();
        }
    }
    finally
    {
        db.shutdown();
    }
}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-lucene5-index,代碼行數:18,代碼來源:ConstraintIndexFailureIT.java

示例11: canReadAndUpgradeOldIndexStoreFormat

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void canReadAndUpgradeOldIndexStoreFormat() throws Exception
{
    File path = new File( "target/var/old-index-store" );
    Neo4jTestCase.deleteFileOrDirectory( path );
    startDatabase( path ).shutdown();
    InputStream stream = getClass().getClassLoader().getResourceAsStream( "old-index.db" );
    writeFile( stream, new File( path, "index.db" ) );
    GraphDatabaseService db = startDatabase( path );
    try ( Transaction ignore = db.beginTx() )
    {
        assertTrue( db.index().existsForNodes( "indexOne" ) );
        Index<Node> indexOne = db.index().forNodes( "indexOne" );
        verifyConfiguration( db, indexOne, LuceneIndexImplementation.EXACT_CONFIG );
        assertTrue( db.index().existsForNodes( "indexTwo" ) );
        Index<Node> indexTwo = db.index().forNodes( "indexTwo" );
        verifyConfiguration( db, indexTwo, LuceneIndexImplementation.FULLTEXT_CONFIG );
        assertTrue( db.index().existsForRelationships( "indexThree" ) );
        Index<Relationship> indexThree = db.index().forRelationships( "indexThree" );
        verifyConfiguration( db, indexThree, LuceneIndexImplementation.EXACT_CONFIG );
    }
    db.shutdown();
}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-lucene5-index,代碼行數:24,代碼來源:TestMigration.java

示例12: main

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
public static void main( String[] args )
{
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( args[0] );

    Index<Node> index;
    Index<Node> index2;
    try ( Transaction tx = db.beginTx() )
    {
        index = db.index().forNodes( "index" );
        index2 = db.index().forNodes( "index2" );
        Node node = db.createNode();
        index.add( node, "key", "value" );
        tx.success();
    }

    try ( Transaction tx = db.beginTx() )
    {
        index.delete();
        index2.add( db.createNode(), "key", "value" );
        tx.success();
    }

    db.shutdown();
    System.exit( 0 );
}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-lucene5-index,代碼行數:26,代碼來源:RecoveryTest.java

示例13: concurrentIndexPopulationAndInsertsShouldNotProduceDuplicates

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void concurrentIndexPopulationAndInsertsShouldNotProduceDuplicates() throws IOException
{
    // Given
    GraphDatabaseService db = newEmbeddedGraphDatabaseWithSlowJobScheduler();

    // When
    try ( Transaction tx = db.beginTx() )
    {
        db.schema().indexFor( label( "SomeLabel" ) ).on( "key" ).create();
        tx.success();
    }
    Node node;
    try ( Transaction tx = db.beginTx() )
    {
        node = db.createNode( label( "SomeLabel" ) );
        node.setProperty( "key", "value" );
        tx.success();
    }
    db.shutdown();

    // Then
    assertThat( nodeIdsInIndex( 1, "value" ), equalTo( singletonList( node.getId() ) ) );
}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-lucene5-index,代碼行數:25,代碼來源:NonUniqueIndexTests.java

示例14: execute_import_should_succeed

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void execute_import_should_succeed() throws IOException {
    this.importTool.execute();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        String result = graphDb.execute("MATCH ()-[r]->() RETURN count(r) AS count").resultAsString();
        Assert.assertEquals("+-------+\n| count |\n+-------+\n| 9     |\n+-------+\n1 row\n", result);
    }
    graphDb.shutdown();

}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:14,代碼來源:Neo4jImportToolTest.java

示例15: insert_edge_should_succeed

import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void insert_edge_should_succeed() throws Exception {
    Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);

    // populate the db with nodes
    List<String> columns = DummyTalendPojo.getColumnList();
    for (int i = 0; i < 100; i++) {
        DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo(i);
        nodeInserter.create(pojo, columns);
    }
    nodeInserter.finish();

    // create relationship
    Neo4jBatchInserterRelationship batchInserterRelationship = getNeo4jBatchInserterRelationship(true);
    for (int i = 0; i < 100; i++) {
        batchInserterRelationship.create(DummyTalendPojo.getDummyTalendPojo(i), DummyTalendPojo.getColumnList());
    }
    batchInserterRelationship.finish();

    // check the database data
    batchDb.shutdown();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        String result = graphDb.execute("MATCH ()-[r:" + REL_TYPE + "]->() RETURN count(r) AS count").resultAsString();
        Assert.assertEquals("+-------+\n| count |\n+-------+\n| 100   |\n+-------+\n1 row\n", result);
    }
    graphDb.shutdown();
}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:31,代碼來源:Neo4jBatchInserterRelationshipTest.java


注:本文中的org.neo4j.graphdb.GraphDatabaseService.shutdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。