|
@@ -23,6 +23,7 @@ import java.util.*;
|
|
|
|
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
|
import org.apache.hadoop.conf.*;
|
|
|
+import org.apache.hadoop.mapreduce.task.JobContextImpl;
|
|
|
import org.apache.hadoop.util.*;
|
|
|
import org.apache.hadoop.fs.*;
|
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
@@ -145,8 +146,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static void setCacheArchives(URI[] archives, Configuration conf) {
|
|
|
- String sarchives = StringUtils.uriToString(archives);
|
|
|
- conf.set(MRJobConfig.CACHE_ARCHIVES, sarchives);
|
|
|
+ Job.setCacheArchives(archives, conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -159,8 +159,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static void setCacheFiles(URI[] files, Configuration conf) {
|
|
|
- String sfiles = StringUtils.uriToString(files);
|
|
|
- conf.set(MRJobConfig.CACHE_FILES, sfiles);
|
|
|
+ Job.setCacheFiles(files, conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -174,7 +173,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static URI[] getCacheArchives(Configuration conf) throws IOException {
|
|
|
- return StringUtils.stringToURI(conf.getStrings(MRJobConfig.CACHE_ARCHIVES));
|
|
|
+ return JobContextImpl.getCacheArchives(conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -188,7 +187,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static URI[] getCacheFiles(Configuration conf) throws IOException {
|
|
|
- return StringUtils.stringToURI(conf.getStrings(MRJobConfig.CACHE_FILES));
|
|
|
+ return JobContextImpl.getCacheFiles(conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -201,10 +200,8 @@ public class DistributedCache {
|
|
|
* @see JobContext#getLocalCacheArchives()
|
|
|
*/
|
|
|
@Deprecated
|
|
|
- public static Path[] getLocalCacheArchives(Configuration conf)
|
|
|
- throws IOException {
|
|
|
- return StringUtils.stringToPath(conf
|
|
|
- .getStrings(MRJobConfig.CACHE_LOCALARCHIVES));
|
|
|
+ public static Path[] getLocalCacheArchives(Configuration conf) throws IOException {
|
|
|
+ return JobContextImpl.getLocalCacheArchives(conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -219,23 +216,7 @@ public class DistributedCache {
|
|
|
@Deprecated
|
|
|
public static Path[] getLocalCacheFiles(Configuration conf)
|
|
|
throws IOException {
|
|
|
- return StringUtils.stringToPath(conf.getStrings(MRJobConfig.CACHE_LOCALFILES));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Parse a list of strings into longs.
|
|
|
- * @param strs the list of strings to parse
|
|
|
- * @return a list of longs that were parsed. same length as strs.
|
|
|
- */
|
|
|
- private static long[] parseTimestamps(String[] strs) {
|
|
|
- if (strs == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- long[] result = new long[strs.length];
|
|
|
- for(int i=0; i < strs.length; ++i) {
|
|
|
- result[i] = Long.parseLong(strs[i]);
|
|
|
- }
|
|
|
- return result;
|
|
|
+ return JobContextImpl.getLocalCacheFiles(conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -248,8 +229,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static long[] getArchiveTimestamps(Configuration conf) {
|
|
|
- return parseTimestamps(
|
|
|
- conf.getStrings(MRJobConfig.CACHE_ARCHIVES_TIMESTAMPS));
|
|
|
+ return JobContextImpl.getArchiveTimestamps(conf);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -263,8 +243,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static long[] getFileTimestamps(Configuration conf) {
|
|
|
- return parseTimestamps(
|
|
|
- conf.getStrings(MRJobConfig.CACHE_FILE_TIMESTAMPS));
|
|
|
+ return JobContextImpl.getFileTimestamps(conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -277,9 +256,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static void addCacheArchive(URI uri, Configuration conf) {
|
|
|
- String archives = conf.get(MRJobConfig.CACHE_ARCHIVES);
|
|
|
- conf.set(MRJobConfig.CACHE_ARCHIVES, archives == null ? uri.toString()
|
|
|
- : archives + "," + uri.toString());
|
|
|
+ Job.addCacheArchive(uri, conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -307,9 +284,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static void addCacheFile(URI uri, Configuration conf) {
|
|
|
- String files = conf.get(MRJobConfig.CACHE_FILES);
|
|
|
- conf.set(MRJobConfig.CACHE_FILES, files == null ? uri.toString() : files + ","
|
|
|
- + uri.toString());
|
|
|
+ Job.addCacheFile(uri, conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -323,9 +298,8 @@ public class DistributedCache {
|
|
|
* @see Job#addFileToClassPath(Path)
|
|
|
*/
|
|
|
@Deprecated
|
|
|
- public static void addFileToClassPath(Path file, Configuration conf)
|
|
|
- throws IOException {
|
|
|
- addFileToClassPath(file, conf, file.getFileSystem(conf));
|
|
|
+ public static void addFileToClassPath(Path file, Configuration conf) throws IOException {
|
|
|
+ Job.addFileToClassPath(file, conf, file.getFileSystem(conf));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -340,7 +314,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
public static void addFileToClassPath(Path file, Configuration conf,
|
|
|
FileSystem fs) {
|
|
|
- addFileToClassPath(file, conf, fs, true);
|
|
|
+ Job.addFileToClassPath(file, conf, fs, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -357,14 +331,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
public static void addFileToClassPath(Path file, Configuration conf,
|
|
|
FileSystem fs, boolean addToCache) {
|
|
|
- String classpath = conf.get(MRJobConfig.CLASSPATH_FILES);
|
|
|
- conf.set(MRJobConfig.CLASSPATH_FILES, classpath == null ? file.toString()
|
|
|
- : classpath + "," + file.toString());
|
|
|
-
|
|
|
- if (addToCache) {
|
|
|
- URI uri = fs.makeQualified(file).toUri();
|
|
|
- addCacheFile(uri, conf);
|
|
|
- }
|
|
|
+ Job.addFileToClassPath(file, conf, fs, addToCache);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -377,16 +344,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static Path[] getFileClassPaths(Configuration conf) {
|
|
|
- ArrayList<String> list = (ArrayList<String>)conf.getStringCollection(
|
|
|
- MRJobConfig.CLASSPATH_FILES);
|
|
|
- if (list.size() == 0) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- Path[] paths = new Path[list.size()];
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- paths[i] = new Path(list.get(i));
|
|
|
- }
|
|
|
- return paths;
|
|
|
+ return JobContextImpl.getFileClassPaths(conf);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -401,7 +359,7 @@ public class DistributedCache {
|
|
|
@Deprecated
|
|
|
public static void addArchiveToClassPath(Path archive, Configuration conf)
|
|
|
throws IOException {
|
|
|
- addArchiveToClassPath(archive, conf, archive.getFileSystem(conf));
|
|
|
+ Job.addArchiveToClassPath(archive, conf, archive.getFileSystem(conf));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -415,12 +373,7 @@ public class DistributedCache {
|
|
|
public static void addArchiveToClassPath
|
|
|
(Path archive, Configuration conf, FileSystem fs)
|
|
|
throws IOException {
|
|
|
- String classpath = conf.get(MRJobConfig.CLASSPATH_ARCHIVES);
|
|
|
- conf.set(MRJobConfig.CLASSPATH_ARCHIVES, classpath == null ? archive
|
|
|
- .toString() : classpath + "," + archive.toString());
|
|
|
- URI uri = fs.makeQualified(archive).toUri();
|
|
|
-
|
|
|
- addCacheArchive(uri, conf);
|
|
|
+ Job.addArchiveToClassPath(archive, conf, fs);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -433,16 +386,7 @@ public class DistributedCache {
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public static Path[] getArchiveClassPaths(Configuration conf) {
|
|
|
- ArrayList<String> list = (ArrayList<String>)conf.getStringCollection(
|
|
|
- MRJobConfig.CLASSPATH_ARCHIVES);
|
|
|
- if (list.size() == 0) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- Path[] paths = new Path[list.size()];
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- paths[i] = new Path(list.get(i));
|
|
|
- }
|
|
|
- return paths;
|
|
|
+ return JobContextImpl.getArchiveClassPaths(conf);
|
|
|
}
|
|
|
|
|
|
/**
|