aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject [5/5] aurora git commit: Use lambdas throughout the project.
Date Tue, 08 Dec 2015 18:27:38 GMT
Use lambdas throughout the project.

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


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

Branch: refs/heads/master
Commit: 2e2371481d9aaccd6a45ad0f442d963d5ae7a3c8
Parents: d7a1619
Author: Bill Farner <wfarner@apache.org>
Authored: Tue Dec 8 10:27:26 2015 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Tue Dec 8 10:27:26 2015 -0800

----------------------------------------------------------------------
 .../common/args/apt/CmdLineProcessor.java       |  52 +-
 .../aurora/common/args/apt/Configuration.java   |   6 +-
 .../apache/aurora/common/args/ArgFilters.java   |  30 +-
 .../apache/aurora/common/args/ArgScanner.java   |  38 +-
 .../org/apache/aurora/common/args/Args.java     |  58 +--
 .../apache/aurora/common/args/ArgumentInfo.java |  20 +-
 .../apache/aurora/common/args/OptionInfo.java   |   6 +-
 .../org/apache/aurora/common/args/Parsers.java  |  46 +-
 .../aurora/common/args/PositionalInfo.java      |   6 +-
 .../args/constraints/RangeNumberVerifier.java   |   6 +-
 .../aurora/common/args/parsers/ListParser.java  |   6 +-
 .../aurora/common/args/parsers/SetParser.java   |   6 +-
 .../org/apache/aurora/common/base/Closures.java |  22 +-
 .../org/apache/aurora/common/base/Commands.java |   6 +-
 .../aurora/common/collections/Iterables2.java   |  10 +-
 .../apache/aurora/common/collections/Pair.java  |  12 +-
 .../common/net/http/handlers/LogConfig.java     |  24 +-
 .../net/http/handlers/TimeSeriesDataSource.java |   6 +-
 .../common/net/http/handlers/VarsHandler.java   |   6 +-
 .../apache/aurora/common/stats/JvmStats.java    |  26 +-
 .../org/apache/aurora/common/stats/Rate.java    |   4 +-
 .../org/apache/aurora/common/stats/Ratio.java   |  24 +-
 .../common/testing/easymock/EasyMockTest.java   |   6 +-
 .../aurora/common/util/BackoffHelper.java       |   8 +-
 .../apache/aurora/common/util/StateMachine.java |  18 +-
 .../aurora/common/zookeeper/CandidateImpl.java  |  96 ++--
 .../apache/aurora/common/zookeeper/Group.java   | 228 ++++-----
 .../aurora/common/zookeeper/ServerSetImpl.java  | 110 ++---
 .../common/zookeeper/ZooKeeperClient.java       |  42 +-
 config/legacy_untested_classes.txt              |   3 +-
 src/main/java/org/apache/aurora/GuiceUtils.java |  23 +-
 .../apache/aurora/scheduler/ResourceSlot.java   |  26 +-
 .../org/apache/aurora/scheduler/Resources.java  |  11 +-
 .../aurora/scheduler/SchedulerLifecycle.java    |  57 +--
 .../aurora/scheduler/SchedulerModule.java       |  16 +-
 .../aurora/scheduler/TaskStatusHandlerImpl.java |  30 +-
 .../org/apache/aurora/scheduler/TaskVars.java   |  29 +-
 .../aurora/scheduler/app/SchedulerMain.java     |  10 +-
 .../aurora/scheduler/async/AsyncModule.java     |   2 +-
 .../aurora/scheduler/base/Conversions.java      |  51 +-
 .../configuration/executor/ExecutorModule.java  |  16 +-
 .../scheduler/cron/quartz/AuroraCronJob.java    | 147 +++---
 .../cron/quartz/CronJobManagerImpl.java         |  59 +--
 .../cron/quartz/CronSchedulerImpl.java          |   8 +-
 .../scheduler/events/PubsubEventModule.java     |  24 +-
 .../scheduler/filter/AttributeAggregate.java    |  50 +-
 .../scheduler/filter/ConstraintMatcher.java     |   7 +-
 .../org/apache/aurora/scheduler/http/Locks.java |  15 +-
 .../aurora/scheduler/http/Maintenance.java      |  35 +-
 .../apache/aurora/scheduler/http/Offers.java    | 107 ++---
 .../apache/aurora/scheduler/http/Quotas.java    |  34 +-
 .../apache/aurora/scheduler/http/Services.java  |  26 +-
 .../apache/aurora/scheduler/http/Slaves.java    |  39 +-
 .../aurora/scheduler/http/StructDump.java       |  48 +-
 .../aurora/scheduler/http/Utilization.java      |  49 +-
 .../aurora/scheduler/http/api/ApiBeta.java      |  19 +-
 .../http/api/GsonMessageBodyHandler.java        |  86 ++--
 .../api/security/Kerberos5ShiroRealmModule.java |  21 +-
 .../ShiroAuthorizingParamInterceptor.java       |  70 ++-
 .../aurora/scheduler/log/mesos/MesosLog.java    |  27 +-
 .../log/mesos/MesosLogStreamModule.java         |   7 +-
 .../scheduler/mesos/MesosSchedulerImpl.java     |  52 +-
 .../scheduler/mesos/MesosTaskFactory.java       |  10 +-
 .../scheduler/mesos/SchedulerDriverService.java |   7 +-
 .../aurora/scheduler/metadata/NearestFit.java   |   9 +-
 .../aurora/scheduler/offers/OfferManager.java   |   7 +-
 .../aurora/scheduler/preemptor/BiCache.java     |   8 +-
 .../preemptor/PendingTaskProcessor.java         | 127 +++--
 .../preemptor/PreemptionVictimFilter.java       |  48 +-
 .../scheduler/preemptor/PreemptorModule.java    |  15 +-
 .../pruning/JobUpdateHistoryPruner.java         |  26 +-
 .../scheduler/pruning/TaskHistoryPruner.java    |  49 +-
 .../aurora/scheduler/quota/QuotaManager.java    | 101 ++--
 .../reconciliation/TaskReconciler.java          |  32 +-
 .../scheduler/reconciliation/TaskTimeout.java   |  19 +-
 .../aurora/scheduler/scheduling/TaskGroups.java |   9 +-
 .../scheduler/scheduling/TaskScheduler.java     |   8 +-
 .../scheduler/scheduling/TaskThrottler.java     |  23 +-
 .../aurora/scheduler/sla/MetricCalculator.java  |   7 +-
 .../aurora/scheduler/sla/SlaAlgorithm.java      | 152 +++---
 .../apache/aurora/scheduler/sla/SlaGroup.java   |  36 +-
 .../aurora/scheduler/state/LockManagerImpl.java |  72 +--
 .../scheduler/state/MaintenanceController.java  | 109 ++---
 .../scheduler/state/StateManagerImpl.java       |  78 +--
 .../aurora/scheduler/state/TaskAssigner.java    |   9 +-
 .../scheduler/state/TaskStateMachine.java       | 326 ++++++-------
 .../aurora/scheduler/stats/ResourceCounter.java |  22 +-
 .../aurora/scheduler/stats/SlotSizeCounter.java |   8 +-
 .../aurora/scheduler/stats/StatsModule.java     |   7 +-
 .../storage/CallOrderEnforcingStorage.java      |  14 +-
 .../aurora/scheduler/storage/Storage.java       |  14 +-
 .../scheduler/storage/StorageBackfill.java      |  12 +-
 .../aurora/scheduler/storage/TaskStore.java     |  77 ++-
 .../scheduler/storage/backup/Recovery.java      |  17 +-
 .../scheduler/storage/backup/StorageBackup.java |  21 +-
 .../storage/backup/TemporaryStorage.java        |  24 +-
 .../scheduler/storage/db/DbAttributeStore.java  |   8 +-
 .../scheduler/storage/db/DbJobUpdateStore.java  |   7 +-
 .../aurora/scheduler/storage/db/DbStorage.java  |  40 +-
 .../storage/db/RowGarbageCollector.java         |  22 +-
 .../scheduler/storage/log/EntrySerializer.java  |   7 +-
 .../scheduler/storage/log/LogStorage.java       | 334 +++++--------
 .../storage/log/SnapshotDeduplicator.java       |   7 +-
 .../storage/log/SnapshotStoreImpl.java          |  49 +-
 .../scheduler/storage/mem/MemTaskStore.java     |  30 +-
 .../aurora/scheduler/storage/mem/Util.java      |  19 +-
 .../scheduler/testing/FakeStatsProvider.java    |  15 +-
 .../scheduler/thrift/ReadOnlySchedulerImpl.java | 252 ++++------
 .../thrift/SchedulerThriftInterface.java        | 472 +++++++++----------
 .../aurora/scheduler/thrift/aop/AopModule.java  |   7 +-
 .../thrift/aop/LoggingInterceptor.java          |  15 +-
 .../aurora/scheduler/updater/JobDiff.java       |   8 +-
 .../updater/JobUpdateControllerImpl.java        | 310 +++++-------
 .../updater/JobUpdateStateMachine.java          |  28 +-
 .../scheduler/updater/OneWayJobUpdater.java     |  15 +-
 115 files changed, 1980 insertions(+), 3300 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons-args/src/main/java/org/apache/aurora/common/args/apt/CmdLineProcessor.java
----------------------------------------------------------------------
diff --git a/commons-args/src/main/java/org/apache/aurora/common/args/apt/CmdLineProcessor.java b/commons-args/src/main/java/org/apache/aurora/common/args/apt/CmdLineProcessor.java
index 5abb06b..d531ba0 100644
--- a/commons-args/src/main/java/org/apache/aurora/common/args/apt/CmdLineProcessor.java
+++ b/commons-args/src/main/java/org/apache/aurora/common/args/apt/CmdLineProcessor.java
@@ -96,11 +96,7 @@ public class CmdLineProcessor extends AbstractProcessor {
   static final String CHECK_LINKAGE_OPTION =
       "com.twitter.common.args.apt.CmdLineProcessor.check_linkage";
 
-  private static final Function<Class<?>, String> GET_NAME = new Function<Class<?>, String>() {
-    @Override public String apply(Class<?> type) {
-      return type.getName();
-    }
-  };
+  private static final Function<Class<?>, String> GET_NAME = Class::getName;
 
   private final Supplier<Configuration> configSupplier =
       Suppliers.memoize(new Supplier<Configuration>() {
@@ -273,17 +269,9 @@ public class CmdLineProcessor extends AbstractProcessor {
   }
 
   private static final Function<Element, Element> EXTRACT_ENCLOSING_CLASS =
-      new Function<Element, Element>() {
-        @Override public Element apply(Element element) {
-          return element.getEnclosingElement();
-        }
-      };
+      Element::getEnclosingElement;
 
-  private final Function<Element, String> extractClassName = new Function<Element, String>() {
-    @Override public String apply(Element element) {
-      return getBinaryName((TypeElement) element);
-    }
-  };
+  private final Function<Element, String> extractClassName = element -> getBinaryName((TypeElement) element);
 
   private final Function<Element, String> extractEnclosingClassName =
       Functions.compose(extractClassName, EXTRACT_ENCLOSING_CLASS);
@@ -325,16 +313,14 @@ public class CmdLineProcessor extends AbstractProcessor {
     }
 
     Iterable<String> parsersFor = Optional.presentInstances(Iterables.transform(parsers,
-        new Function<Element, Optional<String>>() {
-          @Override public Optional<String> apply(Element parser) {
-            TypeMirror parsedType = getTypeArgument(parser.asType(), typeElement(Parser.class));
-            if (parsedType == null) {
-              error("failed to find a type argument for Parser: %s", parser);
-              return Optional.absent();
-            }
-            // Equals on TypeMirrors doesn't work - so we compare string representations :/
-            return Optional.of(typeUtils.erasure(parsedType).toString());
+        parser -> {
+          TypeMirror parsedType = getTypeArgument(parser.asType(), typeElement(Parser.class));
+          if (parsedType == null) {
+            error("failed to find a type argument for Parser: %s", parser);
+            return Optional.absent();
           }
+          // Equals on TypeMirrors doesn't work - so we compare string representations :/
+          return Optional.of(typeUtils.erasure(parsedType).toString());
         }));
     if (configuration != null) {
       parsersFor = Iterables.concat(parsersFor, Iterables.filter(
@@ -358,17 +344,15 @@ public class CmdLineProcessor extends AbstractProcessor {
       final Class<? extends Annotation> argAnnotation) {
 
     return Optional.presentInstances(Iterables.transform(args,
-        new Function<Element, Optional<ArgInfo>>() {
-          @Override public Optional<ArgInfo> apply(Element arg) {
-            @Nullable TypeElement containingType = processArg(parsedTypes, arg, argAnnotation);
-              if (containingType == null) {
-                return Optional.absent();
-              } else {
-                return Optional.of(new ArgInfo(getBinaryName(containingType),
-                    arg.getSimpleName().toString()));
-              }
+        arg -> {
+          @Nullable TypeElement containingType = processArg(parsedTypes, arg, argAnnotation);
+            if (containingType == null) {
+              return Optional.absent();
+            } else {
+              return Optional.of(new ArgInfo(getBinaryName(containingType),
+                  arg.getSimpleName().toString()));
             }
-        }));
+          }));
   }
 
   private Set<? extends Element> getAnnotatedElements(RoundEnvironment roundEnv,

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons-args/src/main/java/org/apache/aurora/common/args/apt/Configuration.java
----------------------------------------------------------------------
diff --git a/commons-args/src/main/java/org/apache/aurora/common/args/apt/Configuration.java b/commons-args/src/main/java/org/apache/aurora/common/args/apt/Configuration.java
index d06ec69..3ff3474 100644
--- a/commons-args/src/main/java/org/apache/aurora/common/args/apt/Configuration.java
+++ b/commons-args/src/main/java/org/apache/aurora/common/args/apt/Configuration.java
@@ -82,11 +82,7 @@ public final class Configuration {
   private static final CharMatcher IDENTIFIER_REST =
       CharMatcher.forPredicate(Character::isJavaIdentifierPart);
 
-  private static final Function<URL, CharSource> URL_TO_SOURCE = new Function<URL, CharSource>() {
-    @Override public CharSource apply(URL input) {
-      return Resources.asCharSource(input, StandardCharsets.UTF_8);
-    }
-  };
+  private static final Function<URL, CharSource> URL_TO_SOURCE = input -> Resources.asCharSource(input, StandardCharsets.UTF_8);
 
   private static final String DEFAULT_RESOURCE_NAME = "cmdline.arg.info.txt";
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/ArgFilters.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/ArgFilters.java b/commons/src/main/java/org/apache/aurora/common/args/ArgFilters.java
index 9a4d441..9fd6eae 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/ArgFilters.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/ArgFilters.java
@@ -51,11 +51,7 @@ public final class ArgFilters {
    */
   public static Predicate<Field> selectPackage(final Package pkg) {
     Preconditions.checkNotNull(pkg);
-    return new Predicate<Field>() {
-      @Override public boolean apply(Field field) {
-        return field.getDeclaringClass().getPackage().equals(pkg);
-      }
-    };
+    return field -> field.getDeclaringClass().getPackage().equals(pkg);
   }
 
   /**
@@ -69,10 +65,8 @@ public final class ArgFilters {
   public static Predicate<Field> selectAllPackagesUnderHere(final Package pkg) {
     Preconditions.checkNotNull(pkg);
     final String prefix = pkg.getName() + '.';
-    return Predicates.or(selectPackage(pkg), new Predicate<Field>() {
-      @Override public boolean apply(Field field) {
-        return field.getDeclaringClass().getPackage().getName().startsWith(prefix);
-      }
+    return Predicates.or(selectPackage(pkg), field -> {
+      return field.getDeclaringClass().getPackage().getName().startsWith(prefix);
     });
   }
 
@@ -84,11 +78,7 @@ public final class ArgFilters {
    */
   public static Predicate<Field> selectClass(final Class<?> clazz) {
     Preconditions.checkNotNull(clazz);
-    return new Predicate<Field>() {
-      @Override public boolean apply(Field field) {
-        return field.getDeclaringClass().equals(clazz);
-      }
-    };
+    return field -> field.getDeclaringClass().equals(clazz);
   }
 
   /**
@@ -100,11 +90,7 @@ public final class ArgFilters {
   public static Predicate<Field> selectClasses(final Class<?> ... cls) {
     Preconditions.checkNotNull(cls);
     final Set<Class<?>> listOfClasses = ImmutableSet.copyOf(cls);
-    return new Predicate<Field>() {
-      @Override public boolean apply(Field field) {
-        return listOfClasses.contains(field.getDeclaringClass());
-      }
-    };
+    return field -> listOfClasses.contains(field.getDeclaringClass());
   }
 
   /**
@@ -116,10 +102,8 @@ public final class ArgFilters {
    */
   public static Predicate<Field> selectCmdLineArg(Class<?> clazz, final String name) {
     MorePreconditions.checkNotBlank(name);
-    return Predicates.and(selectClass(clazz), new Predicate<Field>() {
-      @Override public boolean apply(Field field) {
-        return field.getAnnotation(CmdLine.class).name().equals(name);
-      }
+    return Predicates.and(selectClass(clazz), field -> {
+      return field.getAnnotation(CmdLine.class).name().equals(name);
     });
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/ArgScanner.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/ArgScanner.java b/commons/src/main/java/org/apache/aurora/common/args/ArgScanner.java
index cc4710c..c98ed87 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/ArgScanner.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/ArgScanner.java
@@ -79,28 +79,14 @@ import static com.google.common.base.Preconditions.checkArgument;
  */
 public final class ArgScanner {
 
-  private static final Function<OptionInfo<?>, String> GET_OPTION_INFO_NAME =
-      new Function<OptionInfo<?>, String>() {
-        @Override public String apply(OptionInfo<?> optionInfo) {
-          return optionInfo.getName();
-        }
-      };
+  private static final Function<OptionInfo<?>, String> GET_OPTION_INFO_NAME = ArgumentInfo::getName;
 
   public static final Ordering<OptionInfo<?>> ORDER_BY_NAME =
       Ordering.natural().onResultOf(GET_OPTION_INFO_NAME);
 
-  private static final Function<String, String> ARG_NAME_TO_FLAG = new Function<String, String>() {
-    @Override public String apply(String argName) {
-      return "-" + argName;
-    }
-  };
+  private static final Function<String, String> ARG_NAME_TO_FLAG = argName -> "-" + argName;
 
-  private static final Predicate<OptionInfo<?>> IS_BOOLEAN =
-      new Predicate<OptionInfo<?>>() {
-        @Override public boolean apply(OptionInfo<?> optionInfo) {
-          return optionInfo.isBoolean();
-        }
-      };
+  private static final Predicate<OptionInfo<?>> IS_BOOLEAN = OptionInfo::isBoolean;
 
   // Regular expression to identify a possible dangling assignment.
   // A dangling assignment occurs in two cases:
@@ -122,31 +108,19 @@ public final class ArgScanner {
    * Extracts the name from an @OptionInfo.
    */
   private static final Function<OptionInfo<?>, String> GET_OPTION_INFO_NEGATED_NAME =
-      new Function<OptionInfo<?>, String>() {
-        @Override public String apply(OptionInfo<?> optionInfo) {
-          return optionInfo.getNegatedName();
-        }
-      };
+      OptionInfo::getNegatedName;
 
   /**
    * Gets the canonical name for an @Arg, based on the class containing the field it annotates.
    */
   private static final Function<OptionInfo<?>, String> GET_CANONICAL_ARG_NAME =
-      new Function<OptionInfo<?>, String>() {
-        @Override public String apply(OptionInfo<?> optionInfo) {
-          return optionInfo.getCanonicalName();
-        }
-      };
+      ArgumentInfo::getCanonicalName;
 
   /**
    * Gets the canonical negated name for an @Arg.
    */
   private static final Function<OptionInfo<?>, String> GET_CANONICAL_NEGATED_ARG_NAME =
-      new Function<OptionInfo<?>, String>() {
-        @Override public String apply(OptionInfo<?> optionInfo) {
-          return optionInfo.getCanonicalNegatedName();
-        }
-      };
+      OptionInfo::getCanonicalNegatedName;
 
   private static final Logger LOG = Logger.getLogger(ArgScanner.class.getName());
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/Args.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/Args.java b/commons/src/main/java/org/apache/aurora/common/args/Args.java
index ad0b299..db8e169 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/Args.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/Args.java
@@ -40,49 +40,43 @@ import static org.apache.aurora.common.args.apt.Configuration.ConfigurationExcep
  * a configuration database or from explicitly listed containing classes or objects.
  */
 public final class Args {
+  private static final Logger LOG = Logger.getLogger(Args.class.getName());
+
   @VisibleForTesting
   static final Function<ArgInfo, Optional<Field>> TO_FIELD =
-      new Function<ArgInfo, Optional<Field>>() {
-        @Override public Optional<Field> apply(ArgInfo info) {
-          try {
-            return Optional.of(Class.forName(info.className).getDeclaredField(info.fieldName));
-          } catch (NoSuchFieldException e) {
-            throw new ConfigurationException(e);
-          } catch (ClassNotFoundException e) {
-            throw new ConfigurationException(e);
-          } catch (NoClassDefFoundError e) {
-            // A compilation had this class available at the time the ArgInfo was deposited, but
-            // the classes have been re-bundled with some subset including the class this ArgInfo
-            // points to no longer available.  If the re-bundling is correct, then the arg truly is
-            // not needed.
-            LOG.fine(String.format("Not on current classpath, skipping %s", info));
-            return Optional.absent();
-          }
+      info -> {
+        try {
+          return Optional.of(Class.forName(info.className).getDeclaredField(info.fieldName));
+        } catch (NoSuchFieldException e) {
+          throw new ConfigurationException(e);
+        } catch (ClassNotFoundException e) {
+          throw new ConfigurationException(e);
+        } catch (NoClassDefFoundError e) {
+          // A compilation had this class available at the time the ArgInfo was deposited, but
+          // the classes have been re-bundled with some subset including the class this ArgInfo
+          // points to no longer available.  If the re-bundling is correct, then the arg truly is
+          // not needed.
+          LOG.fine(String.format("Not on current classpath, skipping %s", info));
+          return Optional.absent();
         }
       };
 
-  private static final Logger LOG = Logger.getLogger(Args.class.getName());
-
   private static final Function<Field, OptionInfo<?>> TO_OPTION_INFO =
-      new Function<Field, OptionInfo<?>>() {
-        @Override public OptionInfo<?> apply(Field field) {
-          @Nullable CmdLine cmdLine = field.getAnnotation(CmdLine.class);
-          if (cmdLine == null) {
-            throw new ConfigurationException("No @CmdLine Arg annotation for field " + field);
-          }
-          return OptionInfo.createFromField(field);
+      field -> {
+        @Nullable CmdLine cmdLine = field.getAnnotation(CmdLine.class);
+        if (cmdLine == null) {
+          throw new ConfigurationException("No @CmdLine Arg annotation for field " + field);
         }
+        return OptionInfo.createFromField(field);
       };
 
   private static final Function<Field, PositionalInfo<?>> TO_POSITIONAL_INFO =
-      new Function<Field, PositionalInfo<?>>() {
-        @Override public PositionalInfo<?> apply(Field field) {
-          @Nullable Positional positional = field.getAnnotation(Positional.class);
-          if (positional == null) {
-            throw new ConfigurationException("No @Positional Arg annotation for field " + field);
-          }
-          return PositionalInfo.createFromField(field);
+      field -> {
+        @Nullable Positional positional = field.getAnnotation(Positional.class);
+        if (positional == null) {
+          throw new ConfigurationException("No @Positional Arg annotation for field " + field);
         }
+        return PositionalInfo.createFromField(field);
       };
 
   /**

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/ArgumentInfo.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/ArgumentInfo.java b/commons/src/main/java/org/apache/aurora/common/args/ArgumentInfo.java
index 051e3f9..ca309a2 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/ArgumentInfo.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/ArgumentInfo.java
@@ -214,14 +214,12 @@ public abstract class ArgumentInfo<T> {
 
   private Iterable<ValueVerifier<T>> getVerifiers(final Verifiers verifierOracle) {
     Function<Annotation, Optional<ValueVerifier<T>>> toVerifier =
-        new Function<Annotation, Optional<ValueVerifier<T>>>() {
-          @Override public Optional<ValueVerifier<T>> apply(Annotation annotation) {
-            @Nullable Verifier<? super T> verifier = verifierOracle.get(type, annotation);
-            if (verifier != null) {
-              return Optional.of(new ValueVerifier<T>(verifier, annotation));
-            } else {
-              return Optional.absent();
-            }
+        annotation -> {
+          @Nullable Verifier<? super T> verifier = verifierOracle.get(type, annotation);
+          if (verifier != null) {
+            return Optional.of(new ValueVerifier<T>(verifier, annotation));
+          } else {
+            return Optional.absent();
           }
         };
     return Optional.presentInstances(Iterables.transform(verifierAnnotations, toVerifier));
@@ -238,10 +236,6 @@ public abstract class ArgumentInfo<T> {
     @SuppressWarnings("unchecked") // type.getType() is T
     final Class<? extends T> rawType = (Class<? extends T>) type.getRawType();
     return FluentIterable.from(getVerifiers(verifierOracle)).transform(
-        new Function<ValueVerifier<T>, String>() {
-          @Override public String apply(ValueVerifier<T> verifier) {
-            return verifier.toString(rawType);
-          }
-        }).toList();
+        verifier -> verifier.toString(rawType)).toList();
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java b/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
index c1fe1c7..1271494 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/OptionInfo.java
@@ -81,11 +81,7 @@ public final class OptionInfo<T> extends ArgumentInfo<T> {
         String.format("Argument name '%s' does not match required pattern %s",
             name, ARG_NAME_RE));
 
-    Function<String, String> canonicalizer = new Function<String, String>() {
-      @Override public String apply(String name) {
-        return field.getDeclaringClass().getCanonicalName() + "." + name;
-      }
-    };
+    Function<String, String> canonicalizer = name1 -> field.getDeclaringClass().getCanonicalName() + "." + name1;
 
     @SuppressWarnings({"unchecked", "rawtypes"}) // we have no way to know the type here
     OptionInfo<?> optionInfo = new OptionInfo(

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/Parsers.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/Parsers.java b/commons/src/main/java/org/apache/aurora/common/args/Parsers.java
index 62564a6..c4e5faf 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/Parsers.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/Parsers.java
@@ -43,36 +43,32 @@ public final class Parsers implements ParserOracle {
       Splitter.on(",").trimResults().omitEmptyStrings();
 
   private static final Function<ParserInfo, Class<?>> INFO_TO_PARSED_TYPE =
-      new Function<ParserInfo, Class<?>>() {
-        @Override public Class<?> apply(ParserInfo parserInfo) {
-          try {
-            return Class.forName(parserInfo.parsedType);
-          } catch (ClassNotFoundException e) {
-            throw new ConfigurationException(e);
-          }
+      parserInfo -> {
+        try {
+          return Class.forName(parserInfo.parsedType);
+        } catch (ClassNotFoundException e) {
+          throw new ConfigurationException(e);
         }
       };
 
   @VisibleForTesting
   static final Function<ParserInfo, Parser<?>> INFO_TO_PARSER =
-      new Function<ParserInfo, Parser<?>>() {
-        @Override public Parser<?> apply(ParserInfo parserInfo) {
-          try {
-            Class<?> parserClass = Class.forName(parserInfo.parserClass);
-            Constructor<?> constructor = parserClass.getDeclaredConstructor();
-            constructor.setAccessible(true);
-            return (Parser<?>) constructor.newInstance();
-          } catch (ClassNotFoundException e) {
-            throw new ConfigurationException(e);
-          } catch (InstantiationException e) {
-            throw new ConfigurationException(e);
-          } catch (IllegalAccessException e) {
-            throw new ConfigurationException(e);
-          } catch (NoSuchMethodException e) {
-            throw new ConfigurationException(e);
-          } catch (InvocationTargetException e) {
-            throw new ConfigurationException(e);
-          }
+      parserInfo -> {
+        try {
+          Class<?> parserClass = Class.forName(parserInfo.parserClass);
+          Constructor<?> constructor = parserClass.getDeclaredConstructor();
+          constructor.setAccessible(true);
+          return (Parser<?>) constructor.newInstance();
+        } catch (ClassNotFoundException e) {
+          throw new ConfigurationException(e);
+        } catch (InstantiationException e) {
+          throw new ConfigurationException(e);
+        } catch (IllegalAccessException e) {
+          throw new ConfigurationException(e);
+        } catch (NoSuchMethodException e) {
+          throw new ConfigurationException(e);
+        } catch (InvocationTargetException e) {
+          throw new ConfigurationException(e);
         }
       };
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/PositionalInfo.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/PositionalInfo.java b/commons/src/main/java/org/apache/aurora/common/args/PositionalInfo.java
index 3da1812..ddffdf9 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/PositionalInfo.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/PositionalInfo.java
@@ -106,11 +106,7 @@ public final class PositionalInfo<T> extends ArgumentInfo<List<T>> {
   void load(final ParserOracle parserOracle, List<String> positionalArgs) {
     final Parser<? extends T> parser = parserOracle.get(elementType);
     List<T> assignmentValue = Lists.newArrayList(Iterables.transform(positionalArgs,
-      new Function<String, T>() {
-        @Override public T apply(String argValue) {
-          return parser.parse(parserOracle, elementType.getType(), argValue);
-        }
-      }));
+        argValue -> parser.parse(parserOracle, elementType.getType(), argValue)));
     setValue(assignmentValue);
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/constraints/RangeNumberVerifier.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/constraints/RangeNumberVerifier.java b/commons/src/main/java/org/apache/aurora/common/args/constraints/RangeNumberVerifier.java
index 2725094..bec0523 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/constraints/RangeNumberVerifier.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/constraints/RangeNumberVerifier.java
@@ -54,11 +54,7 @@ public class RangeNumberVerifier implements Verifier<Number> {
 
       converter = Functions.identity();
     } else {
-      converter = new Function<Number, Number>() {
-        @Override public Number apply(Number item) {
-          return item.longValue();
-        }
-      };
+      converter = Number::longValue;
     }
 
     return String.format("must be >= %s and <= %s",

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/parsers/ListParser.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/parsers/ListParser.java b/commons/src/main/java/org/apache/aurora/common/args/parsers/ListParser.java
index 02c10ed..676f88b 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/parsers/ListParser.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/parsers/ListParser.java
@@ -43,10 +43,6 @@ public class ListParser extends TypeParameterizedParser<List<?>> {
     final Type listType = typeParams.get(0);
     final Parser<?> parser = parserOracle.get(TypeToken.of(listType));
     return ImmutableList.copyOf(Iterables.transform(Parsers.MULTI_VALUE_SPLITTER.split(raw),
-        new Function<String, Object>() {
-          @Override public Object apply(String raw) {
-            return parser.parse(parserOracle, listType, raw);
-          }
-        }));
+        raw1 -> parser.parse(parserOracle, listType, raw1)));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/args/parsers/SetParser.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/args/parsers/SetParser.java b/commons/src/main/java/org/apache/aurora/common/args/parsers/SetParser.java
index 1e12b06..75031f4 100644
--- a/commons/src/main/java/org/apache/aurora/common/args/parsers/SetParser.java
+++ b/commons/src/main/java/org/apache/aurora/common/args/parsers/SetParser.java
@@ -45,10 +45,6 @@ public class SetParser extends TypeParameterizedParser<Set<?>> {
     final Parser<?> parser = parserOracle.get(TypeToken.of(setType));
 
     return ImmutableSet.copyOf(Iterables.transform(Parsers.MULTI_VALUE_SPLITTER.split(raw),
-        new Function<String, Object>() {
-          @Override public Object apply(String raw) {
-            return parser.parse(parserOracle, setType, raw);
-          }
-        }));
+        raw1 -> parser.parse(parserOracle, setType, raw1)));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/base/Closures.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/Closures.java b/commons/src/main/java/org/apache/aurora/common/base/Closures.java
index d6cb82a..0953119 100644
--- a/commons/src/main/java/org/apache/aurora/common/base/Closures.java
+++ b/commons/src/main/java/org/apache/aurora/common/base/Closures.java
@@ -28,10 +28,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
  */
 public final class Closures {
 
-  private static final Closure<?> NOOP = new Closure<Object>() {
-    @Override public void execute(Object item) {
-      // noop
-    }
+  private static final Closure<?> NOOP = item -> {
+    // noop
   };
 
   private Closures() {
@@ -55,11 +53,9 @@ public final class Closures {
 
     final Iterable<Closure<T>> closuresCopy = ImmutableList.copyOf(closures);
 
-    return new Closure<T>() {
-      @Override public void execute(T item) {
-        for (Closure<T> closure : closuresCopy) {
-          closure.execute(item);
-        }
+    return item -> {
+      for (Closure<T> closure : closuresCopy) {
+        closure.execute(item);
       }
     };
   }
@@ -77,11 +73,9 @@ public final class Closures {
     checkNotNull(filter);
     checkNotNull(closure);
 
-    return new Closure<T>() {
-      @Override public void execute(T item) {
-        if (filter.apply(item)) {
-          closure.execute(item);
-        }
+    return item -> {
+      if (filter.apply(item)) {
+        closure.execute(item);
       }
     };
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/base/Commands.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/base/Commands.java b/commons/src/main/java/org/apache/aurora/common/base/Commands.java
index 8a88ae3..f549a1b 100644
--- a/commons/src/main/java/org/apache/aurora/common/base/Commands.java
+++ b/commons/src/main/java/org/apache/aurora/common/base/Commands.java
@@ -23,10 +23,8 @@ public final class Commands {
   /**
    * A command that does nothing when executed.
    */
-  public static final Command NOOP = new Command() {
-    @Override public void execute() {
-      // noop
-    }
+  public static final Command NOOP = () -> {
+    // noop
   };
 
   private Commands() {

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/collections/Iterables2.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/collections/Iterables2.java b/commons/src/main/java/org/apache/aurora/common/collections/Iterables2.java
index 072159e..7ae80ce 100644
--- a/commons/src/main/java/org/apache/aurora/common/collections/Iterables2.java
+++ b/commons/src/main/java/org/apache/aurora/common/collections/Iterables2.java
@@ -65,9 +65,7 @@ public final class Iterables2 {
       if (iterators == null) {
         // Iterables -> Iterators.
         iterators = ImmutableList.copyOf(Iterables.transform(iterables,
-            new Function<Iterable<T>, Iterator<T>>() {
-              @Override public Iterator<T> apply(Iterable<T> it) { return it.iterator(); }
-            }));
+            Iterable::iterator));
       }
     }
 
@@ -127,11 +125,7 @@ public final class Iterables2 {
   public static <T> Iterable<List<T>> zip(final Iterable<Iterable<T>> iterables,
       final T defaultValue) {
 
-    return new Iterable<List<T>>() {
-      @Override public Iterator<List<T>> iterator() {
-        return new ZippingIterator<T>(iterables, defaultValue);
-      }
-    };
+    return () -> new ZippingIterator<T>(iterables, defaultValue);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/collections/Pair.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/collections/Pair.java b/commons/src/main/java/org/apache/aurora/common/collections/Pair.java
index b1f9b63..4bd5ff0 100644
--- a/commons/src/main/java/org/apache/aurora/common/collections/Pair.java
+++ b/commons/src/main/java/org/apache/aurora/common/collections/Pair.java
@@ -90,11 +90,7 @@ public class Pair<A, B> {
    * @return A function that will extract the 1st item in a pair.
    */
   public static <S, T> Function<Pair<S, T>, S> first() {
-    return new Function<Pair<S, T>, S>() {
-      @Override public S apply(Pair<S, T> pair) {
-        return pair.first;
-      }
-    };
+    return pair -> pair.first;
   }
 
   /**
@@ -105,11 +101,7 @@ public class Pair<A, B> {
    * @return A function that will extract the 2nd item in a pair.
    */
   public static <S, T> Function<Pair<S, T>, T> second() {
-    return new Function<Pair<S, T>, T>() {
-      @Override public T apply(Pair<S, T> pair) {
-        return pair.second;
-      }
-    };
+    return pair -> pair.second;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogConfig.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogConfig.java b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogConfig.java
index aaaa348..c3fd808 100644
--- a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogConfig.java
+++ b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/LogConfig.java
@@ -89,22 +89,20 @@ public class LogConfig {
   protected String displayPage(Optional<String> configChange) throws TemplateException {
     StringWriter writer = new StringWriter();
 
-    template.writeTemplate(writer, new Closure<StringTemplate>() {
-      @Override public void execute(StringTemplate stringTemplate) {
-        LoggingMXBean logBean = LogManager.getLoggingMXBean();
+    template.writeTemplate(writer, stringTemplate -> {
+      LoggingMXBean logBean = LogManager.getLoggingMXBean();
 
-        if (configChange.isPresent()) {
-          stringTemplate.setAttribute("configChange", configChange.get());
-        }
-
-        List<LoggerConfig> loggerConfigs = Lists.newArrayList();
-        for (String logger : Ordering.natural().immutableSortedCopy(logBean.getLoggerNames())) {
-          loggerConfigs.add(new LoggerConfig(logger, logBean.getLoggerLevel(logger)));
-        }
+      if (configChange.isPresent()) {
+        stringTemplate.setAttribute("configChange", configChange.get());
+      }
 
-        stringTemplate.setAttribute("loggers", loggerConfigs);
-        stringTemplate.setAttribute("levels", LOG_LEVELS);
+      List<LoggerConfig> loggerConfigs = Lists.newArrayList();
+      for (String logger : Ordering.natural().immutableSortedCopy(logBean.getLoggerNames())) {
+        loggerConfigs.add(new LoggerConfig(logger, logBean.getLoggerLevel(logger)));
       }
+
+      stringTemplate.setAttribute("loggers", loggerConfigs);
+      stringTemplate.setAttribute("levels", LOG_LEVELS);
     });
 
     return writer.toString();

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/net/http/handlers/TimeSeriesDataSource.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/TimeSeriesDataSource.java b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/TimeSeriesDataSource.java
index 8039def..e40f327 100644
--- a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/TimeSeriesDataSource.java
+++ b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/TimeSeriesDataSource.java
@@ -86,11 +86,7 @@ public class TimeSeriesDataSource {
     }
 
     final long since = Long.parseLong(Optional.fromNullable(sinceQuery).or("0"));
-    Predicate<List<Number>> sinceFilter = new Predicate<List<Number>>() {
-      @Override public boolean apply(List<Number> next) {
-        return next.get(0).longValue() > since;
-      }
-    };
+    Predicate<List<Number>> sinceFilter = next -> next.get(0).longValue() > since;
 
     ResponseStruct response = new ResponseStruct(
         ImmutableList.<String>builder().add(TIME_METRIC).addAll(names).build(),

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/net/http/handlers/VarsHandler.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/VarsHandler.java b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/VarsHandler.java
index d1f23de..20fd96f 100644
--- a/commons/src/main/java/org/apache/aurora/common/net/http/handlers/VarsHandler.java
+++ b/commons/src/main/java/org/apache/aurora/common/net/http/handlers/VarsHandler.java
@@ -39,11 +39,7 @@ import org.apache.aurora.common.stats.Stat;
 @Path("/vars")
 public class VarsHandler {
 
-  private static final Function<Stat, String> VAR_PRINTER = new Function<Stat, String>() {
-    @Override public String apply(Stat stat) {
-      return stat.getName() + " " + stat.read();
-    }
-  };
+  private static final Function<Stat, String> VAR_PRINTER = stat -> stat.getName() + " " + stat.read();
 
   private final Supplier<Iterable<Stat<?>>> statSupplier;
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/stats/JvmStats.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/stats/JvmStats.java b/commons/src/main/java/org/apache/aurora/common/stats/JvmStats.java
index 03df9b6..d1b072d 100644
--- a/commons/src/main/java/org/apache/aurora/common/stats/JvmStats.java
+++ b/commons/src/main/java/org/apache/aurora/common/stats/JvmStats.java
@@ -188,29 +188,19 @@ public class JvmStats {
     // This is based on code in Bridcage: https://cgit.twitter.biz/birdcage/tree/ \
     // ostrich/src/main/scala/com/twitter/ostrich/stats/StatsCollection.scala
     Stats.exportAll(Iterables.transform(ManagementFactory.getGarbageCollectorMXBeans(),
-        new Function<GarbageCollectorMXBean, Stat<? extends Number>>(){
-          @Override
-          public Stat<? extends Number> apply(final GarbageCollectorMXBean gcMXBean) {
-            return new StatImpl<Long>(
-                "jvm_gc_" + Stats.normalizeName(gcMXBean.getName()) + "_collection_count") {
-              @Override public Long read() {
-                return gcMXBean.getCollectionCount();
-              }
-            };
+        gcMXBean -> new StatImpl<Long>(
+            "jvm_gc_" + Stats.normalizeName(gcMXBean.getName()) + "_collection_count") {
+          @Override public Long read() {
+            return gcMXBean.getCollectionCount();
           }
         }
     ));
 
     Stats.exportAll(Iterables.transform(ManagementFactory.getGarbageCollectorMXBeans(),
-        new Function<GarbageCollectorMXBean, Stat<? extends Number>>(){
-          @Override
-          public Stat<? extends Number> apply(final GarbageCollectorMXBean gcMXBean) {
-            return new StatImpl<Long>(
-                "jvm_gc_" + Stats.normalizeName(gcMXBean.getName()) + "_collection_time_ms") {
-              @Override public Long read() {
-                return gcMXBean.getCollectionTime();
-              }
-            };
+        gcMXBean -> new StatImpl<Long>(
+            "jvm_gc_" + Stats.normalizeName(gcMXBean.getName()) + "_collection_time_ms") {
+          @Override public Long read() {
+            return gcMXBean.getCollectionTime();
           }
         }
     ));

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/stats/Rate.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/stats/Rate.java b/commons/src/main/java/org/apache/aurora/common/stats/Rate.java
index ff29c39..dbb90c4 100644
--- a/commons/src/main/java/org/apache/aurora/common/stats/Rate.java
+++ b/commons/src/main/java/org/apache/aurora/common/stats/Rate.java
@@ -112,9 +112,7 @@ public class Rate<T extends Number> extends SampledStat<Double> {
     Builder(final Stat<T> input) {
       Stats.export(input);
       this.name = input.getName() + "_per_sec";
-      inputAccessor = new Supplier<T>() {
-        @Override public T get() { return input.read(); }
-      };
+      inputAccessor = input::read;
     }
 
     public Builder<T> withName(String name) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/stats/Ratio.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/stats/Ratio.java b/commons/src/main/java/org/apache/aurora/common/stats/Ratio.java
index c332dd3..b73ad90 100644
--- a/commons/src/main/java/org/apache/aurora/common/stats/Ratio.java
+++ b/commons/src/main/java/org/apache/aurora/common/stats/Ratio.java
@@ -53,16 +53,8 @@ public class Ratio extends SampledStat<Double> {
     Stats.export(denominator);
 
     return new Ratio(name,
-        new Supplier<Number>() {
-          @Override public Number get() {
-            return numerator.read();
-          }
-        },
-        new Supplier<Number>() {
-          @Override public Number get() {
-            return denominator.read();
-          }
-        });
+        numerator::read,
+        denominator::read);
   }
 
   public static Ratio of(String name, final Number numerator, final Number denominator) {
@@ -70,16 +62,8 @@ public class Ratio extends SampledStat<Double> {
     Preconditions.checkNotNull(denominator);
 
     return new Ratio(name,
-        new Supplier<Number>() {
-          @Override public Number get() {
-            return numerator;
-          }
-        },
-        new Supplier<Number>() {
-          @Override public Number get() {
-            return denominator;
-          }
-        });
+        () -> numerator,
+        () -> denominator);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/testing/easymock/EasyMockTest.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/testing/easymock/EasyMockTest.java b/commons/src/main/java/org/apache/aurora/common/testing/easymock/EasyMockTest.java
index 4031475..c5500b3 100644
--- a/commons/src/main/java/org/apache/aurora/common/testing/easymock/EasyMockTest.java
+++ b/commons/src/main/java/org/apache/aurora/common/testing/easymock/EasyMockTest.java
@@ -45,11 +45,7 @@ public abstract class EasyMockTest extends TearDownTestCase {
   @Before
   public final void setupEasyMock() {
     control = createControl();
-    addTearDown(new TearDown() {
-      @Override public void tearDown() {
-        control.verify();
-      }
-    });
+    addTearDown(() -> control.verify());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/util/BackoffHelper.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/util/BackoffHelper.java b/commons/src/main/java/org/apache/aurora/common/util/BackoffHelper.java
index e789f80..b251e9b 100644
--- a/commons/src/main/java/org/apache/aurora/common/util/BackoffHelper.java
+++ b/commons/src/main/java/org/apache/aurora/common/util/BackoffHelper.java
@@ -83,11 +83,9 @@ public class BackoffHelper {
    */
   public <E extends Exception> void doUntilSuccess(final ExceptionalSupplier<Boolean, E> task)
       throws InterruptedException, BackoffStoppedException, E {
-    doUntilResult(new ExceptionalSupplier<Boolean, E>() {
-      @Override public Boolean get() throws E {
-        Boolean result = task.get();
-        return Boolean.TRUE.equals(result) ? result : null;
-      }
+    doUntilResult(() -> {
+      Boolean result = task.get();
+      return Boolean.TRUE.equals(result) ? result : null;
     });
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/util/StateMachine.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/util/StateMachine.java b/commons/src/main/java/org/apache/aurora/common/util/StateMachine.java
index 9fbfbb9..dbaaadd 100644
--- a/commons/src/main/java/org/apache/aurora/common/util/StateMachine.java
+++ b/commons/src/main/java/org/apache/aurora/common/util/StateMachine.java
@@ -385,11 +385,7 @@ public class StateMachine<T> {
      * @return A reference to the builder.
      */
     public Builder<T> logTransitions() {
-      return onAnyTransition(new Closure<Transition<T>>() {
-        @Override public void execute(Transition<T> transition) {
-          LOG.info(name + " state machine transition " + transition);
-        }
-      });
+      return onAnyTransition(transition -> LOG.info(name + " state machine transition " + transition));
     }
 
     /**
@@ -438,19 +434,11 @@ public class StateMachine<T> {
     }
 
     private static <T> Function<Transition<T>, T> from() {
-      return new Function<Transition<T>, T>() {
-        @Override public T apply(Transition<T> transition) {
-          return transition.from;
-        }
-      };
+      return transition -> transition.from;
     }
 
     private static <T> Function<Transition<T>, T> to() {
-      return new Function<Transition<T>, T>() {
-        @Override public T apply(Transition<T> transition) {
-          return transition.to;
-        }
-      };
+      return transition -> transition.to;
     }
 
     private static <T> Predicate<Transition<T>> oneSideFilter(

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/zookeeper/CandidateImpl.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/CandidateImpl.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/CandidateImpl.java
index b10a403..bb0a48d 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/CandidateImpl.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/CandidateImpl.java
@@ -49,23 +49,17 @@ public class CandidateImpl implements Candidate {
 
   private static final byte[] UNKNOWN_CANDIDATE_DATA = "<unknown>".getBytes(Charsets.UTF_8);
 
-  private static final Supplier<byte[]> IP_ADDRESS_DATA_SUPPLIER = new Supplier<byte[]>() {
-    @Override public byte[] get() {
-      try {
-        return InetAddress.getLocalHost().getHostAddress().getBytes();
-      } catch (UnknownHostException e) {
-        LOG.log(Level.WARNING, "Failed to determine local address!", e);
-        return UNKNOWN_CANDIDATE_DATA;
-      }
+  private static final Supplier<byte[]> IP_ADDRESS_DATA_SUPPLIER = () -> {
+    try {
+      return InetAddress.getLocalHost().getHostAddress().getBytes();
+    } catch (UnknownHostException e) {
+      LOG.log(Level.WARNING, "Failed to determine local address!", e);
+      return UNKNOWN_CANDIDATE_DATA;
     }
   };
 
   private static final Function<Iterable<String>, String> MOST_RECENT_JUDGE =
-      new Function<Iterable<String>, String>() {
-        @Override public String apply(Iterable<String> candidates) {
-          return Ordering.natural().min(candidates);
-        }
-      };
+      candidates -> Ordering.natural().min(candidates);
 
   private final Group group;
 
@@ -90,56 +84,44 @@ public class CandidateImpl implements Candidate {
   public Supplier<Boolean> offerLeadership(final Leader leader)
       throws JoinException, WatchException, InterruptedException {
 
-    final Membership membership = group.join(IP_ADDRESS_DATA_SUPPLIER, new Command() {
-      @Override public void execute() {
-        leader.onDefeated();
-      }
-    });
+    final Membership membership = group.join(IP_ADDRESS_DATA_SUPPLIER, leader::onDefeated);
 
     final AtomicBoolean elected = new AtomicBoolean(false);
     final AtomicBoolean abdicated = new AtomicBoolean(false);
-    group.watch(new GroupChangeListener() {
-        @Override public void onGroupChange(Iterable<String> memberIds) {
-          boolean noCandidates = Iterables.isEmpty(memberIds);
-          String memberId = membership.getMemberId();
-
-          if (noCandidates) {
-            LOG.warning("All candidates have temporarily left the group: " + group);
-          } else if (!Iterables.contains(memberIds, memberId)) {
-            LOG.severe(String.format(
-                "Current member ID %s is not a candidate for leader, current voting: %s",
-                memberId, memberIds));
-          } else {
-            boolean electedLeader = memberId.equals(getLeader(memberIds));
-            boolean previouslyElected = elected.getAndSet(electedLeader);
-
-            if (!previouslyElected && electedLeader) {
-              LOG.info(String.format("Candidate %s is now leader of group: %s",
-                  membership.getMemberPath(), memberIds));
-
-              leader.onElected(new ExceptionalCommand<JoinException>() {
-                @Override public void execute() throws JoinException {
-                  membership.cancel();
-                  abdicated.set(true);
-                }
-              });
-            } else if (!electedLeader) {
-              if (previouslyElected) {
-                leader.onDefeated();
-              }
-              LOG.info(String.format(
-                  "Candidate %s waiting for the next leader election, current voting: %s",
-                  membership.getMemberPath(), memberIds));
-            }
+    group.watch(memberIds -> {
+      boolean noCandidates = Iterables.isEmpty(memberIds);
+      String memberId = membership.getMemberId();
+
+      if (noCandidates) {
+        LOG.warning("All candidates have temporarily left the group: " + group);
+      } else if (!Iterables.contains(memberIds, memberId)) {
+        LOG.severe(String.format(
+            "Current member ID %s is not a candidate for leader, current voting: %s",
+            memberId, memberIds));
+      } else {
+        boolean electedLeader = memberId.equals(getLeader(memberIds));
+        boolean previouslyElected = elected.getAndSet(electedLeader);
+
+        if (!previouslyElected && electedLeader) {
+          LOG.info(String.format("Candidate %s is now leader of group: %s",
+              membership.getMemberPath(), memberIds));
+
+          leader.onElected(() -> {
+            membership.cancel();
+            abdicated.set(true);
+          });
+        } else if (!electedLeader) {
+          if (previouslyElected) {
+            leader.onDefeated();
           }
+          LOG.info(String.format(
+              "Candidate %s waiting for the next leader election, current voting: %s",
+              membership.getMemberPath(), memberIds));
         }
-      });
+      }
+    });
 
-    return new Supplier<Boolean>() {
-        @Override public Boolean get() {
-          return !abdicated.get() && elected.get();
-        }
-      };
+    return () -> !abdicated.get() && elected.get();
   }
 
   @Nullable

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/zookeeper/Group.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/Group.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/Group.java
index 99a15fe..d368170 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/Group.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/Group.java
@@ -87,11 +87,7 @@ public class Group {
     this.path = ZooKeeperUtils.normalizePath(Preconditions.checkNotNull(path));
 
     this.nodeScheme = Preconditions.checkNotNull(nodeScheme);
-    nodeNameFilter = new Predicate<String>() {
-      @Override public boolean apply(String nodeName) {
-        return Group.this.nodeScheme.isMember(nodeName);
-      }
-    };
+    nodeNameFilter = Group.this.nodeScheme::isMember;
 
     backoffHelper = new BackoffHelper();
   }
@@ -264,47 +260,43 @@ public class Group {
     ensurePersistentGroupPath();
 
     final ActiveMembership groupJoiner = new ActiveMembership(memberData, onLoseMembership);
-    return backoffHelper.doUntilResult(new ExceptionalSupplier<Membership, JoinException>() {
-      @Override public Membership get() throws JoinException {
-        try {
-          return groupJoiner.join();
-        } catch (InterruptedException e) {
-          Thread.currentThread().interrupt();
-          throw new JoinException("Interrupted trying to join group at path: " + path, e);
-        } catch (ZooKeeperConnectionException e) {
+    return backoffHelper.doUntilResult(() -> {
+      try {
+        return groupJoiner.join();
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        throw new JoinException("Interrupted trying to join group at path: " + path, e);
+      } catch (ZooKeeperConnectionException e) {
+        LOG.log(Level.WARNING, "Temporary error trying to join group at path: " + path, e);
+        return null;
+      } catch (KeeperException e) {
+        if (zkClient.shouldRetry(e)) {
           LOG.log(Level.WARNING, "Temporary error trying to join group at path: " + path, e);
           return null;
-        } catch (KeeperException e) {
-          if (zkClient.shouldRetry(e)) {
-            LOG.log(Level.WARNING, "Temporary error trying to join group at path: " + path, e);
-            return null;
-          } else {
-            throw new JoinException("Problem joining partition group at path: " + path, e);
-          }
+        } else {
+          throw new JoinException("Problem joining partition group at path: " + path, e);
         }
       }
     });
   }
 
   private void ensurePersistentGroupPath() throws JoinException, InterruptedException {
-    backoffHelper.doUntilSuccess(new ExceptionalSupplier<Boolean, JoinException>() {
-      @Override public Boolean get() throws JoinException {
-        try {
-          ZooKeeperUtils.ensurePath(zkClient, acl, path);
-          return true;
-        } catch (InterruptedException e) {
-          Thread.currentThread().interrupt();
-          throw new JoinException("Interrupted trying to ensure group at path: " + path, e);
-        } catch (ZooKeeperConnectionException e) {
-          LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+    backoffHelper.doUntilSuccess(() -> {
+      try {
+        ZooKeeperUtils.ensurePath(zkClient, acl, path);
+        return true;
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        throw new JoinException("Interrupted trying to ensure group at path: " + path, e);
+      } catch (ZooKeeperConnectionException e) {
+        LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+        return false;
+      } catch (KeeperException e) {
+        if (zkClient.shouldRetry(e)) {
+          LOG.log(Level.WARNING, "Temporary error ensuring path: " + path, e);
           return false;
-        } catch (KeeperException e) {
-          if (zkClient.shouldRetry(e)) {
-            LOG.log(Level.WARNING, "Temporary error ensuring path: " + path, e);
-            return false;
-          } else {
-            throw new JoinException("Problem ensuring group at path: " + path, e);
-          }
+        } else {
+          throw new JoinException("Problem ensuring group at path: " + path, e);
         }
       }
     });
@@ -361,28 +353,26 @@ public class Group {
     public synchronized void cancel() throws JoinException {
       if (!cancelled) {
         try {
-          backoffHelper.doUntilSuccess(new ExceptionalSupplier<Boolean, JoinException>() {
-            @Override public Boolean get() throws JoinException {
-              try {
-                zkClient.get().delete(nodePath, ZooKeeperUtils.ANY_VERSION);
-                return true;
-              } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                throw new JoinException("Interrupted trying to cancel membership: " + nodePath, e);
-              } catch (ZooKeeperConnectionException e) {
-                LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+          backoffHelper.doUntilSuccess(() -> {
+            try {
+              zkClient.get().delete(nodePath, ZooKeeperUtils.ANY_VERSION);
+              return true;
+            } catch (InterruptedException e) {
+              Thread.currentThread().interrupt();
+              throw new JoinException("Interrupted trying to cancel membership: " + nodePath, e);
+            } catch (ZooKeeperConnectionException e) {
+              LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+              return false;
+            } catch (NoNodeException e) {
+              LOG.info("Membership already cancelled, node at path: " + nodePath +
+                       " has been deleted");
+              return true;
+            } catch (KeeperException e) {
+              if (zkClient.shouldRetry(e)) {
+                LOG.log(Level.WARNING, "Temporary error cancelling membership: " + nodePath, e);
                 return false;
-              } catch (NoNodeException e) {
-                LOG.info("Membership already cancelled, node at path: " + nodePath +
-                         " has been deleted");
-                return true;
-              } catch (KeeperException e) {
-                if (zkClient.shouldRetry(e)) {
-                  LOG.log(Level.WARNING, "Temporary error cancelling membership: " + nodePath, e);
-                  return false;
-                } else {
-                  throw new JoinException("Problem cancelling membership: " + nodePath, e);
-                }
+              } else {
+                throw new JoinException("Problem cancelling membership: " + nodePath, e);
               }
             }
           });
@@ -406,11 +396,7 @@ public class Group {
       if (nodePath == null) {
         // Re-join if our ephemeral node goes away due to session expiry - only needs to be
         // registered once.
-        zkClient.registerExpirationHandler(new Command() {
-          @Override public void execute() {
-            tryJoin();
-          }
-        });
+        zkClient.registerExpirationHandler(this::tryJoin);
       }
 
       byte[] membershipData = memberData.get();
@@ -424,11 +410,9 @@ public class Group {
       this.membershipData = membershipData;
 
       // Re-join if our ephemeral node goes away due to maliciousness.
-      zkClient.get().exists(nodePath, new Watcher() {
-        @Override public void process(WatchedEvent event) {
-          if (event.getType() == EventType.NodeDeleted) {
-            tryJoin();
-          }
+      zkClient.get().exists(nodePath, event -> {
+        if (event.getType() == EventType.NodeDeleted) {
+          tryJoin();
         }
       });
 
@@ -436,24 +420,22 @@ public class Group {
     }
 
     private final ExceptionalSupplier<Boolean, InterruptedException> tryJoin =
-        new ExceptionalSupplier<Boolean, InterruptedException>() {
-          @Override public Boolean get() throws InterruptedException {
-            try {
-              join();
-              return true;
-            } catch (CancelledException e) {
-              // Lost a cancel race - that's ok.
-              return true;
-            } catch (ZooKeeperConnectionException e) {
-              LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+        () -> {
+          try {
+            join();
+            return true;
+          } catch (CancelledException e) {
+            // Lost a cancel race - that's ok.
+            return true;
+          } catch (ZooKeeperConnectionException e) {
+            LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+            return false;
+          } catch (KeeperException e) {
+            if (zkClient.shouldRetry(e)) {
+              LOG.log(Level.WARNING, "Temporary error re-joining group: " + path, e);
               return false;
-            } catch (KeeperException e) {
-              if (zkClient.shouldRetry(e)) {
-                LOG.log(Level.WARNING, "Temporary error re-joining group: " + path, e);
-                return false;
-              } else {
-                throw new IllegalStateException("Permanent problem re-joining group: " + path, e);
-              }
+            } else {
+              throw new IllegalStateException("Permanent problem re-joining group: " + path, e);
             }
           }
         };
@@ -542,32 +524,26 @@ public class Group {
     }
 
     final GroupMonitor groupMonitor = new GroupMonitor(groupChangeListener);
-    backoffHelper.doUntilSuccess(new ExceptionalSupplier<Boolean, WatchException>() {
-      @Override public Boolean get() throws WatchException {
-        try {
-          groupMonitor.watchGroup();
-          return true;
-        } catch (InterruptedException e) {
-          Thread.currentThread().interrupt();
-          throw new WatchException("Interrupted trying to watch group at path: " + path, e);
-        } catch (ZooKeeperConnectionException e) {
+    backoffHelper.doUntilSuccess(() -> {
+      try {
+        groupMonitor.watchGroup();
+        return true;
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        throw new WatchException("Interrupted trying to watch group at path: " + path, e);
+      } catch (ZooKeeperConnectionException e) {
+        LOG.log(Level.WARNING, "Temporary error trying to watch group at path: " + path, e);
+        return null;
+      } catch (KeeperException e) {
+        if (zkClient.shouldRetry(e)) {
           LOG.log(Level.WARNING, "Temporary error trying to watch group at path: " + path, e);
           return null;
-        } catch (KeeperException e) {
-          if (zkClient.shouldRetry(e)) {
-            LOG.log(Level.WARNING, "Temporary error trying to watch group at path: " + path, e);
-            return null;
-          } else {
-            throw new WatchException("Problem trying to watch group at path: " + path, e);
-          }
+        } else {
+          throw new WatchException("Problem trying to watch group at path: " + path, e);
         }
       }
     });
-    return new Command() {
-      @Override public void execute() {
-        groupMonitor.stopWatching();
-      }
-    };
+    return groupMonitor::stopWatching;
   }
 
   /**
@@ -582,30 +558,26 @@ public class Group {
       this.groupChangeListener = groupChangeListener;
     }
 
-    private final Watcher groupWatcher = new Watcher() {
-      @Override public final void process(WatchedEvent event) {
-        if (event.getType() == EventType.NodeChildrenChanged) {
-          tryWatchGroup();
-        }
+    private final Watcher groupWatcher = event -> {
+      if (event.getType() == EventType.NodeChildrenChanged) {
+        tryWatchGroup();
       }
     };
 
     private final ExceptionalSupplier<Boolean, InterruptedException> tryWatchGroup =
-        new ExceptionalSupplier<Boolean, InterruptedException>() {
-          @Override public Boolean get() throws InterruptedException {
-            try {
-              watchGroup();
-              return true;
-            } catch (ZooKeeperConnectionException e) {
-              LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+        () -> {
+          try {
+            watchGroup();
+            return true;
+          } catch (ZooKeeperConnectionException e) {
+            LOG.log(Level.WARNING, "Problem connecting to ZooKeeper, retrying", e);
+            return false;
+          } catch (KeeperException e) {
+            if (zkClient.shouldRetry(e)) {
+              LOG.log(Level.WARNING, "Temporary error re-watching group: " + path, e);
               return false;
-            } catch (KeeperException e) {
-              if (zkClient.shouldRetry(e)) {
-                LOG.log(Level.WARNING, "Temporary error re-watching group: " + path, e);
-                return false;
-              } else {
-                throw new IllegalStateException("Permanent problem re-watching group: " + path, e);
-              }
+            } else {
+              throw new IllegalStateException("Permanent problem re-watching group: " + path, e);
             }
           }
         };
@@ -650,11 +622,7 @@ public class Group {
 
       if (this.members == null) {
         // Reset our watch on the group if session expires - only needs to be registered once.
-        zkClient.registerExpirationHandler(new Command() {
-          @Override public void execute() {
-            tryWatchGroup();
-          }
-        });
+        zkClient.registerExpirationHandler(this::tryWatchGroup);
       }
 
       Set<String> membership = ImmutableSet.copyOf(members);

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
index bb6fbce..6a0a314 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/ServerSetImpl.java
@@ -159,18 +159,10 @@ public class ServerSetImpl implements ServerSet {
 
     final MemberStatus memberStatus =
         new MemberStatus(endpoint, additionalEndpoints, shardId);
-    Supplier<byte[]> serviceInstanceSupplier = new Supplier<byte[]>() {
-      @Override public byte[] get() {
-        return memberStatus.serializeServiceInstance();
-      }
-    };
+    Supplier<byte[]> serviceInstanceSupplier = memberStatus::serializeServiceInstance;
     final Group.Membership membership = group.join(serviceInstanceSupplier);
 
-    return new EndpointStatus() {
-      @Override public void leave() throws UpdateException {
-        memberStatus.leave(membership);
-      }
-    };
+    return () -> memberStatus.leave(membership);
   }
 
   @Override
@@ -252,20 +244,10 @@ public class ServerSetImpl implements ServerSet {
     }
 
     public Command watch() throws Group.WatchException, InterruptedException {
-      Watcher onExpirationWatcher = zkClient.registerExpirationHandler(new Command() {
-        @Override public void execute() {
-          // Servers may have changed Status while we were disconnected from ZooKeeper, check and
-          // re-register our node watches.
-          rebuildServerSet();
-        }
-      });
+      Watcher onExpirationWatcher = zkClient.registerExpirationHandler(this::rebuildServerSet);
 
       try {
-        return group.watch(new Group.GroupChangeListener() {
-          @Override public void onGroupChange(Iterable<String> memberIds) {
-            notifyGroupChange(memberIds);
-          }
-        });
+        return group.watch(this::notifyGroupChange);
       } catch (Group.WatchException e) {
         zkClient.unregister(onExpirationWatcher);
         throw e;
@@ -277,35 +259,33 @@ public class ServerSetImpl implements ServerSet {
 
     private ServiceInstance getServiceInstance(final String nodePath) {
       try {
-        return backoffHelper.doUntilResult(new ExceptionalSupplier<ServiceInstance, RuntimeException>() {
-          @Override public ServiceInstance get() {
-            try {
-              byte[] data = zkClient.get().getData(nodePath, false, null);
-              return ServerSets.deserializeServiceInstance(data, codec);
-            } catch (InterruptedException e) {
-              Thread.currentThread().interrupt();
-              throw new ServiceInstanceFetchException(
-                  "Interrupted updating service data for: " + nodePath, e);
-            } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
+        return backoffHelper.doUntilResult(() -> {
+          try {
+            byte[] data = zkClient.get().getData(nodePath, false, null);
+            return ServerSets.deserializeServiceInstance(data, codec);
+          } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            throw new ServiceInstanceFetchException(
+                "Interrupted updating service data for: " + nodePath, e);
+          } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
+            LOG.log(Level.WARNING,
+                "Temporary error trying to updating service data for: " + nodePath, e);
+            return null;
+          } catch (NoNodeException e) {
+            invalidateNodePath(nodePath);
+            throw new ServiceInstanceDeletedException(nodePath);
+          } catch (KeeperException e) {
+            if (zkClient.shouldRetry(e)) {
               LOG.log(Level.WARNING,
-                  "Temporary error trying to updating service data for: " + nodePath, e);
+                  "Temporary error trying to update service data for: " + nodePath, e);
               return null;
-            } catch (NoNodeException e) {
-              invalidateNodePath(nodePath);
-              throw new ServiceInstanceDeletedException(nodePath);
-            } catch (KeeperException e) {
-              if (zkClient.shouldRetry(e)) {
-                LOG.log(Level.WARNING,
-                    "Temporary error trying to update service data for: " + nodePath, e);
-                return null;
-              } else {
-                throw new ServiceInstanceFetchException(
-                    "Failed to update service data for: " + nodePath, e);
-              }
-            } catch (IOException e) {
+            } else {
               throw new ServiceInstanceFetchException(
-                  "Failed to deserialize the ServiceInstance data for: " + nodePath, e);
+                  "Failed to update service data for: " + nodePath, e);
             }
+          } catch (IOException e) {
+            throw new ServiceInstanceFetchException(
+                "Failed to deserialize the ServiceInstance data for: " + nodePath, e);
           }
         });
       } catch (InterruptedException e) {
@@ -335,20 +315,18 @@ public class ServerSetImpl implements ServerSet {
     }
 
     private final Function<String, ServiceInstance> MAYBE_FETCH_NODE =
-        new Function<String, ServiceInstance>() {
-          @Override public ServiceInstance apply(String memberId) {
-            // This get will trigger a fetch
-            try {
-              return servicesByMemberId.getUnchecked(memberId);
-            } catch (UncheckedExecutionException e) {
-              Throwable cause = e.getCause();
-              if (!(cause instanceof ServiceInstanceDeletedException)) {
-                Throwables.propagateIfInstanceOf(cause, ServiceInstanceFetchException.class);
-                throw new IllegalStateException(
-                    "Unexpected error fetching member data for: " + memberId, e);
-              }
-              return null;
+        memberId -> {
+          // This get will trigger a fetch
+          try {
+            return servicesByMemberId.getUnchecked(memberId);
+          } catch (UncheckedExecutionException e) {
+            Throwable cause = e.getCause();
+            if (!(cause instanceof ServiceInstanceDeletedException)) {
+              Throwables.propagateIfInstanceOf(cause, ServiceInstanceFetchException.class);
+              throw new IllegalStateException(
+                  "Unexpected error fetching member data for: " + memberId, e);
             }
+            return null;
           }
         };
 
@@ -442,11 +420,7 @@ public class ServerSetImpl implements ServerSet {
       if (instance.getAdditionalEndpoints() != null) {
         this.additionalEndpoints = Maps.transformValues(
             instance.getAdditionalEndpoints(),
-            new Function<Endpoint, EndpointSchema>() {
-              @Override public EndpointSchema apply(Endpoint endpoint) {
-                return new EndpointSchema(endpoint);
-              }
-            }
+            EndpointSchema::new
         );
       } else {
         this.additionalEndpoints = Maps.newHashMap();
@@ -495,11 +469,7 @@ public class ServerSetImpl implements ServerSet {
           output.getServiceEndpoint().getHost(), output.getServiceEndpoint().getPort());
       Map<String, Endpoint> additional = Maps.transformValues(
           output.getAdditionalEndpoints(),
-          new Function<EndpointSchema, Endpoint>() {
-            @Override public Endpoint apply(EndpointSchema endpoint) {
-              return new Endpoint(endpoint.getHost(), endpoint.getPort());
-            }
-          }
+          endpoint -> new Endpoint(endpoint.getHost(), endpoint.getPort())
       );
       ServiceInstance instance =
           new ServiceInstance(primary, ImmutableMap.copyOf(additional), output.getStatus());

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/commons/src/main/java/org/apache/aurora/common/zookeeper/ZooKeeperClient.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/ZooKeeperClient.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/ZooKeeperClient.java
index 1761ab7..e399d38 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/ZooKeeperClient.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/ZooKeeperClient.java
@@ -351,25 +351,23 @@ public class ZooKeeperClient {
 
     if (zooKeeper == null) {
       final CountDownLatch connected = new CountDownLatch(1);
-      Watcher watcher = new Watcher() {
-        @Override public void process(WatchedEvent event) {
-          switch (event.getType()) {
-            // Guard the None type since this watch may be used as the default watch on calls by
-            // the client outside our control.
-            case None:
-              switch (event.getState()) {
-                case Expired:
-                  LOG.info("Zookeeper session expired. Event: " + event);
-                  close();
-                  break;
-                case SyncConnected:
-                  connected.countDown();
-                  break;
-              }
-          }
-
-          eventQueue.offer(event);
+      Watcher watcher = event -> {
+        switch (event.getType()) {
+          // Guard the None type since this watch may be used as the default watch on calls by
+          // the client outside our control.
+          case None:
+            switch (event.getState()) {
+              case Expired:
+                LOG.info("Zookeeper session expired. Event: " + event);
+                close();
+                break;
+              case SyncConnected:
+                connected.countDown();
+                break;
+            }
         }
+
+        eventQueue.offer(event);
       };
 
       try {
@@ -413,11 +411,9 @@ public class ZooKeeperClient {
    *     removal.
    */
   public Watcher registerExpirationHandler(final Command onExpired) {
-    Watcher watcher = new Watcher() {
-      @Override public void process(WatchedEvent event) {
-        if (event.getType() == EventType.None && event.getState() == KeeperState.Expired) {
-          onExpired.execute();
-        }
+    Watcher watcher = event -> {
+      if (event.getType() == EventType.None && event.getState() == KeeperState.Expired) {
+        onExpired.execute();
       }
     };
     register(watcher);

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/config/legacy_untested_classes.txt
----------------------------------------------------------------------
diff --git a/config/legacy_untested_classes.txt b/config/legacy_untested_classes.txt
index 07e49b1..f183518 100644
--- a/config/legacy_untested_classes.txt
+++ b/config/legacy_untested_classes.txt
@@ -10,7 +10,6 @@ org/apache/aurora/scheduler/app/SchedulerMain$2$1
 org/apache/aurora/scheduler/app/SchedulerMain$3
 org/apache/aurora/scheduler/app/SchedulerMain$4
 org/apache/aurora/scheduler/async/OfferQueue$OfferQueueImpl$2
-org/apache/aurora/scheduler/base/Conversions$1
 org/apache/aurora/scheduler/base/Conversions$2
 org/apache/aurora/scheduler/base/Conversions$3
 org/apache/aurora/scheduler/configuration/executor/ExecutorModule
@@ -62,13 +61,13 @@ org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule$5
 org/apache/aurora/scheduler/mesos/DriverFactoryImpl
 org/apache/aurora/scheduler/mesos/LibMesosLoadingModule
 org/apache/aurora/scheduler/stats/AsyncStatsModule$OfferAdapter$1
-org/apache/aurora/scheduler/stats/StatsModule$3
 org/apache/aurora/scheduler/stats/TaskStatCalculator
 org/apache/aurora/scheduler/storage/CallOrderEnforcingStorage$State
 org/apache/aurora/scheduler/storage/backup/BackupModule$LifecycleHook
 org/apache/aurora/scheduler/storage/mem/MemTaskStore$Task
 org/apache/aurora/scheduler/storage/mem/Util
 org/apache/aurora/scheduler/storage/mem/Util$1
+org/apache/aurora/scheduler/testing/FakeStatsProvider$1
 org/apache/aurora/scheduler/testing/FakeStatsProvider$3
 org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$1
 org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$LocalClientProvider

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/src/main/java/org/apache/aurora/GuiceUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/GuiceUtils.java b/src/main/java/org/apache/aurora/GuiceUtils.java
index 78b60c2..bc99a3a 100644
--- a/src/main/java/org/apache/aurora/GuiceUtils.java
+++ b/src/main/java/org/apache/aurora/GuiceUtils.java
@@ -62,12 +62,7 @@ public final class GuiceUtils {
   }
 
   private static final Function<Method, Pair<String, Class<?>[]>> CANONICALIZE =
-      new Function<Method, Pair<String, Class<?>[]>>() {
-        @Override
-        public Pair<String, Class<?>[]> apply(Method method) {
-          return Pair.of(method.getName(), method.getParameterTypes());
-        }
-      };
+      method -> Pair.of(method.getName(), method.getParameterTypes());
 
   /**
    * Creates a matcher that will match methods of an interface, optionally excluding inherited
@@ -125,12 +120,8 @@ public final class GuiceUtils {
         });
   }
 
-  private static final Predicate<Method> IS_WHITELISTED = new Predicate<Method>() {
-    @Override
-    public boolean apply(Method method) {
-      return method.getAnnotation(AllowUnchecked.class) != null;
-    }
-  };
+  private static final Predicate<Method> IS_WHITELISTED =
+      method -> method.getAnnotation(AllowUnchecked.class) != null;
 
   private static final Matcher<Method> WHITELIST_MATCHER = new AbstractMatcher<Method>() {
     @Override
@@ -139,12 +130,8 @@ public final class GuiceUtils {
     }
   };
 
-  private static final Predicate<Method> VOID_METHOD = new Predicate<Method>() {
-    @Override
-    public boolean apply(Method method) {
-      return method.getReturnType() == Void.TYPE;
-    }
-  };
+  private static final Predicate<Method> VOID_METHOD =
+      method -> method.getReturnType() == Void.TYPE;
 
   /**
    * Binds an exception trap on all interface methods of all classes bound against an interface.

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java b/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
index 7003b2f..7c3d681 100644
--- a/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
+++ b/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
@@ -124,14 +124,11 @@ public final class ResourceSlot {
         .findFirst();
     ExecutorInfo.Builder executorBuilder = taskBuilder.getExecutorBuilder();
 
-    Consumer<Builder> matchRevocable = new Consumer<Builder>() {
-      @Override
-      public void accept(Builder builder) {
-        if (revocableTaskCpu.isPresent()) {
-          builder.setRevocable(revocableTaskCpu.get().getRevocable());
-        } else {
-          builder.clearRevocable();
-        }
+    Consumer<Builder> matchRevocable = builder -> {
+      if (revocableTaskCpu.isPresent()) {
+        builder.setRevocable(revocableTaskCpu.get().getRevocable());
+      } else {
+        builder.clearRevocable();
       }
     };
 
@@ -353,13 +350,8 @@ public final class ResourceSlot {
   private static final Predicate<Integer> IS_ZERO = e -> e == 0;
 
   private static final Function<Range<Integer>, Protos.Value.Range> RANGE_TRANSFORM =
-      new Function<Range<Integer>, Protos.Value.Range>() {
-        @Override
-        public Protos.Value.Range apply(Range<Integer> input) {
-          return Protos.Value.Range.newBuilder()
-              .setBegin(input.lowerEndpoint())
-              .setEnd(input.upperEndpoint())
-              .build();
-        }
-      };
+      input -> Protos.Value.Range.newBuilder()
+          .setBegin(input.lowerEndpoint())
+          .setEnd(input.upperEndpoint())
+          .build();
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/2e237148/src/main/java/org/apache/aurora/scheduler/Resources.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/Resources.java b/src/main/java/org/apache/aurora/scheduler/Resources.java
index f7d105e..db422a9 100644
--- a/src/main/java/org/apache/aurora/scheduler/Resources.java
+++ b/src/main/java/org/apache/aurora/scheduler/Resources.java
@@ -176,12 +176,7 @@ public final class Resources {
   }
 
   private static final Function<Range, Set<Integer>> RANGE_TO_MEMBERS =
-      new Function<Range, Set<Integer>>() {
-        @Override
-        public Set<Integer> apply(Range range) {
-          return ContiguousSet.create(
-              com.google.common.collect.Range.closed((int) range.getBegin(), (int) range.getEnd()),
-              DiscreteDomain.integers());
-        }
-      };
+      range -> ContiguousSet.create(
+          com.google.common.collect.Range.closed((int) range.getBegin(), (int) range.getEnd()),
+          DiscreteDomain.integers());
 }


Mime
View raw message