Dragos
Dragos

Reputation: 81

Accessing Hadoop from PHP

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!

Upvotes: 4

Views: 8737

Answers (1)

ohm
ohm

Reputation: 140

you can you this api, its helpful https://github.com/simpleenergy/php-WebHDFS

Upvotes: 1

Related Questions