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

Ask Your Question
0

how distinguish backup from primary

I'm working with the example code from

http://wiki.gigaspaces.com/wiki/displ...

specifically, the section titled "Restart a running PU via the Admin API".

The code snippet is:

if( puInstances[i].getSpaceInstance().getMode() == SpaceMode.BACKUP ) {

 restartPUInstance(puInstances[i]);

}

Unfortunately, the "getMode()" method is returning neither SpaceMode.BACKUP

nor SpaceMode.PRIMARY.

How can I identify which PU instance is primary and which is backup?

Thank you.

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

asked 2013-05-22 15:37:17 -0500

smitty3 gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
0

Try this: before calling the pi.getSpaceInstance().getMode() have 5 seconds sleep.

answered 2013-05-22 15:43:01 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

or use this:

final String instStr = pi.waitForSpaceInstance(5, TimeUnit.SECONDS) .getMode() != SpaceMode.PRIMARY?"backup" : "primary";

Shay

shay hassidim gravatar imageshay hassidim ( 2013-05-22 15:53:42 -0500 )edit
0

I tried the "waitForSpaceInstance(5,TimeUnit.SECONDS)".

It didn't help. I get the same result.

answered 2013-05-22 16:32:12 -0500

smitty3 gravatar image
edit flag offensive delete link more

Comments

What's the space schema you are using?

shay hassidim gravatar imageshay hassidim ( 2013-05-22 16:38:28 -0500 )edit
0

Sit in a loop and wait until the mode changes from NONE. A functioning space instance will either be PRIMARY or BACKUP (even when running non-partitioned). Not sure why it takes awhile.

answered 2013-05-22 22:52:28 -0500

edit flag offensive delete link more
0

I played around a little more. I added a hard 5-second sleep before the "getMode()" and that gives me the result I was expecting. (I think this was your first suggestion.).

This leads me to ponder, how would I know that 5 seconds is a sufficient time interval?

In any case, thank you for your help.

answered 2013-05-22 17:20:41 -0500

smitty3 gravatar image
edit flag offensive delete link more

Comments

I was guessing :-)

For now have a loop that will repeat itself in case the getMode() does not return a value with a sleep before repeating the loop.
I will research this internally and get back to you.

shay hassidim gravatar imageshay hassidim ( 2013-05-22 17:37:04 -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-05-22 15:37:17 -0500

Seen: 123 times

Last updated: May 22 '13