mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 14:27:23 +08:00
master: add master.follower to handle read file id lookup requests
This commit is contained in:
@@ -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)
|
||||
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user