You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2014/08/18 23:22:41 UTC

git commit: Add a job update controller interface.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master f08c648b4 -> 4d507d050


Add a job update controller interface.

Bugs closed: AURORA-613

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


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

Branch: refs/heads/master
Commit: 4d507d050caa69962c5067a85c67dc9b1a3ef834
Parents: f08c648
Author: Bill Farner <wf...@apache.org>
Authored: Mon Aug 18 14:19:28 2014 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Mon Aug 18 14:20:01 2014 -0700

----------------------------------------------------------------------
 .../scheduler/updater/JobUpdateController.java  | 75 ++++++++++++++++++++
 .../updater/JobUpdateControllerImpl.java        | 48 +++++++++++++
 .../scheduler/updater/UpdateStateException.java | 28 ++++++++
 3 files changed, 151 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4d507d05/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateController.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateController.java b/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateController.java
new file mode 100644
index 0000000..066238c
--- /dev/null
+++ b/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateController.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aurora.scheduler.updater;
+
+import org.apache.aurora.scheduler.storage.entities.IInstanceKey;
+import org.apache.aurora.scheduler.storage.entities.IJobKey;
+import org.apache.aurora.scheduler.storage.entities.IJobUpdate;
+
+/**
+ * A controller that exposes commands to initiate and modify active job updates.
+ */
+interface JobUpdateController {
+
+  /**
+   * Initiates an update.
+   *
+   * @param update Instructions for what job to update, and how to update it.
+   * @throws UpdateStateException If the update cannot be started, for example if the instructions
+   *                              are invalid, or if there is already an in-progress update for the
+   *                              job.
+   */
+  void start(IJobUpdate update) throws UpdateStateException;
+
+  /**
+   * Pauses an in-progress update.
+   * <p>
+   * A paused update may be resumed by invoking {@link #resume(IJobKey)}.
+   *
+   * @param job Job whose update should be paused.
+   * @throws UpdateStateException If the job update is not in a state that may be paused.
+   */
+  void pause(IJobKey job) throws UpdateStateException;
+
+  /**
+   * Resumes a paused in-progress update.
+   * <p>
+   * The outcome of this call depends on the state the updater was in prior to the pause. If the
+   * updater was rolling forward, it will resume rolling forward. If it was rolling back, it will
+   * resume rolling back.
+   *
+   * @param job Job whose update should be resumed.
+   * @throws UpdateStateException If the job update is not in a state that may be resumed.
+   */
+  void resume(IJobKey job) throws UpdateStateException;
+
+  /**
+   * Aborts an in-progress update.
+   * <p>
+   * This will abandon the update, and make no further modifications to the job on behalf of the
+   * update. An aborted update may not be resumed.
+   *
+   * @param job Job whose update should be aborted.
+   * @throws UpdateStateException If there is no active update for the job.
+   */
+  void abort(IJobKey job) throws UpdateStateException;
+
+  /**
+   * Notifies the updater that an instance has changed state.
+   *
+   * @param instance Identifier fo the instance whose state has changed.
+   * @param deleted {@code true} if the state change was a task deletion, otherwise {@code false}.
+   */
+  void handleStateChange(IInstanceKey instance, boolean deleted);
+}

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4d507d05/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java b/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
new file mode 100644
index 0000000..3bbd6dd
--- /dev/null
+++ b/src/main/java/org/apache/aurora/scheduler/updater/JobUpdateControllerImpl.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aurora.scheduler.updater;
+
+import org.apache.aurora.scheduler.storage.entities.IInstanceKey;
+import org.apache.aurora.scheduler.storage.entities.IJobKey;
+import org.apache.aurora.scheduler.storage.entities.IJobUpdate;
+
+/**
+ * TODO(wfarner): Implement this as part of AURORA-610.
+ */
+public class JobUpdateControllerImpl implements JobUpdateController {
+  @Override
+  public void start(IJobUpdate update) throws UpdateStateException {
+    throw new UnsupportedOperationException("Not yet implemented.");
+  }
+
+  @Override
+  public void pause(IJobKey job) throws UpdateStateException {
+    throw new UnsupportedOperationException("Not yet implemented.");
+  }
+
+  @Override
+  public void resume(IJobKey job) throws UpdateStateException {
+    throw new UnsupportedOperationException("Not yet implemented.");
+  }
+
+  @Override
+  public void abort(IJobKey job) throws UpdateStateException {
+    throw new UnsupportedOperationException("Not yet implemented.");
+  }
+
+  @Override
+  public void handleStateChange(IInstanceKey instance, boolean deleted) {
+    throw new UnsupportedOperationException("Not yet implemented.");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4d507d05/src/main/java/org/apache/aurora/scheduler/updater/UpdateStateException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/updater/UpdateStateException.java b/src/main/java/org/apache/aurora/scheduler/updater/UpdateStateException.java
new file mode 100644
index 0000000..cd29665
--- /dev/null
+++ b/src/main/java/org/apache/aurora/scheduler/updater/UpdateStateException.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aurora.scheduler.updater;
+
+/**
+ * Thrown when an update operation cannot be completed, either because of a bad request or a
+ * request that is invalid based on the state an update is in.
+ */
+public class UpdateStateException extends Exception {
+  public UpdateStateException(String message) {
+    super(message);
+  }
+
+  public UpdateStateException(String message, Throwable cause) {
+    super(message, cause);
+  }
+}