Konstantin Lebedev
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
14 additions and
0 deletions
-
weed/server/master_grpc_server.go
-
weed/server/master_grpc_server_admin.go
-
weed/stats/metrics.go
|
@ -307,6 +307,8 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ |
|
|
case <-ticker.C: |
|
|
case <-ticker.C: |
|
|
if !ms.Topo.IsLeader() { |
|
|
if !ms.Topo.IsLeader() { |
|
|
stats.MasterRaftIsleader.Set(0) |
|
|
stats.MasterRaftIsleader.Set(0) |
|
|
|
|
|
stats.MasterAdminLock.Reset() |
|
|
|
|
|
stats.MasterReplicaPlacementMismatch.Reset() |
|
|
return ms.informNewLeader(stream) |
|
|
return ms.informNewLeader(stream) |
|
|
} else { |
|
|
} else { |
|
|
stats.MasterRaftIsleader.Set(1) |
|
|
stats.MasterRaftIsleader.Set(1) |
|
|
|
@ -3,6 +3,7 @@ package weed_server |
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
"fmt" |
|
|
"fmt" |
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/stats" |
|
|
"math/rand" |
|
|
"math/rand" |
|
|
"sync" |
|
|
"sync" |
|
|
"time" |
|
|
"time" |
|
@ -112,11 +113,13 @@ func (locks *AdminLocks) generateToken(lockName string, clientName string) (ts t |
|
|
lastClient: clientName, |
|
|
lastClient: clientName, |
|
|
} |
|
|
} |
|
|
locks.locks[lockName] = lock |
|
|
locks.locks[lockName] = lock |
|
|
|
|
|
stats.MasterAdminLock.WithLabelValues(clientName).Set(1) |
|
|
return lock.accessLockTime, lock.accessSecret |
|
|
return lock.accessLockTime, lock.accessSecret |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (locks *AdminLocks) deleteLock(lockName string) { |
|
|
func (locks *AdminLocks) deleteLock(lockName string) { |
|
|
locks.Lock() |
|
|
locks.Lock() |
|
|
|
|
|
stats.MasterAdminLock.WithLabelValues(locks.locks[lockName].lastClient).Set(0) |
|
|
defer locks.Unlock() |
|
|
defer locks.Unlock() |
|
|
delete(locks.locks, lockName) |
|
|
delete(locks.locks, lockName) |
|
|
} |
|
|
} |
|
|
|
@ -47,6 +47,14 @@ var ( |
|
|
Help: "is leader", |
|
|
Help: "is leader", |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
MasterAdminLock = prometheus.NewGaugeVec( |
|
|
|
|
|
prometheus.GaugeOpts{ |
|
|
|
|
|
Namespace: Namespace, |
|
|
|
|
|
Subsystem: "master", |
|
|
|
|
|
Name: "admin_lock", |
|
|
|
|
|
Help: "admin lock", |
|
|
|
|
|
}, []string{"client"}) |
|
|
|
|
|
|
|
|
MasterReceivedHeartbeatCounter = prometheus.NewCounterVec( |
|
|
MasterReceivedHeartbeatCounter = prometheus.NewCounterVec( |
|
|
prometheus.CounterOpts{ |
|
|
prometheus.CounterOpts{ |
|
|
Namespace: Namespace, |
|
|
Namespace: Namespace, |
|
@ -199,6 +207,7 @@ var ( |
|
|
func init() { |
|
|
func init() { |
|
|
Gather.MustRegister(MasterClientConnectCounter) |
|
|
Gather.MustRegister(MasterClientConnectCounter) |
|
|
Gather.MustRegister(MasterRaftIsleader) |
|
|
Gather.MustRegister(MasterRaftIsleader) |
|
|
|
|
|
Gather.MustRegister(MasterAdminLock) |
|
|
Gather.MustRegister(MasterReceivedHeartbeatCounter) |
|
|
Gather.MustRegister(MasterReceivedHeartbeatCounter) |
|
|
Gather.MustRegister(MasterLeaderChangeCounter) |
|
|
Gather.MustRegister(MasterLeaderChangeCounter) |
|
|
Gather.MustRegister(MasterReplicaPlacementMismatch) |
|
|
Gather.MustRegister(MasterReplicaPlacementMismatch) |
|
|