Skip to content

Commit b2bdbca

Browse files
committed
added command-line support for hadoop configuration files
1 parent 256f5fe commit b2bdbca

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/main/java/com/tectonica/LmdbToHdfs.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tectonica;
22

33
import java.io.IOException;
4+
import java.util.Arrays;
45

56
import org.apache.hadoop.conf.Configuration;
67
import org.apache.hadoop.fs.Path;
@@ -13,18 +14,21 @@ public class LmdbToHdfs
1314
{
1415
public static void main(String args[]) throws IOException
1516
{
16-
if (args.length != 2)
17+
if (args.length < 2)
1718
{
1819
System.out.println("Lmdb-To-HDFS Loader");
1920
System.out.println("Usage:");
20-
System.out.println(" java -jar lmdbToHdfs.jar <lmdb-path> <hdfs-path>");
21+
System.out.println(" java -jar lmdbToHdfs.jar <lmdb-path> <hdfs-path> [<resource-uri>..]");
2122
System.out.println("Where:");
2223
System.out.println(" <lmdb-path> is a directory containing an LMDB database, e.g. /var/imagenet/lmdb");
23-
System.out.println(" <hdfs-path> is a path for (new) sequence file on HDFS, e.g. hdfs://master:9000/imagenet/lmdb");
24+
System.out.println(
25+
" <hdfs-path> is a path for (new) sequence file on HDFS, e.g. hdfs://master:9000/imagenet/lmdb");
26+
System.out.println(
27+
" <resource-uri> (0 or more values) are URIs of Hadoop configuration file, e.g. file:///usr/local/hadoop/etc/hadoop/core-site.xml");
2428
System.exit(1);
2529
}
2630

27-
lmdbToHdfs(args[0], args[1]);
31+
lmdbToHdfs(args[0], args[1], Arrays.copyOfRange(args, 2, args.length));
2832
}
2933

3034
//////////////////////////////////////////////////////////////////////////////////////////////////
@@ -42,10 +46,12 @@ private static void write(byte[] key, byte[] value) throws IOException
4246

4347
//////////////////////////////////////////////////////////////////////////////////////////////////
4448

45-
private static void lmdbToHdfs(String lmdbPath, String hdfsSeqFile) throws IOException
49+
private static void lmdbToHdfs(String lmdbPath, String hdfsSeqFile, String[] resourceUris) throws IOException
4650
{
4751
Configuration conf = new Configuration();
48-
// conf.addResource(new Path("file:///usr/local/hadoop/etc/hadoop/core-site.xml"));
52+
53+
for (String resourceUri : resourceUris)
54+
conf.addResource(new Path(resourceUri));
4955

5056
try
5157
{

0 commit comments

Comments
 (0)