You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

  1. package storage
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/weed-fs/go/operation"
  5. )
  6. type VolumeInfo struct {
  7. Id VolumeId
  8. Size uint64
  9. ReplicaPlacement *ReplicaPlacement
  10. Ttl *TTL
  11. Collection string
  12. Version Version
  13. FileCount int
  14. DeleteCount int
  15. DeletedByteCount uint64
  16. ReadOnly bool
  17. }
  18. func NewVolumeInfo(m *operation.VolumeInformationMessage) (vi VolumeInfo, err error) {
  19. vi = VolumeInfo{
  20. Id: VolumeId(*m.Id),
  21. Size: *m.Size,
  22. Collection: *m.Collection,
  23. FileCount: int(*m.FileCount),
  24. DeleteCount: int(*m.DeleteCount),
  25. DeletedByteCount: *m.DeletedByteCount,
  26. ReadOnly: *m.ReadOnly,
  27. Version: Version(*m.Version),
  28. }
  29. rp, e := NewReplicaPlacementFromByte(byte(*m.ReplicaPlacement))
  30. if e != nil {
  31. return vi, e
  32. }
  33. vi.ReplicaPlacement = rp
  34. vi.Ttl = LoadTTLFromUint32(*m.Ttl)
  35. return vi, nil
  36. }
  37. func (vi VolumeInfo) String() string {
  38. return fmt.Sprintf("Id:%s, Size:%d, ReplicaPlacement:%s, Collection:%s, Version:%v, FileCount:%d, DeleteCount:%d, DeletedByteCount:%d, ReadOnly:%v", vi.Id, vi.Size, vi.ReplicaPlacement, vi.Collection, vi.Version, vi.FileCount, vi.DeleteCount, vi.DeletedByteCount, vi.ReadOnly)
  39. }