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/01/25 07:34:31 UTC

git commit: AURORA-116: Use only a single write transaction to save HostAttributes in resourceOffers.

Updated Branches:
  refs/heads/master bbfe7367f -> add79f62d


AURORA-116: Use only a single write transaction to save HostAttributes in resourceOffers.

Bugs closed: AURORA-116

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


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

Branch: refs/heads/master
Commit: add79f62d370a8fccc4bb3c20e9d67c15b49787b
Parents: bbfe736
Author: Bill Farner <wf...@apache.org>
Authored: Fri Jan 24 22:33:33 2014 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Fri Jan 24 22:33:33 2014 -0800

----------------------------------------------------------------------
 .../aurora/scheduler/MesosSchedulerImpl.java    | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/add79f62/src/main/java/org/apache/aurora/scheduler/MesosSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/MesosSchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/MesosSchedulerImpl.java
index 2e7d7f7..2f84bdf 100644
--- a/src/main/java/org/apache/aurora/scheduler/MesosSchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/MesosSchedulerImpl.java
@@ -141,17 +141,27 @@ class MesosSchedulerImpl implements Scheduler {
 
   @Timed("scheduler_resource_offers")
   @Override
-  public void resourceOffers(SchedulerDriver driver, List<Offer> offers) {
+  public void resourceOffers(SchedulerDriver driver, final List<Offer> offers) {
     Preconditions.checkState(registered, "Must be registered before receiving offers.");
 
-    for (final Offer offer : offers) {
-      log(Level.FINE, "Received offer: %s", offer);
-      resourceOffers.incrementAndGet();
-      storage.write(new MutateWork.NoResult.Quiet() {
-        @Override protected void execute(MutableStoreProvider storeProvider) {
+    // Store all host attributes in a single write operation to prevent other threads from
+    // securing the storage lock between saves.  We also save the host attributes before passing
+    // offers elsewhere to ensure that host attributes are available before attempting to
+    // schedule tasks associated with offers.
+    // TODO(wfarner): Reconsider the requirements here, we might be able to save host offers
+    //                asynchronously and augment the task scheduler to skip over offers when the
+    //                host attributes cannot be found. (AURORA-116)
+    storage.write(new MutateWork.NoResult.Quiet() {
+      @Override protected void execute(MutableStoreProvider storeProvider) {
+        for (final Offer offer : offers) {
           storeProvider.getAttributeStore().saveHostAttributes(Conversions.getAttributes(offer));
         }
-      });
+      }
+    });
+
+    for (Offer offer : offers) {
+      log(Level.FINE, "Received offer: %s", offer);
+      resourceOffers.incrementAndGet();
 
       // Ordering of task launchers is important here, since offers are consumed greedily.
       // TODO(William Farner): Refactor this area of code now that the primary task launcher