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-3643: Add function execution on specific member #1409
Conversation
This implements function execution onMember and onMembers. Members are identified by their names - see ConfigurationProperties.NAME.
@Override | ||
public DistributedMember getMemberWithName(String name) { | ||
for (DistributedMember id : members.values()) { | ||
if (id.getName() != null && id.getName().equals(name)) { |
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.
Could Objects.equals()
be of use here?
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 second Sarge's suggestion.
} | ||
|
||
@Test | ||
public void noopTest() { |
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.
Is noopTest()
needed?
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.
Looks good, just had a couple of minor improvements.
@@ -59,7 +61,7 @@ | |||
import org.apache.geode.test.junit.categories.IntegrationTest; | |||
|
|||
@Category(IntegrationTest.class) | |||
public class FunctionExecutionIntegrationTest { | |||
public class ExecutFunctionOnRegionIntegrationTest { |
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.
s/Execut/Execute
@Override | ||
public DistributedMember getMemberWithName(String name) { | ||
for (DistributedMember id : members.values()) { | ||
if (id.getName() != null && id.getName().equals(name)) { |
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 second Sarge's suggestion.
|
||
try { | ||
Execution execution; | ||
if (memberIds.size() == 1) { |
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 we need to check this rather than just passing an iterator with one member?
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 don't understand this comment. The FunctionService API has two onMember methods, neither of which takes an iterator as an argument.
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 actually tried making the OnRegion integration test parameterized so it could test both onRegion and OnMember but there were too many places that required specific request/response objects.
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'd misread the call. I think we can do the same call to onMembers
with a Set of size 1. Under the hood, it ends up resolving to the same call, and should have to for sanity.
@@ -59,7 +61,7 @@ | |||
import org.apache.geode.test.junit.categories.IntegrationTest; | |||
|
|||
@Category(IntegrationTest.class) | |||
public class FunctionExecutionIntegrationTest { | |||
public class ExecutFunctionOnRegionIntegrationTest { |
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.
Typo
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 was copied from the other integration test, though X-)
final String functionID = request.getFunctionID(); | ||
ProtocolStringList memberNameList = request.getMemberNameList(); | ||
|
||
final Function<?> function = FunctionService.getFunction(functionID); |
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 avoid copying and pasting code from the on region function here? Maybe a utility or something like that?
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.
@upthewaterspout, the code looks very similar but the request and response objects are different classes, making it difficult to extract much of anything into a helper class. If you have some ideas maybe we could work on that together.
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.
Looks good.
I think we could use one more test for a message with no members listed (though the code handles this fine)
fixups from review comments
fixing a dumb test failure
This implements function execution onMember and onMembers. Members are
identified by their names - see ConfigurationProperties.NAME.
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.