New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GEODE-2999: Add PutIfAbsent to the Protobuf protocol. #1578
GEODE-2999: Add PutIfAbsent to the Protobuf protocol. #1578
Conversation
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.
Should putIfAbsent return the existing value, like the server side API? Or should we call this operation create instead, which is a server side API that does this same thing but doesn't return the existing value.
@@ -86,6 +85,9 @@ private Result processOperation(ClientProtocol.Message request, MessageExecution | |||
logger.error(exception); | |||
return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST, | |||
"Invalid execution context found for operation."); | |||
} catch (UnsupportedOperationException ex) { | |||
return Failure.of(BasicTypes.ErrorCode.UNSUPPORTED_OPERATION, | |||
"Unsupported operation. This may be due to a region type that does not support that operation."); |
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.
Can we return the message of the underlying exception to the user, maybe? I suspect a lot of UnsupportedOperationExceptions are not thrown from Region. Also, we should still log the stack trace I think. Otherwise we may never be able to track down what method actually threw UnsupportedOperation.
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.
Good idea, done.
public static ResourcePermission determineRequiredPermission(RegionAPI.PutIfAbsentRequest request, | ||
ProtobufSerializationService serializer) throws DecodingException { | ||
return new ResourcePermission(ResourcePermission.Resource.DATA, | ||
ResourcePermission.Operation.READ, request.getRegionName(), |
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.
This should be a WRITE permission.
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.
oh, thanks. Good catch.
* @return Request object containing the passed params. | ||
*/ | ||
public static ClientProtocol.Message createPutIfAbsentRequest(String region, | ||
BasicTypes.Entry entry) { |
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.
Why do these utilities exist in the src side? I would think this would only be useful for testing?
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 had meant to put this in MessageUtil
. My bad.
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.
Oh, I misread this. I had thought I'd put the method in the wrong place but in fact this class is only used for tests. I'll move it over.
@upthewaterspout I think you're right about using |
bf2cf14
to
fc30b12
Compare
@upthewaterspout / @WireBaron Can you re-review this, please? |
* Some test cleanup * Add it to the experimental protobuf client driver
fc30b12
to
7dcb732
Compare
rebased on develop. |
This reverts commit 6214a43. Hopefully this fixes CI and can be pushed after.
* Some test cleanup * Add it to the experimental protobuf client driver
Thank you for submitting a contribution to Apache Geode.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
Has your PR been rebased against the latest commit within the target branch (typically
develop
)?Is your initial contribution a single, squashed commit?
Does
gradlew build
run cleanly?Have you written or updated unit tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.