4

I need to access from PHP the HDFS on a Hadoop system which uses cloudera packages in version 0.20.2+923.256.

There is a thrift server for the namenode which runs and also one for the job tracker. I have the following function for accessing the hdfs, but I get an unknown method "listStatus" error. The thrift server is used also by HUE interface to access the HDFS and the job tracker.

Can you help me please to access that HDFS from PHP? Does that thrift uses another API? I didn't find any specification for that API.

$socket = new TSocket(IP,PORT);
$socket->setSendTimeout(10000);
$socket->setRecvTimeout(20000);
$transport = new TBufferedTransport($socket);
$protocol = new TBinaryProtocol($transport);

$client = new ThriftHadoopFileSystemClient($protocol);
$transport->open();
$pathname = new Pathname(array('pathname' => $file));
$result = $client->listStatus($pathname);
echo($result[0]->path);        
$transport->close();
return $result;

Many thanks!

4

1 回答 1

1

你可以给你这个 api,它很有帮助 https://github.com/simpleenergy/php-WebHDFS

于 2014-01-23T13:22:46.760 回答