Change to protocol buffer for volume-join-masster message

Reduced size to about 1/5 of the previous json format message
This commit is contained in:
Chris Lu
2014-04-21 02:11:10 -07:00
parent 637469e656
commit 1818a2a2da
9 changed files with 388 additions and 46 deletions

View File

@@ -1,6 +1,8 @@
package storage
import ()
import (
"code.google.com/p/weed-fs/go/operation"
)
type VolumeInfo struct {
Id VolumeId
@@ -13,3 +15,22 @@ type VolumeInfo struct {
DeletedByteCount uint64
ReadOnly bool
}
func NewVolumeInfo(m *operation.VolumeInformationMessage) (vi VolumeInfo, err error) {
vi = VolumeInfo{
Id: VolumeId(*m.Id),
Size: *m.Size,
Collection: *m.Collection,
FileCount: int(*m.FileCount),
DeleteCount: int(*m.DeleteCount),
DeletedByteCount: *m.DeletedByteCount,
ReadOnly: *m.ReadOnly,
Version: Version(*m.Version),
}
rp, e := NewReplicaPlacementFromByte(byte(*m.ReplicaPlacement))
if e != nil {
return vi, e
}
vi.ReplicaPlacement = rp
return vi, nil
}