Pivotal Knowledge Base


How to Execute Function on All the Members Hosting a Partitioned Region


Multiple members hosting the same Partitioned region


A function invoked to run on "all members" hosting a given Partitioned region, may only be executed on a subset of the members.


GemFire determines the number of members hosting a Partitioned region on which to execute a Function automatically based on the return value of the optimizeForWrite() method of Function object.

If optimizeForWrite() returns false (i.e. optimize for read), GemFire executes the function on the least number of members hosting the region needed to access all data entries. For example, if you have a Partitioned region spanning two members with redundant-copies="0" (i.e. no redundant copies), then each data entry is exclusively stored on a single member. In this case, the GemFire Function has to be executed on both members, since this would be required for local access to all entries. On the other hand, if you have two members and create the Partitioned region with redundant-copies="1" (i.e. 1 redundant copy), then each entry exists on both members (one as a primary, other as a redundant copy). Hence, the GemFire Function will be executed on just one of the members because each member has all the entries (including primaries and redundant copies). Hence, it is enough to execute the function on only one of the members.

However, if optimizeForWrite() returns true (i.e. optimize for write), the GemFire Function is executed on all members hosting Partitioned region that store the primary data in order to update all entries.  


Whether or not you actually intend to write, in order to guarantee execution of all the members, you must implement the optimizeForWrite() method of your Function object to return "true", e.g.:

public boolean optimizeForWrite() {
    return true;


Powered by Zendesk