1 Star 0 Fork 0

zx/hdfs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
stat_fs.go 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
Junjie Qian 提交于 2017-01-31 10:28 +08:00 . Add StatFs and the df [-h] command
package hdfs
import (
"errors"
hdfs "github.com/colinmarc/hdfs/protocol/hadoop_hdfs"
"github.com/colinmarc/hdfs/rpc"
)
var StatFsError = errors.New("Failed to get HDFS usage")
// FsInfo provides information about HDFS
type FsInfo struct {
Capacity uint64
Used uint64
Remaining uint64
UnderReplicated uint64
CorruptBlocks uint64
MissingBlocks uint64
MissingReplOneBlocks uint64
BlocksInFuture uint64
PendingDeletionBlocks uint64
}
func (c *Client) StatFs() (FsInfo, error) {
req := &hdfs.GetFsStatusRequestProto{}
resp := &hdfs.GetFsStatsResponseProto{}
err := c.namenode.Execute("getFsStats", req, resp)
if err != nil {
if nnErr, ok := err.(*rpc.NamenodeError); ok {
err = interpretException(nnErr.Exception, err)
}
return FsInfo{}, err
}
var fs FsInfo
fs.Capacity = resp.GetCapacity()
fs.Used = resp.GetUsed()
fs.Remaining = resp.GetRemaining()
fs.UnderReplicated = resp.GetUnderReplicated()
fs.CorruptBlocks = resp.GetCorruptBlocks()
fs.MissingBlocks = resp.GetMissingBlocks()
fs.MissingReplOneBlocks = resp.GetMissingReplOneBlocks()
fs.BlocksInFuture = resp.GetBlocksInFuture()
fs.PendingDeletionBlocks = resp.GetPendingDeletionBlocks()
return fs, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/z_matrix/hdfs.git
git@gitee.com:z_matrix/hdfs.git
z_matrix
hdfs
hdfs
v1.1.3

搜索帮助