mrferos / webhdfs
WebHDFS implementation in PHP
dev-master
2014-10-30 23:37 UTC
Requires
- php: >=5.3.0
- ext-curl: *
This package is auto-updated.
Last update: 2024-11-06 09:59:24 UTC
README
Description
php-WebHDFS is a PHP client for WebHDFS.
Dependencies
Todo
- Write unit tests
- Consider swapping out the original Curl class for Guzzle
Usage
File and Directory Operations
Create and Write to a File
hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->create('user/hadoop-username/new-file.txt', 'local-file.txt');
Append to a File
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->append('user/hadoop-username/file-to-append-to.txt', 'local-file.txt');
Concat File(s)
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->concat('user/hadoop-username/concatenated-file.txt', '/test/file1,/test/file2,/test/file3');
Open and Read a File
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $response = $hdfs->open('user/hadoop-username/file.txt');
Make a Directory
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->mkdirs('user/hadoop-username/new/directory/structure');
Create a Symbolic Link
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->createSymLink('user/hadoop-username/file.txt', '/user/hadoop-username/symlink-to-file.txt');
Rename a File/Directory
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->rename('user/hadoop-username/file.txt', '/user/hadoop-username/renamed-file.txt');
Delete a File/Directory
hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->delete('user/hadoop-username/file.txt');
Status of a File/Directory
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $response = $hdfs->getFileStatus('user/hadoop-username/file.txt');
List a Directory
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $response = $hdfs->listStatus('user/hadoop-username/');
Other File System Operations
Get Content Summary of a Directory
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $response = $hdfs->getContentSummary('user/hadoop-username/');
Get File Checksum
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $response = $hdfs->getFileChecksum('user/hadoop-username/file.txt');
Get Home Directory
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $response = $hdfs->getHomeDirectory();
Set Permission
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->setPermission('user/hadoop-username/file.txt', '777');
Set Owner
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->setOwner('user/hadoop-username/file.txt', 'other-user');
Set Replication Factor
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $hdfs->setReplication('user/hadoop-username/file.txt', '2');
Set Access or Modification Time
$hdfs = new WebHDFS\WebHDFS('mynamenode.hadoop.com', '50070', 'hadoop-username'); $response = $hdfs->setTimes('user/hadoop-username/file.txt');