initial add hashicorp raft

This commit is contained in:
Konstantin Lebedev
2022-04-04 13:50:56 +05:00
parent dfe5bfbe2b
commit c514710b7b
7 changed files with 342 additions and 7 deletions

View File

@@ -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 {
@@ -29,3 +32,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() {
}