master: add master.follower to handle read file id lookup requests

This commit is contained in:
Chris Lu
2021-08-12 18:10:59 -07:00
parent 5469019852
commit 5571f4f70a
8 changed files with 306 additions and 116 deletions

View File

@@ -68,10 +68,6 @@ func (ms *MasterServer) ProcessGrowRequest() {
func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupVolumeRequest) (*master_pb.LookupVolumeResponse, error) {
if !ms.Topo.IsLeader() {
return nil, raft.NotLeaderError
}
resp := &master_pb.LookupVolumeResponse{}
volumeLocations := ms.lookupVolumeId(req.VolumeIds, req.Collection)

View File

@@ -44,6 +44,7 @@ type MasterOption struct {
DisableHttp bool
MetricsAddress string
MetricsIntervalSec int
IsFollower bool
}
type MasterServer struct {
@@ -145,7 +146,9 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers []string) *Maste
ms.ProcessGrowRequest()
ms.startAdminScripts()
if !option.IsFollower {
ms.startAdminScripts()
}
return ms
}
@@ -193,8 +196,8 @@ func (ms *MasterServer) proxyToLeader(f http.HandlerFunc) http.HandlerFunc {
proxy.Transport = util.Transport
proxy.ServeHTTP(w, r)
} else {
// drop it to the floor
// writeJsonError(w, r, errors.New(ms.Topo.RaftServer.Name()+" does not know Leader yet:"+ms.Topo.RaftServer.Leader()))
// handle requests locally
f(w, r)
}
}
}