multithreading - JGroups RPC: NoSuchMethodException -
have view consisting of 3 server nodes (american samoa, alaska, alabama) , 1 client node (voterclient). whenever try invoke vote method in first server within view in below case american samoa, nosuchmethodexception. here list of nodes in view shown below: (ping_dest american samoa, pingable_mbrs=[american samoa, alaska, alabama, voterclient]). when call
// call vote method on state. voteresult = dispatcher.callremotemethod(address1, "vote", new object[] { obj.id, obj.candidate }, new class[] { string.class, string.class }, new requestoptions(responsemode.get_all, 50000)); where address1 address of "american samoa", , obj.id , obj.candidate string parameters of remote vote method, nosuchmethodexception.
here log , exception:
1644 debug [main] org.jgroups.protocols.fd_sock - view_change received: [american samoa, alaska, alabama, voterclient, voterclient] 1664 debug [fd_sock pinger,stateservergroup,voterclient] org.jgroups.protocols.fd_sock - ping_dest american samoa, pingable_mbrs=[american samoa, alaska, alabama, voterclient, voterclient] 1664 debug [main] org.jgroups.protocols.pbcast.stable - [ergonomics] setting max_bytes 20mb (5 members) should occuring right????? state server address: american samoa. java.lang.nosuchmethodexception: vote @ org.jgroups.blocks.methodcall.invoke(methodcall.java:312) @ org.jgroups.blocks.rpcdispatcher.handle(rpcdispatcher.java:326) @ org.jgroups.blocks.requestcorrelator.handlerequest(requestcorrelator.java:456) @ org.jgroups.blocks.requestcorrelator.receivemessage(requestcorrelator.java:363) @ org.jgroups.blocks.requestcorrelator.receive(requestcorrelator.java:238) @ org.jgroups.blocks.messagedispatcher$protocoladapter.up(messagedispatcher.java:543) @ org.jgroups.jchannel.up(jchannel.java:716) @ org.jgroups.stack.protocolstack.up(protocolstack.java:1026) @ org.jgroups.protocols.pbcast.state_transfer.up(state_transfer.java:178) @ org.jgroups.protocols.frag2.up(frag2.java:181) @ org.jgroups.protocols.flowcontrol.up(flowcontrol.java:418) @ org.jgroups.protocols.flowcontrol.up(flowcontrol.java:400) @ org.jgroups.protocols.pbcast.gms.up(gms.java:889) ... @ org.jgroups.protocols.tp$incomingpacket.handlemymessage(tp.java:1728) @ org.jgroups.protocols.tp$incomingpacket.run(tp.java:1710) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) failed on dispatcher voteaction.
here vote method:
public class evoterserver extends receiveradapter implements runnable{ private static final string serverproperties = null; // default properties private static logger logger = logger.getlogger(evoterserver.class); private jchannel channel = null; private string statename = null; private static final string serverproperties = null; // default properties private static final string channelname = "stateservergroup"; private boolean isrunning = true; @override public void run() { try { channel = new jchannel(serverproperties); channel.setname(statename); @suppresswarnings("unused") rpcdispatcher dispatcher = new rpcdispatcher(channel, this, this, this); channel.connect(channelname); channel.getstate(null, 0); logger.info(statename + " server started @ " + new date() + "."); logger.info(statename + " joined channel '" + channelname + "' (" + channel.getview().size() + " members)."); logger.info(statename + " server ready serve requests."); logger.info(statename + " server's channel address " + channel.getaddress() + "."); isrunning = true; while(isrunning) { util.sleep(10000); } } catch(exception e) { logger.error("evoterserver.run(); state: " + statename + "; " + e.getmessage(), e); } { util.close(channel); } } public boolean vote(string voterid, string candidatename) { system.out.println("vote " + candidatename + " " + voterid + "."); return true; } } here driver class' (main method snippet); how initialize servers each state.
string [] state_names = {"alabama", "alaska", "american samoa"}; (int = 0; < 3; i++) { try { evoterserver server = new evoterserver(state_names[i]); new thread(server).start(); } catch (throwable t) { logger.error(t.getmessage(), t); } } i think has coordinator elected gms. client can't vote when coordinator same voting server state. below shows how coordinator american samoa elected:
1401 debug [main] org.jgroups.protocols.udp - created unicast receiver thread 1401 debug [main] org.jgroups.protocols.udp - created multicast receiver thread 1411 debug [main] org.jgroups.protocols.pbcast.gms - election results: {american samoa=2} 1411 debug [main] org.jgroups.protocols.pbcast.gms - sending join(voterclient) american samoa 1523 debug [main] org.jgroups.protocols.pbcast.nakack - [setdigest()]
java.lang.nosuchmethodexception: vote
jgroups throws exception methodcall.invoke() if unable find method in question. see number of reasons why happening:
- you mentioned working on other servers. 1 running older version of software? maybe
vote()method updated recently? - any chance
evoterserverhandler object has not been registered appropriately? - i'm curious error message
failed on dispatcher voteaction.voteaction? chance registered instead ofevoterserver? maybe that's different channel accident attached wrong group?
hope here helps.
Comments
Post a Comment