I am using fork channel api to fork my main channel. I have set it as a receiver using my implementation of reciever adapter. I can send and receive messages but cannot use the inherited method "viewAccepted" which should theoretically get invoked when there is a change in the jgroups view. But I do not get control to this method when I add a node or remove a node. However I still get control at my main channel's infinispan listerner class implementation annotated by @ViewChanged. This makes me confused.
Is this the expected behavior?
The fork channel does not send messages via the main channel. Is this understanding right?
When a node in main channel goes down or a new node is added, the fork channel also behaves similar to main channel. Is this right?
Is there a way to convert Infinispan Address to JGroups Address?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using fork channel api to fork my main channel. I have set it as a
receiver using my implementation of reciever adapter. I can send and
receive messages but cannot use the inherited method "viewAccepted"
which should theoretically get invoked when there is a change in the
jgroups view.
Take a look at the program below. I set a ReceiverAdapter and implement
viewAccepted(), which is called.
But I do not get control to this method when I add a node
or remove a node. However I still get control at my main channel's
infinispan listerner class implementation annotated by @ViewChanged.
This makes me confused.
Is this the expected behavior?
The fork channel does not send messages via the main channel. Is
this understanding right?
No. A ForkChannel is depending on the main channel, and its lifecycle is
a subset of the main channel's lifecycle.
When a node in main channel goes down or a new node is added, the
fork channel also behaves similar to main channel. Is this right?
Yes
Is there a way to convert Infinispan Address to JGroups Address?
I suggest look at how the InfinispanAddress is implemented. I assume
this is possible; for example JGroupsAddress has a getJGroupsAddress()
method.
public class bla4 {
protected JChannel ch;
protected ForkChannel fc1, fc2;
public ReceiverAdapterImpl() { //Constructor of my receiver adapter implementation
jGroupsTransport = ispnCache.getAdvancedCache().getRpcManager().getTransport();
jGroupsMainChannel = ((JGroupsTransport)jGroupsTransport).getChannel();
jGroupsForkChannel = new ForkChannel(jGroupsMainChannel,
"stackId",
"channelId",
true, ProtocolStack.Position.ABOVE, TCP.class); jGroupsForkChannel.connect("comms");
jGroupsForkChannel.setReceiver(this);
}
But when a new node was added to the cluster I did not get control to my viewAccepted() method in my ReceiverAdapter. I do not have control over infinispan channel creation, so I cannot call my mainChannel.connect() after I create forkChannel. Is this the problem?
I get call back in my infinispan listener class to its @VIewChanged annotated method though.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
public void viewAccepted(View view) {
System.out.println("view = " + view);
}
public static void main(String[] args) throws Exception {
new bla4().start();
}
}
On 26.03.19 14:09, Jikku Joyce wrote:
Hi Bela,
Thanks for the reply.
I created ForkedChannel as below:
public ReceiverAdapterImpl() { //Constructor of my receiver adapter implementation
jGroupsTransport = ispnCache.getAdvancedCache().getRpcManager().getTransport();
jGroupsMainChannel = ((JGroupsTransport)jGroupsTransport).getChannel();
jGroupsForkChannel = new ForkChannel(jGroupsMainChannel,
"stackId",
"channelId",
true, ProtocolStack.Position.ABOVE, TCP.class); jGroupsForkChannel.connect("comms");
jGroupsForkChannel.setReceiver(this);
}
But when a new node was added to the cluster I did not get control to my
viewAccepted() method in my ReceiverAdapter. I do not have control over
infinispan channel creation, so I cannot call my mainChannel.connect()
after I create forkChannel. Is this the problem?
I get call back in my infinispan listener class to its @VIewChanged
annotated method though.
I tried with FRAG2 initially. But I was not able to create fork channel and was getting a null pointer exception as below:
java.lang.NullPointerException
at org.jgroups.stack.ProtocolStack.insertProtocol(ProtocolStack.java:603)
at org.jgroups.fork.ForkChannel.getFORK(ForkChannel.java:281)
at org.jgroups.fork.ForkChannel.<init>(ForkChannel.java:75)
Then only when I used TCP.class I was able to get it working. Any idea why this happens?
When I analyse my main channel :
my bottom protocol is TCP,
down protocol is STATE_TRANSFER,
top protocol is STATE_TRANSFER and
up protocol is null.
Can you share your JGroups configuration too?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, FRAG2 is not in your stack. Try STATE_TRANSFER instead.
You cannot place FORK directly above the transport, it needs to be at the top of the stack!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am using fork channel api to fork my main channel. I have set it as a receiver using my implementation of reciever adapter. I can send and receive messages but cannot use the inherited method "viewAccepted" which should theoretically get invoked when there is a change in the jgroups view. But I do not get control to this method when I add a node or remove a node. However I still get control at my main channel's infinispan listerner class implementation annotated by @ViewChanged. This makes me confused.
On 25.03.19 13:17, Jikku Joyce wrote:
Take a look at the program below. I set a ReceiverAdapter and implement
viewAccepted(), which is called.
No. A ForkChannel is depending on the main channel, and its lifecycle is
a subset of the main channel's lifecycle.
Yes
I suggest look at how the InfinispanAddress is implemented. I assume
this is possible; for example JGroupsAddress has a getJGroupsAddress()
method.
public class bla4 {
protected JChannel ch;
protected ForkChannel fc1, fc2;
view);
}
});
fc2.setReceiver(new ReceiverAdapter() {
public void viewAccepted(View view) {
System.out.printf("%s: view is %s\n", fc2.getAddress(),
view);
}
});
}
--
Bela Ban | http://www.jgroups.org
Hi Bela,
Thanks for the reply.
I created ForkedChannel as below:
But when a new node was added to the cluster I did not get control to my viewAccepted() method in my ReceiverAdapter. I do not have control over infinispan channel creation, so I cannot call my mainChannel.connect() after I create forkChannel. Is this the problem?
I get call back in my infinispan listener class to its @VIewChanged annotated method though.
You main mistake was to add FORK just above the transport (TCP).
Instead, FORK needs to be placed at the top of the protocol stack:
public class bla4 extends ReceiverAdapter {
protected JChannel ch;
ProtocolStack.Position.ABOVE, FRAG2.class);
jGroupsForkChannel.setReceiver(this);
jGroupsForkChannel.connect("comms");
System.out.printf("-- %s started, waiting for messages\n",
jGroupsForkChannel.getAddress());
}
}
On 26.03.19 14:09, Jikku Joyce wrote:
--
Bela Ban | http://www.jgroups.org
Hi Bela,
I tried with FRAG2 initially. But I was not able to create fork channel and was getting a null pointer exception as below:
Then only when I used TCP.class I was able to get it working. Any idea why this happens?
When I analyse my main channel :
my bottom protocol is TCP,
down protocol is STATE_TRANSFER,
top protocol is STATE_TRANSFER and
up protocol is null.
Can you share your JGroups configuration too?
Well, FRAG2 is not in your stack. Try STATE_TRANSFER instead.
You cannot place FORK directly above the transport, it needs to be at the top of the stack!
That worked Bela !!! Thanks a lot for the help.