mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-10 00:07:44 +02:00
support multiple locks
This commit is contained in:
1 parent
bf86e38f9a
commit
d4235afe4d
5 files changed
+234
-166
No files matched your search
@@ -14,6 +14,7 @@ const (
|
||||
RenewInteval = 4 * time.Second
|
||||
SafeRenewInteval = 3 * time.Second
|
||||
InitLockInteval = 1 * time.Second
|
||||
AdminLockName = "admin"
|
||||
)
|
||||
|
||||
type ExclusiveLocker struct {
|
||||
@@ -44,6 +45,7 @@ func (l *ExclusiveLocker) RequestLock() {
|
||||
resp, err := client.LeaseAdminToken(context.Background(), &master_pb.LeaseAdminTokenRequest{
|
||||
PreviousToken: atomic.LoadInt64(&l.token),
|
||||
PreviousLockTime: atomic.LoadInt64(&l.lockTsNs),
|
||||
LockName: AdminLockName,
|
||||
})
|
||||
if err == nil {
|
||||
atomic.StoreInt64(&l.token, resp.Token)
|
||||
@@ -67,6 +69,7 @@ func (l *ExclusiveLocker) RequestLock() {
|
||||
resp, err := client.LeaseAdminToken(context.Background(), &master_pb.LeaseAdminTokenRequest{
|
||||
PreviousToken: atomic.LoadInt64(&l.token),
|
||||
PreviousLockTime: atomic.LoadInt64(&l.lockTsNs),
|
||||
LockName: AdminLockName,
|
||||
})
|
||||
if err == nil {
|
||||
atomic.StoreInt64(&l.token, resp.Token)
|
||||
@@ -92,6 +95,7 @@ func (l *ExclusiveLocker) ReleaseLock() {
|
||||
client.ReleaseAdminToken(context.Background(), &master_pb.ReleaseAdminTokenRequest{
|
||||
PreviousToken: atomic.LoadInt64(&l.token),
|
||||
PreviousLockTime: atomic.LoadInt64(&l.lockTsNs),
|
||||
LockName: AdminLockName,
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user