分享

hdfs创建文件的不解

datong838 发表于 2013-10-25 10:44:49 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 4058
请教一个:我用两台电脑配置了一个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()函数,而在网页中查看文件缺失是建立成功了。
希望大家帮忙分析一下,

没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条