1
1
package com .tectonica ;
2
2
3
3
import java .io .IOException ;
4
+ import java .util .Arrays ;
4
5
5
6
import org .apache .hadoop .conf .Configuration ;
6
7
import org .apache .hadoop .fs .Path ;
@@ -13,18 +14,21 @@ public class LmdbToHdfs
13
14
{
14
15
public static void main (String args []) throws IOException
15
16
{
16
- if (args .length != 2 )
17
+ if (args .length < 2 )
17
18
{
18
19
System .out .println ("Lmdb-To-HDFS Loader" );
19
20
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>..] " );
21
22
System .out .println ("Where:" );
22
23
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" );
24
28
System .exit (1 );
25
29
}
26
30
27
- lmdbToHdfs (args [0 ], args [1 ]);
31
+ lmdbToHdfs (args [0 ], args [1 ], Arrays . copyOfRange ( args , 2 , args . length ) );
28
32
}
29
33
30
34
//////////////////////////////////////////////////////////////////////////////////////////////////
@@ -42,10 +46,12 @@ private static void write(byte[] key, byte[] value) throws IOException
42
46
43
47
//////////////////////////////////////////////////////////////////////////////////////////////////
44
48
45
- private static void lmdbToHdfs (String lmdbPath , String hdfsSeqFile ) throws IOException
49
+ private static void lmdbToHdfs (String lmdbPath , String hdfsSeqFile , String [] resourceUris ) throws IOException
46
50
{
47
51
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 ));
49
55
50
56
try
51
57
{
0 commit comments