diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2022-04-10 23:00:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-10 23:00:05 -0700 |
| commit | a87f57e47c9a39c7f431448ac1f99954a30151da (patch) | |
| tree | 0d142482d59098ffc4a481cb73d7c91803e4aff8 /weed/topology/cluster_commands.go | |
| parent | c6ec5269f4b34d79ab8e13050623501b8befda32 (diff) | |
| parent | 931cb9e5818b202c3855321c9b12a6149d121ffa (diff) | |
| download | seaweedfs-a87f57e47c9a39c7f431448ac1f99954a30151da.tar.xz seaweedfs-a87f57e47c9a39c7f431448ac1f99954a30151da.zip | |
Merge pull request #2868 from kmlebedev/hashicorp_raft
hashicorp raft
Diffstat (limited to 'weed/topology/cluster_commands.go')
| -rw-r--r-- | weed/topology/cluster_commands.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/weed/topology/cluster_commands.go b/weed/topology/cluster_commands.go index 152691ccb..1bcc6b449 100644 --- a/weed/topology/cluster_commands.go +++ b/weed/topology/cluster_commands.go @@ -1,9 +1,12 @@ package topology import ( + "encoding/json" + "fmt" "github.com/chrislusf/raft" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/storage/needle" + hashicorpRaft "github.com/hashicorp/raft" ) type MaxVolumeIdCommand struct { @@ -20,6 +23,7 @@ func (c *MaxVolumeIdCommand) CommandName() string { return "MaxVolumeId" } +// deprecatedCommandApply represents the old interface to apply a command to the server. func (c *MaxVolumeIdCommand) Apply(server raft.Server) (interface{}, error) { topo := server.Context().(*Topology) before := topo.GetMaxVolumeId() @@ -29,3 +33,19 @@ func (c *MaxVolumeIdCommand) Apply(server raft.Server) (interface{}, error) { return nil, nil } + +func (s *MaxVolumeIdCommand) Persist(sink hashicorpRaft.SnapshotSink) error { + b, err := json.Marshal(s) + if err != nil { + return fmt.Errorf("marshal: %v", err) + } + _, err = sink.Write(b) + if err != nil { + sink.Cancel() + return fmt.Errorf("sink.Write(): %v", err) + } + return sink.Close() +} + +func (s *MaxVolumeIdCommand) Release() { +} |
