aboutsummaryrefslogtreecommitdiff
path: root/weed/storage
diff options
context:
space:
mode:
authorChris Lu <chris.lu@uber.com>2019-03-17 20:27:08 -0700
committerChris Lu <chris.lu@uber.com>2019-03-17 20:27:08 -0700
commitaca653c08bfaae205e3a62ae9e58ce327a5a583f (patch)
tree83cc519f45f0186c10365c5a332e8a995fdb00ed /weed/storage
parent22fbbf023b180e3c51261b0746a52be715e86648 (diff)
downloadseaweedfs-aca653c08bfaae205e3a62ae9e58ce327a5a583f.tar.xz
seaweedfs-aca653c08bfaae205e3a62ae9e58ce327a5a583f.zip
weed shell: list volumes
Diffstat (limited to 'weed/storage')
-rw-r--r--weed/storage/store.go16
-rw-r--r--weed/storage/volume.go16
-rw-r--r--weed/storage/volume_info.go16
3 files changed, 34 insertions, 14 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go
index 96c819666..a29f3c163 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -144,24 +144,12 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
for _, location := range s.Locations {
maxVolumeCount = maxVolumeCount + location.MaxVolumeCount
location.Lock()
- for k, v := range location.volumes {
+ for _, v := range location.volumes {
if maxFileKey < v.nm.MaxFileKey() {
maxFileKey = v.nm.MaxFileKey()
}
if !v.expired(s.VolumeSizeLimit) {
- volumeMessage := &master_pb.VolumeInformationMessage{
- Id: uint32(k),
- Size: uint64(v.Size()),
- Collection: v.Collection,
- FileCount: uint64(v.nm.FileCount()),
- DeleteCount: uint64(v.nm.DeletedCount()),
- DeletedByteCount: v.nm.DeletedSize(),
- ReadOnly: v.readOnly,
- ReplicaPlacement: uint32(v.ReplicaPlacement.Byte()),
- Version: uint32(v.Version()),
- Ttl: v.Ttl.ToUint32(),
- }
- volumeMessages = append(volumeMessages, volumeMessage)
+ volumeMessages = append(volumeMessages, v.ToVolumeInformationMessage())
} else {
if v.expiredLongEnough(MAX_TTL_VOLUME_REMOVAL_DELAY) {
location.deleteVolumeById(v.Id)
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index 07c72ecb4..5cec0c5ed 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -2,6 +2,7 @@ package storage
import (
"fmt"
+ "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"os"
"path"
"sync"
@@ -134,3 +135,18 @@ func (v *Volume) expiredLongEnough(maxDelayMinutes uint32) bool {
}
return false
}
+
+func (v *Volume) ToVolumeInformationMessage() *master_pb.VolumeInformationMessage {
+ return &master_pb.VolumeInformationMessage{
+ Id: uint32(v.Id),
+ Size: uint64(v.Size()),
+ Collection: v.Collection,
+ FileCount: uint64(v.nm.FileCount()),
+ DeleteCount: uint64(v.nm.DeletedCount()),
+ DeletedByteCount: v.nm.DeletedSize(),
+ ReadOnly: v.readOnly,
+ ReplicaPlacement: uint32(v.ReplicaPlacement.Byte()),
+ Version: uint32(v.Version()),
+ Ttl: v.Ttl.ToUint32(),
+ }
+}
diff --git a/weed/storage/volume_info.go b/weed/storage/volume_info.go
index f6614a9de..450100e59 100644
--- a/weed/storage/volume_info.go
+++ b/weed/storage/volume_info.go
@@ -45,6 +45,22 @@ func (vi VolumeInfo) String() string {
vi.Id, vi.Size, vi.ReplicaPlacement, vi.Collection, vi.Version, vi.FileCount, vi.DeleteCount, vi.DeletedByteCount, vi.ReadOnly)
}
+func (vi VolumeInfo) ToVolumeInformationMessage() *master_pb.VolumeInformationMessage {
+ return &master_pb.VolumeInformationMessage{
+ Id: uint32(vi.Id),
+ Size: uint64(vi.Size),
+ Collection: vi.Collection,
+ FileCount: uint64(vi.FileCount),
+ DeleteCount: uint64(vi.DeleteCount),
+ DeletedByteCount: vi.DeletedByteCount,
+ ReadOnly: vi.ReadOnly,
+ ReplicaPlacement: uint32(vi.ReplicaPlacement.Byte()),
+ Version: uint32(vi.Version),
+ Ttl: vi.Ttl.ToUint32(),
+ }
+}
+
+
/*VolumesInfo sorting*/
type volumeInfos []*VolumeInfo