Example #1
0
 /**
  * Return the Transaction for {@code destination} that is backed up to {@code file}. This method
  * will finish committing the transaction before returning.
  *
  * @param destination
  * @param file
  * @return The restored Transaction
  */
 public static void recover(Engine destination, String file) {
   try {
     Transaction transaction =
         new Transaction(
             destination,
             FileSystem.map(file, MapMode.READ_ONLY, 0, FileSystem.getFileSize(file)));
     transaction.invokeSuperDoCommit();
     FileSystem.deleteFile(file);
   } catch (Exception e) {
     Logger.warn(
         "Attempted to recover a transaction from {}, "
             + "but the data is corrupted. This indicates that "
             + "Concourse Server shutdown before the transaction "
             + "could properly commit, so none of the data "
             + "in the transaction has persisted.",
         file);
     Logger.debug("Transaction backup in {} is corrupt because " + "of {}", file, e);
     FileSystem.deleteFile(file);
   }
 }
Example #2
0
 @Override
 protected void doCommit() {
   String file = ((Engine) destination).transactionStore + File.separator + id + ".txn";
   FileChannel channel = FileSystem.getFileChannel(file);
   try {
     channel.write(serialize());
     channel.force(true);
     Logger.info("Created backup for transaction {} at '{}'", this, file);
     invokeSuperDoCommit();
     FileSystem.deleteFile(file);
   } catch (IOException e) {
     throw Throwables.propagate(e);
   } finally {
     FileSystem.closeFileChannel(channel);
   }
 }