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

Ask Your Question
0

Accessing local partition member

Hi,

I have a client application which accesses a remote clustered partitioned space. The client app runs on the same machine as one of the partition members. How can I access the exact partition member that is running on the same machine as my client app?

asked 2013-11-14 15:12:04 -0500

dncheu1 gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

When routing a task you should provide a value that will be used to calculate the partition that will be executing it.

GiagSpace.execute ( Task , Routing Value)

If the Routing Value will be equal to the partition number the task will be routed to the relevant partition.

The partition number equals to the partition ID you can get from the admin API minus 1.

Space space = admin.getSpaces().waitFor(spaceName, 10 , TimeUnit.SECONDS);

SpacePartition spacePartitions[] = space.getPartitions();

for (int i = 0; i < spacePartitions.length; i++) {

  ....

   gigaspace.execute ( Task , partition.getPartitionId() - 1)

  ....
}

See example how you can use the admin API to get access to space partitions: http://wiki.gigaspaces.com/wiki/displ...

You should provide enough time for the client to get info about all partitions (async activity internally). That's why the timeout provided is very important.

Shay

answered 2013-11-16 20:48:34 -0500

shay hassidim gravatar image
edit flag offensive delete link more
0

The simplest way would be getting the partition Id using the administration api and executing a Task using the partition id minus one as the routing value.

answered 2013-11-14 15:52:41 -0500

shay hassidim gravatar image

updated 2013-12-06 13:30:38 -0500

edit flag offensive delete link more

Comments

Hi,

Can you elaborate a little more on "executing a Task using partition ID minus one as the routing value"? How does this guarantee that I will be talking to the space member that is located on the same machine?

Also, I'm having some issues with the admin API. My code is:

Admin admin = new AdminFactory().createAdmin(); admin.getGridServiceAgents().waitForAtLeastOne(); System.out.println(admin.getSpaces().getSpaces().length);

Sometimes it prints 0 spaces, and sometimes it prints 1 (there is a space running). I'm just wondering why the results are not consistent.

Thanks!

dncheu1 gravatar imagedncheu1 ( 2013-11-14 16:24:29 -0500 )edit

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

Stats

Asked: 2013-11-14 15:12:04 -0500

Seen: 396 times

Last updated: Dec 06 '13