mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-01-18 06:30:07 +08:00
Add compact revision in volume super block
This commit is contained in:
parent
98d4adbb8a
commit
dac3b592ed
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/go/glog"
|
"github.com/chrislusf/seaweedfs/go/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/go/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -16,12 +17,14 @@ const (
|
|||||||
* Byte 0: version, 1 or 2
|
* Byte 0: version, 1 or 2
|
||||||
* Byte 1: Replica Placement strategy, 000, 001, 002, 010, etc
|
* Byte 1: Replica Placement strategy, 000, 001, 002, 010, etc
|
||||||
* Byte 2 and byte 3: Time to live. See TTL for definition
|
* 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
|
* Rest bytes: Reserved
|
||||||
*/
|
*/
|
||||||
type SuperBlock struct {
|
type SuperBlock struct {
|
||||||
version Version
|
version Version
|
||||||
ReplicaPlacement *ReplicaPlacement
|
ReplicaPlacement *ReplicaPlacement
|
||||||
Ttl *TTL
|
Ttl *TTL
|
||||||
|
CompactRevision uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SuperBlock) Version() Version {
|
func (s *SuperBlock) Version() Version {
|
||||||
@ -32,6 +35,7 @@ func (s *SuperBlock) Bytes() []byte {
|
|||||||
header[0] = byte(s.version)
|
header[0] = byte(s.version)
|
||||||
header[1] = s.ReplicaPlacement.Byte()
|
header[1] = s.ReplicaPlacement.Byte()
|
||||||
s.Ttl.ToBytes(header[2:4])
|
s.Ttl.ToBytes(header[2:4])
|
||||||
|
util.Uint16toBytes(header[4:6], s.CompactRevision)
|
||||||
return header
|
return header
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,5 +76,6 @@ func ParseSuperBlock(header []byte) (superBlock SuperBlock, err error) {
|
|||||||
err = fmt.Errorf("cannot read replica type: %s", err.Error())
|
err = fmt.Errorf("cannot read replica type: %s", err.Error())
|
||||||
}
|
}
|
||||||
superBlock.Ttl = LoadTTLFromBytes(header[2:4])
|
superBlock.Ttl = LoadTTLFromBytes(header[2:4])
|
||||||
|
superBlock.CompactRevision = util.BytesToUint16(header[4:6])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user