initial add hashicorp raft
This commit is contained in:
@@ -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() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user