lifeSo commented on code in PR #919: URL: https://github.com/apache/incubator-uniffle/pull/919#discussion_r1213967270
########## client-tez/src/main/java/org/apache/tez/common/UmbilicalUtils.java: ########## @@ -0,0 +1,112 @@ +/* + * 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.common; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.security.PrivilegedExceptionAction; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.ipc.RPC; +import org.apache.hadoop.mapred.JobConf; +import org.apache.hadoop.net.NetUtils; +import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.tez.dag.api.TezException; +import org.apache.tez.dag.records.TezTaskAttemptID; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.uniffle.common.ShuffleServerInfo; + +public class UmbilicalUtils { + private static final Logger LOG = LoggerFactory.getLogger(UmbilicalUtils.class); + + private UmbilicalUtils() { + } + + /** + * + * @return Get Application Master host and port from config file + */ + private static Pair<String, Integer> getAmHostPort() { + JobConf conf = new JobConf(RssTezConfig.RSS_CONF_FILE); + String host = conf.get(RssTezConfig.RSS_AM_SHUFFLE_MANAGER_ADDRESS, "null host"); + int port = conf.getInt(RssTezConfig.RSS_AM_SHUFFLE_MANAGER_PORT, -1); + LOG.info("Got RssConf am info, host is: {}, port is: {}", host, port); + return new ImmutablePair<>(host, port); + } + + /** + * + * @param applicationId Application Id of this task + * @param conf Configuration + * @param taskAttemptId task Attempt Id + * @param shuffleId computed using dagId, up dagName, down dagName by RssTezUtils.computeShuffleId() method. + * @return Shuffle Server Info by request Application Master + * @throws IOException + * @throws InterruptedException + * @throws TezException + */ + private static Map<Integer, List<ShuffleServerInfo>> doRequestShuffleServer( + ApplicationId applicationId, + Configuration conf, + TezTaskAttemptID taskAttemptId, + int shuffleId) throws IOException, InterruptedException, TezException { + UserGroupInformation taskOwner = UserGroupInformation.createRemoteUser(applicationId.toString()); + + Pair<String, Integer> amHostPort = getAmHostPort(); + final InetSocketAddress address = NetUtils.createSocketAddrForHost(amHostPort.getLeft(), amHostPort.getRight()); Review Comment: ok, we format the code in : https://github.com/apache/incubator-uniffle/pull/920/commits/3c374bbc248cd2d411235c205d5e804c8dba7002 and we may modify the methed to add unit test. thanks for merge -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
