1

我正在使用 Thrift 访问 HDFS。

  1. 这是 HDFS 上预期的(和正确的)内容。

    [hadoop@hdp-namenode-01 ~]$ hadoop fs -ls /
    Found 3 items
    drwxr-xr-x   - hadoop supergroup          0 2012-04-26 14:07 /home
    drwxr-xr-x   - hadoop supergroup          0 2012-04-26 14:21 /tmp
    drwxr-xr-x   - hadoop supergroup          0 2012-04-26 14:20 /user
    
  2. 然后我启动一个 HDFSThriftServer

    [hadoop@hdp-namenode-01 ~]$ jps
    17290 JobTracker
    16980 NameNode
    27289 Jps
    17190 SecondaryNameNode
    17511 RunJar
    25270 HadoopThriftServer
    
  3. 尝试通过 PHP 中的 Thrift 访问内容。

    $transport = new TSocket(HDFS_HOST, HDFS_PORT);
    $transport->setRecvTimeout(60000);
    $transport->setSendTimeout(60000);
    $protocol =new TBinaryProtocol($transport);
    $client = new ThriftHadoopFileSystemClient($protocol);
    logv("connect hdfs");
    $transport->open();
    logv("testing existent of `%s'", $remote_uri);
    $remote_path = new Pathname(array('pathname' => $remote_uri));
    $remote_file = null;
    try {
            $remote_file = $client->listStatus($remote_path);
    } catch(Exception $e) { }
    if (!$remote_file)
        loge("could not open `%s'", $remote_uri);

While$remote_uri是绝对路径。对于$remote_uri === '/non/existent'or'/user'等​​,listStatus 总是失败。但是如果我将其更改为'/tmp',我发现它列出了'/tmp'thrift 服务器本地 FS 的内容。

所以返回的内容是thrift服务器上的本地FS,而不是HDFS!这里有什么问题?

4

0 回答 0