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
feature: Expose API to let client define number of expected values in a Get. #6655
Merged
bulldozer-bot
merged 46 commits into
develop
from
lmeireles/expose-get-with-expected-size
Aug 30, 2023
Merged
Changes from 32 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
6c2aa5f
Expose API to let client define number of expected values
LucasIME 99f2125
Add generated changelog entries
svc-changelog 7e76c60
accept revapi change
LucasIME e3224bd
T -> Timestamp
LucasIME 8d5320d
Extract validation to private method and unsafe log the cells
LucasIME d3afa8d
fix documentation typo
LucasIME 37ac526
Add cache test
LucasIME b557bc7
fix test
LucasIME 90477bd
test for not reducing
LucasIME ffaa25c
description
LucasIME 648e54e
Add methods with cachedLookupRef to TransactionScopedCache gets
LucasIME f273357
Add test verifying we don't decrease number of expected cells if cach…
LucasIME 773e1ad
verify no lock is ever called
LucasIME 34c0b25
Merge branch 'develop' into lmeireles/expose-get-with-expected-size
LucasIME 0a13148
rev api
LucasIME d54908e
catch interrupted properly
LucasIME 3d913ff
skip lock check and not lock
LucasIME 797e635
fix test description
LucasIME 2926f79
Array equals instead of !=
LucasIME e8c08c7
testing all fetched cached
LucasIME f48fd14
Extract validor to separate class
LucasIME 89cb066
update expected exception class
LucasIME bf5b271
Add test to verify we throw if we have cached more values than we expect
LucasIME 2739a48
Restrict dangerous API usage
LucasIME 918ead8
rename validator
LucasIME 6a1426f
Treat interrupted and execution exceptions differently.
LucasIME 2ab80f9
Make MoreCellsPresentThanExpectedException SafeLoggable
LucasIME a42100a
assert args in exception
LucasIME f91d0ba
cell count validator tests
LucasIME 8f0a05d
add test to verify we don't filter down the cells we pass to the cell…
LucasIME e147c14
import
LucasIME 9d61cc7
spotless
LucasIME b2292ce
fix test style
LucasIME 82da62a
Changing getWithExpectedSize to return a Result type (#6686)
LucasIME ad4d984
Merge branch 'develop' into lmeireles/expose-get-with-expected-size
LucasIME 3227916
rev api
LucasIME 806abe0
Autorelease 0.908.0-rc1
LucasIME b8d981f
store number of expected cells on exception too
LucasIME 9e25ffa
Autorelease 0.908.0-rc2
LucasIME 11951f1
Merge branch 'develop' into lmeireles/expose-get-with-expected-size
LucasIME f1912e1
fix ambiguous reference
LucasIME f11d972
don't count deleted local writes as expected cells
LucasIME 1f68638
Merge branch 'develop' into lmeireles/expose-get-with-expected-size
LucasIME cad58d2
Autorelease 0.919.0-rc1
LucasIME b3f7284
Autorelease 0.919.0-rc2
LucasIME 86831da
missing space
LucasIME File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
23 changes: 23 additions & 0 deletions
23
...ain/java/com/palantir/atlasdb/transaction/api/annotations/ReviewedRestrictedApiUsage.java
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,23 @@ | ||
/* | ||
* (c) Copyright 2023 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.atlasdb.transaction.api.annotations; | ||
|
||
/** | ||
* Annotation to be used to indicate that usage of a restricted method is intentional and all the nuances about it | ||
* are understood. | ||
*/ | ||
public @interface ReviewedRestrictedApiUsage {} |
67 changes: 67 additions & 0 deletions
67
...om/palantir/atlasdb/transaction/api/exceptions/MoreCellsPresentThanExpectedException.java
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,67 @@ | ||
/* | ||
* (c) Copyright 2023 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.atlasdb.transaction.api.exceptions; | ||
|
||
import com.palantir.atlasdb.keyvalue.api.Cell; | ||
import com.palantir.logsafe.Arg; | ||
import com.palantir.logsafe.Safe; | ||
import com.palantir.logsafe.SafeArg; | ||
import com.palantir.logsafe.SafeLoggable; | ||
import com.palantir.logsafe.Unsafe; | ||
import com.palantir.logsafe.UnsafeArg; | ||
import com.palantir.logsafe.exceptions.SafeExceptions; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public final class MoreCellsPresentThanExpectedException extends IllegalStateException implements SafeLoggable { | ||
|
||
private static final String MESSAGE = | ||
"KeyValueService returned more results than Get expected. This means there is a bug" | ||
+ "either in the SnapshotTransaction implementation or in how the client is " | ||
LucasIME marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ "using such method."; | ||
private final List<Arg<?>> arguments; | ||
private final Map<Cell, byte[]> fetchedCells; | ||
|
||
public MoreCellsPresentThanExpectedException(Map<Cell, byte[]> fetchedCells, long expectedNumberOfCells) { | ||
super(SafeExceptions.renderMessage( | ||
MESSAGE, argsFrom(fetchedCells, expectedNumberOfCells).toArray(Arg<?>[]::new))); | ||
this.fetchedCells = fetchedCells; | ||
this.arguments = argsFrom(fetchedCells, expectedNumberOfCells); | ||
} | ||
|
||
public Map<Cell, byte[]> getFetchedCells() { | ||
return fetchedCells; | ||
} | ||
|
||
@Override | ||
public @Safe String getLogMessage() { | ||
return MESSAGE; | ||
} | ||
|
||
@Override | ||
public List<Arg<?>> getArgs() { | ||
return arguments; | ||
} | ||
|
||
@Unsafe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to the SafeLoggingPropagation check. Otherwise we fail to compile with the following message:
|
||
private static List<Arg<?>> argsFrom(Map<Cell, byte[]> retrievedCells, long expectedNumberOfCells) { | ||
return List.of( | ||
SafeArg.of("expectedNumberOfCells", expectedNumberOfCells), | ||
SafeArg.of("numberOfCellsRetrieved", retrievedCells.size()), | ||
UnsafeArg.of("retrievedCells", retrievedCells)); | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have also just replaced the existing
get
andgetAsync
to receive theCacheLookupResult
instead of creating new two separate methods. Let me know what you prefer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How bad would this change have been? Basically I think it's nicer to just have one get/getAsync, but I understand refactoring this might be very difficult/costly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very, tbh. Although this PR is already getting quite big, so I'll try to do the refactor in a separate one.