aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject incubator-aurora git commit: Enable checkstyle indentation check, fix violations.
Date Tue, 17 Feb 2015 22:04:22 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 882169ed3 -> 219c3adcd


Enable checkstyle indentation check, fix violations.

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


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

Branch: refs/heads/master
Commit: 219c3adcddc2ad8645d238ce8a6d73a937acee37
Parents: 882169e
Author: Bill Farner <wfarner@apache.org>
Authored: Tue Feb 17 14:03:20 2015 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Tue Feb 17 14:03:20 2015 -0800

----------------------------------------------------------------------
 config/checkstyle/checkstyle.xml                | 17 +++++++++++-
 .../scheduler/configuration/Resources.java      | 10 +++----
 .../aurora/scheduler/http/StructDump.java       |  2 +-
 .../aurora/scheduler/sla/SlaAlgorithm.java      | 28 ++++++++++----------
 .../scheduler/state/MaintenanceController.java  | 12 ++++-----
 .../scheduler/state/TaskStateMachine.java       |  4 +--
 .../aurora/scheduler/storage/SnapshotStore.java |  2 +-
 .../aurora/scheduler/storage/Storage.java       |  2 +-
 .../scheduler/storage/mem/MemTaskStore.java     |  2 +-
 .../scheduler/thrift/ReadOnlySchedulerImpl.java | 19 ++++++-------
 .../thrift/SchedulerThriftInterface.java        | 18 ++++++-------
 .../scheduler/async/TaskSchedulerImplTest.java  |  7 ++---
 .../mesos/MesosTaskFactoryImplTest.java         | 26 +++++++++---------
 .../scheduler/thrift/aop/ForwardingThrift.java  | 21 +++++++--------
 14 files changed, 93 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/config/checkstyle/checkstyle.xml
----------------------------------------------------------------------
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index c4c6c44..580d9d3 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -41,6 +41,10 @@ limitations under the License.
   To completely disable a check, just comment it out or delete it from the file.
 
   Finally, it is worth reading the documentation.
+
+  TODO(wfarner): Iterate on this file to converge towards the google style checks provided
+  by checkstyle:
+  https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
 -->
 
 <module name="Checker">
@@ -63,7 +67,9 @@ limitations under the License.
 
   <!-- Checks for whitespace                               -->
   <!-- See http://checkstyle.sf.net/config_whitespace.html -->
-  <module name="FileTabCharacter"/>
+  <module name="FileTabCharacter">
+    <property name="eachLine" value="true"/>
+  </module>
 
   <!-- Miscellaneous other checks.                   -->
   <!-- See http://checkstyle.sf.net/config_misc.html -->
@@ -82,6 +88,15 @@ limitations under the License.
   <module name="TreeWalker">
     <property name="tabWidth" value="2"/>
 
+    <module name="Indentation">
+      <property name="basicOffset" value="2"/>
+      <property name="braceAdjustment" value="0"/>
+      <property name="caseIndent" value="2"/>
+      <property name="throwsIndent" value="4"/>
+      <property name="lineWrappingIndentation" value="4"/>
+      <property name="arrayInitIndent" value="2"/>
+    </module>
+
     <!-- needed for SuppressWithNearbyCommentFilter -->
     <module name="FileContentsHolder"/>
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java b/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
index b5a3140..673a690 100644
--- a/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
+++ b/src/main/java/org/apache/aurora/scheduler/configuration/Resources.java
@@ -108,10 +108,10 @@ public class Resources {
    */
   public List<Resource> toResourceList(Set<Integer> selectedPorts) {
     ImmutableList.Builder<Resource> resourceBuilder =
-      ImmutableList.<Resource>builder()
-          .add(Resources.makeMesosResource(CPUS, numCpus))
-          .add(Resources.makeMesosResource(DISK_MB, disk.as(Data.MB)))
-          .add(Resources.makeMesosResource(RAM_MB, ram.as(Data.MB)));
+        ImmutableList.<Resource>builder()
+            .add(Resources.makeMesosResource(CPUS, numCpus))
+            .add(Resources.makeMesosResource(DISK_MB, disk.as(Data.MB)))
+            .add(Resources.makeMesosResource(RAM_MB, ram.as(Data.MB)));
     if (!selectedPorts.isEmpty()) {
       resourceBuilder.add(Resources.makeMesosRangeResource(Resources.PORTS, selectedPorts));
     }
@@ -266,7 +266,7 @@ public class Resources {
   }
 
   private static Resource getResource(List<Resource> resource, String key) {
-      return Iterables.find(resource, withName(key), null);
+    return Iterables.find(resource, withName(key), null);
   }
 
   private static Predicate<Resource> withName(final String name) {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/http/StructDump.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/StructDump.java b/src/main/java/org/apache/aurora/scheduler/http/StructDump.java
index 12b28be..063170a 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/StructDump.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/StructDump.java
@@ -59,7 +59,7 @@ public class StructDump extends JerseyTemplateServlet {
   }
 
   private static final String USAGE =
-    "<html>Usage: /structdump/task/{task_id} or /structdump/cron/{role}/{env}/{job}</html>";
+      "<html>Usage: /structdump/task/{task_id} or /structdump/cron/{role}/{env}/{job}</html>";
 
   @GET
   @Produces(MediaType.TEXT_HTML)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java b/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
index eae79d5..ff73ca6 100644
--- a/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
+++ b/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java
@@ -141,7 +141,7 @@ interface SlaAlgorithm {
         }
       }
 
-     return SlaUtil.percentile(waitTimes, 50.0);
+      return SlaUtil.percentile(waitTimes, 50.0);
     }
   }
 
@@ -299,19 +299,19 @@ interface SlaAlgorithm {
     /**
      * Combine all task events per given instance into the unified sorted instance history
view.
      */
-    private static final Function<Collection<IScheduledTask>, List<ITaskEvent>>
-        TASKS_TO_SORTED_TASK_EVENTS = new Function<Collection<IScheduledTask>, List<ITaskEvent>>()
{
-      @Override
-      public List<ITaskEvent> apply(Collection<IScheduledTask> tasks) {
-        List<ITaskEvent> result = Lists.newLinkedList();
-        for (IScheduledTask task : tasks) {
-          result.addAll(task.getTaskEvents());
-        }
+    private static final Function<Collection<IScheduledTask>, List<ITaskEvent>>
TO_SORTED_EVENTS =
+        new Function<Collection<IScheduledTask>, List<ITaskEvent>>() {
+          @Override
+          public List<ITaskEvent> apply(Collection<IScheduledTask> tasks) {
+            List<ITaskEvent> result = Lists.newLinkedList();
+            for (IScheduledTask task : tasks) {
+              result.addAll(task.getTaskEvents());
+            }
 
-        return Ordering.natural()
-            .onResultOf(TASK_EVENT_TO_TIMESTAMP).immutableSortedCopy(result);
-      }
-    };
+            return Ordering.natural()
+                .onResultOf(TASK_EVENT_TO_TIMESTAMP).immutableSortedCopy(result);
+          }
+        };
 
     /**
      * Convert instance history into the {@link SlaState} based {@link Interval} list.
@@ -407,7 +407,7 @@ interface SlaAlgorithm {
       Map<InstanceId, List<Interval>> instanceSlaTimeline =
           Maps.transformValues(
               Multimaps.index(tasks, TO_ID).asMap(),
-              Functions.compose(TASK_EVENTS_TO_INTERVALS, TASKS_TO_SORTED_TASK_EVENTS));
+              Functions.compose(TASK_EVENTS_TO_INTERVALS, TO_SORTED_EVENTS));
 
       // Given the instance timeline converted to SlaState-based time intervals, aggregate
the
       // platform uptime per given timeFrame.

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/state/MaintenanceController.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/MaintenanceController.java b/src/main/java/org/apache/aurora/scheduler/state/MaintenanceController.java
index 9158271..b6f642e 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/MaintenanceController.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/MaintenanceController.java
@@ -216,12 +216,12 @@ public interface MaintenanceController {
         };
 
     private static final Function<HostStatus, MaintenanceMode> GET_MODE =
-      new Function<HostStatus, MaintenanceMode>() {
-        @Override
-        public MaintenanceMode apply(HostStatus status) {
-          return status.getMode();
-        }
-      };
+        new Function<HostStatus, MaintenanceMode>() {
+          @Override
+          public MaintenanceMode apply(HostStatus status) {
+            return status.getMode();
+          }
+        };
 
     @Override
     public MaintenanceMode getMode(final String host) {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java b/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
index cb870f9..4a7ca62 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
@@ -401,8 +401,8 @@ class TaskStateMachine {
                             addFollowup(RESCHEDULE);
                             break;
 
-                           default:
-                             // No-op.
+                          default:
+                            // No-op.
                         }
                       }
                     }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/storage/SnapshotStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/SnapshotStore.java b/src/main/java/org/apache/aurora/scheduler/storage/SnapshotStore.java
index 49584a9..6b5e5dd 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/SnapshotStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/SnapshotStore.java
@@ -24,7 +24,7 @@ public interface SnapshotStore<T> {
    *
    * @return A blob that can be used to recover local storage via {@link #applySnapshot(Object)}.
    */
-   T createSnapshot();
+  T createSnapshot();
 
   /**
    * Applies a snapshot blob to the local storage system, wiping out all existing data and

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/Storage.java b/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
index 2055e11..83a59ce 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/Storage.java
@@ -218,7 +218,7 @@ public interface Storage {
    *
    * @throws StorageException if there was a problem preparing storage.
    */
-   void prepare() throws StorageException;
+  void prepare() throws StorageException;
 
   /**
    * A non-volatile storage that has additional methods to control its lifecycle.

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
index 1b79850..9c76fa5 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
@@ -75,7 +75,7 @@ class MemTaskStore implements TaskStore.Mutable {
       new Function<Query.Builder, Optional<Set<IJobKey>>>() {
         @Override
         public Optional<Set<IJobKey>> apply(Query.Builder query) {
-            return JobKeys.from(query);
+          return JobKeys.from(query);
         }
       };
   private static final Function<Query.Builder, Optional<Set<String>>> QUERY_TO_SLAVE_HOST
=

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
index 2e58f67..ee76189 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
@@ -99,14 +99,15 @@ import static org.apache.aurora.scheduler.thrift.Responses.invalidRequest;
 import static org.apache.aurora.scheduler.thrift.Responses.ok;
 
 class ReadOnlySchedulerImpl implements ReadOnlyScheduler.Iface {
-  private static final Function<Entry<ITaskConfig, Collection<Integer>>, ConfigGroup>
-      CONFIG_TO_GROUP = new Function<Entry<ITaskConfig, Collection<Integer>>,
ConfigGroup>() {
-
-    @Override
-    public ConfigGroup apply(Entry<ITaskConfig, Collection<Integer>> input) {
-      return new ConfigGroup(input.getKey().newBuilder(), ImmutableSet.copyOf(input.getValue()));
-    }
-  };
+  private static final Function<Entry<ITaskConfig, Collection<Integer>>, ConfigGroup>
TO_GROUP =
+      new Function<Entry<ITaskConfig, Collection<Integer>>, ConfigGroup>()
{
+        @Override
+        public ConfigGroup apply(Entry<ITaskConfig, Collection<Integer>> input)
{
+          return new ConfigGroup(
+              input.getKey().newBuilder(),
+              ImmutableSet.copyOf(input.getValue()));
+        }
+      };
 
   private final Storage storage;
   private final NearestFit nearestFit;
@@ -223,7 +224,7 @@ class ReadOnlySchedulerImpl implements ReadOnlyScheduler.Iface {
         Multimaps.forMap(tasksByInstance),
         HashMultimap.<ITaskConfig, Integer>create());
     Iterable<ConfigGroup> groups = Iterables.transform(
-        instancesByDetails.asMap().entrySet(), CONFIG_TO_GROUP);
+        instancesByDetails.asMap().entrySet(), TO_GROUP);
 
     ConfigSummary summary = new ConfigSummary(job, ImmutableSet.copyOf(groups));
     return ok(Result.configSummaryResult(new ConfigSummaryResult().setSummary(summary)));

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 580369f..2d21a97 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -1345,15 +1345,15 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
   private SessionContext authorizeJobUpdateAction(IJobUpdateKey key, SessionKey session)
       throws AuthFailedException {
 
-      Optional<SessionContext> maybeCoordinatorContext = isUpdateCoordinator(session);
-      SessionContext context;
-      if (maybeCoordinatorContext.isPresent()) {
-        context = maybeCoordinatorContext.get();
-      } else {
-        context = sessionValidator.checkAuthenticated(
-            session,
-            ImmutableSet.of(key.getJob().getRole()));
-      }
+    Optional<SessionContext> maybeCoordinatorContext = isUpdateCoordinator(session);
+    SessionContext context;
+    if (maybeCoordinatorContext.isPresent()) {
+      context = maybeCoordinatorContext.get();
+    } else {
+      context = sessionValidator.checkAuthenticated(
+          session,
+          ImmutableSet.of(key.getJob().getRole()));
+    }
 
     return context;
   }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/test/java/org/apache/aurora/scheduler/async/TaskSchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/async/TaskSchedulerImplTest.java b/src/test/java/org/apache/aurora/scheduler/async/TaskSchedulerImplTest.java
index d0e1193..7963e47 100644
--- a/src/test/java/org/apache/aurora/scheduler/async/TaskSchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/async/TaskSchedulerImplTest.java
@@ -344,9 +344,10 @@ public class TaskSchedulerImplTest extends EasyMockTest {
 
   private AssignmentCapture expectLaunchAttempt(boolean taskLaunched)
       throws OfferQueue.LaunchException {
-        AssignmentCapture capture = new AssignmentCapture();
-        expect(offerQueue.launchFirst(capture(capture.assigner))).andReturn(taskLaunched);
-        return capture;
+
+    AssignmentCapture capture = new AssignmentCapture();
+    expect(offerQueue.launchFirst(capture(capture.assigner))).andReturn(taskLaunched);
+    return capture;
   }
 
   private void assignAndAssert(

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
b/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
index 5f08d00..444d6d3 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
@@ -48,19 +48,19 @@ public class MesosTaskFactoryImplTest {
 
   private static final String EXECUTOR_WRAPPER_PATH = "/fake/executor_wrapper.sh";
   private static final IAssignedTask TASK = IAssignedTask.build(new AssignedTask()
-    .setInstanceId(2)
-    .setTaskId("task-id")
-    .setAssignedPorts(ImmutableMap.of("http", 80))
-    .setTask(new TaskConfig()
-        .setJob(new JobKey("role", "environment", "job-name"))
-        .setOwner(new Identity("role", "user"))
-        .setEnvironment("environment")
-        .setJobName("job-name")
-        .setDiskMb(10)
-        .setRamMb(100)
-        .setNumCpus(5)
-        .setContainer(Container.mesos(new MesosContainer()))
-        .setRequestedPorts(ImmutableSet.of("http"))));
+      .setInstanceId(2)
+      .setTaskId("task-id")
+      .setAssignedPorts(ImmutableMap.of("http", 80))
+      .setTask(new TaskConfig()
+          .setJob(new JobKey("role", "environment", "job-name"))
+          .setOwner(new Identity("role", "user"))
+          .setEnvironment("environment")
+          .setJobName("job-name")
+          .setDiskMb(10)
+          .setRamMb(100)
+          .setNumCpus(5)
+          .setContainer(Container.mesos(new MesosContainer()))
+          .setRequestedPorts(ImmutableSet.of("http"))));
   private static final IAssignedTask TASK_WITH_DOCKER = IAssignedTask.build(TASK.newBuilder()
       .setTask(
           new TaskConfig(TASK.getTask().newBuilder())

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/219c3adc/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java b/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
index bc26c4c..2405bb8 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/aop/ForwardingThrift.java
@@ -129,20 +129,19 @@ abstract class ForwardingThrift implements AuroraAdmin.Iface {
     return delegate.createJob(description, lock, session);
   }
 
-    @Override
-    public Response scheduleCronJob(JobConfiguration description, Lock lock, SessionKey session)
-        throws TException {
-
-      return delegate.scheduleCronJob(description, lock, session);
-    }
+  @Override
+  public Response scheduleCronJob(JobConfiguration description, Lock lock, SessionKey session)
+      throws TException {
 
-    @Override
-    public Response descheduleCronJob(JobKey job, Lock lock, SessionKey session) throws TException
{
+    return delegate.scheduleCronJob(description, lock, session);
+  }
 
-      return delegate.descheduleCronJob(job, lock, session);
-    }
+  @Override
+  public Response descheduleCronJob(JobKey job, Lock lock, SessionKey session) throws TException
{
+    return delegate.descheduleCronJob(job, lock, session);
+  }
 
-    @Override
+  @Override
   public Response replaceCronTemplate(JobConfiguration config, Lock lock, SessionKey session)
       throws TException {
 


Mime
View raw message