|
|
@ -55,7 +55,7 @@ type MasterServer struct { |
|
|
|
vg *topology.VolumeGrowth |
|
|
|
vgLock sync.Mutex |
|
|
|
|
|
|
|
bounedLeaderChan chan int |
|
|
|
boundedLeaderChan chan int |
|
|
|
|
|
|
|
// notifying clients
|
|
|
|
clientChansLock sync.RWMutex |
|
|
@ -96,7 +96,7 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers []string) *Maste |
|
|
|
MasterClient: wdclient.NewMasterClient(grpcDialOption, "master", option.Host, 0, "", peers), |
|
|
|
adminLocks: NewAdminLocks(), |
|
|
|
} |
|
|
|
ms.bounedLeaderChan = make(chan int, 16) |
|
|
|
ms.boundedLeaderChan = make(chan int, 16) |
|
|
|
|
|
|
|
seq := ms.createSequencer(option) |
|
|
|
if nil == seq { |
|
|
@ -157,8 +157,8 @@ func (ms *MasterServer) proxyToLeader(f http.HandlerFunc) http.HandlerFunc { |
|
|
|
if ms.Topo.IsLeader() { |
|
|
|
f(w, r) |
|
|
|
} else if ms.Topo.RaftServer != nil && ms.Topo.RaftServer.Leader() != "" { |
|
|
|
ms.bounedLeaderChan <- 1 |
|
|
|
defer func() { <-ms.bounedLeaderChan }() |
|
|
|
ms.boundedLeaderChan <- 1 |
|
|
|
defer func() { <-ms.boundedLeaderChan }() |
|
|
|
targetUrl, err := url.Parse("http://" + ms.Topo.RaftServer.Leader()) |
|
|
|
if err != nil { |
|
|
|
writeJsonError(w, r, http.StatusInternalServerError, |
|
|
|