[
https://issues.apache.org/jira/browse/GEODE-5288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16508428#comment-16508428
]
ASF subversion and git services commented on GEODE-5288:
--------------------------------------------------------
Commit 48539ed423c33139770464742255ea6f6302b87f in geode's branch
refs/heads/develop from [~jinmeiliao]
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=48539ed ]
GEODE-5288: improve ResultModel assertions. Fix test
> Execute function on region should not iterate through all the servers hosting
> the region.
> ------------------------------------------------------------------------------------------
>
> Key: GEODE-5288
> URL: https://issues.apache.org/jira/browse/GEODE-5288
> Project: Geode
> Issue Type: Bug
> Components: gfsh
> Reporter: Jinmei Liao
> Assignee: Jinmei Liao
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> Currently, if we 3 servers hosting a partitioned region "regionA", and we
> execute the following command where the genericFunctionId is just printing
> out the id of the function once:
> gfsh> execute function --id=genericFunctionId --region=/regionA:
> Member | Status | Message
> -------- | ------ | ---------------------------------------------------------
> server-1 | OK | [genericFunctionId, genericFunctionId, genericFunctionId]
> server-2 | OK | [genericFunctionId, genericFunctionId, genericFunctionId]
> server-3 | OK | [genericFunctionId, genericFunctionId, genericFunctionId]
>
> we are executing on all 3 servers, and each server would then execute the
> function 3 times, so we are executing the function for a total of 9 times
> which is not correct. (we should only be executing it 3 times all together).
> {code}
> // test set up:
> locator = cluster.startLocatorVM(0);
> server1 = cluster.startServerVM(1, "group1", locator.getPort());
> server2 = cluster.startServerVM(2, "group1", locator.getPort());
> server3 = cluster.startServerVM(3, "group2", locator.getPort());
> gfsh.connectAndVerify(locator);
> // register the function on all members
> MemberVM.invokeInEveryMember(()->{
> FunctionService.registerFunction(new GenericFunctionOp(functionId));
> }, server1, server2, server3);
> // create a partitioned region on only group1
> gfsh.executeAndAssertThat("create region --name=regionA
> --type=PARTITION").statusIsSuccess().tableHasRowCount("Member",
> 3).tableHasColumnWithExactValuesInAnyOrder("Member", "server-1", "server-2",
> "server-3");
>
> // function body
> public static class GenericFunctionOp implements Function {
> private String functionId;
> GenericFunctionOp(String functionId) {
> this.functionId = functionId;
> }
> @Override
> public void execute(FunctionContext context) {
> String filter = null;
> if(context instanceof RegionFunctionContext) {
> RegionFunctionContext rContext = (RegionFunctionContext) context;
> Set filters = rContext.getFilter();
> filter = Strings.join(filters, ',');
> }
> String argument = null;
> Object arguments = (context.getArguments());
> if (arguments instanceof String[]) {
> argument = String.join(",", (String[]) arguments);
> }
> if(filter !=null && argument != null){
> context.getResultSender().lastResult(functionId + "-" + filter + "-"
> +argument);
> }
> else if (filter != null) {
> context.getResultSender().lastResult(functionId + "-" + filter);
> }
> else if (argument != null) {
> context.getResultSender().lastResult(functionId + "-" + argument);
> }
> else{
> context.getResultSender().lastResult(functionId);
> }
> }
> public String getId() {
> return functionId;
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)