diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java index e9674cf..b878206 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java @@ -23,13 +23,11 @@ import java.net.InetSocketAddress; import java.net.URI; import java.net.URISyntaxException; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; -import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.Text; import org.apache.hadoop.security.SecurityUtil; @@ -49,7 +47,8 @@ * from/to 'serializableFormat' to/from hadoop/nativejava data structures. * */ -@Private +@Public +@Stable public class ConverterUtils { public static final String APPLICATION_PREFIX = "application"; @@ -64,6 +63,8 @@ * @return path from {@link URL} * @throws URISyntaxException */ + @Public + @Stable public static Path getPathFromYarnURL(URL url) throws URISyntaxException { String scheme = url.getScheme() == null ? "" : url.getScheme(); @@ -81,26 +82,15 @@ public static Path getPathFromYarnURL(URL url) throws URISyntaxException { return new Path( (new URI(scheme, authority, url.getFile(), null, null)).normalize()); } - - /** - * change from CharSequence to string for map key and value - * @param env map for converting - * @return string,string map - */ - public static Map convertToString( - Map env) { - - Map stringMap = new HashMap(); - for (Entry entry: env.entrySet()) { - stringMap.put(entry.getKey().toString(), entry.getValue().toString()); - } - return stringMap; - } + @Public + @Stable public static URL getYarnUrlFromPath(Path path) { return getYarnUrlFromURI(path.toUri()); } + @Public + @Stable public static URL getYarnUrlFromURI(URI uri) { URL url = RecordFactoryProvider.getRecordFactory(null).newRecordInstance(URL.class); if (uri.getHost() != null) { @@ -119,6 +109,8 @@ public static String toString(ApplicationId appId) { return appId.toString(); } + @Public + @Stable public static ApplicationId toApplicationId(RecordFactory recordFactory, String appIdStr) { Iterator it = _split(appIdStr).iterator(); @@ -126,6 +118,8 @@ public static ApplicationId toApplicationId(RecordFactory recordFactory, return toApplicationId(recordFactory, it); } + @Public + @Stable private static ApplicationId toApplicationId(RecordFactory recordFactory, Iterator it) { ApplicationId appId = ApplicationId.newInstance(Long.parseLong(it.next()), @@ -133,6 +127,8 @@ private static ApplicationId toApplicationId(RecordFactory recordFactory, return appId; } + @Public + @Stable private static ApplicationAttemptId toApplicationAttemptId( Iterator it) throws NumberFormatException { ApplicationId appId = ApplicationId.newInstance(Long.parseLong(it.next()), @@ -142,6 +138,8 @@ private static ApplicationAttemptId toApplicationAttemptId( return appAttemptId; } + @Public + @Stable private static ApplicationId toApplicationId( Iterator it) throws NumberFormatException { ApplicationId appId = ApplicationId.newInstance(Long.parseLong(it.next()), @@ -153,6 +151,8 @@ public static String toString(ContainerId cId) { return cId == null ? null : cId.toString(); } + @Public + @Stable public static NodeId toNodeIdWithDefaultPort(String nodeIdStr) { if (nodeIdStr.indexOf(":") < 0) { return toNodeId(nodeIdStr + ":0"); @@ -160,6 +160,8 @@ public static NodeId toNodeIdWithDefaultPort(String nodeIdStr) { return toNodeId(nodeIdStr); } + @Public + @Stable public static NodeId toNodeId(String nodeIdStr) { String[] parts = nodeIdStr.split(":"); if (parts.length != 2) { @@ -175,10 +177,14 @@ public static NodeId toNodeId(String nodeIdStr) { } } + @Public + @Stable public static ContainerId toContainerId(String containerIdStr) { return ContainerId.fromString(containerIdStr); } + @Public + @Stable public static ApplicationAttemptId toApplicationAttemptId( String applicationAttmeptIdStr) { Iterator it = _split(applicationAttmeptIdStr).iterator(); @@ -197,6 +203,8 @@ public static ApplicationAttemptId toApplicationAttemptId( } } + @Public + @Stable public static ApplicationId toApplicationId( String appIdStr) { Iterator it = _split(appIdStr).iterator(); @@ -227,6 +235,8 @@ public static ApplicationId toApplicationId( * @param serviceAddr the connect address for the service * @return rpc token */ + @Public + @Stable public static Token convertFromYarn( org.apache.hadoop.yarn.api.records.Token protoToken, InetSocketAddress serviceAddr) { @@ -246,6 +256,8 @@ public static ApplicationId toApplicationId( * @param protoToken the yarn token * @param service the service for the token */ + @Public + @Stable public static Token convertFromYarn( org.apache.hadoop.yarn.api.records.Token protoToken, Text service) {