tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ss...@apache.org
Subject tez git commit: TEZ-1903. Fix findbugs warnings in tez-runtime-internal module. (sseth)
Date Mon, 12 Jan 2015 20:13:28 GMT
Repository: tez
Updated Branches:
  refs/heads/master 3d3156118 -> c8bae3649


TEZ-1903. Fix findbugs warnings in tez-runtime-internal module. (sseth)


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

Branch: refs/heads/master
Commit: c8bae364972f897988544e62a551c3ace2c28a87
Parents: 3d31561
Author: Siddharth Seth <sseth@apache.org>
Authored: Mon Jan 12 12:13:10 2015 -0800
Committer: Siddharth Seth <sseth@apache.org>
Committed: Mon Jan 12 12:13:10 2015 -0800

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 tez-runtime-internals/findbugs-exclude.xml      | 43 ++++++++++++++++++++
 .../runtime/LogicalIOProcessorRuntimeTask.java  | 25 ++++--------
 .../org/apache/tez/runtime/RuntimeTask.java     | 11 ++---
 .../api/impl/TezMergedInputContextImpl.java     |  3 +-
 .../common/resources/MemoryDistributor.java     |  1 +
 6 files changed, 62 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/c8bae364/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7370aa7..e16a2e9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,7 @@ Release 0.7.0: Unreleased
 INCOMPATIBLE CHANGES
 
 ALL CHANGES:
+  TEZ-1903. Fix findbugs warnings in tez-runtime-internal module.
   TEZ-1896. Move the default heartbeat timeout and checkinterval to TezConfiguration.
   TEZ-1923. FetcherOrderedGrouped gets into infinite loop due to memory pressure.
   TEZ-1274. Remove Key/Value type checks in IFile.

http://git-wip-us.apache.org/repos/asf/tez/blob/c8bae364/tez-runtime-internals/findbugs-exclude.xml
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/findbugs-exclude.xml b/tez-runtime-internals/findbugs-exclude.xml
index 5b11308..bc8a2c0 100644
--- a/tez-runtime-internals/findbugs-exclude.xml
+++ b/tez-runtime-internals/findbugs-exclude.xml
@@ -13,4 +13,47 @@
 -->
 <FindBugsFilter>
 
+
+  <Match>
+    <Class name="org.apache.tez.runtime.api.impl.TezMergedInputContextImpl"/>
+    <Method name="&lt;init&gt;"/>
+    <Bug pattern="EI_EXPOSE_REP2"/>
+  </Match>
+
+  <Match>
+    <Class name="org.apache.tez.runtime.api.impl.TezTaskContextImpl"/>
+    <Method name="&lt;init&gt;"/>
+    <Bug pattern="EI_EXPOSE_REP2"/>
+  </Match>
+
+  <Match>
+    <Class name="org.apache.tez.runtime.LogicalIOProcessorRuntimeTask"/>
+    <Method name="&lt;init&gt;"/>
+    <Bug pattern="EI_EXPOSE_REP2"/>
+  </Match>
+
+  <Match>
+    <Class name="~org\.apache\.tez\.runtime\.internals\.api\.events\.SystemEventProtos\$.*Proto"
/>
+    <Field name="PARSER"/>
+    <Bug pattern="MS_SHOULD_BE_FINAL"/>
+  </Match>
+
+  <Match>
+    <Class name="~org\.apache\.tez\.runtime\.internals\.api\.events\.SystemEventProtos\$.*Proto"
/>
+    <Field name="unknownFields"/>
+    <Bug pattern="SE_BAD_FIELD"/>
+  </Match>
+
+  <Match>
+    <Class name="~org\.apache\.tez\.runtime\.internals\.api\.events\.SystemEventProtos\$.*Proto\$Builder"
/>
+    <Method name="maybeForceBuilderInitialization"/>
+    <Bug pattern="UCF_USELESS_CONTROL_FLOW"/>
+  </Match>
+
+  <Match>
+    <Class name="org.apache.tez.runtime.RuntimeTask"/>
+    <Field name="fatalErrorMessage"/>
+    <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+  </Match>
+
 </FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/tez/blob/c8bae364/tez-runtime-internals/src/main/java/org/apache/tez/runtime/LogicalIOProcessorRuntimeTask.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/LogicalIOProcessorRuntimeTask.java
b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/LogicalIOProcessorRuntimeTask.java
index 99b318d..c3f90a5 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/LogicalIOProcessorRuntimeTask.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/LogicalIOProcessorRuntimeTask.java
@@ -160,7 +160,7 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
     this.serviceConsumerMetadata = serviceConsumerMetadata;
     this.envMap = envMap;
     this.eventsToBeProcessed = new LinkedBlockingQueue<TezEvent>();
-    this.state = State.NEW;
+    this.state.set(State.NEW);
     this.appAttemptNumber = appAttemptNumber;
     int numInitializers = numInputs + numOutputs; // Processor is initialized in the main
thread.
     numInitializers = (numInitializers == 0 ? 1 : numInitializers);
@@ -183,8 +183,8 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
    */
   public void initialize() throws Exception {
     LOG.info("Initializing LogicalProcessorIORuntimeTask");
-    Preconditions.checkState(this.state == State.NEW, "Already initialized");
-    this.state = State.INITED;
+    Preconditions.checkState(this.state.get() == State.NEW, "Already initialized");
+    this.state.set(State.INITED);
 
     LOG.info("Creating processor" + ", processorClassName=" + processorDescriptor.getClassName());
     this.processorContext = createProcessorContext();
@@ -320,19 +320,17 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
   }
 
   public void run() throws Exception {
-    synchronized (this.state) {
-      Preconditions.checkState(this.state == State.INITED,
-          "Can only run while in INITED state. Current: " + this.state);
-      this.state = State.RUNNING;
-    }
+    Preconditions.checkState(this.state.get() == State.INITED,
+        "Can only run while in INITED state. Current: " + this.state);
+    this.state.set(State.RUNNING);
     processor.run(runInputMap, runOutputMap);
   }
 
   public void close() throws Exception {
     try {
-      Preconditions.checkState(this.state == State.RUNNING,
+      Preconditions.checkState(this.state.get() == State.RUNNING,
           "Can only run while in RUNNING state. Current: " + this.state);
-      this.state = State.CLOSED;
+      this.state.set(State.CLOSED);
 
       // Close the Processor.
       processor.close();
@@ -392,7 +390,7 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
     }
   }
 
-  private class StartInputCallable implements Callable<Void> {
+  private static class StartInputCallable implements Callable<Void> {
     private final LogicalInput input;
     private final String srcVertexName;
 
@@ -540,11 +538,6 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
     LogicalInput input = ReflectionUtils.createClazzInstance(inputDesc.getClassName(),
         new Class[]{MergedInputContext.class, List.class},
         new Object[]{mergedInputContext, constituentInputs});
-    if (!(input instanceof LogicalInput)) {
-      throw new TezUncheckedException(inputDesc.getClass().getName()
-          + " is not a sub-type of LogicalInput."
-          + " Only LogicalInput sub-types supported by LogicalIOProcessor.");
-    }
     return input;
   }
 

http://git-wip-us.apache.org/repos/asf/tez/blob/c8bae364/tez-runtime-internals/src/main/java/org/apache/tez/runtime/RuntimeTask.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/RuntimeTask.java b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/RuntimeTask.java
index 5f2eb93..4dfa936 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/RuntimeTask.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/RuntimeTask.java
@@ -21,6 +21,7 @@ package org.apache.tez.runtime;
 import java.util.Collection;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.tez.common.counters.TezCounters;
@@ -33,7 +34,7 @@ import org.apache.tez.runtime.metrics.TaskCounterUpdater;
 public abstract class RuntimeTask {
 
   protected AtomicBoolean hasFatalError = new AtomicBoolean(false);
-  protected Throwable fatalError = null;
+  protected AtomicReference<Throwable> fatalError = new AtomicReference<Throwable>();
   protected String fatalErrorMessage = null;
   protected float progress;
   protected final TezCounters tezCounters;
@@ -60,7 +61,7 @@ public abstract class RuntimeTask {
     NEW, INITED, RUNNING, CLOSED;
   }
 
-  protected State state;
+  protected final AtomicReference<State> state = new AtomicReference<State>();
 
   public String getVertexName() {
     return taskSpec.getVertexName();
@@ -68,12 +69,12 @@ public abstract class RuntimeTask {
 
   public void setFatalError(Throwable t, String message) {
     hasFatalError.set(true);
-    this.fatalError = t;
+    this.fatalError.set(t);
     this.fatalErrorMessage = message;
   }
   
-  public synchronized Throwable getFatalError() {
-    return fatalError;
+  public Throwable getFatalError() {
+    return this.fatalError.get();
   }
 
   public boolean hadFatalError() {

http://git-wip-us.apache.org/repos/asf/tez/blob/c8bae364/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezMergedInputContextImpl.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezMergedInputContextImpl.java
b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezMergedInputContextImpl.java
index e71a0bc..74592c6 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezMergedInputContextImpl.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezMergedInputContextImpl.java
@@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
 import javax.annotation.Nullable;
 
+import java.util.Arrays;
 import java.util.Map;
 
 import org.apache.tez.dag.api.UserPayload;
@@ -63,7 +64,7 @@ public class TezMergedInputContextImpl implements MergedInputContext {
 
   @Override
   public String[] getWorkDirs() {
-    return workDirs;
+    return Arrays.copyOf(workDirs, workDirs.length);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/tez/blob/c8bae364/tez-runtime-internals/src/main/java/org/apache/tez/runtime/common/resources/MemoryDistributor.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/common/resources/MemoryDistributor.java
b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/common/resources/MemoryDistributor.java
index 00c381c..0e3f67d 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/common/resources/MemoryDistributor.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/common/resources/MemoryDistributor.java
@@ -177,6 +177,7 @@ public class MemoryDistributor {
       Preconditions.checkState(numOutputsSeen.get() <= numTotalOutputs,
           "Num Requesting Inputs higher than total # of outputs: " + numOutputsSeen + ",
"
               + numTotalOutputs);
+      break;
     case PROCESSOR:
       break;
     default:


Mime
View raw message