Repository: tez Updated Branches: refs/heads/TEZ-3334 bee148439 -> d77f9b7fc
TEZ-3509. Make DAG Deletion path based (Kuhu Shukla via jeagles) Project: http://git-wip-us.apache.org/repos/asf/tez/repo Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/d77f9b7f Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/d77f9b7f Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/d77f9b7f Branch: refs/heads/TEZ-3334 Commit: d77f9b7fcacf81c449e6c8ecd9342ba0cdb1660c Parents: bee1484 Author: Jonathan Eagles <[email protected]> Authored: Wed Nov 30 10:30:56 2016 -0600 Committer: Jonathan Eagles <[email protected]> Committed: Wed Nov 30 10:30:56 2016 -0600 ---------------------------------------------------------------------- .../tez/dag/app/launcher/DeletionTracker.java | 57 ++++++++++++++++ .../dag/app/launcher/DeletionTrackerImpl.java | 68 ++++++++++++++++++++ 2 files changed, 125 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tez/blob/d77f9b7f/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTracker.java ---------------------------------------------------------------------- diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTracker.java b/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTracker.java new file mode 100644 index 0000000..0409a30 --- /dev/null +++ b/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTracker.java @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.dag.app.launcher; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.tez.common.security.JobTokenSecretManager; +import org.apache.tez.dag.api.TezConfiguration; +import org.apache.tez.dag.records.TezDAGID; + +public abstract class DeletionTracker { + + protected final Configuration conf; + protected ExecutorService dagDeleteService; + protected String pluginName; + + public DeletionTracker(Configuration conf, String pluginName) { + this.conf = conf; + dagDeleteService = Executors.newFixedThreadPool( + conf.getInt(TezConfiguration.TEZ_AM_DAG_DELETION_THREAD_COUNT_LIMIT, + TezConfiguration.TEZ_AM_DAG_DELETION_THREAD_COUNT_LIMIT_DEFAULT), new ThreadFactoryBuilder() + .setDaemon(true).setNameFormat("ShuffleDeleteTracker #%d").build()); + this.pluginName = pluginName; + } + + public void dagComplete(TezDAGID dag, JobTokenSecretManager jobTokenSecretManager) { + //do nothing + } + + public void addNodeShufflePorts(NodeId nodeId, int port) { + //do nothing + } + + public void shutdown() { + dagDeleteService.shutdownNow(); + dagDeleteService = null; + } +} http://git-wip-us.apache.org/repos/asf/tez/blob/d77f9b7f/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTrackerImpl.java ---------------------------------------------------------------------- diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTrackerImpl.java b/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTrackerImpl.java new file mode 100644 index 0000000..4a4a4ae --- /dev/null +++ b/tez-dag/src/main/java/org/apache/tez/dag/app/launcher/DeletionTrackerImpl.java @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.dag.app.launcher; + + +import java.util.Map; + +import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.tez.common.security.JobTokenSecretManager; +import org.apache.tez.dag.records.TezDAGID; +import org.apache.hadoop.conf.Configuration; +import org.apache.tez.dag.api.TezConfiguration; +import org.apache.tez.runtime.library.common.TezRuntimeUtils; + +public class DeletionTrackerImpl extends DeletionTracker { + Map<NodeId, Integer> nodeIdShufflePortMap; + String pluginName; + + public DeletionTrackerImpl(Map<NodeId, Integer> nodeIdShufflePortMap, Configuration conf, String pluginName) { + super(conf, pluginName); + this.nodeIdShufflePortMap = nodeIdShufflePortMap; + } + + @Override + public void dagComplete(TezDAGID dag, JobTokenSecretManager jobTokenSecretManager) { + boolean shouldDelete = conf.getBoolean(TezConfiguration.TEZ_AM_DAG_DELETE_ENABLED, + TezConfiguration.TEZ_AM_DAG_DELETE_ENABLED_DEFAULT); + if (!shouldDelete) { + return; + } + for (Map.Entry<NodeId, Integer> entry : nodeIdShufflePortMap.entrySet()) { + NodeId nodeId = entry.getKey(); + int shufflePort = entry.getValue(); + //TODO: add check for healthy node + if (shufflePort != TezRuntimeUtils.INVALID_PORT) { + DagDeleteRunnable dagDeleteRunnable = new DagDeleteRunnable(nodeId, + shufflePort, dag, conf, jobTokenSecretManager, this.pluginName); + dagDeleteService.submit(dagDeleteRunnable); + } + } + nodeIdShufflePortMap.clear(); + } + + @Override + public void addNodeShufflePorts(NodeId nodeId, int port) { + if (port != TezRuntimeUtils.INVALID_PORT) { + if(nodeIdShufflePortMap.get(nodeId) == null) { + nodeIdShufflePortMap.put(nodeId, port); + } + } + } +}
