forked from colinmarc/hdfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat_fs.go
41 lines (35 loc) · 1.06 KB
/
stat_fs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package hdfs
import (
hdfs "github.com/colinmarc/hdfs/v2/internal/protocol/hadoop_hdfs"
)
// 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 {
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
}