aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevi...@apache.org
Subject incubator-aurora git commit: Stream backups directly to file.
Date Fri, 23 Jan 2015 20:45:14 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 3fa004b98 -> e3b8905ed


Stream backups directly to file.

Testing Done:
./gradlew build

Bugs closed: AURORA-1053

Reviewed at https://reviews.apache.org/r/30224/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/e3b8905e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/e3b8905e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/e3b8905e

Branch: refs/heads/master
Commit: e3b8905ede3209fe82d0ec1bf5cb5f187d45be2f
Parents: 3fa004b
Author: Kevin Sweeney <kevints@apache.org>
Authored: Fri Jan 23 11:26:11 2015 -0800
Committer: Kevin Sweeney <kevints@apache.org>
Committed: Fri Jan 23 11:26:11 2015 -0800

----------------------------------------------------------------------
 .../scheduler/storage/backup/StorageBackup.java | 21 ++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e3b8905e/src/main/java/org/apache/aurora/scheduler/storage/backup/StorageBackup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/backup/StorageBackup.java b/src/main/java/org/apache/aurora/scheduler/storage/backup/StorageBackup.java
index 69521d3..a20378a 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/backup/StorageBackup.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/backup/StorageBackup.java
@@ -13,9 +13,12 @@
  */
 package org.apache.aurora.scheduler.storage.backup;
 
+import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 import java.text.DateFormat;
@@ -40,10 +43,13 @@ import com.twitter.common.quantity.Time;
 import com.twitter.common.stats.Stats;
 import com.twitter.common.util.Clock;
 
-import org.apache.aurora.codec.ThriftBinaryCodec;
-import org.apache.aurora.codec.ThriftBinaryCodec.CodingException;
 import org.apache.aurora.gen.storage.Snapshot;
 import org.apache.aurora.scheduler.storage.SnapshotStore;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TIOStreamTransport;
+import org.apache.thrift.transport.TTransport;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
@@ -153,15 +159,18 @@ public interface StorageBackup {
       String tempBackupName = "temp_" + backupName;
       File tempFile = new File(config.dir, tempBackupName);
       LOG.info("Saving backup to " + tempFile);
-      try {
-        byte[] backup = ThriftBinaryCodec.encodeNonNull(snapshot);
-        Files.write(backup, tempFile);
+      try (
+          OutputStream tempFileStream = new BufferedOutputStream(new FileOutputStream(tempFile)))
{
+
+        TTransport transport = new TIOStreamTransport(tempFileStream);
+        TProtocol protocol = new TBinaryProtocol(transport);
+        snapshot.write(protocol);
         Files.move(tempFile, new File(config.dir, backupName));
         successes.incrementAndGet();
       } catch (IOException e) {
         failures.incrementAndGet();
         LOG.log(Level.SEVERE, "Failed to prepare backup " + backupName + ": " + e, e);
-      } catch (CodingException e) {
+      } catch (TException e) {
         LOG.log(Level.SEVERE, "Failed to encode backup " + backupName + ": " + e, e);
         failures.incrementAndGet();
       } finally {


Mime
View raw message