1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.eos.hadoop;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.apache.hadoop.filecache.DistributedCache;
21 import org.apache.hadoop.fs.FileSystem;
22 import org.apache.hadoop.fs.Path;
23 import org.apache.hadoop.mapred.JobConf;
24
25 import java.io.IOException;
26 import java.net.URI;
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33
34 public class TestDistributedCacheStrategy implements DistributedCacheStrategy {
35
36
37 private static final Log LOG =
38 LogFactory.getLog(TestDistributedCacheStrategy.class.getName());
39
40
41
42
43 @SuppressWarnings("nls")
44 public Path[] distributedCachePathes(final JobConf conf) throws IOException
45 {
46
47 final URI[] uris = DistributedCache.getCacheFiles(conf);
48 final List<Path> pathes = new ArrayList<Path>();
49
50 for (final URI uri : uris) {
51 final Path p = new Path(uri.toASCIIString());
52 final FileSystem fs = p.getFileSystem(conf);
53 final Path qualified = p.makeQualified(fs);
54 LOG.info("uri: " + uri + " - qualified path: " + qualified);
55 pathes.add(qualified);
56 }
57
58 return pathes.toArray(new Path[uris.length]);
59 }
60 }