一.代码(有bug)
GitHub - michaelbutler/php-WebHDFS: A PHP client for WebHDFS
二.调用代码
1.代码1.代码
|
GitHub - michaelbutler/php-WebHDFS: A PHP client for WebHDFS
|
GitHub - michaelbutler/php-WebHDFS: A PHP client for WebHDFS
四.代码有bug。当上传文件时,这个代码有bug
解决方式,加头即可。
四.调用说明,来自README.md
文件和目录操作
创建和写入文件
hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > create(' user / hadoop-username / new-file.txt ',' local-file.txt ');
直接创建内容并将其写入文件
hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > createWithData(' user / hadoop-username / new-file.txt ',' content ');
附加到文件
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > append(' user / hadoop-username / file-to-append-to.txt ',' local-file.txt ');
Concat文件
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > concat(' user / hadoop-username / concatenated-file.txt ',' / test / file1,/ test / file2,/ test / file3 ');
打开并读取文件
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ response = $ hdfs - > open(' user / hadoop-username / file.txt ');
制作目录
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > mkdirs(' user / hadoop-username / new / directory / structure ');
创建符号链接
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > createSymLink(' user / hadoop-username / file.txt ',' / user / hadoop-username / symlink - to -file.txt ');
重命名文件/目录
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > rename(' user / hadoop-username / file.txt ',' / user / hadoop-username / renamed -file.txt ');
删除文件/目录
hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > delete(' user / hadoop-username / file.txt ');
文件/目录的状态
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ response = $ hdfs - > getFileStatus(' user / hadoop-username / file.txt ');
列出目录
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ response = $ hdfs - > listStatus(' user / hadoop-username / ');
其他文件系统操作
获取目录的内容摘要
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ response = $ hdfs - > getContentSummary(' user / hadoop-username / ');
获取文件校验和
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ response = $ hdfs - > getFileChecksum(' user / hadoop-username / file.txt ');
获取主目录
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ response = $ hdfs - > getHomeDirectory();
设置权限
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > setPermission(' user / hadoop-username / file.txt ',' 777 ');
设置所有者
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > setOwner(' user / hadoop-username / file.txt ',' other-user ');
设置复制因子
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ hdfs - > setReplication(' user / hadoop-username / file.txt ',' 2 ');
设置访问或修改时间
$ hdfs = new WebHDFS(' mynamenode.hadoop.com ',' 50070 ',' hadoop-username '); $ response = $ hdfs - > setTimes(' user / hadoop-username / file.txt ');