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

Ask Your Question
0

gigaSpace.getClustered() question

Hi, I have in pu.xml: <os-core:space id="space" url="/./mySpace?NOWriteLease=true"> .... <os-core:giga-space id="gigaSpace" space="space" tx-manager="transactionManager"/> Then in my class: @GigaSpaceContext(name = "gigaSpace") public static GigaSpace gigaSpace;

In an environment with 2 partitions I want to be notified in both of them when an POJO is written in either of them. For this I use:

EventSessionFactory factory = EventSessionFactory.getFactory(gigaSpace.getClustered().getSpace()); EventSessionConfig config = new EventSessionConfig(); session = factory.newDataEventSession(config, null); template = new MyObject(); eventRegistration = session.addListener(template, new net.jini.core.event.RemoteEventListener() { ..... }, Lease.FOREVER, null, null, NotifyActionType.NOTIFY_WRITE);

Do i use this correctly? Shouldn't I get notified in each partition when a MyObject is written to space? I was notified only once...just in the partition where myObject was written I suppose. This happened with both partitions deployed in the same container (single VM, a test environement).

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=3646]{quote}

asked 2011-04-21 04:03:13 -0500

lukeh 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
0

Here is what you should have:

<os-core:space id="space" url="/./mySpace?NOWriteLease=true">
<os-core:giga-space id="gigaSpace" space="space" tx-manager="transactionManager"/>
<os-core:space id="clusteredspace" url="jini://*/*/mySpace?NOWriteLease=true">
<os-core:giga-space id="clusteredgigaSpace" space="clusteredspace" />

in your class:

@GigaSpaceContext(name = "gigaSpace")
public GigaSpace gigaSpace;
@GigaSpaceContext(name = "clusteredgigaSpace")
public GigaSpace clusteredgigaSpace;

You should avoid using static variables.
by default a space proxy to a colocated space is non-clustered and interact only with the colocated space.
by default a space proxy to a remote space is clustered and span all partitions.

Shay

answered 2011-04-21 04:09:03 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

Thanks Shay,

I understand what you are saying about defining the clustered space in pu.xml.

Just out of curiosity: The way I tried is incorrect? Why? Maybe you explained in the last part but maybe is because my English and I don't get it. Should have worked as I did it with partitions not collocated, but with collocated it shouldn't work?

lukeh gravatar imagelukeh ( 2011-04-21 04:34:37 -0500 )edit

We do not recommend converting a non-clustered proxy into a clustered proxy via the API as you have done.
You should inject it as I have demonstrated.

Shay

shay hassidim gravatar imageshay hassidim ( 2011-04-21 04:40:06 -0500 )edit

I see. Can you please give me an example of what getClustered() is useful and reliable to help me better understand it?

lukeh gravatar imagelukeh ( 2011-04-21 04:49:01 -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: 2011-04-21 04:03:13 -0500

Seen: 272 times

Last updated: Apr 21 '11