Je tente de construire un programme Hadoop, dont le but est de cat
fichiers que j'ai déjà téléchargés sur HDFS, basé en grande partie sur this tutorial, le programme ressemble à ceci:Compilation de programme Hadoop Java avec des dépendances supplémentaires
import java.io.*;
import java.net.URI;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
public class ReadHDFS {
public static void main(String[] args) throws IOException {
String uri = args[0];
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), conf);
FSDataInputStream in = null ;
try
{
in = fs.open(new Path(uri));
IOUtils.copyBytes(in, System.out, 4096, false);
}
finally
{
IOUtils.closeStream(in);
}
}
}
Il me semble que le tutoriel est défectueux, Parce que- selon ma compréhension - IOUtils fait partie de la bibliothèque apache.commons
. Cependant, bien que j'ai ajouté la ligne suivante au programme que j'ai essayé de déployer:
import org.apache.commons.compress.utils.IOUtils;
Je suis encore rencontré l'erreur suivante:
C'est:
FileSystemCat.java:37: error: cannot find symbol
IOUtils.copyBytes(in, System.out, 4096, false);
^
symbol: method copyBytes(InputStream,PrintStream,int,boolean)
location: class IOUtils
FileSystemCat.java:40: error: cannot find symbol
IOUtils.closeStream(in);
^
symbol: variable in
location: class FileSystemCat
2 errors
Je l'exécuter sur le NameNode avec cette commande:
javac -cp /usr/local/hadoop/share/hadoop/common/hadoop-common-2.8.1.jar:/home/ubuntu/job_program/commons-io-2.5/commons-io-2.5.jar FileSystemCat.java