aboutsummaryrefslogtreecommitdiff
path: root/go/storage/volume.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-03-02 22:16:54 -0800
committerChris Lu <chris.lu@gmail.com>2014-03-02 22:16:54 -0800
commit27c74a7e66558a4f9ce0d10621606dfed98a3abb (patch)
treef16eef19480fd51ccbef54c05d39c2eacf309e56 /go/storage/volume.go
parentedae676913363bdd1e5a50bf0778fdcc3c6d6051 (diff)
downloadseaweedfs-27c74a7e66558a4f9ce0d10621606dfed98a3abb.tar.xz
seaweedfs-27c74a7e66558a4f9ce0d10621606dfed98a3abb.zip
Major:
change replication_type to ReplicaPlacement, hopefully cleaner code works for 9 possible ReplicaPlacement xyz x : number of copies on other data centers y : number of copies on other racks z : number of copies on current rack x y z each can be 0,1,2 Minor: weed server "-mdir" default to "-dir" if empty
Diffstat (limited to 'go/storage/volume.go')
-rw-r--r--go/storage/volume.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/go/storage/volume.go b/go/storage/volume.go
index a8d8f9a58..59c3055e3 100644
--- a/go/storage/volume.go
+++ b/go/storage/volume.go
@@ -17,14 +17,14 @@ const (
)
type SuperBlock struct {
- Version Version
- ReplicaType ReplicationType
+ Version Version
+ ReplicaPlacement *ReplicaPlacement
}
func (s *SuperBlock) Bytes() []byte {
header := make([]byte, SuperBlockSize)
header[0] = byte(s.Version)
- header[1] = s.ReplicaType.Byte()
+ header[1] = s.ReplicaPlacement.Byte()
return header
}
@@ -41,15 +41,15 @@ type Volume struct {
accessLock sync.Mutex
}
-func NewVolume(dirname string, collection string, id VolumeId, replicationType ReplicationType) (v *Volume, e error) {
+func NewVolume(dirname string, collection string, id VolumeId, replicaPlacement *ReplicaPlacement) (v *Volume, e error) {
v = &Volume{dir: dirname, Collection: collection, Id: id}
- v.SuperBlock = SuperBlock{ReplicaType: replicationType}
+ v.SuperBlock = SuperBlock{ReplicaPlacement: replicaPlacement}
e = v.load(true, true)
return
}
func loadVolumeWithoutIndex(dirname string, collection string, id VolumeId) (v *Volume, e error) {
v = &Volume{dir: dirname, Collection: collection, Id: id}
- v.SuperBlock = SuperBlock{ReplicaType: CopyNil}
+ v.SuperBlock = SuperBlock{}
e = v.load(false, false)
return
}
@@ -90,7 +90,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool) error {
}
}
- if v.ReplicaType == CopyNil {
+ if v.ReplicaPlacement == nil {
e = v.readSuperBlock()
} else {
e = v.maybeWriteSuperBlock()
@@ -173,13 +173,13 @@ func (v *Volume) readSuperBlock() (err error) {
}
func ParseSuperBlock(header []byte) (superBlock SuperBlock, err error) {
superBlock.Version = Version(header[0])
- if superBlock.ReplicaType, err = NewReplicationTypeFromByte(header[1]); err != nil {
+ if superBlock.ReplicaPlacement, err = NewReplicaPlacementFromByte(header[1]); err != nil {
err = fmt.Errorf("cannot read replica type: %s", err.Error())
}
return
}
func (v *Volume) NeedToReplicate() bool {
- return v.ReplicaType.GetCopyCount() > 1
+ return v.ReplicaPlacement.GetCopyCount() > 1
}
func (v *Volume) isFileUnchanged(n *Needle) bool {