コード例 #1
0
 protected void configureSourceDb(final EmbeddedGraphDatabase graphDb) {
   XaDataSource neoStoreXaDataSource =
       graphDb
           .getConfig()
           .getPersistenceModule()
           .getPersistenceManager()
           .getPersistenceSource()
           .getXaDataSource();
   neoStoreXaDataSource.keepLogicalLogs(true);
   XaDataSourceManager xaDsm = graphDb.getConfig().getTxModule().getXaDataSourceManager();
   XaDataSource ds = xaDsm.getXaDataSource("lucene");
   ((LuceneDataSource) ds).keepLogicalLogs(true);
 }
  @Test
  public void testTxCacheLoadIsolation() throws Exception {
    Node node = getGraphDb().createNode();
    node.setProperty("someproptest", "testing");
    Node node1 = getGraphDb().createNode();
    node1.setProperty("someotherproptest", 2);
    commit();
    EmbeddedGraphDatabase graphDb = (EmbeddedGraphDatabase) getGraphDb();
    TransactionManager txManager = graphDb.getConfig().getTxModule().getTxManager();
    NodeManager nodeManager = graphDb.getConfig().getGraphDbModule().getNodeManager();

    txManager.begin();
    node.setProperty("someotherproptest", "testing2");
    Relationship rel = node.createRelationshipTo(node1, MyRelTypes.TEST);
    javax.transaction.Transaction txA = txManager.suspend();
    txManager.begin();
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(!node.hasProperty("someotherproptest"));
    assertTrue(!node.hasRelationship());
    nodeManager.clearCache();
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(!node.hasProperty("someotherproptest"));
    javax.transaction.Transaction txB = txManager.suspend();
    txManager.resume(txA);
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(node.hasProperty("someotherproptest"));
    assertTrue(node.hasRelationship());
    nodeManager.clearCache();
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(node.hasProperty("someotherproptest"));
    assertTrue(node.hasRelationship());
    txManager.suspend();
    txManager.resume(txB);
    assertEquals("testing", node.getProperty("someproptest"));
    assertTrue(!node.hasProperty("someotherproptest"));
    assertTrue(!node.hasRelationship());
    txManager.rollback();
    txManager.resume(txA);
    node.delete();
    node1.delete();
    rel.delete();
    txManager.commit();
    newTransaction();
  }
 @Override
 protected void configureSourceDb(final EmbeddedGraphDatabase graphDb) {
   PersistenceSource persistenceSource =
       graphDb.getConfig().getPersistenceModule().getPersistenceManager().getPersistenceSource();
   ((NeoStoreXaDataSource) persistenceSource.getXaDataSource()).keepLogicalLogs(false);
 }
コード例 #4
0
 @Override
 public Config getConfig() {
   return inner.getConfig();
 }
  @Test
  public void testLowGrabSize() {
    Map<String, String> config = new HashMap<String, String>();
    config.put("relationship_grab_size", "1");
    EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(getStorePath("neo2"), config);
    Transaction tx = graphDb.beginTx();
    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.createRelationshipTo(node2, MyRelTypes.TEST);
    node2.createRelationshipTo(node1, MyRelTypes.TEST2);
    node1.createRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
    tx.success();
    tx.finish();
    tx = graphDb.beginTx();
    Set<Relationship> rels = new HashSet<Relationship>();
    RelationshipType types[] =
        new RelationshipType[] {MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL};
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();

    for (Relationship rel : node1.getRelationships(types)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships()) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(types)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships()) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships(Direction.OUTGOING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(2, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships(Direction.INCOMING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(1, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(Direction.OUTGOING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(1, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(Direction.INCOMING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(2, rels.size());

    tx.success();
    tx.finish();
    graphDb.shutdown();
  }