aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject [1/4] aurora git commit: Use slf4j throughout the scheduler.
Date Mon, 04 Jan 2016 04:50:20 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 5b46fd158 -> 9ed81a7db


http://git-wip-us.apache.org/repos/asf/aurora/blob/9ed81a7d/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java b/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
index 6b1d2b1..965bfa7 100644
--- a/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
+++ b/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
@@ -21,7 +21,6 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
 
 import javax.inject.Inject;
 
@@ -53,6 +52,8 @@ import org.apache.mesos.Protos.TaskState;
 import org.apache.mesos.Protos.TaskStatus;
 import org.apache.mesos.Scheduler;
 import org.apache.mesos.SchedulerDriver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static java.util.Objects.requireNonNull;
 
@@ -64,7 +65,7 @@ import static org.apache.mesos.Protos.FrameworkInfo;
 @SuppressWarnings("deprecation")
 public class FakeMaster implements SchedulerDriver, DriverFactory {
 
-  private static final Logger LOG = Logger.getLogger(FakeMaster.class.getName());
+  private static final Logger LOG = LoggerFactory.getLogger(FakeMaster.class);
 
   private final Map<TaskID, Task> activeTasks = Collections.synchronizedMap(Maps.newHashMap());
   private final Map<OfferID, Offer> idleOffers = Collections.synchronizedMap(Maps.newHashMap());

http://git-wip-us.apache.org/repos/asf/aurora/blob/9ed81a7d/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java b/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
index 8761106..dd7ff31 100644
--- a/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
@@ -19,16 +19,14 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
 import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
 
 import static org.easymock.EasyMock.contains;
-import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expectLastCall;
 
 public class AsyncUtilTest extends EasyMockTest {
@@ -87,10 +85,7 @@ public class AsyncUtilTest extends EasyMockTest {
   }
 
   private void expectLogging() {
-    logger.log(
-        eq(Level.SEVERE),
-        contains("Expected exception."),
-        EasyMock.<ExecutionException>anyObject());
+    logger.error(contains("Expected exception."), EasyMock.<ExecutionException>anyObject());
 
     expectLastCall().andAnswer(() -> {
       latch.countDown();

http://git-wip-us.apache.org/repos/asf/aurora/blob/9ed81a7d/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java b/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
index 4709b77..2676e3c 100644
--- a/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
@@ -15,8 +15,6 @@ package org.apache.aurora.scheduler.events;
 
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.util.concurrent.Executor;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import com.google.common.eventbus.EventBus;
 import com.google.common.eventbus.Subscribe;
@@ -39,9 +37,9 @@ import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
 
 import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.eq;
 import static org.junit.Assert.assertEquals;
 
 public class PubsubEventModuleTest extends EasyMockTest {
@@ -61,7 +59,7 @@ public class PubsubEventModuleTest extends EasyMockTest {
 
   @Test
   public void testHandlesDeadEvent() {
-    logger.warning(String.format(PubsubEventModule.DEAD_EVENT_MESSAGE, "hello"));
+    logger.warn(String.format(PubsubEventModule.DEAD_EVENT_MESSAGE, "hello"));
 
     control.replay();
 
@@ -70,7 +68,7 @@ public class PubsubEventModuleTest extends EasyMockTest {
 
   @Test
   public void testPubsubExceptionTracking() throws Exception {
-    logger.log(eq(Level.SEVERE), anyString(), EasyMock.<Throwable>anyObject());
+    logger.error(anyString(), EasyMock.<Throwable>anyObject());
 
     control.replay();
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/9ed81a7d/src/test/java/org/apache/aurora/scheduler/http/ServletFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/ServletFilterTest.java b/src/test/java/org/apache/aurora/scheduler/http/ServletFilterTest.java
index 4057e7c..21371d9 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/ServletFilterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/ServletFilterTest.java
@@ -16,6 +16,7 @@ package org.apache.aurora.scheduler.http;
 import java.io.IOException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
+
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/9ed81a7d/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 6dffd77..242530a 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
@@ -15,8 +15,6 @@ package org.apache.aurora.scheduler.mesos;
 
 import java.nio.charset.StandardCharsets;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
@@ -52,14 +50,16 @@ import org.apache.mesos.Protos.TaskStatus;
 import org.apache.mesos.Protos.TaskStatus.Reason;
 import org.apache.mesos.Protos.TaskStatus.Source;
 import org.apache.mesos.SchedulerDriver;
+import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 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.easymock.EasyMock.expectLastCall;
 import static org.junit.Assert.assertTrue;
@@ -142,8 +142,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
 
   @Before
   public void setUp() {
-    Logger log = Logger.getAnonymousLogger();
-    log.setLevel(Level.INFO);
+    Logger log = LoggerFactory.getLogger("");
     initializeScheduler(log);
   }
 
@@ -161,8 +160,8 @@ public class MesosSchedulerImplTest extends EasyMockTest {
         offerManager,
         eventSink,
         MoreExecutors.sameThreadExecutor(),
-        logger,
-        new CachedCounters(new FakeStatsProvider()));
+        new CachedCounters(new FakeStatsProvider()),
+        logger);
     driver = createMock(SchedulerDriver.class);
   }
 
@@ -196,11 +195,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testAcceptOfferFineLogging() {
+  public void testAcceptOfferDebugLogging() {
     Logger mockLogger = createMock(Logger.class);
     mockLogger.info(anyString());
-    expect(mockLogger.isLoggable(Level.FINE)).andReturn(true);
-    mockLogger.log(eq(Level.FINE), anyString());
+    mockLogger.debug(anyString(), EasyMock.<Object>anyObject());
     initializeScheduler(mockLogger);
 
     new AbstractOfferTest() {
@@ -347,10 +345,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testStatusReconciliationAcceptsFineLogging() {
+  public void testStatusReconciliationAcceptsDebugLogging() {
     Logger mockLogger = createMock(Logger.class);
     mockLogger.info(anyString());
-    mockLogger.log(eq(Level.FINE), anyString());
+    mockLogger.debug(anyString());
     initializeScheduler(mockLogger);
 
     new AbstractStatusReconciliationTest() {

http://git-wip-us.apache.org/repos/asf/aurora/blob/9ed81a7d/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
index 0d9628c..76da6d8 100644
--- a/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
@@ -13,8 +13,6 @@
  */
 package org.apache.aurora.scheduler.offers;
 
-import java.util.logging.Level;
-
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
@@ -76,8 +74,6 @@ public class OfferManagerImplTest extends EasyMockTest {
 
   @Before
   public void setUp() {
-    OfferManagerImpl.LOG.setLevel(Level.FINE);
-    addTearDown(() -> OfferManagerImpl.LOG.setLevel(Level.INFO));
     driver = createMock(Driver.class);
     DelayExecutor executorMock = createMock(DelayExecutor.class);
     clock = FakeScheduledExecutor.fromDelayExecutor(executorMock);

http://git-wip-us.apache.org/repos/asf/aurora/blob/9ed81a7d/src/test/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorageTest.java
b/src/test/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorageTest.java
index d09178a..3c4e2bd 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorageTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/WriteAheadStorageTest.java
@@ -14,8 +14,6 @@
 package org.apache.aurora.scheduler.storage.log;
 
 import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableSet;
@@ -48,6 +46,7 @@ import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
 
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
@@ -123,14 +122,13 @@ public class WriteAheadStorageTest extends EasyMockTest {
             new ScheduledTask().setAssignedTask(new AssignedTask().setTaskId("a"))));
 
     expect(taskStore.mutateTasks(query, mutator)).andReturn(mutated);
-    expect(log.isLoggable(Level.FINE)).andReturn(false);
+    log.debug(EasyMock.anyString(), EasyMock.<Object>anyObject());
     expectOp(Op.saveTasks(new SaveTasks(IScheduledTask.toBuildersSet(mutated))));
 
     // With increased logging.
     expect(taskStore.mutateTasks(query, mutator)).andReturn(mutated);
-    expect(log.isLoggable(Level.FINE)).andReturn(true);
     expectOp(Op.saveTasks(new SaveTasks(IScheduledTask.toBuildersSet(mutated))));
-    log.fine(EasyMock.anyString());
+    log.debug(EasyMock.anyString(), EasyMock.<Object>anyObject());
 
     control.replay();
 


Mime
View raw message