Пример #1
0
  public OnlineBackup full(String targetDirectory, boolean verification) {
    if (directoryContainsDb(targetDirectory)) {
      throw new RuntimeException(targetDirectory + " already contains a database");
    }

    BackupClient client =
        new BackupClient(hostNameOrIp, port, StringLogger.DEV_NULL, Client.NO_STORE_ID_GETTER);
    try {
      Response<Void> response = client.fullBackup(new ToFileStoreWriter(targetDirectory));
      GraphDatabaseService targetDb =
          startTemporaryDb(targetDirectory, VerificationLevel.NONE /* run full check instead */);
      try {
        unpackResponse(response, targetDb, MasterUtil.txHandlerForFullCopy());
      } finally {
        targetDb.shutdown();
      }
      if (verification) {
        StoreAccess newStore = new StoreAccess(targetDirectory);
        try {
          ConsistencyCheck.run(newStore, false);
        } finally {
          newStore.close();
        }
      }
    } finally {
      client.shutdown();
    }
    return this;
  }
Пример #2
0
 public final <T extends CommonAbstractStore, R extends Abstract64BitRecord> void process(
     RecordProcessor<R> processor, StoreAccess<T, R> store, Filter<? super R>... filters) {
   long highId = store.getHighId();
   System.err.printf("%s for %s records%n", processor, Long.toString(highId));
   int lastPercent = 0;
   for (R record : store.scan(filters)) {
     processor.process(record);
     int permille = (int) ((record.getId() * 1000L) / highId);
     if (permille != lastPercent) progress(lastPercent = permille);
   }
   if (lastPercent != 1000) progress(1000);
 }