aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject incubator-aurora git commit: Add storage support for associating a message with job update events.
Date Thu, 05 Mar 2015 23:09:22 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 70494a174 -> 21661a7c5


Add storage support for associating a message with job update events.

Bugs closed: AURORA-1077

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


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

Branch: refs/heads/master
Commit: 21661a7c568a14b3d1599fdf9f6f0dd1e0a68963
Parents: 70494a1
Author: Bill Farner <wfarner@apache.org>
Authored: Thu Mar 5 15:08:16 2015 -0800
Committer: Bill Farner <wfarner@twitter.com>
Committed: Thu Mar 5 15:08:16 2015 -0800

----------------------------------------------------------------------
 .../thrift/org/apache/aurora/gen/api.thrift     |  6 ++++
 .../storage/db/JobUpdateDetailsMapper.xml       |  1 +
 .../storage/db/JobUpdateEventMapper.xml         |  6 ++--
 .../aurora/scheduler/storage/db/schema.sql      |  3 +-
 .../storage/db/DBJobUpdateStoreTest.java        | 35 ++++++++------------
 5 files changed, 26 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/21661a7c/api/src/main/thrift/org/apache/aurora/gen/api.thrift
----------------------------------------------------------------------
diff --git a/api/src/main/thrift/org/apache/aurora/gen/api.thrift b/api/src/main/thrift/org/apache/aurora/gen/api.thrift
index 1cd21e5..6ca1a1e 100644
--- a/api/src/main/thrift/org/apache/aurora/gen/api.thrift
+++ b/api/src/main/thrift/org/apache/aurora/gen/api.thrift
@@ -698,6 +698,12 @@ struct JobUpdateEvent {
 
   /** User who performed this event (if user-initiated). */
   3: optional string user
+
+  /**
+   * Message from the user (for user-initiated transitions) or the scheduler about why the
state was
+   * changed.
+   */
+  4: optional string message
 }
 
 /** Event marking a state transition in job instance update lifecycle. */

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/21661a7c/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
index 1b2aa74..4536cd3 100644
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
+++ b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateDetailsMapper.xml
@@ -397,6 +397,7 @@
       e.status AS e_status,
       e.user AS e_user,
       e.timestamp_ms AS e_timestamp_ms,
+      e.message AS e_message,
       i.id AS i_id,
       i.action AS i_action,
       i.instance_id AS i_instance_id,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/21661a7c/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
index d813b19..910d830 100644
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
+++ b/src/main/resources/org/apache/aurora/scheduler/storage/db/JobUpdateEventMapper.xml
@@ -22,12 +22,14 @@
       update_row_id,
       status,
       user,
-      timestamp_ms
+      timestamp_ms,
+      message
     ) VALUES (
       <include refid="org.apache.aurora.scheduler.storage.db.JobUpdateDetailsMapper.select_update_row_id"/>,
       #{event.status, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.JobUpdateStatusTypeHandler},
       #{event.user},
-      #{event.timestampMs}
+      #{event.timestampMs},
+      #{event.message}
     )
   </insert>
 </mapper>

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/21661a7c/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql b/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql
index a0d6b54..ed73ef7 100644
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql
+++ b/src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql
@@ -160,7 +160,8 @@ CREATE TABLE job_update_events(
   update_row_id BIGINT NOT NULL REFERENCES job_updates(id) ON DELETE CASCADE,
   status INT NOT NULL REFERENCES job_update_statuses(id),
   timestamp_ms BIGINT NOT NULL,
-  user VARCHAR
+  user VARCHAR,
+  message VARCHAR
 );
 
 CREATE TABLE job_instance_update_events(

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/21661a7c/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
b/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
index 7198db0..9810750 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DBJobUpdateStoreTest.java
@@ -237,10 +237,9 @@ public class DBJobUpdateStoreTest {
   @Test
   public void testSaveJobEvents() {
     IJobUpdateKey updateId = makeKey("u3");
-    String user = "test";
     IJobUpdate update = makeJobUpdate(updateId);
-    IJobUpdateEvent event1 = makeJobUpdateEvent(ROLLING_FORWARD, 124L, user);
-    IJobUpdateEvent event2 = makeJobUpdateEvent(ROLL_FORWARD_PAUSED, 125L, user);
+    IJobUpdateEvent event1 = makeJobUpdateEvent(ROLLING_FORWARD, 124L);
+    IJobUpdateEvent event2 = makeJobUpdateEvent(ROLL_FORWARD_PAUSED, 125L);
 
     saveUpdate(update, Optional.of("lock1"));
     assertUpdate(update);
@@ -388,12 +387,11 @@ public class DBJobUpdateStoreTest {
   public void testTruncateJobUpdates() {
     IJobUpdateKey updateId = makeKey("u5");
     IJobUpdate update = makeJobUpdate(updateId);
-    IJobUpdateEvent updateEvent = IJobUpdateEvent.build(new JobUpdateEvent(ROLLING_FORWARD,
123L));
     IJobInstanceUpdateEvent instanceEvent = IJobInstanceUpdateEvent.build(
         new JobInstanceUpdateEvent(0, 125L, INSTANCE_ROLLBACK_FAILED));
 
     saveUpdate(update, Optional.of("lock"));
-    saveJobEvent(updateEvent, updateId);
+    saveJobEvent(makeJobUpdateEvent(ROLLING_FORWARD, 123L), updateId);
     saveJobInstanceEvent(instanceEvent, updateId);
     assertEquals(
         populateExpected(update, ROLLING_FORWARD, CREATED_MS, 125L),
@@ -424,13 +422,13 @@ public class DBJobUpdateStoreTest {
     IJobUpdate update6 = makeJobUpdate(updateId6);
     IJobUpdate update7 = makeJobUpdate(updateId7);
 
-    IJobUpdateEvent updateEvent1 = IJobUpdateEvent.build(new JobUpdateEvent(ROLLING_BACK,
123L));
-    IJobUpdateEvent updateEvent2 = IJobUpdateEvent.build(new JobUpdateEvent(ABORTED, 124L));
-    IJobUpdateEvent updateEvent3 = IJobUpdateEvent.build(new JobUpdateEvent(ROLLED_BACK,
125L));
-    IJobUpdateEvent updateEvent4 = IJobUpdateEvent.build(new JobUpdateEvent(FAILED, 126L));
-    IJobUpdateEvent updateEvent5 = IJobUpdateEvent.build(new JobUpdateEvent(ERROR, 123L));
-    IJobUpdateEvent updateEvent6 = IJobUpdateEvent.build(new JobUpdateEvent(FAILED, 125L));
-    IJobUpdateEvent updateEvent7 = IJobUpdateEvent.build(new JobUpdateEvent(ROLLING_FORWARD,
126L));
+    IJobUpdateEvent updateEvent1 = makeJobUpdateEvent(ROLLING_BACK, 123L);
+    IJobUpdateEvent updateEvent2 = makeJobUpdateEvent(ABORTED, 124L);
+    IJobUpdateEvent updateEvent3 = makeJobUpdateEvent(ROLLED_BACK, 125L);
+    IJobUpdateEvent updateEvent4 = makeJobUpdateEvent(FAILED, 126L);
+    IJobUpdateEvent updateEvent5 = makeJobUpdateEvent(ERROR, 123L);
+    IJobUpdateEvent updateEvent6 = makeJobUpdateEvent(FAILED, 125L);
+    IJobUpdateEvent updateEvent7 = makeJobUpdateEvent(ROLLING_FORWARD, 126L);
 
     update1 = populateExpected(
         saveUpdateNoEvent(update1, Optional.of("lock1")), ROLLING_BACK, 123L, 123L);
@@ -949,16 +947,9 @@ public class DBJobUpdateStoreTest {
 
   private static IJobUpdateEvent makeJobUpdateEvent(JobUpdateStatus status, long timestampMs)
{
     return IJobUpdateEvent.build(
-        new JobUpdateEvent(status, timestampMs));
-  }
-
-  private static IJobUpdateEvent makeJobUpdateEvent(
-      JobUpdateStatus status,
-      long timestampMs,
-      String user) {
-
-    return IJobUpdateEvent.build(
-        new JobUpdateEvent(status, timestampMs).setUser(user));
+        new JobUpdateEvent(status, timestampMs)
+            .setUser("user")
+            .setMessage("message"));
   }
 
   private IJobInstanceUpdateEvent makeJobInstanceEvent(


Mime
View raw message