Fixes JIRA issue SGF-304 changing the GroupMembersFunctionExecution class to call the correct GemFire com.gemstone.gemfire.cache.execute.FunctionService method, onMembers(groups:String[]) (plural). Performed additional refactoring in related classes.

This commit is contained in:
John Blum
2014-08-11 16:21:58 -07:00
parent 0e3b8885d4
commit 324b25e5cf
4 changed files with 52 additions and 30 deletions

View File

@@ -16,9 +16,9 @@ package org.springframework.data.gemfire.function.execution;
import com.gemstone.gemfire.distributed.DistributedMember;
/**
*
* @author David Turanski
*
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionTemplate
* @see com.gemstone.gemfire.distributed.DistributedMember
*/
public class GemfireOnMemberFunctionTemplate extends AbstractFunctionTemplate {
@@ -46,8 +46,9 @@ public class GemfireOnMemberFunctionTemplate extends AbstractFunctionTemplate {
return new DefaultMemberFunctionExecution();
} else if (distributedMember == null) {
return new GroupMemberFunctionExecution(this.groups);
}
}
return new DistributedMemberFunctionExecution(this.distributedMember);
}
}

View File

@@ -18,36 +18,36 @@ import com.gemstone.gemfire.distributed.DistributedMember;
/**
* @author David Turanski
*
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionTemplate
* @see com.gemstone.gemfire.distributed.DistributedMember
*/
public class GemfireOnMembersFunctionTemplate extends AbstractFunctionTemplate {
private final Set<DistributedMember> distributedMembers;
private final String[] groups;
public GemfireOnMembersFunctionTemplate (Set<DistributedMember> distributedMembers) {
this.distributedMembers = distributedMembers;
this.groups = null;
}
public GemfireOnMembersFunctionTemplate (String[] groups) {
this.distributedMembers = null;
this.groups = groups;
}
public GemfireOnMembersFunctionTemplate () {
this.distributedMembers = null;
this.groups = null;
}
protected AbstractFunctionExecution getFunctionExecution() {
if (distributedMembers == null && groups == null) {
return new AllMembersFunctionExecution();
} else if (distributedMembers == null) {
return new GroupMembersFunctionExecution(this.groups);
}
}
return new DistributedMembersFunctionExecution(this.distributedMembers);
}

View File

@@ -19,22 +19,33 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
/**
* @author David Turanski
*
* @author John Blum
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionExecution
* @see com.gemstone.gemfire.cache.execute.Execution
* @see com.gemstone.gemfire.cache.execute.FunctionService
*/
class GroupMemberFunctionExecution extends AbstractFunctionExecution {
private final String groups[];
private final String[] groups;
/**
*
* @param groups
* Constructs an instance of the GroupMemberFunctionExecution class to execute a data independent Function
* on a single member from each of the specified groups.
*
* @param groups the list of GemFire Groups from which to pick a member from each group on which to execute
* the data independent Function.
*/
public GroupMemberFunctionExecution(String... groups) {
super();
Assert.notEmpty(groups, "groups cannot be null or empty.");
public GroupMemberFunctionExecution(final String... groups) {
Assert.notEmpty(groups, "'groups' cannot be null or empty.");
this.groups = groups;
}
/**
* Executes the data independent Function on a single member from each of the specified groups.
*
* @return an Execution to execute the Function.
* @see com.gemstone.gemfire.cache.execute.FunctionService#onMember(String...)
*/
@Override
protected Execution getExecution() {
return FunctionService.onMember(this.groups);

View File

@@ -19,25 +19,35 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
/**
* @author David Turanski
*
* @author John Blum
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionExecution
* @see com.gemstone.gemfire.cache.execute.Execution
* @see com.gemstone.gemfire.cache.execute.FunctionService
*/
class GroupMembersFunctionExecution extends AbstractFunctionExecution {
private final String groups[];
private final String[] groups;
/**
*
* @param groups
* Constructs an instance of the GroupMembersFunctionExecution class to execute a data independent Function
* on all members from each of the specified groups.
*
* @param groups the list of GemFire Groups indicating the members on which to execute the data independent Function.
*/
public GroupMembersFunctionExecution(String... groups) {
super();
Assert.notEmpty(groups, "groups cannot be null or empty.");
public GroupMembersFunctionExecution(final String... groups) {
Assert.notEmpty(groups, "'groups' cannot be null or empty.");
this.groups = groups;
}
/**
* Executes the data independent Function on all members from each of the specified groups.
*
* @return an Execution to execute the Function.
* @see com.gemstone.gemfire.cache.execute.FunctionService#onMembers(String...)
*/
@Override
protected Execution getExecution() {
return FunctionService.onMember(this.groups);
return FunctionService.onMembers(this.groups);
}
}