hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1155099 - in /hadoop/common/branches/MR-279/mapreduce: ./ dev-support/ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/cli...
Date Mon, 08 Aug 2011 21:00:53 GMT
Author: mahadev
Date: Mon Aug  8 21:00:52 2011
New Revision: 1155099

URL: http://svn.apache.org/viewvc?rev=1155099&view=rev
Log:
Fix findbugs warnings in mr-client modules part 3 (mahadev)

Modified:
    hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
    hadoop/common/branches/MR-279/mapreduce/dev-support/findbugs-exclude.xml
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/LocalContainerLauncher.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/client/MRClientService.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/JobImpl.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/recover/RecoveryService.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMCommunicator.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMContainerAllocator.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/DefaultSpeculator.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/LegacyTaskRuntimeEstimator.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java

Modified: hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/CHANGES.txt?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/CHANGES.txt (original)
+++ hadoop/common/branches/MR-279/mapreduce/CHANGES.txt Mon Aug  8 21:00:52 2011
@@ -4,6 +4,8 @@ Trunk (unreleased changes)
 
   MAPREDUCE-279
  
+    Fix findbugs warnings in mr-client modules part 3 (mahadev)
+
     Fix findbugs warnings in mr-client modules part 2 (mahadev)
  
     Fix findbugs warnings in mr-client modules, part 1  (mahadev) 

Modified: hadoop/common/branches/MR-279/mapreduce/dev-support/findbugs-exclude.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/dev-support/findbugs-exclude.xml?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/dev-support/findbugs-exclude.xml (original)
+++ hadoop/common/branches/MR-279/mapreduce/dev-support/findbugs-exclude.xml Mon Aug  8 21:00:52
2011
@@ -440,5 +440,20 @@
   <Match>
     <Class name="~org\.apache\.hadoop\.mapreduce\.v2\.proto.*" />
   </Match>
-
+  
+   <Match>
+     <Class name="org.apache.hadoop.mapreduce.v2.app.rm.RMContainerAllocator" />
+      <Field name="mapResourceReqt" />
+     <Bug pattern="IS2_INCONSISTENT_SYNC" />
+   </Match>
+  
+   <Match>
+     <Class name="org.apache.hadoop.mapreduce.v2.app.rm.RMContainerAllocator" />
+      <Field name="reduceResourceReqt" />
+     <Bug pattern="IS2_INCONSISTENT_SYNC" />
+   </Match>
+   <!--
+     The above 2 fields are accessed locally and only via methods that are synchronized.

+     -->
+  
  </FindBugsFilter>

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/LocalContainerLauncher.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/LocalContainerLauncher.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/LocalContainerLauncher.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/LocalContainerLauncher.java
Mon Aug  8 21:00:52 2011
@@ -439,7 +439,7 @@ FIXME:  do we really need to worry about
               // this is recursive, unlike File delete():
               deleted = curFC.delete(new Path(curLocalFiles[j].getName()),true);
             }
-          } catch (Exception e) {
+          } catch (IOException e) {
             deleted = false;
           }
           if (!deleted) {

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/client/MRClientService.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/client/MRClientService.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/client/MRClientService.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/client/MRClientService.java
Mon Aug  8 21:00:52 2011
@@ -31,7 +31,6 @@ import org.apache.commons.codec.binary.B
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.mapreduce.JobACL;
 import org.apache.hadoop.mapreduce.v2.api.MRClientProtocol;
 import org.apache.hadoop.mapreduce.v2.api.protocolrecords.FailTaskAttemptRequest;
@@ -187,10 +186,11 @@ public class MRClientService extends Abs
       if (job == null) {
         throw RPCUtil.getRemoteException("Unknown job " + jobID);
       }
-      JobACL operation = JobACL.VIEW_JOB;
-      if (modifyAccess) {
-        operation = JobACL.MODIFY_JOB;
-      }
+      //TODO fix job acls.
+      //JobACL operation = JobACL.VIEW_JOB;
+      //if (modifyAccess) {
+      //  operation = JobACL.MODIFY_JOB;
+      //}
       //TO disable check access ofr now.
       //checkAccess(job, operation);
       return job;

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/JobImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/JobImpl.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/JobImpl.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/JobImpl.java
Mon Aug  8 21:00:52 2011
@@ -842,9 +842,13 @@ public class JobImpl implements org.apac
           attemptID.getTaskId().setTaskType(TaskType.MAP);
           TaskAttemptContext taskContext = new TaskAttemptContextImpl(job.conf,
               TypeConverter.fromYarn(attemptID));
-          OutputFormat outputFormat = ReflectionUtils.newInstance(
-              taskContext.getOutputFormatClass(), job.conf);
-          job.committer = outputFormat.getOutputCommitter(taskContext);
+          try {
+            OutputFormat outputFormat = ReflectionUtils.newInstance(
+                taskContext.getOutputFormatClass(), job.conf);
+            job.committer = outputFormat.getOutputCommitter(taskContext);
+          } catch(Exception e) {
+            throw new IOException("Failed to assign outputcommitter", e);
+          }
         } else {
           job.jobContext = new org.apache.hadoop.mapred.JobContextImpl(
               new JobConf(job.conf), job.oldJobId);
@@ -950,7 +954,7 @@ public class JobImpl implements org.apac
         return JobState.INITED;
         //TODO XXX Should JobInitedEvent be generated here (instead of in StartTransition)
 
-      } catch (Exception e) {
+      } catch (IOException e) {
         LOG.warn("Job init failed", e);
         job.addDiagnostic("Job init failed : "
             + StringUtils.stringifyException(e));

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
Mon Aug  8 21:00:52 2011
@@ -155,7 +155,7 @@ public abstract class TaskAttemptImpl im
   private Token<JobTokenIdentifier> jobToken;
   private static AtomicBoolean initialClasspathFlag = new AtomicBoolean();
   private static String initialClasspath = null;
-
+  private final Object classpathLock = new Object();
   private long launchTime;
   private long finishTime;
   private WrappedProgressSplitsBlock progressSplitBlock;
@@ -508,7 +508,7 @@ public abstract class TaskAttemptImpl im
    * a parent CLC and use it for all the containers.
    */
   private String getInitialClasspath() throws IOException {
-    synchronized (initialClasspathFlag) {
+    synchronized (classpathLock) {
       if (initialClasspathFlag.get()) {
         return initialClasspath;
       }

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/recover/RecoveryService.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/recover/RecoveryService.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/recover/RecoveryService.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/recover/RecoveryService.java
Mon Aug  8 21:00:52 2011
@@ -111,9 +111,7 @@ public class RecoveryService extends Com
     this.startCount = startCount;
     this.dispatcher = new RecoveryDispatcher();
     this.clock = new ControlledClock(clock);
-    if (dispatcher instanceof Service) {
       addService((Service) dispatcher);
-    }
   }
 
   @Override

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMCommunicator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMCommunicator.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMCommunicator.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMCommunicator.java
Mon Aug  8 21:00:52 2011
@@ -272,6 +272,9 @@ public class RMCommunicator extends Abst
     allocateRequest.addAllReleases(new ArrayList<ContainerId>());
     AllocateResponse allocateResponse = scheduler.allocate(allocateRequest);
     AMResponse response = allocateResponse.getAMResponse();
+    if (response.getReboot()) {
+      LOG.info("Event from RM: shutting down Application Master");
+    }
   }
 
 }

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMContainerAllocator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMContainerAllocator.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMContainerAllocator.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMContainerAllocator.java
Mon Aug  8 21:00:52 2011
@@ -30,8 +30,8 @@ import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -54,7 +54,6 @@ import org.apache.hadoop.mapreduce.v2.ap
 import org.apache.hadoop.yarn.api.records.AMResponse;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.hadoop.yarn.api.records.ContainerState;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.util.RackResolver;
@@ -394,7 +393,10 @@ public class RMContainerAllocator extend
     }
   }
 
-  private String getStat() {
+  /**
+   * Synchronized to avoid findbugs warnings
+   */
+  private synchronized String getStat() {
     return "PendingReduces:" + pendingReduces.size() +
         " ScheduledMaps:" + scheduledRequests.maps.size() +
         " ScheduledReduces:" + scheduledRequests.reduces.size() +

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/DefaultSpeculator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/DefaultSpeculator.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/DefaultSpeculator.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/DefaultSpeculator.java
Mon Aug  8 21:00:52 2011
@@ -267,7 +267,7 @@ public class DefaultSpeculator extends A
       case TASK_CONTAINER_NEED_UPDATE:
       {
         AtomicInteger need = containerNeed(event.getTaskID());
-        int newNeed = need.addAndGet(event.containersNeededChange());
+        need.addAndGet(event.containersNeededChange());
         break;
       }
 

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/LegacyTaskRuntimeEstimator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/LegacyTaskRuntimeEstimator.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/LegacyTaskRuntimeEstimator.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/speculate/LegacyTaskRuntimeEstimator.java
Mon Aug  8 21:00:52 2011
@@ -22,8 +22,6 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.mapreduce.v2.api.records.JobId;
 import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId;
 import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState;
@@ -40,7 +38,7 @@ public class LegacyTaskRuntimeEstimator 
 
   private final Map<TaskAttempt, AtomicLong> attemptRuntimeEstimates
       = new ConcurrentHashMap<TaskAttempt, AtomicLong>();
-  private final Map<TaskAttempt, AtomicLong> attemptRuntimeEstimateVariances
+  private final ConcurrentHashMap<TaskAttempt, AtomicLong> attemptRuntimeEstimateVariances
       = new ConcurrentHashMap<TaskAttempt, AtomicLong>();
 
   @Override
@@ -93,16 +91,11 @@ public class LegacyTaskRuntimeEstimator 
       }
 
       if (estimateVarianceContainer == null) {
-        synchronized (attemptRuntimeEstimateVariances) {
-          if (attemptRuntimeEstimateVariances.get(taskAttempt) == null) {
-            attemptRuntimeEstimateVariances.put(taskAttempt, new AtomicLong());
-          }
-
-          estimateVarianceContainer
-              = attemptRuntimeEstimateVariances.get(taskAttempt);
-        }
+        attemptRuntimeEstimateVariances.putIfAbsent(taskAttempt, new AtomicLong());
+        estimateVarianceContainer = attemptRuntimeEstimateVariances.get(taskAttempt);
       }
 
+
       long estimate = -1;
       long varianceEstimate = -1;
 
@@ -115,7 +108,9 @@ public class LegacyTaskRuntimeEstimator 
       if (estimateContainer != null) {
         estimateContainer.set(estimate);
       }
-      estimateVarianceContainer.set(varianceEstimate);
+      if (estimateVarianceContainer != null) {
+        estimateVarianceContainer.set(varianceEstimate);
+      }
     }
   }
 

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java
Mon Aug  8 21:00:52 2011
@@ -140,7 +140,7 @@ public class JobHistoryUtils {
    * @throws IOException if the filename format is invalid.
    */
   public static JobID getJobIDFromHistoryFilePath(String pathString) throws IOException {
-    String [] parts = pathString.split(File.separator);
+    String [] parts = pathString.split(Path.SEPARATOR);
     String fileNamePart = parts[parts.length -1];
     JobIndexInfo jobIndexInfo =  FileNameIndexUtils.getIndexInfo(fileNamePart);
     return TypeConverter.fromYarn(jobIndexInfo.getJobId());
@@ -293,8 +293,8 @@ public class JobHistoryUtils {
     Matcher matcher = TIMESTAMP_DIR_PATTERN.matcher(path);
     if (matcher.find()) {
       String matched = matcher.group();
-      matched.intern();
-      return matched;
+      String ret = matched.intern();
+      return ret;
     } else {
       return null;
     }

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java?rev=1155099&r1=1155098&r2=1155099&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/util/MRApps.java
Mon Aug  8 21:00:52 2011
@@ -156,41 +156,49 @@ public class MRApps extends Apps {
 
   public static void setInitialClasspath(
       Map<String, String> environment) throws IOException {
-
-    // Get yarn mapreduce-app classpath from generated classpath
-    // Works if compile time env is same as runtime. Mainly tests.
-    ClassLoader thisClassLoader =
-        Thread.currentThread().getContextClassLoader();
-    String mrAppGeneratedClasspathFile = "mrapp-generated-classpath";
-    InputStream classpathFileStream =
-        thisClassLoader.getResourceAsStream(mrAppGeneratedClasspathFile);
-    BufferedReader reader =
-        new BufferedReader(new InputStreamReader(classpathFileStream));
-    addToClassPath(environment, reader.readLine().trim());
-    // Put the file itself on classpath for tasks.
-    addToClassPath(environment,
-        thisClassLoader.getResource(mrAppGeneratedClasspathFile).getFile());
-
-    // If runtime env is different.
-    if (System.getenv().get("YARN_HOME") != null) {
-      ShellCommandExecutor exec =
-         new ShellCommandExecutor(new String[] {
-              System.getenv().get("YARN_HOME") + "/bin/yarn",
-              "classpath" });
-      exec.execute();
-      addToClassPath(environment, exec.getOutput().trim());
-    }
-
-    // Get yarn mapreduce-app classpath
-    if (System.getenv().get("HADOOP_MAPRED_HOME")!= null) {
-      ShellCommandExecutor exec =
-          new ShellCommandExecutor(new String[] {
-              System.getenv().get("HADOOP_MAPRED_HOME") + "/bin/mapred",
-              "classpath" });
-      exec.execute();
-      addToClassPath(environment, exec.getOutput().trim());
+    InputStream classpathFileStream = null;
+    try {
+      // Get yarn mapreduce-app classpath from generated classpath
+      // Works if compile time env is same as runtime. Mainly tests.
+      ClassLoader thisClassLoader =
+          Thread.currentThread().getContextClassLoader();
+      String mrAppGeneratedClasspathFile = "mrapp-generated-classpath";
+      classpathFileStream =
+          thisClassLoader.getResourceAsStream(mrAppGeneratedClasspathFile);
+      BufferedReader reader =
+          new BufferedReader(new InputStreamReader(classpathFileStream));
+      String cp = reader.readLine();
+      if (cp != null) {
+        addToClassPath(environment, cp.trim());
+      }
+      // Put the file itself on classpath for tasks.
+      addToClassPath(environment,
+          thisClassLoader.getResource(mrAppGeneratedClasspathFile).getFile());
+
+      // If runtime env is different.
+      if (System.getenv().get("YARN_HOME") != null) {
+        ShellCommandExecutor exec =
+            new ShellCommandExecutor(new String[] {
+                System.getenv().get("YARN_HOME") + "/bin/yarn",
+            "classpath" });
+        exec.execute();
+        addToClassPath(environment, exec.getOutput().trim());
+      }
+
+      // Get yarn mapreduce-app classpath
+      if (System.getenv().get("HADOOP_MAPRED_HOME")!= null) {
+        ShellCommandExecutor exec =
+            new ShellCommandExecutor(new String[] {
+                System.getenv().get("HADOOP_MAPRED_HOME") + "/bin/mapred",
+            "classpath" });
+        exec.execute();
+        addToClassPath(environment, exec.getOutput().trim());
+      }
+    } finally {
+      if (classpathFileStream != null) {
+        classpathFileStream.close();
+      }
     }
-
     // TODO: Remove duplicates.
   }
 



Mime
View raw message