diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-03-15 23:03:49 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-03-15 23:03:49 -0700 |
| commit | 41143b3b78a1021111edc28a27f76ae2529f99a8 (patch) | |
| tree | 5508f149f59363f5bdab3c16a23c02d57d4e310d /go/topology/cluster_commands.go | |
| parent | fb75fe852c5282cef436329bb0700d4d0e09f511 (diff) | |
| download | seaweedfs-41143b3b78a1021111edc28a27f76ae2529f99a8.tar.xz seaweedfs-41143b3b78a1021111edc28a27f76ae2529f99a8.zip | |
toughen weedfs clustering, adding synchronizing max volume id among
peers in order to avoid the same volume id being assigned twice
1. moving raft.Server to topology
2. adding max volume id command for raft
Diffstat (limited to 'go/topology/cluster_commands.go')
| -rw-r--r-- | go/topology/cluster_commands.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/go/topology/cluster_commands.go b/go/topology/cluster_commands.go new file mode 100644 index 000000000..dc0a40c8d --- /dev/null +++ b/go/topology/cluster_commands.go @@ -0,0 +1,31 @@ +package topology + +import ( + "code.google.com/p/weed-fs/go/glog" + "code.google.com/p/weed-fs/go/storage" + "github.com/goraft/raft" +) + +type MaxVolumeIdCommand struct { + MaxVolumeId storage.VolumeId `json:"maxVolumeId"` +} + +func NewMaxVolumeIdCommand(value storage.VolumeId) *MaxVolumeIdCommand { + return &MaxVolumeIdCommand{ + MaxVolumeId: value, + } +} + +func (c *MaxVolumeIdCommand) CommandName() string { + return "MaxVolumeId" +} + +func (c *MaxVolumeIdCommand) Apply(server raft.Server) (interface{}, error) { + topo := server.Context().(*Topology) + before := topo.GetMaxVolumeId() + topo.UpAdjustMaxVolumeId(c.MaxVolumeId) + + glog.V(0).Infoln("max volume id", before, "==>", topo.GetMaxVolumeId()) + + return nil, nil +} |
