hadoop-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J├╝rgen Kaatz <ka...@etracker.com>
Subject Hadoop/HDFS Thrift/PHP connection doesnt work
Date Fri, 17 Jul 2009 11:47:43 GMT
Hi,

I'm trying to use thrift with PHP to handle file system operations on HDFS without any success.

I run a thrift server instance started with the script 'start_thrift_server.sh' located in
'hadoop/src/contrib/thriftfs/scripts/'. Then I use a little script 'hdfs.php' to connect to
this thrift server and try to create a new file 'foo' on HDFS. But the file is created on
my local filesystem not on HDFS.

Can anybody help me?
Thanks Juergen

-- hdfs.php ------------------------------------------------------------------------
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');

$GLOBALS['THRIFT_ROOT'] = '/home/hadoop/cc/thrift'; define('ETCC_THRIFT_ROOT', $GLOBALS['THRIFT_ROOT']);

require_once(ETCC_THRIFT_ROOT.'/Thrift.php' ); require_once(ETCC_THRIFT_ROOT.'/transport/TSocket.php'
); require_once(ETCC_THRIFT_ROOT.'/transport/TBufferedTransport.php' ); require_once(ETCC_THRIFT_ROOT.'/protocol/TBinaryProtocol.php'
);

$socket = new TSocket('hadoop-master', 50021); $socket->setSendTimeout(10000); $socket->setRecvTimeout(20000);
$transport = new TBufferedTransport($socket); $protocol = new TBinaryProtocol($transport);

require_once(ETCC_THRIFT_ROOT.'/packages/hadoopfs/ThriftHadoopFileSystem.php');
$client = new ThriftHadoopFileSystemClient($protocol);

$transport->open();

try
{
    $pathname = new Pathname(array('pathname' => 'foo'));
    // $result = $client->listStatus($pathname);
    $result = $client->create($pathname);
    $client->close($result);
    print_r($result);
}
catch(Exception $e)
{
    print_r($e);
}

$transport->close();


Mime
View raw message