aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject git commit: Optionally ignore unknown transaction operations.
Date Mon, 03 Nov 2014 20:39:37 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 1149d7ab1 -> c03cea5ab


Optionally ignore unknown transaction operations.

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


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

Branch: refs/heads/master
Commit: c03cea5ab0c30ae800e2efd3d02d575d3a5f9b32
Parents: 1149d7a
Author: Bill Farner <wfarner@apache.org>
Authored: Mon Nov 3 12:37:19 2014 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Mon Nov 3 12:37:19 2014 -0800

----------------------------------------------------------------------
 .../aurora/scheduler/storage/log/LogStorage.java       | 13 ++++++++++++-
 .../aurora/scheduler/storage/log/LogStorageTest.java   |  8 ++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c03cea5a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
index ec9ccfd..cbab759 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/log/LogStorage.java
@@ -30,6 +30,8 @@ import javax.inject.Qualifier;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.twitter.common.application.ShutdownRegistry;
+import com.twitter.common.args.Arg;
+import com.twitter.common.args.CmdLine;
 import com.twitter.common.base.Closure;
 import com.twitter.common.inject.TimedInterceptor.Timed;
 import com.twitter.common.quantity.Amount;
@@ -219,6 +221,11 @@ public class LogStorage implements NonVolatileStorage, DistributedSnapshotStore
   @Qualifier
   public @interface WriteBehind { }
 
+  // TODO(wfarner): This is a temporary emergency fix.  Revisit.
+  @CmdLine(name = "log_storage_fail_on_unknown_op",
+      help = "If true, fail if an unknown log transition operation is encountered.")
+  public static final Arg<Boolean> FAIL_ON_UNKNOWN_OP = Arg.create(false);
+
   @Inject
   LogStorage(LogManager logManager,
              ShutdownRegistry shutdownRegistry,
@@ -480,7 +487,11 @@ public class LogStorage implements NonVolatileStorage, DistributedSnapshotStore
         break;
 
       default:
-        throw new IllegalStateException("Unknown transaction op: " + op);
+        if (FAIL_ON_UNKNOWN_OP.get()) {
+          throw new IllegalStateException("Unknown transaction op: " + op);
+        } else {
+          LOG.log(Level.SEVERE, "Unkown transaction op: " + op);
+        }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c03cea5a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
index 2d44bd5..8eb5c3f 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
@@ -209,6 +209,7 @@ public class LogStorageTest extends EasyMockTest {
     Entry entry2 = createMock(Entry.class);
     Entry entry3 = createMock(Entry.class);
     Entry entry4 = createMock(Entry.class);
+    Entry entry5 = createMock(Entry.class);
     String frameworkId1 = "bob";
     LogEntry recoveredEntry1 =
         createTransaction(Op.saveFrameworkId(new SaveFrameworkId(frameworkId1)));
@@ -226,11 +227,14 @@ public class LogStorageTest extends EasyMockTest {
         .setMode(MaintenanceMode.DRAINED));
     LogEntry recoveredEntry4 =
         createTransaction(Op.saveHostAttributes(new SaveHostAttributes(attributes.newBuilder())));
+    LogEntry recoveredEntry5 =
+        createTransaction(Op.pruneJobUpdateHistory(new PruneJobUpdateHistory()));
     expect(entry1.contents()).andReturn(ThriftBinaryCodec.encodeNonNull(recoveredEntry1));
     expect(entry2.contents()).andReturn(ThriftBinaryCodec.encodeNonNull(recoveredEntry2));
     expect(entry3.contents()).andReturn(ThriftBinaryCodec.encodeNonNull(recoveredEntry3));
     expect(entry4.contents()).andReturn(ThriftBinaryCodec.encodeNonNull(recoveredEntry4));
-    expect(stream.readAll()).andReturn(Iterators.forArray(entry1, entry2, entry3, entry4));
+    expect(entry5.contents()).andReturn(ThriftBinaryCodec.encodeNonNull(recoveredEntry5));
+    expect(stream.readAll()).andReturn(Iterators.forArray(entry1, entry2, entry3, entry4,
entry5));
 
     final Capture<MutateWork<Void, RuntimeException>> recoveryWork = createCapture();
     expect(storageUtil.storage.write(capture(recoveryWork))).andAnswer(
@@ -275,7 +279,7 @@ public class LogStorageTest extends EasyMockTest {
             snapshotWork.getValue().apply(storageUtil.mutableStoreProvider);
             return null;
           }
-        }).times(4);
+        }).times(5);
 
     control.replay();
 


Mime
View raw message