You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Jens Deppe (JIRA)" <ji...@apache.org> on 2019/03/29 15:20:00 UTC

[jira] [Resolved] (GEODE-5288) Execute function on region should not iterate through all the servers hosting the region.

     [ https://issues.apache.org/jira/browse/GEODE-5288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jens Deppe resolved GEODE-5288.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 1.8.0

> 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
>             Fix For: 1.8.0
>
>          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)