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