seaweedfs/weed/cluster/lock_manager/lock_manager.go

183 lines
5.1 KiB
Go
Raw Normal View History

2023-06-25 15:58:21 +08:00
package lock_manager
import (
"fmt"
"github.com/google/uuid"
2024-01-30 14:46:23 +08:00
"github.com/seaweedfs/seaweedfs/weed/glog"
2024-02-05 01:20:21 +08:00
"sync"
2023-06-25 15:58:21 +08:00
"time"
)
2023-06-26 08:37:54 +08:00
var LockErrorNonEmptyTokenOnNewLock = fmt.Errorf("lock: non-empty token on a new lock")
var LockErrorNonEmptyTokenOnExpiredLock = fmt.Errorf("lock: non-empty token on an expired lock")
var LockErrorTokenMismatch = fmt.Errorf("lock: token mismatch")
var UnlockErrorTokenMismatch = fmt.Errorf("unlock: token mismatch")
2024-01-30 14:46:23 +08:00
var LockNotFound = fmt.Errorf("lock not found")
2023-06-26 08:37:54 +08:00
Squashed commit of the following: commit 482742514656e9b5a652acf7406740fbc55db13d Author: chrislu <chris.lu@gmail.com> Date: Sat Sep 16 15:05:38 2023 -0700 balancer works commit 3b50139f68d5f59961113cf8fd0b903a7294a6ca Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:22:32 2023 -0700 comments commit 7f685ce7ba8853775e7c02c5b5c242d7920d62d3 Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:20:05 2023 -0700 adjust APIs commit 436d99443b399082f75f4ceb7595e8b5ac0a8ba3 Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 14 23:49:05 2023 -0700 receive broker stats commit b771fefa374fe237ff1317bbd03a9297a52191e3 Merge: 0a851ec00 890881037 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 13 00:03:47 2023 -0700 Merge branch 'master' into sub commit 0a851ec00b455c72b405503f6f1f41728b15962e Author: chrislu <chris.lu@gmail.com> Date: Sun Sep 10 22:01:25 2023 -0700 Create balancer.go commit 39941edc0bae3b9a4a2c3344caf494f7ab80a82a Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 7 23:55:19 2023 -0700 add publisher shutdown commit 875f562779f239a140d1008732b5375c0e511e61 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:16:41 2023 -0700 server side send response at least once per second commit 984b6c54cf6b0defaa6e727ab5e36809411fe92c Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:15:29 2023 -0700 ack interval 128 commit 2492a454997a59ffe00405e365290addc460078a Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 22:39:46 2023 -0700 ack interval commit ba67e6ca2998e82eb23abf5c431bdf9a92e966ea Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:50 2023 -0700 api for sub commit 9e4f98569898985ed285d8bb8a39b4ea5f095a98 Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:30 2023 -0700 publish, benchmark commit cb470d44df2fed94ad8fd370b1c281cb126d373b Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 1 00:36:51 2023 -0700 can pub and sub commit 1eb2da46d5d5a52c1012aa19ef31c1c8ed568d9e Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:02:12 2023 -0700 connect and publish commit 504ae8383ac3a0838d31d04b31623872b5734b31 Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:01:25 2023 -0700 protoc version commit dbcba75271a4617b5931c4779ca0f7c924369a8f Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:59:04 2023 -0700 rename to lookup commit c9caf3311995290c36ed369b48fbbab23d6bc7b5 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:33:46 2023 -0700 move functions commit 4d6c18d86f07ee35625f207c94539727944a8776 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 17:50:59 2023 -0700 pub sub initial tests commit 4eb8e8624d8280d8aa4a227afc06bcacbfe732a7 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:14:39 2023 -0700 rename commit 19904566706e9dba502f1ffd1f6fdf0bf876e99c Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:13:14 2023 -0700 sub commit 905911853dd5103496e8fc9b47934fa3a48da214 Author: chrislu <chris.lu@gmail.com> Date: Sat Aug 26 13:39:21 2023 -0700 adjust proto
2023-09-17 06:06:16 +08:00
// LockManager local lock manager, used by distributed lock manager
2023-06-25 15:58:21 +08:00
type LockManager struct {
2024-02-05 01:20:21 +08:00
locks map[string]*Lock
accessLock sync.RWMutex
2023-06-25 15:58:21 +08:00
}
type Lock struct {
2023-06-26 05:14:40 +08:00
Token string
ExpiredAtNs int64
Key string // only used for moving locks
Squashed commit of the following: commit 482742514656e9b5a652acf7406740fbc55db13d Author: chrislu <chris.lu@gmail.com> Date: Sat Sep 16 15:05:38 2023 -0700 balancer works commit 3b50139f68d5f59961113cf8fd0b903a7294a6ca Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:22:32 2023 -0700 comments commit 7f685ce7ba8853775e7c02c5b5c242d7920d62d3 Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:20:05 2023 -0700 adjust APIs commit 436d99443b399082f75f4ceb7595e8b5ac0a8ba3 Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 14 23:49:05 2023 -0700 receive broker stats commit b771fefa374fe237ff1317bbd03a9297a52191e3 Merge: 0a851ec00 890881037 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 13 00:03:47 2023 -0700 Merge branch 'master' into sub commit 0a851ec00b455c72b405503f6f1f41728b15962e Author: chrislu <chris.lu@gmail.com> Date: Sun Sep 10 22:01:25 2023 -0700 Create balancer.go commit 39941edc0bae3b9a4a2c3344caf494f7ab80a82a Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 7 23:55:19 2023 -0700 add publisher shutdown commit 875f562779f239a140d1008732b5375c0e511e61 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:16:41 2023 -0700 server side send response at least once per second commit 984b6c54cf6b0defaa6e727ab5e36809411fe92c Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:15:29 2023 -0700 ack interval 128 commit 2492a454997a59ffe00405e365290addc460078a Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 22:39:46 2023 -0700 ack interval commit ba67e6ca2998e82eb23abf5c431bdf9a92e966ea Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:50 2023 -0700 api for sub commit 9e4f98569898985ed285d8bb8a39b4ea5f095a98 Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:30 2023 -0700 publish, benchmark commit cb470d44df2fed94ad8fd370b1c281cb126d373b Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 1 00:36:51 2023 -0700 can pub and sub commit 1eb2da46d5d5a52c1012aa19ef31c1c8ed568d9e Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:02:12 2023 -0700 connect and publish commit 504ae8383ac3a0838d31d04b31623872b5734b31 Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:01:25 2023 -0700 protoc version commit dbcba75271a4617b5931c4779ca0f7c924369a8f Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:59:04 2023 -0700 rename to lookup commit c9caf3311995290c36ed369b48fbbab23d6bc7b5 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:33:46 2023 -0700 move functions commit 4d6c18d86f07ee35625f207c94539727944a8776 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 17:50:59 2023 -0700 pub sub initial tests commit 4eb8e8624d8280d8aa4a227afc06bcacbfe732a7 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:14:39 2023 -0700 rename commit 19904566706e9dba502f1ffd1f6fdf0bf876e99c Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:13:14 2023 -0700 sub commit 905911853dd5103496e8fc9b47934fa3a48da214 Author: chrislu <chris.lu@gmail.com> Date: Sat Aug 26 13:39:21 2023 -0700 adjust proto
2023-09-17 06:06:16 +08:00
Owner string
2023-06-25 15:58:21 +08:00
}
func NewLockManager() *LockManager {
t := &LockManager{
2024-02-05 01:20:21 +08:00
locks: make(map[string]*Lock),
2023-06-25 15:58:21 +08:00
}
go t.CleanUp()
return t
}
2024-02-03 07:54:57 +08:00
func (lm *LockManager) Lock(path string, expiredAtNs int64, token string, owner string) (lockOwner, renewToken string, err error) {
2024-02-05 01:20:21 +08:00
lm.accessLock.Lock()
defer lm.accessLock.Unlock()
glog.V(4).Infof("lock %s %v %v %v", path, time.Unix(0, expiredAtNs), token, owner)
if oldValue, found := lm.locks[path]; found {
if oldValue.ExpiredAtNs > 0 && oldValue.ExpiredAtNs < time.Now().UnixNano() {
// lock is expired, set to a new lock
if token != "" {
glog.V(4).Infof("lock expired key %s non-empty token %v owner %v ts %s", path, token, owner, time.Unix(0, oldValue.ExpiredAtNs))
err = LockErrorNonEmptyTokenOnExpiredLock
return
2023-06-25 15:58:21 +08:00
} else {
2024-02-05 01:20:21 +08:00
// new lock
renewToken = uuid.New().String()
glog.V(4).Infof("key %s new token %v owner %v", path, renewToken, owner)
lm.locks[path] = &Lock{Token: renewToken, ExpiredAtNs: expiredAtNs, Owner: owner}
return
2023-06-25 15:58:21 +08:00
}
2024-02-05 01:20:21 +08:00
}
// not expired
lockOwner = oldValue.Owner
if oldValue.Token == token {
// token matches, renew the lock
renewToken = uuid.New().String()
glog.V(4).Infof("key %s old token %v owner %v => %v owner %v", path, oldValue.Token, oldValue.Owner, renewToken, owner)
lm.locks[path] = &Lock{Token: renewToken, ExpiredAtNs: expiredAtNs, Owner: owner}
return
2023-06-25 15:58:21 +08:00
} else {
if token == "" {
2023-06-26 05:14:40 +08:00
// new lock
2024-02-05 01:20:21 +08:00
glog.V(4).Infof("key %s locked by %v", path, oldValue.Owner)
err = fmt.Errorf("lock already owned by %v", oldValue.Owner)
return
2023-06-25 15:58:21 +08:00
}
2024-02-05 01:20:21 +08:00
glog.V(4).Infof("key %s expected token %v owner %v received %v from %v", path, oldValue.Token, oldValue.Owner, token, owner)
err = fmt.Errorf("lock: token mismatch")
return
2023-06-25 15:58:21 +08:00
}
2024-02-05 01:20:21 +08:00
} else {
glog.V(4).Infof("key %s no lock owner %v", path, owner)
if token == "" {
// new lock
glog.V(4).Infof("key %s new token %v owner %v", path, token, owner)
renewToken = uuid.New().String()
lm.locks[path] = &Lock{Token: renewToken, ExpiredAtNs: expiredAtNs, Owner: owner}
return
} else {
glog.V(4).Infof("key %s non-empty token %v owner %v", path, token, owner)
err = LockErrorNonEmptyTokenOnNewLock
return
}
}
2023-06-25 15:58:21 +08:00
}
func (lm *LockManager) Unlock(path string, token string) (isUnlocked bool, err error) {
2024-02-05 01:20:21 +08:00
lm.accessLock.Lock()
defer lm.accessLock.Unlock()
if oldValue, found := lm.locks[path]; found {
now := time.Now()
if oldValue.ExpiredAtNs > 0 && oldValue.ExpiredAtNs < now.UnixNano() {
// lock is expired, delete it
isUnlocked = true
glog.V(4).Infof("key %s expired at %v", path, time.Unix(0, oldValue.ExpiredAtNs))
delete(lm.locks, path)
return
}
if oldValue.Token == token {
2023-06-25 15:58:21 +08:00
isUnlocked = true
2024-02-05 01:20:21 +08:00
glog.V(4).Infof("key %s unlocked with %v", path, token)
delete(lm.locks, path)
return
} else {
isUnlocked = false
err = UnlockErrorTokenMismatch
return
2023-06-25 15:58:21 +08:00
}
2024-02-05 01:20:21 +08:00
}
err = LockNotFound
2023-06-25 15:58:21 +08:00
return
}
func (lm *LockManager) CleanUp() {
2024-02-05 01:20:21 +08:00
2023-06-25 15:58:21 +08:00
for {
time.Sleep(1 * time.Minute)
now := time.Now().UnixNano()
2024-02-05 01:20:21 +08:00
lm.accessLock.Lock()
for key, value := range lm.locks {
if value == nil {
2024-02-05 01:20:21 +08:00
continue
}
2023-06-26 05:14:40 +08:00
if now > value.ExpiredAtNs {
2024-02-05 01:20:21 +08:00
glog.V(4).Infof("key %s expired at %v", key, time.Unix(0, value.ExpiredAtNs))
delete(lm.locks, key)
2023-06-25 15:58:21 +08:00
}
2024-02-05 01:20:21 +08:00
}
lm.accessLock.Unlock()
2023-06-25 15:58:21 +08:00
}
}
2023-06-26 05:14:40 +08:00
// SelectLocks takes out locks by key
2023-06-25 15:58:21 +08:00
// if keyFn return true, the lock will be taken out
2023-06-26 05:14:40 +08:00
func (lm *LockManager) SelectLocks(selectFn func(key string) bool) (locks []*Lock) {
2024-02-05 01:20:21 +08:00
lm.accessLock.RLock()
defer lm.accessLock.RUnlock()
2023-06-25 15:58:21 +08:00
now := time.Now().UnixNano()
2024-02-05 01:20:21 +08:00
for key, lock := range lm.locks {
2023-06-26 05:14:40 +08:00
if now > lock.ExpiredAtNs {
2024-02-05 01:20:21 +08:00
glog.V(4).Infof("key %s expired at %v", key, time.Unix(0, lock.ExpiredAtNs))
delete(lm.locks, key)
continue
2023-06-25 15:58:21 +08:00
}
2023-06-26 05:14:40 +08:00
if selectFn(key) {
2024-02-05 01:20:21 +08:00
glog.V(4).Infof("key %s selected and deleted", key)
delete(lm.locks, key)
2023-06-25 15:58:21 +08:00
lock.Key = key
locks = append(locks, lock)
}
2024-02-05 01:20:21 +08:00
}
2023-06-25 15:58:21 +08:00
return
}
2023-06-26 05:14:40 +08:00
// InsertLock inserts a lock unconditionally
Squashed commit of the following: commit 482742514656e9b5a652acf7406740fbc55db13d Author: chrislu <chris.lu@gmail.com> Date: Sat Sep 16 15:05:38 2023 -0700 balancer works commit 3b50139f68d5f59961113cf8fd0b903a7294a6ca Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:22:32 2023 -0700 comments commit 7f685ce7ba8853775e7c02c5b5c242d7920d62d3 Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:20:05 2023 -0700 adjust APIs commit 436d99443b399082f75f4ceb7595e8b5ac0a8ba3 Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 14 23:49:05 2023 -0700 receive broker stats commit b771fefa374fe237ff1317bbd03a9297a52191e3 Merge: 0a851ec00 890881037 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 13 00:03:47 2023 -0700 Merge branch 'master' into sub commit 0a851ec00b455c72b405503f6f1f41728b15962e Author: chrislu <chris.lu@gmail.com> Date: Sun Sep 10 22:01:25 2023 -0700 Create balancer.go commit 39941edc0bae3b9a4a2c3344caf494f7ab80a82a Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 7 23:55:19 2023 -0700 add publisher shutdown commit 875f562779f239a140d1008732b5375c0e511e61 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:16:41 2023 -0700 server side send response at least once per second commit 984b6c54cf6b0defaa6e727ab5e36809411fe92c Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:15:29 2023 -0700 ack interval 128 commit 2492a454997a59ffe00405e365290addc460078a Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 22:39:46 2023 -0700 ack interval commit ba67e6ca2998e82eb23abf5c431bdf9a92e966ea Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:50 2023 -0700 api for sub commit 9e4f98569898985ed285d8bb8a39b4ea5f095a98 Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:30 2023 -0700 publish, benchmark commit cb470d44df2fed94ad8fd370b1c281cb126d373b Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 1 00:36:51 2023 -0700 can pub and sub commit 1eb2da46d5d5a52c1012aa19ef31c1c8ed568d9e Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:02:12 2023 -0700 connect and publish commit 504ae8383ac3a0838d31d04b31623872b5734b31 Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:01:25 2023 -0700 protoc version commit dbcba75271a4617b5931c4779ca0f7c924369a8f Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:59:04 2023 -0700 rename to lookup commit c9caf3311995290c36ed369b48fbbab23d6bc7b5 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:33:46 2023 -0700 move functions commit 4d6c18d86f07ee35625f207c94539727944a8776 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 17:50:59 2023 -0700 pub sub initial tests commit 4eb8e8624d8280d8aa4a227afc06bcacbfe732a7 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:14:39 2023 -0700 rename commit 19904566706e9dba502f1ffd1f6fdf0bf876e99c Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:13:14 2023 -0700 sub commit 905911853dd5103496e8fc9b47934fa3a48da214 Author: chrislu <chris.lu@gmail.com> Date: Sat Aug 26 13:39:21 2023 -0700 adjust proto
2023-09-17 06:06:16 +08:00
func (lm *LockManager) InsertLock(path string, expiredAtNs int64, token string, owner string) {
2024-02-05 01:20:21 +08:00
lm.accessLock.Lock()
defer lm.accessLock.Unlock()
lm.locks[path] = &Lock{Token: token, ExpiredAtNs: expiredAtNs, Owner: owner}
Squashed commit of the following: commit 482742514656e9b5a652acf7406740fbc55db13d Author: chrislu <chris.lu@gmail.com> Date: Sat Sep 16 15:05:38 2023 -0700 balancer works commit 3b50139f68d5f59961113cf8fd0b903a7294a6ca Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:22:32 2023 -0700 comments commit 7f685ce7ba8853775e7c02c5b5c242d7920d62d3 Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:20:05 2023 -0700 adjust APIs commit 436d99443b399082f75f4ceb7595e8b5ac0a8ba3 Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 14 23:49:05 2023 -0700 receive broker stats commit b771fefa374fe237ff1317bbd03a9297a52191e3 Merge: 0a851ec00 890881037 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 13 00:03:47 2023 -0700 Merge branch 'master' into sub commit 0a851ec00b455c72b405503f6f1f41728b15962e Author: chrislu <chris.lu@gmail.com> Date: Sun Sep 10 22:01:25 2023 -0700 Create balancer.go commit 39941edc0bae3b9a4a2c3344caf494f7ab80a82a Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 7 23:55:19 2023 -0700 add publisher shutdown commit 875f562779f239a140d1008732b5375c0e511e61 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:16:41 2023 -0700 server side send response at least once per second commit 984b6c54cf6b0defaa6e727ab5e36809411fe92c Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:15:29 2023 -0700 ack interval 128 commit 2492a454997a59ffe00405e365290addc460078a Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 22:39:46 2023 -0700 ack interval commit ba67e6ca2998e82eb23abf5c431bdf9a92e966ea Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:50 2023 -0700 api for sub commit 9e4f98569898985ed285d8bb8a39b4ea5f095a98 Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:30 2023 -0700 publish, benchmark commit cb470d44df2fed94ad8fd370b1c281cb126d373b Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 1 00:36:51 2023 -0700 can pub and sub commit 1eb2da46d5d5a52c1012aa19ef31c1c8ed568d9e Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:02:12 2023 -0700 connect and publish commit 504ae8383ac3a0838d31d04b31623872b5734b31 Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:01:25 2023 -0700 protoc version commit dbcba75271a4617b5931c4779ca0f7c924369a8f Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:59:04 2023 -0700 rename to lookup commit c9caf3311995290c36ed369b48fbbab23d6bc7b5 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:33:46 2023 -0700 move functions commit 4d6c18d86f07ee35625f207c94539727944a8776 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 17:50:59 2023 -0700 pub sub initial tests commit 4eb8e8624d8280d8aa4a227afc06bcacbfe732a7 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:14:39 2023 -0700 rename commit 19904566706e9dba502f1ffd1f6fdf0bf876e99c Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:13:14 2023 -0700 sub commit 905911853dd5103496e8fc9b47934fa3a48da214 Author: chrislu <chris.lu@gmail.com> Date: Sat Aug 26 13:39:21 2023 -0700 adjust proto
2023-09-17 06:06:16 +08:00
}
func (lm *LockManager) GetLockOwner(key string) (owner string, err error) {
2024-02-05 01:20:21 +08:00
lm.accessLock.RLock()
defer lm.accessLock.RUnlock()
if lock, found := lm.locks[key]; found {
2024-01-30 14:46:23 +08:00
return lock.Owner, nil
}
err = LockNotFound
Squashed commit of the following: commit 482742514656e9b5a652acf7406740fbc55db13d Author: chrislu <chris.lu@gmail.com> Date: Sat Sep 16 15:05:38 2023 -0700 balancer works commit 3b50139f68d5f59961113cf8fd0b903a7294a6ca Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:22:32 2023 -0700 comments commit 7f685ce7ba8853775e7c02c5b5c242d7920d62d3 Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 15 22:20:05 2023 -0700 adjust APIs commit 436d99443b399082f75f4ceb7595e8b5ac0a8ba3 Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 14 23:49:05 2023 -0700 receive broker stats commit b771fefa374fe237ff1317bbd03a9297a52191e3 Merge: 0a851ec00 890881037 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 13 00:03:47 2023 -0700 Merge branch 'master' into sub commit 0a851ec00b455c72b405503f6f1f41728b15962e Author: chrislu <chris.lu@gmail.com> Date: Sun Sep 10 22:01:25 2023 -0700 Create balancer.go commit 39941edc0bae3b9a4a2c3344caf494f7ab80a82a Author: chrislu <chris.lu@gmail.com> Date: Thu Sep 7 23:55:19 2023 -0700 add publisher shutdown commit 875f562779f239a140d1008732b5375c0e511e61 Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:16:41 2023 -0700 server side send response at least once per second commit 984b6c54cf6b0defaa6e727ab5e36809411fe92c Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 23:15:29 2023 -0700 ack interval 128 commit 2492a454997a59ffe00405e365290addc460078a Author: chrislu <chris.lu@gmail.com> Date: Wed Sep 6 22:39:46 2023 -0700 ack interval commit ba67e6ca2998e82eb23abf5c431bdf9a92e966ea Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:50 2023 -0700 api for sub commit 9e4f98569898985ed285d8bb8a39b4ea5f095a98 Author: chrislu <chris.lu@gmail.com> Date: Mon Sep 4 21:43:30 2023 -0700 publish, benchmark commit cb470d44df2fed94ad8fd370b1c281cb126d373b Author: chrislu <chris.lu@gmail.com> Date: Fri Sep 1 00:36:51 2023 -0700 can pub and sub commit 1eb2da46d5d5a52c1012aa19ef31c1c8ed568d9e Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:02:12 2023 -0700 connect and publish commit 504ae8383ac3a0838d31d04b31623872b5734b31 Author: chrislu <chris.lu@gmail.com> Date: Mon Aug 28 09:01:25 2023 -0700 protoc version commit dbcba75271a4617b5931c4779ca0f7c924369a8f Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:59:04 2023 -0700 rename to lookup commit c9caf3311995290c36ed369b48fbbab23d6bc7b5 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 18:33:46 2023 -0700 move functions commit 4d6c18d86f07ee35625f207c94539727944a8776 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 17:50:59 2023 -0700 pub sub initial tests commit 4eb8e8624d8280d8aa4a227afc06bcacbfe732a7 Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:14:39 2023 -0700 rename commit 19904566706e9dba502f1ffd1f6fdf0bf876e99c Author: chrislu <chris.lu@gmail.com> Date: Sun Aug 27 13:13:14 2023 -0700 sub commit 905911853dd5103496e8fc9b47934fa3a48da214 Author: chrislu <chris.lu@gmail.com> Date: Sat Aug 26 13:39:21 2023 -0700 adjust proto
2023-09-17 06:06:16 +08:00
return
2023-06-26 05:14:40 +08:00
}