This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new getLockState() debugging endpoint (#5302)
- Loading branch information
Showing
16 changed files
with
264 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type: improvement | ||
improvement: | ||
description: Add new getLockState(LockDescriptor) debugging endpoint to the RemoteLockService, which allows for easier, more targeted debugging than would be possible with previous logCurrentState() endpoint. Provide a LockDescriptor, and get the current set of clients holding and waiting for the lock. | ||
links: | ||
- https://github.com/palantir/atlasdb/pull/5302 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* (c) Copyright 2021 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.palantir.lock; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
@JsonSerialize(as = ImmutableLockState.class) | ||
@JsonDeserialize(as = ImmutableLockState.class) | ||
public interface LockState { | ||
boolean isWriteLocked(); | ||
|
||
boolean isFrozen(); | ||
|
||
List<LockClient> exactCurrentLockHolders(); | ||
|
||
List<LockHolder> holders(); | ||
|
||
List<LockRequester> requesters(); | ||
|
||
@Value.Immutable | ||
@JsonSerialize(as = ImmutableLockHolder.class) | ||
@JsonDeserialize(as = ImmutableLockHolder.class) | ||
interface LockHolder { | ||
static LockHolder from(HeldLocksToken lock) { | ||
return ImmutableLockHolder.builder() | ||
.client(lock.getClient()) | ||
.creationDateMs(lock.getCreationDateMs()) | ||
.expirationDateMs(lock.getExpirationDateMs()) | ||
.numOtherLocksHeld(lock.getLocks().size() - 1) | ||
.versionId(Optional.ofNullable(lock.getVersionId())) | ||
.requestingThread(lock.getRequestingThread()) | ||
.build(); | ||
} | ||
|
||
LockClient client(); | ||
|
||
long creationDateMs(); | ||
|
||
long expirationDateMs(); | ||
|
||
int numOtherLocksHeld(); | ||
|
||
Optional<Long> versionId(); | ||
|
||
String requestingThread(); | ||
} | ||
|
||
@Value.Immutable | ||
@JsonSerialize(as = ImmutableLockRequester.class) | ||
@JsonDeserialize(as = ImmutableLockRequester.class) | ||
interface LockRequester { | ||
static ImmutableLockRequester from(LockRequest request, LockClient client) { | ||
return ImmutableLockRequester.builder() | ||
.client(client) | ||
.lockGroupBehavior(request.getLockGroupBehavior()) | ||
.blockingMode(request.getBlockingMode()) | ||
.blockingDuration(Optional.ofNullable(request.getBlockingDuration())) | ||
.versionId(Optional.ofNullable(request.getVersionId())) | ||
.requestingThread(request.getCreatingThreadName()) | ||
.build(); | ||
} | ||
|
||
LockClient client(); | ||
|
||
LockGroupBehavior lockGroupBehavior(); | ||
|
||
BlockingMode blockingMode(); | ||
|
||
Optional<TimeDuration> blockingDuration(); | ||
|
||
Optional<Long> versionId(); | ||
|
||
String requestingThread(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.