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

Ask Your Question
0

PostPrimary on notify container on LocalView called multiple times

Hi,

I'm using gigaspaces-xap-premium-9.0.0-ga and have the following schema runing on two GSCs:

cluster-schema="partitioned-sync2backup" number-of-instances="2" number-of-backups="1" max-instances-per-vm="1"

On that space I have a LocalView (defined in pu.xml) and a notify container defined with annotations (@Notify(gigaSpace = "localView", replicateNotifyTemplate = ReplicateNotifyTemplateType.FALSE)) and it also keep an injected reference to the local space.

It's @PostPrimary is called multiple times (the log is merged from both GSCs):

Line 197: 17 Oct 2014 10:47:16,052 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [SpaceModeContextBean]  @@@ 417260240 SPACE MODE BEAN LOADED, SPACE  with 1420327748
Line 204: 17 Oct 2014 10:47:16,077 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [SpaceModeContextBean]  @@@ 139410354 SPACE MODE BEAN LOADED, SPACE with 1884560043
Line 205: 17 Oct 2014 10:47:16,086 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1411466930 with 1420327748
Line 211: 17 Oct 2014 10:47:16,110 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1450593141 with 1884560043
Line 219: 17 Oct 2014 10:47:16,143 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1411466930 with 1420327748
Line 221: 17 Oct 2014 10:47:16,144 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1450593141 with 1884560043
Line 225: 17 Oct 2014 10:47:16,145 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1411466930 with 1420327748
Line 231: 17 Oct 2014 10:47:16,147 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1450593141 with 1884560043
Line 238: 17 Oct 2014 10:47:16,150 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1411466930 with 1420327748
Line 240: 17 Oct 2014 10:47:16,155 EEST INFO  [GS-LRMI Connection-pool-1-thread-1] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1450593141 with 1884560043
Line 307: 17 Oct 2014 10:47:46,893 EEST INFO  [GS-LRMI Connection-pool-1-thread-2] [CancelAllCommand]  @@@CancelAllCommand PostBackup. 1176205158 with 893119871
Line 356: 17 Oct 2014 10:47:47,625 EEST INFO  [GS-LRMI Connection-pool-1-thread-2] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 1176205158 with 893119871
Line 361: 17 Oct 2014 10:47:47,826 EEST INFO  [GS-LRMI Connection-pool-1-thread-2] [CancelAllCommand]  @@@CancelAllCommand PostBackup. 4022921 with 1041240190
Line 381: 17 Oct 2014 10:47:48,242 EEST INFO  [GS-LRMI Connection-pool-1-thread-2] [CancelAllCommand]  @@@CancelAllCommand PostPrimary. 4022921 with 1041240190

The numbers in the log are System.identityHashCode(). On the first two line there is a space mode bean, the rest are from the container on the view, on all of them the final id after "with" is from a spring injected object to which I'll come back in a question (3). So, questions:

  1. Why does it call PostPrimary four times on the containers where the injected local space is active?
  2. Why does it call both PostPrimary and PostBackup on the containers where the injected local space is backup?
  3. Is it reliable to flag the injected object (ids 1420327748 1884560043 after "with" in log) from the space mode been so I can know in the containers which has a local space reference active and not backup? (to avoid com.gigaspaces.cluster.activeelection.InactiveSpaceException servers as backup-only space and can't accept any operation while primary)
  4. InactiveSpaceException is harmless in this situation as to me it seems the containers with active local space are doing their jobs and the ones throwing the exception won't do it? (just for my information as I still want to get rid of it)

Thanks,

Lucian

asked 2014-10-17 03:56:26 -0500

lukeh gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Hi,

Regarding questions 1-2: you have more than one proxy.

Please use: SpaceUtils.isSameSpace(gigaSpace.getSpace(),event.getSpace()))) in order to verify you got the event on the proper proxy.

Regarding questions 3-4: after using SpaceUtils.isSameSpace() method there is not need to use hashcode.

Regards,

Yuval

answered 2014-10-21 03:54:06 -0500

Yuval gravatar image
edit flag offensive delete link more

Comments

Hi,

On your first answer: you mean by what I described it results that I have more then one, or you mean that I must have some other proxies beside the intended one?

The event comes from the proxy:

<os-core:space id="clusteredSpace" url="jini://*/*/mySpace"/>

<os-core:local-view id="localViewSpace" space="clusteredSpace">

<os-core:giga-space id="localView" space="localViewSpace"/>

and gigaSpace is

<os-core:space id="space" url="/./mySpace?NOWriteLease=true">

<os-core:giga-space id="gigaSpace" space="space" tx-manager="transactionManager"/>

On the second one isSameSpace will return true in the containers where gigaSpace is primary active and if true I won't get that exception? (hascode was just for logging not using it in code)

Thanks,

Lucian

lukeh gravatar imagelukeh ( 2014-10-22 03:42:03 -0500 )edit

Hi,

I meant that in your post primary code you should verify whether the event that you got comes from the same proxy that you are currently working on (you have more than one space: clusteredSpace, localView). You can do that by using isSameSpace() method.

Regards,

Yuval

Yuval gravatar imageYuval ( 2014-10-22 04:53:24 -0500 )edit

Sorry but I'm more confused now, what event in @PostPrimary? And still not understanding if is normal and why I have so much calls to PostPrimary

lukeh gravatar imagelukeh ( 2014-10-22 05:05:44 -0500 )edit

The reason for receiving many calls to PostPrimary is that you have more than one proxy. For each proxy you are getting notifications. In your bean you should do something like that:

boolean isPrimary; @PostPrimary public void afterChangeModeToPrimary(AfterSpaceModeChangeEvent event) { if (SpaceUtils.isSameSpace(gigaSpace.getSpace(),event.getSpace())) {
isPrimary = true }

@PostBackup public void afterChangeModeToBackup(AfterSpaceModeChangeEvent event) { if (SpaceUtils.isSameSpace(gigaSpace.getSpace(), event.getSpace())) {
isPrimary = false;
}

Yuval

Yuval gravatar imageYuval ( 2014-10-22 07:05:41 -0500 )edit

It seems the solution works but now that I cleared those InactiveSpaceException from the containers I noticed them thrown too from a SpaceModeContextBaen#afterPropertiesSet() when I try to read from the local space in that method and I don't think the exception was around before I had the view in pu.xml.

Is there a similar thing to do? Where to get the event or something?

Edit: Actually I would need to have a reference in that bean to the view too. Something like:

@GigaSpaceContext(name = "gigaSpace")
public static GigaSpace gigaSpace;
@GigaSpaceContext(name = "localView")
public static GigaSpace viewSpace;

but with or without that viewSpace there it still gives the exceptions and checking SpaceUtils.isSameSpace(gigaSpace.getSpace(), viewSpace.getSpace()) doesn't seem to do the trick

lukeh gravatar imagelukeh ( 2014-10-30 10:00:58 -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: 2014-10-17 03:52:18 -0500

Seen: 240 times

Last updated: Oct 21 '14