请教一个:我用两台电脑配置了一个hadoop环境,并用eclipse做断点调试。调试简单的文件建立过程:
就是如下简单的代码:
Configuration conf=new Configuration();
String localsrc=" ";
String dat=" ";
InputStream in=new BufferedInputStream(new FileInputStream(localsrc));
FileSystem fs=FileSystem.get(URI.creat(dst),conf);
OutputStream out=fs.create(new Path(dst),new Prgressable(){public void Progress(){System.out.println(".");}});
断点跟踪一下:
OutputStream out=fs.create(new Path(dst),new Progressable(){
因为out是DistributedFileSystem所以到了这个类里来了:
public FSDataOutputStream create(Path f, FsPermission permission,
boolean overwrite,
int bufferSize, short replication, long blockSize,
Progressable progress) throws IOException {
return new FSDataOutputStream
(dfs.create(getPathName(f), permission,
overwrite, replication, blockSize, progress, bufferSize),
statistics);
}
dfs是DFSClient类型的,所以到了这个类,DFSClent里德函数create()里有一句很重要:
OutputStream result = new DFSOutputStream(src, masked,
overwrite, replication, blockSize, progress, buffersize,
conf.getInt("io.bytes.per.checksum", 512));
然后到了DFSOutputStream的构造函数里
try {
namenode.create(
src, masked, clientName, overwrite, replication, blockSize);
}看到了调用namenode的create()方法,
Create a new file entry in the namespace.是在文件系统创建一个文件入口,并不会分配block给它。
我的是为什么断点执行不到namenode里的create()函数,而在网页中查看文件缺失是建立成功了。
希望大家帮忙分析一下, |
|