You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by ss...@apache.org on 2015/01/05 22:15:57 UTC
[2/2] tez git commit: TEZ-1837. Restrict usage of Environment
variables to main methods. (sseth)
TEZ-1837. Restrict usage of Environment variables to main methods.
(sseth)
Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/97607447
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/97607447
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/97607447
Branch: refs/heads/master
Commit: 976074473a09443e55e250e0e66f6b80c92980cf
Parents: dcd73b3
Author: Siddharth Seth <ss...@apache.org>
Authored: Mon Jan 5 13:15:57 2015 -0800
Committer: Siddharth Seth <ss...@apache.org>
Committed: Mon Jan 5 13:15:57 2015 -0800
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../tez/runtime/api/ExecutionContext.java | 32 +++++++++++
.../org/apache/tez/runtime/api/TaskContext.java | 6 ++
.../org/apache/tez/common/TezUtilsInternal.java | 13 -----
.../java/org/apache/tez/client/LocalClient.java | 16 +++---
.../java/org/apache/tez/dag/app/AppContext.java | 3 +
.../org/apache/tez/dag/app/DAGAppMaster.java | 58 +++++++++++++-------
.../app/launcher/LocalContainerLauncher.java | 39 ++++++-------
.../impl/SimpleHistoryLoggingService.java | 3 +-
.../tez/dag/utils/RelocalizationUtils.java | 9 ++-
.../org/apache/tez/runtime/task/TezChild.java | 40 +++++++++-----
.../apache/tez/runtime/task/TezTaskRunner.java | 8 ++-
.../apache/tez/dag/app/MockDAGAppMaster.java | 8 +--
.../org/apache/tez/dag/app/MockLocalClient.java | 8 ++-
.../tez/runtime/task/TestTaskExecution.java | 3 +-
.../tez/mapreduce/processor/MapUtils.java | 15 ++---
.../processor/reduce/TestReduceProcessor.java | 7 +--
.../util/TestTezMxBeanResourceCalculator.java | 2 +-
.../runtime/LogicalIOProcessorRuntimeTask.java | 29 +++++-----
.../org/apache/tez/runtime/RuntimeTask.java | 4 +-
.../runtime/api/impl/ExecutionContextImpl.java | 31 +++++++++++
.../runtime/api/impl/TezInputContextImpl.java | 6 +-
.../runtime/api/impl/TezOutputContextImpl.java | 6 +-
.../api/impl/TezProcessorContextImpl.java | 6 +-
.../runtime/api/impl/TezTaskContextImpl.java | 11 +++-
.../tez/runtime/metrics/TaskCounterUpdater.java | 9 +--
.../TestLogicalIOProcessorRuntimeTask.java | 8 ++-
.../runtime/library/common/shuffle/Fetcher.java | 18 +++---
.../common/shuffle/impl/ShuffleManager.java | 3 +-
.../orderedgrouped/FetcherOrderedGrouped.java | 9 +--
.../common/shuffle/orderedgrouped/Shuffle.java | 3 +-
.../writers/UnorderedPartitionedKVWriter.java | 3 +-
.../output/OrderedPartitionedKVOutput.java | 4 +-
.../library/output/UnorderedKVOutput.java | 3 +-
.../library/common/shuffle/TestFetcher.java | 15 +----
.../shuffle/orderedgrouped/TestFetcher.java | 5 +-
.../library/output/TestOnFileSortedOutput.java | 7 ++-
.../output/TestOnFileUnorderedKVOutput.java | 4 +-
38 files changed, 278 insertions(+), 177 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2590b75..c41ec49 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,7 @@ Release 0.7.0: Unreleased
INCOMPATIBLE CHANGES
ALL CHANGES:
+ TEZ-1837. Restrict usage of Environment variables to main methods.
TEZ-1867. Create new central dispatcher for Tez AM
TEZ-1844. Shouldn't invoke system.exit in local mode when AM is failed to start.
TEZ-1889. Fix test-patch to provide correct findbugs report.
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-api/src/main/java/org/apache/tez/runtime/api/ExecutionContext.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/runtime/api/ExecutionContext.java b/tez-api/src/main/java/org/apache/tez/runtime/api/ExecutionContext.java
new file mode 100644
index 0000000..b120ecc
--- /dev/null
+++ b/tez-api/src/main/java/org/apache/tez/runtime/api/ExecutionContext.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.runtime.api;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Execution context for a running task
+ *
+ * This interface is not meant to be implemented by users
+ */
+@InterfaceAudience.Public
+public interface ExecutionContext {
+
+ /**
+ * Get the hostname on which the JVM is running.
+ * @return the hostname
+ */
+ public String getHostName();
+}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-api/src/main/java/org/apache/tez/runtime/api/TaskContext.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/runtime/api/TaskContext.java b/tez-api/src/main/java/org/apache/tez/runtime/api/TaskContext.java
index cd90282..42918b9 100644
--- a/tez-api/src/main/java/org/apache/tez/runtime/api/TaskContext.java
+++ b/tez-api/src/main/java/org/apache/tez/runtime/api/TaskContext.java
@@ -180,5 +180,11 @@ public interface TaskContext {
* @return Parallelism of the current vertex.
*/
public int getVertexParallelism();
+
+ /**
+ * Get the execution context for a running task
+ * @return the execution context
+ */
+ public ExecutionContext getExecutionContext();
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
----------------------------------------------------------------------
diff --git a/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java b/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
index 2ca153c..ad4648e 100644
--- a/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
+++ b/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
@@ -215,19 +215,6 @@ public class TezUtilsInternal {
return bytes;
}
- public static String getContainerLogDir() {
- String logDirsStr = System.getenv(Environment.LOG_DIRS.name());
- if (logDirsStr == null || logDirsStr.isEmpty()) {
- return null;
- }
- String[] logDirs = StringUtils.split(logDirsStr, ',');
- if (logDirs.length == 0) {
- return null;
- }
- int logIndex = RANDOM.nextInt(logDirs.length);
- return logDirs[logIndex];
- }
-
/**
* Convert DAGPlan to text. Skip sensitive informations like credentials.
*
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java b/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
index 68432f4..94b8474 100644
--- a/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
+++ b/tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
@@ -274,9 +274,6 @@ public class LocalClient extends FrameworkClient {
fs.mkdirs(logDir);
fs.mkdirs(localDir);
- EnvironmentUpdateUtils.put(Environment.LOG_DIRS.name(), logDir.toUri().getPath());
- EnvironmentUpdateUtils.put(Environment.LOCAL_DIRS.name(), localDir.toUri().getPath());
-
// Add session specific credentials to the AM credentials.
UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();
ByteBuffer tokens = appContext.getAMContainerSpec().getTokens();
@@ -298,9 +295,10 @@ public class LocalClient extends FrameworkClient {
int nmHttpPort = YarnConfiguration.DEFAULT_NM_WEBAPP_PORT;
long appSubmitTime = System.currentTimeMillis();
- dagAppMaster = createDAGAppMaster(applicationAttemptId, cId, currentHost, nmPort, nmHttpPort,
- new SystemClock(),
- appSubmitTime, isSession, userDir.toUri().getPath());
+ dagAppMaster =
+ createDAGAppMaster(applicationAttemptId, cId, currentHost, nmPort, nmHttpPort,
+ new SystemClock(), appSubmitTime, isSession, userDir.toUri().getPath(),
+ new String[] {localDir.toUri().getPath()}, new String[] {logDir.toUri().getPath()});
clientHandler = new DAGClientHandler(dagAppMaster);
DAGAppMaster.initAndStartAppMaster(dagAppMaster, currentUser.getShortUserName());
@@ -324,9 +322,11 @@ public class LocalClient extends FrameworkClient {
@VisibleForTesting
protected DAGAppMaster createDAGAppMaster(ApplicationAttemptId applicationAttemptId,
ContainerId cId, String currentHost, int nmPort, int nmHttpPort,
- Clock clock, long appSubmitTime, boolean isSession, String userDir) {
+ Clock clock, long appSubmitTime, boolean isSession, String userDir,
+ String[] localDirs, String[] logDirs) {
return new DAGAppMaster(applicationAttemptId, cId, currentHost, nmPort, nmHttpPort,
- new SystemClock(), appSubmitTime, isSession, userDir, versionInfo.getVersion());
+ new SystemClock(), appSubmitTime, isSession, userDir, localDirs, logDirs,
+ versionInfo.getVersion(), 1);
}
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/dag/app/AppContext.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/AppContext.java b/tez-dag/src/main/java/org/apache/tez/dag/app/AppContext.java
index 5cedc56..e92fe95 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/AppContext.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/AppContext.java
@@ -93,4 +93,7 @@ public interface AppContext {
ACLManager getAMACLManager();
+ String[] getLogDirs();
+
+ String[] getLocalDirs();
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java b/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
index 1347c23..30df120 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
@@ -43,6 +43,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Random;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
@@ -204,6 +205,8 @@ public class DAGAppMaster extends AbstractService {
private final int nmPort;
private final int nmHttpPort;
private final String workingDirectory;
+ private final String[] localDirs;
+ private final String[] logDirs;
private ContainerSignatureMatcher containerSignatureMatcher;
private AMContainerMap containers;
private AMNodeTracker nodes;
@@ -223,6 +226,7 @@ public class DAGAppMaster extends AbstractService {
private HistoryEventHandler historyEventHandler;
private final Map<String, LocalResource> amResources = new HashMap<String, LocalResource>();
private final Map<String, LocalResource> cumulativeAdditionalResources = new HashMap<String, LocalResource>();
+ private final int maxAppAttempts;
private boolean isLocal = false; //Local mode flag
@@ -279,7 +283,7 @@ public class DAGAppMaster extends AbstractService {
public DAGAppMaster(ApplicationAttemptId applicationAttemptId,
ContainerId containerId, String nmHost, int nmPort, int nmHttpPort,
Clock clock, long appSubmitTime, boolean isSession, String workingDirectory,
- String clientVersion) {
+ String [] localDirs, String[] logDirs, String clientVersion, int maxAppAttempts) {
super(DAGAppMaster.class.getName());
this.clock = clock;
this.startTime = clock.getTime();
@@ -292,9 +296,12 @@ public class DAGAppMaster extends AbstractService {
this.state = DAGAppMasterState.NEW;
this.isSession = isSession;
this.workingDirectory = workingDirectory;
+ this.localDirs = localDirs;
+ this.logDirs = logDirs;
this.shutdownHandler = new DAGAppMasterShutdownHandler();
this.dagVersionInfo = new TezDagVersionInfo();
this.clientVersion = clientVersion;
+ this.maxAppAttempts = maxAppAttempts;
// TODO Metrics
//this.metrics = DAGAppMetrics.create();
@@ -313,12 +320,6 @@ public class DAGAppMaster extends AbstractService {
TezConfiguration.TEZ_AM_DISABLE_CLIENT_VERSION_CHECK,
TezConfiguration.TEZ_AM_DISABLE_CLIENT_VERSION_CHECK_DEFAULT);
- int maxAppAttempts = 1;
- String maxAppAttemptsEnv = System.getenv(
- ApplicationConstants.MAX_APP_ATTEMPTS_ENV);
- if (maxAppAttemptsEnv != null) {
- maxAppAttempts = Integer.valueOf(maxAppAttemptsEnv);
- }
isLastAMRetry = appAttemptID.getAttemptId() >= maxAppAttempts;
// Check client - AM version compatibility
@@ -767,7 +768,7 @@ public class DAGAppMaster extends AbstractService {
LOG.warn("Failed to generate json for DAG", e);
}
- generateDAGVizFile(dagId, dagPB);
+ generateDAGVizFile(dagId, dagPB, logDirs);
writePBTextFile(newDag);
return newDag;
} // end createDag()
@@ -786,7 +787,7 @@ public class DAGAppMaster extends AbstractService {
return m.replaceAll("_");
}
- private void generateDAGVizFile(TezDAGID dagId, DAGPlan dagPB) {
+ private void generateDAGVizFile(TezDAGID dagId, DAGPlan dagPB, String[] logDirs) {
Graph graph = new Graph(sanitizeLabelForViz(dagPB.getName()));
for (VertexPlan v : dagPB.getVertexList()) {
@@ -826,15 +827,9 @@ public class DAGAppMaster extends AbstractService {
+ ", schedulingType=" + e.getSchedulingType().name().trim() + "]");
}
- String logDirs = System.getenv(Environment.LOG_DIRS.name());
String outputFile = "";
- if (logDirs != null && !logDirs.isEmpty()) {
- int pos = logDirs.indexOf(",");
- if (pos != -1) {
- outputFile += logDirs.substring(0, pos);
- } else {
- outputFile += logDirs;
- }
+ if (logDirs != null && logDirs.length != 0) {
+ outputFile += logDirs[0];
outputFile += File.separator;
}
outputFile += dagId.toString() + ".dot";
@@ -854,8 +849,8 @@ public class DAGAppMaster extends AbstractService {
if (dag.getConf().getBoolean(TezConfiguration.TEZ_GENERATE_DEBUG_ARTIFACTS,
TezConfiguration.TEZ_GENERATE_DEBUG_ARTIFACTS_DEFAULT)) {
- String logFile = TezUtilsInternal.getContainerLogDir() + File.separatorChar + dag.getID().toString()
- + "-" + TezConstants.TEZ_PB_PLAN_TEXT_NAME;
+ String logFile = logDirs[new Random().nextInt(logDirs.length)] + File.separatorChar +
+ dag.getID().toString() + "-" + TezConstants.TEZ_PB_PLAN_TEXT_NAME;
LOG.info("Writing DAG plan to: " + logFile);
File outFile = new File(logFile);
@@ -1181,7 +1176,7 @@ public class DAGAppMaster extends AbstractService {
public URI apply(LocalResource input) {
return getLocalResourceUri(input);
}
- }), getConfig());
+ }), getConfig(), workingDirectory);
} catch (IOException e) {
throw new TezException(e);
}
@@ -1316,6 +1311,16 @@ public class DAGAppMaster extends AbstractService {
}
@Override
+ public String[] getLogDirs() {
+ return logDirs;
+ }
+
+ @Override
+ public String[] getLocalDirs() {
+ return localDirs;
+ }
+
+ @Override
public Map<ApplicationAccessType, String> getApplicationACLs() {
if (getServiceState() != STATE.STARTED) {
throw new TezUncheckedException(
@@ -1805,6 +1810,14 @@ public class DAGAppMaster extends AbstractService {
clientVersion = VersionInfo.UNKNOWN;
}
+ // TODO Should this be defaulting to 1. Was there a version of YARN where this was not setup ?
+ int maxAppAttempts = 1;
+ String maxAppAttemptsEnv = System.getenv(
+ ApplicationConstants.MAX_APP_ATTEMPTS_ENV);
+ if (maxAppAttemptsEnv != null) {
+ maxAppAttempts = Integer.valueOf(maxAppAttemptsEnv);
+ }
+
validateInputParam(appSubmitTimeStr,
ApplicationConstants.APP_SUBMIT_TIME_ENV);
@@ -1829,7 +1842,10 @@ public class DAGAppMaster extends AbstractService {
Integer.parseInt(nodePortString),
Integer.parseInt(nodeHttpPortString), new SystemClock(), appSubmitTime,
cliParser.hasOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION),
- System.getenv(Environment.PWD.name()), clientVersion);
+ System.getenv(Environment.PWD.name()),
+ TezCommonUtils.getTrimmedStrings(System.getenv(Environment.LOCAL_DIRS.name())),
+ TezCommonUtils.getTrimmedStrings(System.getenv(Environment.LOG_DIRS.name())),
+ clientVersion, maxAppAttempts);
ShutdownHookManager.get().addShutdownHook(
new DAGAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY);
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/LocalContainerLauncher.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/LocalContainerLauncher.java b/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/LocalContainerLauncher.java
index 9eb695e..ea0f9a5 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/LocalContainerLauncher.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/LocalContainerLauncher.java
@@ -23,6 +23,8 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
@@ -41,16 +43,13 @@ import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.service.AbstractService;
-import org.apache.hadoop.util.Shell;
import org.apache.hadoop.yarn.api.ApplicationConstants.Environment;
import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.tez.common.EnvironmentUpdateUtils;
-import org.apache.tez.common.TezCommonUtils;
+import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper;
import org.apache.tez.common.TezTaskUmbilicalProtocol;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezException;
@@ -68,6 +67,9 @@ import org.apache.tez.dag.app.rm.container.AMContainerEventType;
import org.apache.tez.dag.history.DAGHistoryEvent;
import org.apache.tez.dag.history.events.ContainerLaunchedEvent;
import org.apache.tez.dag.records.TaskAttemptTerminationCause;
+import org.apache.tez.runtime.api.ExecutionContext;
+import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
+import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
import org.apache.tez.runtime.task.TezChild;
@@ -84,6 +86,8 @@ public class LocalContainerLauncher extends AbstractService implements
private final TaskAttemptListener taskAttemptListener;
private final AtomicBoolean serviceStopped = new AtomicBoolean(false);
private final String workingDirectory;
+ private final Map<String, String> localEnv = new HashMap<String, String>();
+ private final ExecutionContext ExecutionContext;
private final ConcurrentHashMap<ContainerId, ListenableFuture<TezChild.ContainerExecutionResult>>
runningContainers =
@@ -103,19 +107,15 @@ public class LocalContainerLauncher extends AbstractService implements
public LocalContainerLauncher(AppContext context,
TaskAttemptListener taskAttemptListener,
- String workingDirectory) throws
- UnknownHostException {
+ String workingDirectory) throws UnknownHostException {
super(LocalContainerLauncher.class.getName());
this.context = context;
this.taskAttemptListener = taskAttemptListener;
this.workingDirectory = workingDirectory;
- EnvironmentUpdateUtils.put("NM_AUX_SERVICE_mapreduce_shuffle",
- Base64.encodeBase64String(ByteBuffer.allocate(4).putInt(0).array()));
- EnvironmentUpdateUtils.put(Environment.NM_HOST.toString(),
- InetAddress.getLocalHost().getHostName());
- if (Shell.WINDOWS) {
- EnvironmentUpdateUtils.put(Environment.USER.name(), System.getenv("USERNAME"));
- }
+ AuxiliaryServiceHelper.setServiceDataIntoEnv(
+ ShuffleUtils.SHUFFLE_HANDLER_SERVICE_ID, ByteBuffer.allocate(4).putInt(0), localEnv);
+ ExecutionContext = new ExecutionContextImpl(InetAddress.getLocalHost().getHostName());
+ // User cannot be set here since it isn't available till a DAG is running.
}
@Override
@@ -186,16 +186,12 @@ public class LocalContainerLauncher extends AbstractService implements
private void launch(NMCommunicatorLaunchRequestEvent event) {
String tokenIdentifier = context.getApplicationID().toString();
-
- String[] localDirs =
- TezCommonUtils.getTrimmedStrings(System.getenv(Environment.LOCAL_DIRS.name()));
-
try {
ListenableFuture<TezChild.ContainerExecutionResult> runningTaskFuture =
taskExecutorService.submit(createSubTask(context.getAMConf(),
event.getContainerId(), tokenIdentifier,
context.getApplicationAttemptId().getAttemptId(),
- localDirs, (TezTaskUmbilicalProtocol) taskAttemptListener));
+ context.getLocalDirs(), (TezTaskUmbilicalProtocol) taskAttemptListener));
runningContainers.put(event.getContainerId(), runningTaskFuture);
Futures
.addCallback(runningTaskFuture, new RunningTaskCallback(context, event.getContainerId()),
@@ -294,12 +290,16 @@ public class LocalContainerLauncher extends AbstractService implements
ContainerLaunchedEvent lEvt =
new ContainerLaunchedEvent(containerId, context.getClock().getTime(),
context.getApplicationAttemptId());
+
context.getHistoryHandler().handle(new DAGHistoryEvent(context.getCurrentDAGID(), lEvt));
+ Map<String, String> containerEnv = new HashMap<String, String>();
+ containerEnv.putAll(localEnv);
+ containerEnv.put(Environment.USER.name(), context.getUser());
// Pull in configuration specified for the session.
TezChild tezChild =
TezChild.newTezChild(defaultConf, null, 0, containerId.toString(), tokenIdentifier,
- attemptNumber, localDirs, workingDirectory, System.getenv());
+ attemptNumber, localDirs, workingDirectory, containerEnv, "", ExecutionContext);
tezChild.setUmbilical(tezTaskUmbilicalProtocol);
return tezChild.run();
}
@@ -314,4 +314,5 @@ public class LocalContainerLauncher extends AbstractService implements
throw new TezUncheckedException(e);
}
}
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/dag/history/logging/impl/SimpleHistoryLoggingService.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/history/logging/impl/SimpleHistoryLoggingService.java b/tez-dag/src/main/java/org/apache/tez/dag/history/logging/impl/SimpleHistoryLoggingService.java
index 1cbf516..95ee010 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/history/logging/impl/SimpleHistoryLoggingService.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/history/logging/impl/SimpleHistoryLoggingService.java
@@ -19,6 +19,7 @@
package org.apache.tez.dag.history.logging.impl;
import java.io.IOException;
+import java.util.Random;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -62,7 +63,7 @@ public class SimpleHistoryLoggingService extends HistoryLoggingService {
String logDirPath = conf.get(TezConfiguration.TEZ_SIMPLE_HISTORY_LOGGING_DIR);
final String logFileName = LOG_FILE_NAME_PREFIX + "." + appContext.getApplicationAttemptId();
if (logDirPath == null || logDirPath.isEmpty()) {
- String logDir = TezUtilsInternal.getContainerLogDir();
+ String logDir = appContext.getLogDirs()[new Random().nextInt(appContext.getLogDirs().length)];
LOG.info("Log file location for SimpleHistoryLoggingService not specified, defaulting to"
+ " containerLogDir=" + logDir);
Path p;
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/dag/utils/RelocalizationUtils.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/utils/RelocalizationUtils.java b/tez-dag/src/main/java/org/apache/tez/dag/utils/RelocalizationUtils.java
index bcd65e4..7b5c49c 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/utils/RelocalizationUtils.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/utils/RelocalizationUtils.java
@@ -31,7 +31,6 @@ import org.apache.commons.codec.digest.DigestUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.yarn.api.ApplicationConstants.Environment;
import org.apache.tez.common.ReflectionUtils;
import org.apache.tez.dag.api.TezException;
@@ -40,7 +39,7 @@ import com.google.common.collect.Lists;
public class RelocalizationUtils {
public static List<URL> processAdditionalResources(Map<String, URI> additionalResources,
- Configuration conf) throws IOException, TezException {
+ Configuration conf, String destDir) throws IOException, TezException {
if (additionalResources == null || additionalResources.isEmpty()) {
return Collections.emptyList();
}
@@ -48,7 +47,7 @@ public class RelocalizationUtils {
List<URL> urls = Lists.newArrayListWithCapacity(additionalResources.size());
for (Entry<String, URI> lrEntry : additionalResources.entrySet()) {
- Path dFile = downloadResource(lrEntry.getKey(), lrEntry.getValue(), conf);
+ Path dFile = downloadResource(lrEntry.getKey(), lrEntry.getValue(), conf, destDir);
urls.add(dFile.toUri().toURL());
}
return urls;
@@ -58,10 +57,10 @@ public class RelocalizationUtils {
ReflectionUtils.addResourcesToSystemClassLoader(urls);
}
- private static Path downloadResource(String destName, URI uri, Configuration conf)
+ private static Path downloadResource(String destName, URI uri, Configuration conf, String destDir)
throws IOException {
FileSystem fs = FileSystem.get(uri, conf);
- Path cwd = new Path(System.getenv(Environment.PWD.name()));
+ Path cwd = new Path(destDir);
Path dFile = new Path(cwd, destName);
Path srcPath = new Path(uri);
fs.copyToLocalFile(srcPath, dFile);
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/runtime/task/TezChild.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/runtime/task/TezChild.java b/tez-dag/src/main/java/org/apache/tez/runtime/task/TezChild.java
index e433a5e..ae77709 100644
--- a/tez-dag/src/main/java/org/apache/tez/runtime/task/TezChild.java
+++ b/tez-dag/src/main/java/org/apache/tez/runtime/task/TezChild.java
@@ -61,6 +61,8 @@ import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.records.TezVertexID;
import org.apache.tez.dag.utils.RelocalizationUtils;
+import org.apache.tez.runtime.api.ExecutionContext;
+import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.api.impl.TaskSpec;
import org.apache.tez.runtime.common.objectregistry.ObjectRegistryImpl;
import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
@@ -91,9 +93,12 @@ public class TezChild {
private final long sendCounterInterval;
private final int maxEventsToGet;
private final boolean isLocal;
+ private final String workingDir;
private final ListeningExecutorService executor;
private final ObjectRegistryImpl objectRegistry;
+ private final String pid;
+ private final ExecutionContext ExecutionContext;
private final Map<String, ByteBuffer> serviceConsumerMetadata = new HashMap<String, ByteBuffer>();
private final Map<String, String> serviceProviderEnvMap;
@@ -105,15 +110,19 @@ public class TezChild {
private TezVertexID lastVertexID;
public TezChild(Configuration conf, String host, int port, String containerIdentifier,
- String tokenIdentifier, int appAttemptNumber, String[] localDirs,
+ String tokenIdentifier, int appAttemptNumber, String workingDir, String[] localDirs,
Map<String, String> serviceProviderEnvMap,
- ObjectRegistryImpl objectRegistry)
+ ObjectRegistryImpl objectRegistry, String pid,
+ ExecutionContext ExecutionContext)
throws IOException, InterruptedException {
this.defaultConf = conf;
this.containerIdString = containerIdentifier;
this.appAttemptNumber = appAttemptNumber;
this.localDirs = localDirs;
this.serviceProviderEnvMap = serviceProviderEnvMap;
+ this.workingDir = workingDir;
+ this.pid = pid;
+ this.ExecutionContext = ExecutionContext;
getTaskMaxSleepTime = defaultConf.getInt(
TezConfiguration.TEZ_TASK_GET_TASK_SLEEP_INTERVAL_MS_MAX,
@@ -216,7 +225,7 @@ public class TezChild {
TezTaskRunner taskRunner = new TezTaskRunner(defaultConf, childUGI,
localDirs, containerTask.getTaskSpec(), umbilical, appAttemptNumber,
serviceConsumerMetadata, serviceProviderEnvMap, startedInputsMap, taskReporter,
- executor, objectRegistry);
+ executor, objectRegistry, pid, this.ExecutionContext);
boolean shouldDie;
try {
shouldDie = !taskRunner.run();
@@ -294,7 +303,7 @@ public class TezChild {
public URI apply(TezLocalResource input) {
return input.getUri();
}
- }), defaultConf);
+ }), defaultConf, workingDir);
RelocalizationUtils.addUrlsToClassPath(downloadedUrls);
LOG.info("Done localizing additional resources");
@@ -389,7 +398,8 @@ public class TezChild {
public static TezChild newTezChild(Configuration conf, String host, int port, String containerIdentifier,
String tokenIdentifier, int attemptNumber, String[] localDirs, String workingDirectory,
- Map<String, String> serviceProviderEnvMap)
+ Map<String, String> serviceProviderEnvMap, @Nullable String pid,
+ ExecutionContext ExecutionContext)
throws IOException, InterruptedException, TezException {
// Pull in configuration specified for the session.
@@ -399,14 +409,6 @@ public class TezChild {
UserGroupInformation.setConfiguration(conf);
Limits.setConfiguration(conf);
- final String pid = System.getenv().get("JVM_PID");
- LOG.info("PID, containerIdentifier: " + pid + ", " + containerIdentifier);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Info from cmd line: AM-host: " + host + " AM-port: " + port
- + " containerIdentifier: " + containerIdentifier + " appAttemptNumber: " + attemptNumber
- + " tokenIdentifier: " + tokenIdentifier);
- }
-
// Should this be part of main - Metrics and ObjectRegistry. TezTask setup should be independent
// of this class. Leaving it here, till there's some entity representing a running JVM.
DefaultMetricsSystem.initialize("TezTask");
@@ -415,7 +417,8 @@ public class TezChild {
ObjectRegistryImpl objectRegistry = new ObjectRegistryImpl();
return new TezChild(conf, host, port, containerIdentifier, tokenIdentifier,
- attemptNumber, localDirs, serviceProviderEnvMap, objectRegistry);
+ attemptNumber, workingDirectory, localDirs, serviceProviderEnvMap, objectRegistry, pid,
+ ExecutionContext);
}
public static void main(String[] args) throws IOException, InterruptedException, TezException {
@@ -433,9 +436,16 @@ public class TezChild {
final int attemptNumber = Integer.parseInt(args[4]);
final String[] localDirs = TezCommonUtils.getTrimmedStrings(System.getenv(Environment.LOCAL_DIRS
.name()));
+ final String pid = System.getenv().get("JVM_PID");
+ LOG.info("PID, containerIdentifier: " + pid + ", " + containerIdentifier);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Info from cmd line: AM-host: " + host + " AM-port: " + port
+ + " containerIdentifier: " + containerIdentifier + " appAttemptNumber: " + attemptNumber
+ + " tokenIdentifier: " + tokenIdentifier);
+ }
TezChild tezChild = newTezChild(defaultConf, host, port, containerIdentifier,
tokenIdentifier, attemptNumber, localDirs, System.getenv(Environment.PWD.name()),
- System.getenv());
+ System.getenv(), pid, new ExecutionContextImpl(System.getenv(Environment.NM_HOST.name())));
tezChild.run();
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/main/java/org/apache/tez/runtime/task/TezTaskRunner.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/runtime/task/TezTaskRunner.java b/tez-dag/src/main/java/org/apache/tez/runtime/task/TezTaskRunner.java
index 937c8cd..6e655f9 100644
--- a/tez-dag/src/main/java/org/apache/tez/runtime/task/TezTaskRunner.java
+++ b/tez-dag/src/main/java/org/apache/tez/runtime/task/TezTaskRunner.java
@@ -32,12 +32,12 @@ import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSError;
import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.util.ExitUtil;
import org.apache.log4j.Logger;
import org.apache.tez.common.TezTaskUmbilicalProtocol;
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.records.TezTaskAttemptID;
import org.apache.tez.runtime.LogicalIOProcessorRuntimeTask;
+import org.apache.tez.runtime.api.ExecutionContext;
import org.apache.tez.runtime.api.ObjectRegistry;
import org.apache.tez.runtime.api.impl.EventMetaData;
import org.apache.tez.runtime.api.impl.TaskSpec;
@@ -71,14 +71,16 @@ public class TezTaskRunner implements TezUmbilical, ErrorReporter {
TaskSpec taskSpec, TezTaskUmbilicalProtocol umbilical, int appAttemptNumber,
Map<String, ByteBuffer> serviceConsumerMetadata, Map<String, String> serviceProviderEnvMap,
Multimap<String, String> startedInputsMap, TaskReporter taskReporter,
- ListeningExecutorService executor, ObjectRegistry objectRegistry)
+ ListeningExecutorService executor, ObjectRegistry objectRegistry, String pid,
+ ExecutionContext ExecutionContext)
throws IOException {
this.tezConf = tezConf;
this.ugi = ugi;
this.taskReporter = taskReporter;
this.executor = executor;
task = new LogicalIOProcessorRuntimeTask(taskSpec, appAttemptNumber, tezConf, localDirs, this,
- serviceConsumerMetadata, serviceProviderEnvMap, startedInputsMap, objectRegistry);
+ serviceConsumerMetadata, serviceProviderEnvMap, startedInputsMap, objectRegistry, pid,
+ ExecutionContext);
taskReporter.registerTask(task, this);
taskRunning = new AtomicBoolean(true);
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java b/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
index d84f933..aca572b 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/MockDAGAppMaster.java
@@ -40,9 +40,7 @@ import org.apache.hadoop.yarn.util.Clock;
import org.apache.tez.client.TezApiVersionInfo;
import org.apache.tez.common.ContainerContext;
import org.apache.tez.common.ContainerTask;
-import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.api.TezUncheckedException;
-import org.apache.tez.dag.app.RecoveryParser.RecoveredDAGData;
import org.apache.tez.dag.app.dag.event.VertexEventRouteEvent;
import org.apache.tez.dag.app.launcher.ContainerLauncher;
import org.apache.tez.dag.app.rm.NMCommunicatorEvent;
@@ -303,10 +301,10 @@ public class MockDAGAppMaster extends DAGAppMaster {
public MockDAGAppMaster(ApplicationAttemptId applicationAttemptId, ContainerId containerId,
String nmHost, int nmPort, int nmHttpPort, Clock clock, long appSubmitTime,
- boolean isSession, String workingDirectory, AtomicBoolean launcherGoFlag,
- boolean initFailFlag, boolean startFailFlag) {
+ boolean isSession, String workingDirectory, String[] localDirs, String[] logDirs,
+ AtomicBoolean launcherGoFlag, boolean initFailFlag, boolean startFailFlag) {
super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, clock, appSubmitTime,
- isSession, workingDirectory, new TezApiVersionInfo().getVersion());
+ isSession, workingDirectory, localDirs, logDirs, new TezApiVersionInfo().getVersion(), 1);
containerLauncher = new MockContainerLauncher(launcherGoFlag);
shutdownHandler = new MockDAGAppMasterShutdownHandler();
this.initFailFlag = initFailFlag;
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/test/java/org/apache/tez/dag/app/MockLocalClient.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/MockLocalClient.java b/tez-dag/src/test/java/org/apache/tez/dag/app/MockLocalClient.java
index 49b7c6f..4a2fa9b 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/MockLocalClient.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/MockLocalClient.java
@@ -47,12 +47,14 @@ public class MockLocalClient extends LocalClient {
this.startFailFlag = startFailFlag;
}
+ @Override
protected DAGAppMaster createDAGAppMaster(ApplicationAttemptId applicationAttemptId,
ContainerId cId, String currentHost, int nmPort, int nmHttpPort,
- Clock clock, long appSubmitTime, boolean isSession, String userDir) {
+ Clock clock, long appSubmitTime, boolean isSession, String userDir,
+ String[] localDirs, String[] logDirs) {
mockApp = new MockDAGAppMaster(applicationAttemptId, cId, currentHost, nmPort, nmHttpPort,
- (mockClock!=null ? mockClock : clock), appSubmitTime, isSession, userDir, mockAppLauncherGoFlag,
- initFailFlag, startFailFlag);
+ (mockClock!=null ? mockClock : clock), appSubmitTime, isSession, userDir, localDirs, logDirs,
+ mockAppLauncherGoFlag, initFailFlag, startFailFlag);
return mockApp;
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-dag/src/test/java/org/apache/tez/runtime/task/TestTaskExecution.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/runtime/task/TestTaskExecution.java b/tez-dag/src/test/java/org/apache/tez/runtime/task/TestTaskExecution.java
index f7087f1..b18324a 100644
--- a/tez-dag/src/test/java/org/apache/tez/runtime/task/TestTaskExecution.java
+++ b/tez-dag/src/test/java/org/apache/tez/runtime/task/TestTaskExecution.java
@@ -63,6 +63,7 @@ import org.apache.tez.dag.records.TezVertexID;
import org.apache.tez.runtime.api.ProcessorContext;
import org.apache.tez.runtime.api.events.TaskAttemptCompletedEvent;
import org.apache.tez.runtime.api.events.TaskAttemptFailedEvent;
+import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.api.impl.InputSpec;
import org.apache.tez.runtime.api.impl.OutputSpec;
import org.apache.tez.runtime.api.impl.TaskSpec;
@@ -698,7 +699,7 @@ public class TestTaskExecution {
TezTaskRunner taskRunner = new TezTaskRunner(tezConf, ugi, localDirs, taskSpec, umbilical, 1,
new HashMap<String, ByteBuffer>(), new HashMap<String, String>(), HashMultimap.<String, String> create(), taskReporter,
- executor, null);
+ executor, null, "", new ExecutionContextImpl("localhost"));
return taskRunner;
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/MapUtils.java
----------------------------------------------------------------------
diff --git a/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/MapUtils.java b/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/MapUtils.java
index 3b4c066..8ec17eb 100644
--- a/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/MapUtils.java
+++ b/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/MapUtils.java
@@ -48,9 +48,7 @@ import org.apache.hadoop.mapreduce.split.JobSplit.SplitMetaInfo;
import org.apache.hadoop.mapreduce.split.SplitMetaInfoReaderTez;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.util.DiskChecker.DiskErrorException;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper;
-import org.apache.tez.common.EnvironmentUpdateUtils;
import org.apache.tez.common.MRFrameworkConfigs;
import org.apache.tez.common.TezUtils;
import org.apache.tez.common.TezRuntimeFrameworkConfigs;
@@ -60,6 +58,7 @@ import org.apache.tez.mapreduce.TezTestUtils;
import org.apache.tez.mapreduce.hadoop.MRJobConfig;
import org.apache.tez.mapreduce.processor.map.MapProcessor;
import org.apache.tez.runtime.LogicalIOProcessorRuntimeTask;
+import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.api.impl.InputSpec;
import org.apache.tez.runtime.api.impl.OutputSpec;
import org.apache.tez.runtime.api.impl.TaskSpec;
@@ -218,14 +217,12 @@ public class MapUtils {
Map<String, ByteBuffer> serviceConsumerMetadata = new HashMap<String, ByteBuffer>();
serviceConsumerMetadata.put(ShuffleUtils.SHUFFLE_HANDLER_SERVICE_ID,
ShuffleUtils.convertJobTokenToBytes(shuffleToken));
- Map<String, String> serviceProviderEnvMap = new HashMap<String, String>();
+ Map<String, String> envMap = new HashMap<String, String>();
ByteBuffer shufflePortBb = ByteBuffer.allocate(4).putInt(0, 8000);
AuxiliaryServiceHelper
.setServiceDataIntoEnv(ShuffleUtils.SHUFFLE_HANDLER_SERVICE_ID, shufflePortBb,
- serviceProviderEnvMap);
- EnvironmentUpdateUtils.put(ApplicationConstants.Environment.NM_HOST
- .toString(), "localhost");
-
+ envMap);
+
LogicalIOProcessorRuntimeTask task = new LogicalIOProcessorRuntimeTask(
taskSpec,
0,
@@ -233,8 +230,8 @@ public class MapUtils {
new String[] {workDir.toString()},
umbilical,
serviceConsumerMetadata,
- serviceProviderEnvMap,
- HashMultimap.<String, String>create(), null);
+ envMap,
+ HashMultimap.<String, String>create(), null, "", new ExecutionContextImpl("localhost"));
return task;
}
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/reduce/TestReduceProcessor.java
----------------------------------------------------------------------
diff --git a/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/reduce/TestReduceProcessor.java b/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/reduce/TestReduceProcessor.java
index bd82ab8..b378f37 100644
--- a/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/reduce/TestReduceProcessor.java
+++ b/tez-mapreduce/src/test/java/org/apache/tez/mapreduce/processor/reduce/TestReduceProcessor.java
@@ -38,9 +38,7 @@ import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.SequenceFileOutputFormat;
import org.apache.hadoop.mapreduce.MRConfig;
import org.apache.hadoop.security.token.Token;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper;
-import org.apache.tez.common.EnvironmentUpdateUtils;
import org.apache.tez.common.MRFrameworkConfigs;
import org.apache.tez.common.TezUtils;
import org.apache.tez.common.TezRuntimeFrameworkConfigs;
@@ -65,6 +63,7 @@ import org.apache.tez.runtime.LogicalIOProcessorRuntimeTask;
import org.apache.tez.runtime.api.Event;
import org.apache.tez.runtime.api.events.CompositeDataMovementEvent;
import org.apache.tez.runtime.api.events.DataMovementEvent;
+import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.api.impl.EventType;
import org.apache.tez.runtime.api.impl.InputSpec;
import org.apache.tez.runtime.api.impl.OutputSpec;
@@ -215,8 +214,6 @@ public class TestReduceProcessor {
AuxiliaryServiceHelper
.setServiceDataIntoEnv(ShuffleUtils.SHUFFLE_HANDLER_SERVICE_ID, shufflePortBb,
serviceProviderEnvMap);
- EnvironmentUpdateUtils.put(ApplicationConstants.Environment.NM_HOST
- .toString(), "localhost");
LogicalIOProcessorRuntimeTask task = new LogicalIOProcessorRuntimeTask(
taskSpec,
@@ -226,7 +223,7 @@ public class TestReduceProcessor {
new TestUmbilical(),
serviceConsumerMetadata,
serviceProviderEnvMap,
- HashMultimap.<String, String>create(), null);
+ HashMultimap.<String, String>create(), null, "", new ExecutionContextImpl("localhost"));
List<Event> destEvents = new LinkedList<Event>();
destEvents.add(dme);
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-plugins/tez-mbeans-resource-calculator/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java
----------------------------------------------------------------------
diff --git a/tez-plugins/tez-mbeans-resource-calculator/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java b/tez-plugins/tez-mbeans-resource-calculator/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java
index 1aba859..4be8229 100644
--- a/tez-plugins/tez-mbeans-resource-calculator/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java
+++ b/tez-plugins/tez-mbeans-resource-calculator/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java
@@ -40,7 +40,7 @@ public class TestTezMxBeanResourceCalculator {
TezConfiguration.TEZ_TASK_RESOURCE_CALCULATOR_PROCESS_TREE_CLASS, null,
ResourceCalculatorProcessTree.class);
resourceCalculator = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree(
- System.getenv().get("JVM_PID"), clazz, conf);
+ "", clazz, conf);
}
@After
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/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 1407b94..99b318d 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
@@ -49,6 +49,7 @@ import org.apache.tez.dag.api.ProcessorDescriptor;
import org.apache.tez.dag.api.TezUncheckedException;
import org.apache.tez.dag.records.TezTaskAttemptID;
import org.apache.tez.runtime.api.AbstractLogicalIOProcessor;
+import org.apache.tez.runtime.api.ExecutionContext;
import org.apache.tez.runtime.api.Event;
import org.apache.tez.runtime.api.Input;
import org.apache.tez.runtime.api.InputFrameworkInterface;
@@ -116,7 +117,7 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
private final LinkedHashMap<String, LogicalOutput> runOutputMap;
private final Map<String, ByteBuffer> serviceConsumerMetadata;
- private final Map<String, String> serviceProviderEnvMap;
+ private final Map<String, String> envMap;
private final ExecutorService initializerExecutor;
private final CompletionService<Void> initializerCompletionService;
@@ -131,15 +132,15 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
private final InputReadyTracker inputReadyTracker;
private final ObjectRegistry objectRegistry;
-
- // KKK Make sure LogicalInputFramework checks are in place
+ private final ExecutionContext ExecutionContext;
public LogicalIOProcessorRuntimeTask(TaskSpec taskSpec, int appAttemptNumber,
Configuration tezConf, String[] localDirs, TezUmbilical tezUmbilical,
- Map<String, ByteBuffer> serviceConsumerMetadata, Map<String, String> serviceProviderEnvMap,
- Multimap<String, String> startedInputsMap, ObjectRegistry objectRegistry) throws IOException {
+ Map<String, ByteBuffer> serviceConsumerMetadata, Map<String, String> envMap,
+ Multimap<String, String> startedInputsMap, ObjectRegistry objectRegistry,
+ String pid, ExecutionContext ExecutionContext) throws IOException {
// TODO Remove jobToken from here post TEZ-421
- super(taskSpec, tezConf, tezUmbilical);
+ super(taskSpec, tezConf, tezUmbilical, pid);
LOG.info("Initializing LogicalIOProcessorRuntimeTask with TaskSpec: "
+ taskSpec);
int numInputs = taskSpec.getInputs().size();
@@ -157,7 +158,7 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
this.processorDescriptor = taskSpec.getProcessorDescriptor();
this.serviceConsumerMetadata = serviceConsumerMetadata;
- this.serviceProviderEnvMap = serviceProviderEnvMap;
+ this.envMap = envMap;
this.eventsToBeProcessed = new LinkedBlockingQueue<TezEvent>();
this.state = State.NEW;
this.appAttemptNumber = appAttemptNumber;
@@ -174,6 +175,7 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
this.startedInputsMap = startedInputsMap;
this.inputReadyTracker = new InputReadyTracker();
this.objectRegistry = objectRegistry;
+ this.ExecutionContext = ExecutionContext;
}
/**
@@ -486,8 +488,9 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
taskSpec.getTaskAttemptID(),
tezCounters, inputIndex,
inputSpec.getInputDescriptor().getUserPayload(), this,
- serviceConsumerMetadata, serviceProviderEnvMap, initialMemoryDistributor,
- inputSpec.getInputDescriptor(), inputMap, inputReadyTracker, objectRegistry);
+ serviceConsumerMetadata, envMap, initialMemoryDistributor,
+ inputSpec.getInputDescriptor(), inputMap, inputReadyTracker, objectRegistry,
+ ExecutionContext);
return inputContext;
}
@@ -500,8 +503,8 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
taskSpec.getTaskAttemptID(),
tezCounters, outputIndex,
outputSpec.getOutputDescriptor().getUserPayload(), this,
- serviceConsumerMetadata, serviceProviderEnvMap, initialMemoryDistributor,
- outputSpec.getOutputDescriptor(), objectRegistry);
+ serviceConsumerMetadata, envMap, initialMemoryDistributor,
+ outputSpec.getOutputDescriptor(), objectRegistry, ExecutionContext);
return outputContext;
}
@@ -512,8 +515,8 @@ public class LogicalIOProcessorRuntimeTask extends RuntimeTask {
taskSpec.getVertexParallelism(),
taskSpec.getTaskAttemptID(),
tezCounters, processorDescriptor.getUserPayload(), this,
- serviceConsumerMetadata, serviceProviderEnvMap, initialMemoryDistributor,
- processorDescriptor, inputReadyTracker, objectRegistry);
+ serviceConsumerMetadata, envMap, initialMemoryDistributor,
+ processorDescriptor, inputReadyTracker, objectRegistry, ExecutionContext);
return processorContext;
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/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 eec36c0..5f2eb93 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
@@ -45,7 +45,7 @@ public abstract class RuntimeTask {
private final TaskCounterUpdater counterUpdater;
protected RuntimeTask(TaskSpec taskSpec, Configuration tezConf,
- TezUmbilical tezUmbilical) {
+ TezUmbilical tezUmbilical, String pid) {
this.taskSpec = taskSpec;
this.tezConf = tezConf;
this.tezUmbilical = tezUmbilical;
@@ -53,7 +53,7 @@ public abstract class RuntimeTask {
this.eventCounter = new AtomicInteger(0);
this.progress = 0.0f;
this.taskDone = new AtomicBoolean(false);
- this.counterUpdater = new TaskCounterUpdater(tezCounters, tezConf);
+ this.counterUpdater = new TaskCounterUpdater(tezCounters, tezConf, pid);
}
protected enum State {
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/ExecutionContextImpl.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/ExecutionContextImpl.java b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/ExecutionContextImpl.java
new file mode 100644
index 0000000..6037c7b
--- /dev/null
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/ExecutionContextImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tez.runtime.api.impl;
+
+import org.apache.tez.runtime.api.ExecutionContext;
+
+public class ExecutionContextImpl implements ExecutionContext {
+
+ private final String hostname;
+
+ public ExecutionContextImpl(String hostname) {
+ this.hostname = hostname;
+ }
+
+ @Override
+ public String getHostName() {
+ return hostname;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezInputContextImpl.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezInputContextImpl.java b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezInputContextImpl.java
index 62311e9..460efbf 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezInputContextImpl.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezInputContextImpl.java
@@ -38,6 +38,7 @@ import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.records.TezTaskAttemptID;
import org.apache.tez.runtime.InputReadyTracker;
import org.apache.tez.runtime.RuntimeTask;
+import org.apache.tez.runtime.api.ExecutionContext;
import org.apache.tez.runtime.api.Event;
import org.apache.tez.runtime.api.LogicalInput;
import org.apache.tez.runtime.api.InputContext;
@@ -66,12 +67,13 @@ public class TezInputContextImpl extends TezTaskContextImpl
Map<String, ByteBuffer> serviceConsumerMetadata,
Map<String, String> auxServiceEnv, MemoryDistributor memDist,
InputDescriptor inputDescriptor, Map<String, LogicalInput> inputs,
- InputReadyTracker inputReadyTracker, ObjectRegistry objectRegistry) {
+ InputReadyTracker inputReadyTracker, ObjectRegistry objectRegistry,
+ ExecutionContext ExecutionContext) {
super(conf, workDirs, appAttemptNumber, dagName, taskVertexName,
vertexParallelism, taskAttemptID, wrapCounters(counters,
taskVertexName, sourceVertexName, conf), runtimeTask, tezUmbilical,
serviceConsumerMetadata, auxServiceEnv, memDist, inputDescriptor,
- objectRegistry);
+ objectRegistry, ExecutionContext);
checkNotNull(inputIndex, "inputIndex is null");
checkNotNull(sourceVertexName, "sourceVertexName is null");
checkNotNull(inputs, "input map is null");
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezOutputContextImpl.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezOutputContextImpl.java b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezOutputContextImpl.java
index 7b53075..88e87ce 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezOutputContextImpl.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezOutputContextImpl.java
@@ -37,6 +37,7 @@ import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.records.TezTaskAttemptID;
import org.apache.tez.runtime.RuntimeTask;
+import org.apache.tez.runtime.api.ExecutionContext;
import org.apache.tez.runtime.api.Event;
import org.apache.tez.runtime.api.ObjectRegistry;
import org.apache.tez.runtime.api.OutputContext;
@@ -61,12 +62,13 @@ public class TezOutputContextImpl extends TezTaskContextImpl
@Nullable UserPayload userPayload, RuntimeTask runtimeTask,
Map<String, ByteBuffer> serviceConsumerMetadata,
Map<String, String> auxServiceEnv, MemoryDistributor memDist,
- OutputDescriptor outputDescriptor, ObjectRegistry objectRegistry) {
+ OutputDescriptor outputDescriptor, ObjectRegistry objectRegistry,
+ ExecutionContext ExecutionContext) {
super(conf, workDirs, appAttemptNumber, dagName, taskVertexName,
vertexParallelism, taskAttemptID,
wrapCounters(counters, taskVertexName, destinationVertexName, conf),
runtimeTask, tezUmbilical, serviceConsumerMetadata,
- auxServiceEnv, memDist, outputDescriptor, objectRegistry);
+ auxServiceEnv, memDist, outputDescriptor, objectRegistry, ExecutionContext);
checkNotNull(outputIndex, "outputIndex is null");
checkNotNull(destinationVertexName, "destinationVertexName is null");
this.userPayload = userPayload;
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezProcessorContextImpl.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezProcessorContextImpl.java b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezProcessorContextImpl.java
index 9b4dc6a..3317c80 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezProcessorContextImpl.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezProcessorContextImpl.java
@@ -38,6 +38,7 @@ import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.records.TezTaskAttemptID;
import org.apache.tez.runtime.InputReadyTracker;
import org.apache.tez.runtime.RuntimeTask;
+import org.apache.tez.runtime.api.ExecutionContext;
import org.apache.tez.runtime.api.Event;
import org.apache.tez.runtime.api.Input;
import org.apache.tez.runtime.api.ObjectRegistry;
@@ -57,10 +58,11 @@ public class TezProcessorContextImpl extends TezTaskContextImpl implements Proce
@Nullable UserPayload userPayload, RuntimeTask runtimeTask,
Map<String, ByteBuffer> serviceConsumerMetadata,
Map<String, String> auxServiceEnv, MemoryDistributor memDist,
- ProcessorDescriptor processorDescriptor, InputReadyTracker inputReadyTracker, ObjectRegistry objectRegistry) {
+ ProcessorDescriptor processorDescriptor, InputReadyTracker inputReadyTracker, ObjectRegistry objectRegistry,
+ ExecutionContext ExecutionContext) {
super(conf, workDirs, appAttemptNumber, dagName, vertexName, vertexParallelism, taskAttemptID,
counters, runtimeTask, tezUmbilical, serviceConsumerMetadata,
- auxServiceEnv, memDist, processorDescriptor, objectRegistry);
+ auxServiceEnv, memDist, processorDescriptor, objectRegistry, ExecutionContext);
checkNotNull(inputReadyTracker, "inputReadyTracker is null");
this.userPayload = userPayload;
this.sourceInfo = new EventMetaData(EventProducerConsumerType.PROCESSOR,
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezTaskContextImpl.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezTaskContextImpl.java b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezTaskContextImpl.java
index 16fe3f6..d9de7b5 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezTaskContextImpl.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/api/impl/TezTaskContextImpl.java
@@ -35,6 +35,7 @@ import org.apache.tez.common.counters.TezCounters;
import org.apache.tez.dag.api.EntityDescriptor;
import org.apache.tez.dag.records.TezTaskAttemptID;
import org.apache.tez.runtime.RuntimeTask;
+import org.apache.tez.runtime.api.ExecutionContext;
import org.apache.tez.runtime.api.MemoryUpdateCallback;
import org.apache.tez.runtime.api.ObjectRegistry;
import org.apache.tez.runtime.api.TaskContext;
@@ -62,6 +63,7 @@ public abstract class TezTaskContextImpl implements TaskContext {
private final String dagName;
private final ObjectRegistry objectRegistry;
private final int vertexParallelism;
+ private final ExecutionContext ExecutionContext;
@Private
public TezTaskContextImpl(Configuration conf, String[] workDirs, int appAttemptNumber,
@@ -69,7 +71,8 @@ public abstract class TezTaskContextImpl implements TaskContext {
TezTaskAttemptID taskAttemptID, TezCounters counters, RuntimeTask runtimeTask,
TezUmbilical tezUmbilical, Map<String, ByteBuffer> serviceConsumerMetadata,
Map<String, String> auxServiceEnv, MemoryDistributor memDist,
- EntityDescriptor<?> descriptor, ObjectRegistry objectRegistry) {
+ EntityDescriptor<?> descriptor, ObjectRegistry objectRegistry,
+ ExecutionContext ExecutionContext) {
checkNotNull(conf, "conf is null");
checkNotNull(dagName, "dagName is null");
checkNotNull(taskVertexName, "taskVertexName is null");
@@ -99,6 +102,7 @@ public abstract class TezTaskContextImpl implements TaskContext {
this.descriptor = descriptor;
this.objectRegistry = objectRegistry;
this.vertexParallelism = vertexParallelism;
+ this.ExecutionContext = ExecutionContext;
}
@Override
@@ -203,6 +207,11 @@ public abstract class TezTaskContextImpl implements TaskContext {
tezUmbilical.signalFatalError(taskAttemptID, t, message, sourceInfo);
}
+ @Override
+ public ExecutionContext getExecutionContext() {
+ return this.ExecutionContext;
+ }
+
private int generateId() {
return ID_GEN.incrementAndGet();
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-internals/src/main/java/org/apache/tez/runtime/metrics/TaskCounterUpdater.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/metrics/TaskCounterUpdater.java b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/metrics/TaskCounterUpdater.java
index cc57887..dfdb035 100644
--- a/tez-runtime-internals/src/main/java/org/apache/tez/runtime/metrics/TaskCounterUpdater.java
+++ b/tez-runtime-internals/src/main/java/org/apache/tez/runtime/metrics/TaskCounterUpdater.java
@@ -51,14 +51,16 @@ public class TaskCounterUpdater {
*/
private Map<String, FileSystemStatisticUpdater> statisticUpdaters =
new HashMap<String, FileSystemStatisticUpdater>();
- protected GcTimeUpdater gcUpdater;
+ protected final GcTimeUpdater gcUpdater;
private ResourceCalculatorProcessTree pTree;
private long initCpuCumulativeTime = 0;
+ private final String pid;
- public TaskCounterUpdater(TezCounters counters, Configuration conf) {
+ public TaskCounterUpdater(TezCounters counters, Configuration conf, String pid) {
this.tezCounters = counters;
this.conf = conf;
this.gcUpdater = new GcTimeUpdater(tezCounters);
+ this.pid = pid;
initResourceCalculatorPlugin();
recordInitialCpuStats();
}
@@ -142,8 +144,7 @@ public class TaskCounterUpdater {
TezConfiguration.TEZ_TASK_RESOURCE_CALCULATOR_PROCESS_TREE_CLASS, null,
ResourceCalculatorProcessTree.class);
- pTree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree(
- System.getenv().get("JVM_PID"), clazz, conf);
+ pTree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree(pid, clazz, conf);
LOG.info(" Using ResourceCalculatorProcessTree : " + pTree);
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java
----------------------------------------------------------------------
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java
index 2e922db..60f8d46 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java
@@ -45,6 +45,7 @@ import org.apache.tez.runtime.api.InputContext;
import org.apache.tez.runtime.api.OutputContext;
import org.apache.tez.runtime.api.ProcessorContext;
import org.apache.tez.runtime.api.Writer;
+import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.api.impl.InputSpec;
import org.apache.tez.runtime.api.impl.OutputSpec;
import org.apache.tez.runtime.api.impl.TaskSpec;
@@ -76,7 +77,8 @@ public class TestLogicalIOProcessorRuntimeTask {
TaskSpec task2 = createTaskSpec(taId2, "dag2", "vertex1", 10);
LogicalIOProcessorRuntimeTask lio1 = new LogicalIOProcessorRuntimeTask(task1, 0, tezConf, null,
- umbilical, serviceConsumerMetadata, new HashMap<String, String>(), startedInputsMap, null);
+ umbilical, serviceConsumerMetadata, new HashMap<String, String>(), startedInputsMap, null,
+ "", new ExecutionContextImpl("localhost"));
lio1.initialize();
lio1.run();
@@ -93,8 +95,8 @@ public class TestLogicalIOProcessorRuntimeTask {
assertEquals(30, lio1.getOutputContexts().iterator().next().getVertexParallelism());
LogicalIOProcessorRuntimeTask lio2 = new LogicalIOProcessorRuntimeTask(task2, 0, tezConf, null,
- umbilical, serviceConsumerMetadata, new HashMap<String, String>(), startedInputsMap, null);
-
+ umbilical, serviceConsumerMetadata, new HashMap<String, String>(), startedInputsMap, null,
+ "", new ExecutionContextImpl("localhost"));
lio2.initialize();
lio2.run();
lio2.close();
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/Fetcher.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/Fetcher.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/Fetcher.java
index 6875966..e600f18 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/Fetcher.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/Fetcher.java
@@ -88,6 +88,8 @@ public class Fetcher implements Callable<FetchResult> {
private final ApplicationId appId;
private final String logIdentifier;
+
+ private final String localHostname;
private final AtomicBoolean isShutDown = new AtomicBoolean(false);
@@ -128,7 +130,8 @@ public class Fetcher implements Callable<FetchResult> {
LocalDirAllocator localDirAllocator,
Path lockPath,
boolean localDiskFetchEnabled,
- boolean sharedFetchEnabled) {
+ boolean sharedFetchEnabled,
+ String localHostname) {
this.fetcherCallback = fetcherCallback;
this.inputManager = inputManager;
this.jobTokenSecretMgr = jobTokenSecretManager;
@@ -146,6 +149,7 @@ public class Fetcher implements Callable<FetchResult> {
this.localFs = localFs;
this.localDirAllocator = localDirAllocator;
this.lockPath = lockPath;
+ this.localHostname = localHostname;
try {
if (this.sharedFetchEnabled) {
@@ -180,8 +184,7 @@ public class Fetcher implements Callable<FetchResult> {
HostFetchResult hostFetchResult;
- if (localDiskFetchEnabled &&
- host.equals(System.getenv(ApplicationConstants.Environment.NM_HOST.toString()))) {
+ if (localDiskFetchEnabled && host.equals(localHostname)) {
hostFetchResult = setupLocalDiskFetch();
} else if (multiplex) {
hostFetchResult = doSharedFetch();
@@ -898,10 +901,10 @@ public class Fetcher implements Callable<FetchResult> {
public FetcherBuilder(FetcherCallback fetcherCallback,
HttpConnectionParams params, FetchedInputAllocator inputManager,
ApplicationId appId, JobTokenSecretManager jobTokenSecretMgr, String srcNameTrimmed,
- Configuration conf, boolean localDiskFetchEnabled) {
+ Configuration conf, boolean localDiskFetchEnabled, String localHostname) {
this.fetcher = new Fetcher(fetcherCallback, params, inputManager, appId,
jobTokenSecretMgr, srcNameTrimmed, conf, null, null, null, localDiskFetchEnabled,
- false);
+ false, localHostname);
}
public FetcherBuilder(FetcherCallback fetcherCallback,
@@ -909,10 +912,11 @@ public class Fetcher implements Callable<FetchResult> {
ApplicationId appId, JobTokenSecretManager jobTokenSecretMgr, String srcNameTrimmed,
Configuration conf, RawLocalFileSystem localFs,
LocalDirAllocator localDirAllocator, Path lockPath,
- boolean localDiskFetchEnabled, boolean sharedFetchEnabled) {
+ boolean localDiskFetchEnabled, boolean sharedFetchEnabled,
+ String localHostname) {
this.fetcher = new Fetcher(fetcherCallback, params, inputManager, appId,
jobTokenSecretMgr, srcNameTrimmed, conf, localFs, localDirAllocator,
- lockPath, localDiskFetchEnabled, sharedFetchEnabled);
+ lockPath, localDiskFetchEnabled, sharedFetchEnabled, localHostname);
}
public FetcherBuilder setHttpConnectionParameters(HttpConnectionParams httpParams) {
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/ShuffleManager.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/ShuffleManager.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/ShuffleManager.java
index b7067e5..42013e3 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/ShuffleManager.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/ShuffleManager.java
@@ -354,7 +354,8 @@ public class ShuffleManager implements FetcherCallback {
FetcherBuilder fetcherBuilder = new FetcherBuilder(ShuffleManager.this,
httpConnectionParams, inputManager, inputContext.getApplicationId(),
jobTokenSecretMgr, srcNameTrimmed, conf, localFs, localDirAllocator,
- lockDisk, localDiskFetchEnabled, sharedFetchEnabled);
+ lockDisk, localDiskFetchEnabled, sharedFetchEnabled,
+ inputContext.getExecutionContext().getHostName());
if (codec != null) {
fetcherBuilder.setCompressionParameters(codec);
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/FetcherOrderedGrouped.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/FetcherOrderedGrouped.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/FetcherOrderedGrouped.java
index d51e45e..56b6c42 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/FetcherOrderedGrouped.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/FetcherOrderedGrouped.java
@@ -36,7 +36,6 @@ import org.apache.hadoop.fs.LocalDirAllocator;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.tez.common.TezUtilsInternal;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.tez.common.TezRuntimeFrameworkConfigs;
import org.apache.tez.common.counters.TezCounter;
import org.apache.tez.common.security.JobTokenSecretManager;
@@ -75,6 +74,7 @@ class FetcherOrderedGrouped extends Thread {
private final Shuffle shuffle;
private final int id;
private final String logIdentifier;
+ private final String localHostname;
private static int nextId = 0;
private int currentPartition = -1;
@@ -105,7 +105,8 @@ class FetcherOrderedGrouped extends Thread {
boolean ifileReadAhead, int ifileReadAheadLength,
CompressionCodec codec,
InputContext inputContext, Configuration conf,
- boolean localDiskFetchEnabled) throws IOException {
+ boolean localDiskFetchEnabled,
+ String localHostname) throws IOException {
setDaemon(true);
this.scheduler = scheduler;
this.merger = merger;
@@ -135,6 +136,7 @@ class FetcherOrderedGrouped extends Thread {
this.codec = null;
}
this.conf = conf;
+ this.localHostname = localHostname;
this.localDiskFetchEnabled = localDiskFetchEnabled;
@@ -159,8 +161,7 @@ class FetcherOrderedGrouped extends Thread {
String hostPort = host.getHostIdentifier();
String hostname = hostPort.substring(0, hostPort.indexOf(":"));
- if (localDiskFetchEnabled &&
- hostname.equals(System.getenv(ApplicationConstants.Environment.NM_HOST.toString()))) {
+ if (localDiskFetchEnabled && hostname.equals(localHostname)) {
setupLocalDiskFetch(host);
} else {
// Shuffle
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/Shuffle.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/Shuffle.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/Shuffle.java
index fccb181..a9701a6 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/Shuffle.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/Shuffle.java
@@ -333,7 +333,8 @@ public class Shuffle implements ExceptionReporter {
FetcherOrderedGrouped
fetcher = new FetcherOrderedGrouped(httpConnectionParams, scheduler, merger,
metrics, Shuffle.this, jobTokenSecretMgr, ifileReadAhead, ifileReadAheadLength,
- codec, inputContext, conf, localDiskFetchEnabled);
+ codec, inputContext, conf, localDiskFetchEnabled,
+ inputContext.getExecutionContext().getHostName());
fetchers.add(fetcher);
fetcher.start();
}
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/writers/UnorderedPartitionedKVWriter.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/writers/UnorderedPartitionedKVWriter.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/writers/UnorderedPartitionedKVWriter.java
index 1ba00a0..74095c6 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/writers/UnorderedPartitionedKVWriter.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/writers/UnorderedPartitionedKVWriter.java
@@ -47,7 +47,6 @@ import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.DataInputBuffer;
import org.apache.hadoop.io.compress.CompressionCodec;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.tez.common.TezCommonUtils;
import org.apache.tez.common.TezUtilsInternal;
import org.apache.tez.common.counters.TaskCounter;
@@ -780,7 +779,7 @@ public class UnorderedPartitionedKVWriter extends BaseUnorderedPartitionedKVWrit
@VisibleForTesting
String getHost() {
- return System.getenv(ApplicationConstants.Environment.NM_HOST.toString());
+ return outputContext.getExecutionContext().getHostName();
}
@VisibleForTesting
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/OrderedPartitionedKVOutput.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/OrderedPartitionedKVOutput.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/OrderedPartitionedKVOutput.java
index b3290a5..5af9f86 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/OrderedPartitionedKVOutput.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/OrderedPartitionedKVOutput.java
@@ -32,7 +32,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.tez.common.TezCommonUtils;
import org.apache.tez.common.TezRuntimeFrameworkConfigs;
import org.apache.tez.common.TezUtils;
@@ -182,8 +181,7 @@ public class OrderedPartitionedKVOutput extends AbstractLogicalOutput {
}
}
if (!sendEmptyPartitionDetails || outputGenerated) {
- String host = System.getenv(ApplicationConstants.Environment.NM_HOST
- .toString());
+ String host = getContext().getExecutionContext().getHostName();
ByteBuffer shuffleMetadata = getContext()
.getServiceProviderMetaData(ShuffleUtils.SHUFFLE_HANDLER_SERVICE_ID);
int shufflePort = ShuffleUtils.deserializeShuffleProviderMetaData(shuffleMetadata);
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/UnorderedKVOutput.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/UnorderedKVOutput.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/UnorderedKVOutput.java
index 7bfc397..2911f0d 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/UnorderedKVOutput.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/output/UnorderedKVOutput.java
@@ -31,7 +31,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.tez.common.TezUtils;
import org.apache.tez.common.TezCommonUtils;
import org.apache.tez.common.TezRuntimeFrameworkConfigs;
@@ -165,7 +164,7 @@ public class UnorderedKVOutput extends AbstractLogicalOutput {
@VisibleForTesting
@Private
String getHost() {
- return System.getenv(ApplicationConstants.Environment.NM_HOST.toString());
+ return getContext().getExecutionContext().getHostName();
}
private static final Set<String> confKeys = new HashSet<String>();
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java
index 5cee83a..e6f0c4a 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java
@@ -38,17 +38,10 @@ import com.google.common.collect.Lists;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.tez.common.EnvironmentUpdateUtils;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
-import org.apache.tez.runtime.library.common.shuffle.FetchResult;
-import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
-import org.apache.tez.runtime.library.common.shuffle.Fetcher;
-import org.apache.tez.runtime.library.common.shuffle.FetcherCallback;
-import org.apache.tez.runtime.library.common.shuffle.LocalDiskFetchedInput;
import org.apache.tez.runtime.library.common.sort.impl.TezIndexRecord;
import org.junit.Assert;
import org.junit.Test;
@@ -65,14 +58,13 @@ public class TestFetcher {
public void testLocalFetchModeSetting() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, "true");
- EnvironmentUpdateUtils.put(ApplicationConstants.Environment.NM_HOST.toString(), HOST);
InputAttemptIdentifier[] srcAttempts = {
new InputAttemptIdentifier(0, 1, InputAttemptIdentifier.PATH_PREFIX + "pathComponent_1")
};
FetcherCallback fetcherCallback = mock(FetcherCallback.class);
Fetcher.FetcherBuilder builder = new Fetcher.FetcherBuilder(fetcherCallback, null, null,
- ApplicationId.newInstance(0, 1), null, "fetcherTest", conf, true);
+ ApplicationId.newInstance(0, 1), null, "fetcherTest", conf, true, HOST);
builder.assignWork(HOST, PORT, 0, Arrays.asList(srcAttempts));
Fetcher fetcher = spy(builder.build());
@@ -90,7 +82,7 @@ public class TestFetcher {
// When disabled use http fetch
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, "false");
builder = new Fetcher.FetcherBuilder(fetcherCallback, null, null,
- ApplicationId.newInstance(0, 1), null, "fetcherTest", conf, false);
+ ApplicationId.newInstance(0, 1), null, "fetcherTest", conf, false, HOST);
builder.assignWork(HOST, PORT, 0, Arrays.asList(srcAttempts));
fetcher = spy(builder.build());
@@ -120,11 +112,10 @@ public class TestFetcher {
TezConfiguration conf = new TezConfiguration();
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, "true");
- EnvironmentUpdateUtils.put(ApplicationConstants.Environment.NM_HOST.toString(), HOST);
int partition = 42;
FetcherCallback callback = mock(FetcherCallback.class);
Fetcher.FetcherBuilder builder = new Fetcher.FetcherBuilder(callback, null, null,
- ApplicationId.newInstance(0, 1), null, "fetcherTest", conf, true);
+ ApplicationId.newInstance(0, 1), null, "fetcherTest", conf, true, HOST);
builder.assignWork(HOST, PORT, partition, Arrays.asList(srcAttempts));
Fetcher fetcher = spy(builder.build());
http://git-wip-us.apache.org/repos/asf/tez/blob/97607447/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java
index 0c6c437..782f261 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java
@@ -63,7 +63,6 @@ import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import javax.crypto.SecretKey;
public class TestFetcher {
@@ -86,7 +85,7 @@ public class TestFetcher {
FetcherOrderedGrouped
fetcher = new FetcherOrderedGrouped(null, scheduler, merger, metrics, shuffle, null,
- false, 0, null, inputContext, conf, true);
+ false, 0, null, inputContext, conf, true, HOST);
FetcherOrderedGrouped spyFetcher = spy(fetcher);
MapHost host = new MapHost(1, HOST + ":" + PORT,
@@ -229,7 +228,7 @@ public class TestFetcher {
ShuffleUtils.constructHttpShuffleConnectionParams(conf);
FetcherOrderedGrouped mockFetcher =
new FetcherOrderedGrouped(httpConnectionParams, scheduler, merger, metrics, shuffle, null,
- false, 0, null, inputContext, conf, false);
+ false, 0, null, inputContext, conf, false, HOST);
final FetcherOrderedGrouped fetcher = spy(mockFetcher);
final MapHost host = new MapHost(1, HOST + ":" + PORT,