From 26eff062c88581cad9e1a784c985535f7a897ba0 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 25 Jun 2023 14:17:58 -0700 Subject: [PATCH] refactor --- weed/cluster/lock_manager/distributed_lock_manager.go | 8 ++++---- weed/cluster/lock_manager/lock_ring.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/weed/cluster/lock_manager/distributed_lock_manager.go b/weed/cluster/lock_manager/distributed_lock_manager.go index 0bcc7b02d..a76de9e4a 100644 --- a/weed/cluster/lock_manager/distributed_lock_manager.go +++ b/weed/cluster/lock_manager/distributed_lock_manager.go @@ -15,7 +15,7 @@ func NewDistributedLockManager() *DistributedLockManager { } func (dlm *DistributedLockManager) Lock(host pb.ServerAddress, key string, expiredAtNs int64, token string, servers []pb.ServerAddress) (renewToken string, movedTo pb.ServerAddress, err error) { - server := HashKeyToServer(key, servers) + server := hashKeyToServer(key, servers) if server != host { movedTo = server return @@ -25,7 +25,7 @@ func (dlm *DistributedLockManager) Lock(host pb.ServerAddress, key string, expir } func (dlm *DistributedLockManager) Unlock(host pb.ServerAddress, key string, token string, servers []pb.ServerAddress) (movedTo pb.ServerAddress, err error) { - server := HashKeyToServer(key, servers) + server := hashKeyToServer(key, servers) if server != host { movedTo = server return @@ -41,10 +41,10 @@ func (dlm *DistributedLockManager) InsertLock(key string, expiredAtNs int64, tok } func (dlm *DistributedLockManager) SelectNotOwnedLocks(host pb.ServerAddress, servers []pb.ServerAddress) (locks []*Lock) { return dlm.lockManager.SelectLocks(func(key string) bool { - server := HashKeyToServer(key, servers) + server := hashKeyToServer(key, servers) return server != host }) } func (dlm *DistributedLockManager) CalculateTargetServer(key string, servers []pb.ServerAddress) pb.ServerAddress { - return HashKeyToServer(key, servers) + return hashKeyToServer(key, servers) } diff --git a/weed/cluster/lock_manager/lock_ring.go b/weed/cluster/lock_manager/lock_ring.go index eca86618a..c59aab184 100644 --- a/weed/cluster/lock_manager/lock_ring.go +++ b/weed/cluster/lock_manager/lock_ring.go @@ -161,7 +161,7 @@ func (r *LockRing) GetSnapshot() (servers []pb.ServerAddress) { return r.snapshots[0].servers } -func HashKeyToServer(key string, servers []pb.ServerAddress) pb.ServerAddress { +func hashKeyToServer(key string, servers []pb.ServerAddress) pb.ServerAddress { if len(servers) == 0 { return "" }