Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

How to know number of partitions

Hi ! Is there a way of knowing in runtime the number of partition a space have ? I need something similar to this http://www.gigaspaces.com/wiki/displa... but only that I'm not doing that on initial load. I need one of this: 1) From a remote space, knowing how many partitions are there 2) From collocated space, knowing the total partitions and which partition am I. Thanks !

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3098]{quote}

asked 2009-05-21 14:06:04 -0500

pruggia gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

1. Here is a cool way to do that:

public class NumberPartitionsTask implements DistributedTask<Integer, Long> {
  public Integer execute() throws Exception {     return 1;   }
  public Long reduce(List<AsyncResult<Integer>> results) throws Exception {
    long sum = 0;
    for (AsyncResult<Integer> result : results) {
      if (result.getException() != null) {
        throw result.getException();
      sum += result.getResult();
    return sum;

Client code

AsyncFuture<Long> future = gigaSpace.execute(new NumberPartitionsTask ());
long result = future.get(); // result will be the number of partitions

Another way would be to use the Admin API.

2. Use the @ClusterInfoContext:

public class DataProcessorService {
    public ClusterInfo clusteinfo;


answered 2009-05-21 14:17:39 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2009-05-21 14:06:04 -0500

Seen: 101 times

Last updated: May 21 '09