aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Suppress task reconciliation status update logging.
Date Mon, 22 Jun 2015 19:54:56 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 155947135 -> 3351b09b8


Suppress task reconciliation status update logging.

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


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

Branch: refs/heads/master
Commit: 3351b09b8f2b36fa1ee8c7674a7dfe2c2804c659
Parents: 1559471
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Mon Jun 22 12:52:06 2015 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Mon Jun 22 12:52:06 2015 -0700

----------------------------------------------------------------------
 .../scheduler/mesos/MesosSchedulerImpl.java     | 11 ++++-
 .../scheduler/mesos/MesosSchedulerImplTest.java | 47 ++++++++++++++++++--
 2 files changed, 53 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/3351b09b/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
index f233d5a..4f7a1be 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
@@ -60,6 +60,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import static java.util.Objects.requireNonNull;
 
 import static org.apache.mesos.Protos.Offer;
+import static org.apache.mesos.Protos.TaskStatus.Reason.REASON_RECONCILIATION;
 
 /**
  * Location for communication with mesos.
@@ -193,7 +194,13 @@ public class MesosSchedulerImpl implements Scheduler {
     }
   }
 
-  private static void logStatusUpdate(Logger log, TaskStatus status) {
+  private static void logStatusUpdate(Logger logger, TaskStatus status) {
+    // Periodic task reconciliation runs generate a large amount of no-op messages.
+    // Suppress logging for reconciliation status updates by default.
+    Level level = status.hasReason() && status.getReason() == REASON_RECONCILIATION
+        ? Level.FINE
+        : Level.INFO;
+
     StringBuilder message = new StringBuilder("Received status update for task ")
         .append(status.getTaskId().getValue())
         .append(" in state ")
@@ -207,7 +214,7 @@ public class MesosSchedulerImpl implements Scheduler {
     if (status.hasMessage()) {
       message.append(": ").append(status.getMessage());
     }
-    log.info(message.toString());
+    logger.log(level, message.toString());
   }
 
   private static final Function<Double, Long> SECONDS_TO_MICROS = new Function<Double,
Long>() {

http://git-wip-us.apache.org/repos/asf/aurora/blob/3351b09b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
index f0f9ac3..e4e1587 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
@@ -62,6 +62,8 @@ import org.junit.Test;
 import static org.apache.aurora.gen.MaintenanceMode.DRAINING;
 import static org.apache.aurora.gen.MaintenanceMode.NONE;
 import static org.apache.mesos.Protos.Offer;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertTrue;
 
@@ -106,14 +108,19 @@ public class MesosSchedulerImplTest extends EasyMockTest {
               .setMode(NONE)
               .setAttributes(ImmutableSet.<Attribute>of())));
 
-  private static final TaskStatus STATUS = TaskStatus.newBuilder()
+  private static final TaskStatus.Builder STATUS_BUILDER = TaskStatus.newBuilder()
       .setState(TaskState.TASK_RUNNING)
       .setSource(Source.SOURCE_SLAVE)
       // Only testing data plumbing, this field with TASK_RUNNING would not normally happen,
       .setReason(Reason.REASON_COMMAND_EXECUTOR_FAILED)
       .setMessage("message")
       .setTimestamp(1D)
-      .setTaskId(TaskID.newBuilder().setValue("task-id").build())
+      .setTaskId(TaskID.newBuilder().setValue("task-id").build());
+
+  private static final TaskStatus STATUS = STATUS_BUILDER.build();
+
+  private static final TaskStatus STATUS_RECONCILIATION = STATUS_BUILDER
+      .setReason(Reason.REASON_RECONCILIATION)
       .build();
 
   private static final TaskStatusReceived PUBSUB_EVENT = new TaskStatusReceived(
@@ -123,6 +130,13 @@ public class MesosSchedulerImplTest extends EasyMockTest {
       Optional.of(1000000L)
   );
 
+  private static final TaskStatusReceived PUBSUB_RECONCILIATION_EVENT = new TaskStatusReceived(
+      STATUS_RECONCILIATION.getState(),
+      Optional.of(STATUS_RECONCILIATION.getSource()),
+      Optional.of(STATUS_RECONCILIATION.getReason()),
+      Optional.of(1000000L)
+  );
+
   private Logger log;
   private StorageTestUtil storageUtil;
   private Command shutdownCommand;
@@ -137,6 +151,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   public void setUp() {
     log = Logger.getAnonymousLogger();
     log.setLevel(Level.INFO);
+    initializeScheduler(log);
+  }
+
+  private void initializeScheduler(Logger logger) {
     storageUtil = new StorageTestUtil(this);
     shutdownCommand = createMock(Command.class);
     final Lifecycle lifecycle =
@@ -151,7 +169,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
         ImmutableList.of(systemLauncher, userLauncher),
         eventSink,
         MoreExecutors.sameThreadExecutor(),
-        log,
+        logger,
         new CachedCounters(new FakeStatsProvider()));
     driver = createMock(SchedulerDriver.class);
   }
@@ -396,6 +414,23 @@ public class MesosSchedulerImplTest extends EasyMockTest {
     scheduler.executorLost(driver, EXECUTOR_ID, SLAVE_ID, 1);
   }
 
+  @Test
+  public void testStatusReconciliationAcceptsFineLogging() {
+    Logger mockLogger = createMock(Logger.class);
+    mockLogger.info(anyString());
+    mockLogger.log(eq(Level.FINE), anyString());
+    initializeScheduler(mockLogger);
+
+    new StatusReconciliationFixture() {
+      @Override
+      void expectations() {
+        eventSink.post(PUBSUB_RECONCILIATION_EVENT);
+        expect(systemLauncher.statusUpdate(status)).andReturn(false);
+        expect(userLauncher.statusUpdate(status)).andReturn(true);
+      }
+    }.run();
+  }
+
   private void expectOfferAttributesSaved(HostOffer offer) {
     expect(storageUtil.attributeStore.getHostAttributes(offer.getOffer().getHostname()))
         .andReturn(Optional.<IHostAttributes>absent());
@@ -472,4 +507,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
       scheduler.statusUpdate(driver, status);
     }
   }
+
+  private abstract class StatusReconciliationFixture extends StatusFixture {
+    StatusReconciliationFixture() {
+      super(STATUS_RECONCILIATION);
+    }
+  }
 }


Mime
View raw message