Add volume server RPCs to read and update state flags. (#8186)
* Boostrap persistent state for volume servers. This PR implements logic load/save persistent state information for storages associated with volume servers, and reporting state changes back to masters via heartbeat messages. More work ensues! See https://github.com/seaweedfs/seaweedfs/issues/7977 for details. * Add volume server RPCs to read and update state flags.
This commit is contained in:
@@ -69,3 +69,19 @@ func (st *State) Save() error {
|
||||
glog.V(1).Infof("Saved store state %v to %s", st.Pb, st.FilePath)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *State) Update(state *volume_server_pb.VolumeServerState) error {
|
||||
if state == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
origState := st.Pb
|
||||
st.Pb = state
|
||||
err := st.Save()
|
||||
if err != nil {
|
||||
// restore the original state upon save failures, to avoid skew between in-memory and disk state protos.
|
||||
st.Pb = origState
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user