@Override
 public void run(GraphDatabaseAPI graphdb) {
   try (Transaction ignored = graphdb.beginTx()) {
     for (int i = 0; i < count; i++)
       graphdb.index().forNodes("index" + i).get("name", i).getSingle();
   }
   if (resume) resumeFlushThread();
 }
 @Override
 public void run(GraphDatabaseAPI graphdb) {
   try (Transaction tx = graphdb.beginTx()) {
     for (int i = 0; i < 3; i++)
       graphdb.index().forNodes("index" + i).add(graphdb.createNode(), "name", "" + i);
     tx.success();
   }
 }
Beispiel #3
0
 @Override
 public void run(GraphDatabaseAPI graphdb) {
   assertNotNull("No graph database", graphdb);
   Index<Node> index = graphdb.index().forNodes("nodes");
   assertNotNull("No index", index);
   Node node = index.get("name", "value").getSingle();
   assertNotNull("could not get the node", node);
   assertEquals("yes", node.getProperty("correct"));
 }
  @Test
  public void givenClusterWithCreatedIndexWhenDeleteIndexOnMasterThenIndexIsDeletedOnSlave()
      throws Throwable {
    ClusterManager clusterManager =
        new ClusterManager(
            fromXml(getClass().getResource("/threeinstances.xml").toURI()),
            TargetDirectory.forTest(getClass()).cleanDirectory("testCluster"),
            MapUtil.stringMap(
                HaSettings.ha_server.name(), ":6001-6005", HaSettings.tx_push_factor.name(), "2"));
    try {
      // Given
      clusterManager.start();

      clusterManager.getDefaultCluster().await(ClusterManager.allSeesAllAsAvailable());

      GraphDatabaseAPI master = clusterManager.getDefaultCluster().getMaster();
      try (Transaction tx = master.beginTx()) {
        master.index().forNodes("Test");
        tx.success();
      }

      HighlyAvailableGraphDatabase aSlave = clusterManager.getDefaultCluster().getAnySlave();
      try (Transaction tx = aSlave.beginTx()) {
        assertThat(aSlave.index().existsForNodes("Test"), equalTo(true));
        tx.success();
      }

      // When
      try (Transaction tx = master.beginTx()) {
        master.index().forNodes("Test").delete();
        tx.success();
      }

      // Then
      HighlyAvailableGraphDatabase anotherSlave = clusterManager.getDefaultCluster().getAnySlave();
      try (Transaction tx = anotherSlave.beginTx()) {
        assertThat(anotherSlave.index().existsForNodes("Test"), equalTo(false));
        tx.success();
      }
    } finally {
      clusterManager.stop();
    }
  }
  public static void main(String[] args) throws IOException {
    GraphDatabaseAPI db = (GraphDatabaseAPI) new GraphDatabaseFactory().newEmbeddedDatabase(dir);
    Transaction tx = db.beginTx();
    db.createNode().createRelationshipTo(db.createNode(), MyRelTypes.TEST);
    tx.success();
    tx.close();

    db.getDependencyResolver().resolveDependency(LogRotation.class).rotateLogFile();

    tx = db.beginTx();
    db.index().forNodes("index").add(db.createNode(), dir, db.createNode());
    tx.success();
    tx.close();
    exit(0);
  }
Beispiel #6
0
    @Override
    public void run(GraphDatabaseAPI graphdb) {
      Transaction tx = graphdb.beginTx();
      Node node;
      try { // hack to get around another bug
        node = graphdb.createNode();

        tx.success();
      } finally {
        tx.finish();
      }
      tx = graphdb.beginTx();
      try {
        node.setProperty("correct", "yes");
        graphdb.index().forNodes("nodes").add(node, "name", "value");

        tx.success();
      } finally {
        tx.finish();
      }
    }