diff options
| author | chrislusf <chris.lu@gmail.com> | 2015-05-08 23:34:14 -0700 |
|---|---|---|
| committer | chrislusf <chris.lu@gmail.com> | 2015-05-08 23:34:14 -0700 |
| commit | dac3b592ed3940240eb8c0e3a25150049a87d416 (patch) | |
| tree | 51656b6083545ab789d718fd8774c87d10cc1c8e /go/storage | |
| parent | 98d4adbb8a6c0c98b582fc5c13961f3c4431056c (diff) | |
| download | seaweedfs-dac3b592ed3940240eb8c0e3a25150049a87d416.tar.xz seaweedfs-dac3b592ed3940240eb8c0e3a25150049a87d416.zip | |
Add compact revision in volume super block
Diffstat (limited to 'go/storage')
| -rw-r--r-- | go/storage/volume_super_block.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/go/storage/volume_super_block.go b/go/storage/volume_super_block.go index 0404cb57c..e37360075 100644 --- a/go/storage/volume_super_block.go +++ b/go/storage/volume_super_block.go @@ -5,6 +5,7 @@ import ( "os" "github.com/chrislusf/seaweedfs/go/glog" + "github.com/chrislusf/seaweedfs/go/util" ) const ( @@ -16,12 +17,14 @@ const ( * Byte 0: version, 1 or 2 * Byte 1: Replica Placement strategy, 000, 001, 002, 010, etc * Byte 2 and byte 3: Time to live. See TTL for definition +* Byte 4 and byte 5: The number of times the volume has been compacted. * Rest bytes: Reserved */ type SuperBlock struct { version Version ReplicaPlacement *ReplicaPlacement Ttl *TTL + CompactRevision uint16 } func (s *SuperBlock) Version() Version { @@ -32,6 +35,7 @@ func (s *SuperBlock) Bytes() []byte { header[0] = byte(s.version) header[1] = s.ReplicaPlacement.Byte() s.Ttl.ToBytes(header[2:4]) + util.Uint16toBytes(header[4:6], s.CompactRevision) return header } @@ -72,5 +76,6 @@ func ParseSuperBlock(header []byte) (superBlock SuperBlock, err error) { err = fmt.Errorf("cannot read replica type: %s", err.Error()) } superBlock.Ttl = LoadTTLFromBytes(header[2:4]) + superBlock.CompactRevision = util.BytesToUint16(header[4:6]) return } |
