I have created a cluster with 2 nodes (Node1 and Node2) using jgroups library. The cluster is formed successfully. But while invoking callable from Node1 to Node2, it is getting executed infinite times in Node2 and one time in Node1.
Jgroups version used is 3.6.1.Final
The protocols configuration file used is
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.0.xsd">
<TCP bind_port="7951"
bind_addr="192.XXX.XXX.1"
loopback="true"
recv_buf_size="${tcp.recv_buf_size:20M}"
send_buf_size="${tcp.send_buf_size:640K}"
discard_incompatible_packets="true"
max_bundle_size="64K"
max_bundle_timeout="30"
enable_bundling="true"
use_send_queues="true"
sock_conn_timeout="3000"
timer_type="new"
timer.min_threads="4"
timer.max_threads="10"
timer.keep_alive_time="3000"
timer.queue_max_size="500"
thread_pool.enabled="true"
thread_pool.min_threads="10"
thread_pool.max_threads="80"
thread_pool.keep_alive_time="5000"
thread_pool.queue_enabled="false"
thread_pool.queue_max_size="100"
thread_pool.rejection_policy="discard"
oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="1"
oob_thread_pool.max_threads="8"
oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="discard"/>
<TCPPING timeout="3000"
initial_hosts="192.XXX.XXX.1[7951],192.XXX.XXX.2[7950]"
port_range="1"
num_initial_members="2"/>
<MERGE2 min_interval="10000"
max_interval="30000"/>
<FD_SOCK/>
<FD timeout="3000" max_tries="3" />
<VERIFY_SUSPECT timeout="1500" />
<BARRIER />
<pbcast.NAKACK use_mcast_xmit="false"
exponential_backoff="5000"
discard_delivered_msgs="false"/>
<UNICAST />
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="true" join_timeout="3000"
view_bundling="true"/>
<UFC max_credits="2M"
min_threshold="0.4"/>
<MFC max_credits="2M"
min_threshold="0.4"/>
<FRAG2 frag_size="60K" />
<!-- <pbcast.STATE_TRANSFER/> -->
</config>
Used the following code to create the channel and invoke the callRemoteMethod method.
public void initialize(String protocolFileName) throws Exception
{
File file = new File("." + File.separator + "config" + File.separator + protocolFileName);
System.out.println(file.getAbsolutePath());
InputStream inputStream = new FileInputStream(file);
this.jChannel = new JChannel(inputStream);
this.jChannel.setName("DEFAULT_CHANNEL");
this.rpcDispatcher = new RpcDispatcher(jChannel, null, new MembershipListener(), new TestClass());
this.requestOptions = new RequestOptions(ResponseMode.GET_NONE, -1) .setTransientFlags(org.jgroups.Message.TransientFlag.DONT_LOOPBACK);
}
public void start() throws Exception {
this.jChannel.connect("DEFAULT_CHANNEL");
// this.jChannel.getState(null, 10000);
System.out.println("Channel Started");
}
public <T> T send(String remoteNodeIP, int Port) throws Exception {
final MethodCall call = new MethodCall(TestClass.class.getMethod("execute", Integer.class));
System.out.println("Inside send method " + InetAddress.getLocalHost().getHostAddress());
call.setArgs(1);
return rpcDispatcher.callRemoteMethod(new IpAddress(remoteNodeIP, Port), call, this.requestOptions);
}
Registered a TestClass to the dispatcher and its execute method is given as methodCall argument to the callRemoteMethod of dispatcher.
public class TestClass {
/**
Method which will be invoked on the remote node
@param a
@return
*/
public String execute(Integer a) {
System.out.println("Value :" + a);
return "hello";
}
}
Invoked the send method using input as (192.XXX.XXX.2, 7950)
Please help me to resolve this issue.