From 41143b3b78a1021111edc28a27f76ae2529f99a8 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 15 Mar 2014 23:03:49 -0700 Subject: 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 --- go/topology/cluster_commands.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 go/topology/cluster_commands.go (limited to 'go/topology/cluster_commands.go') 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 +} -- cgit v1.2.3