public Management generateLEReq(String hbInfo) { String nodeId = "zero"; logger.info("Inside Leader election build"); logger.info(hbInfo); String[] parts = hbInfo.split(":"); String port = parts[1]; if (port.equals("5670")) { nodeId = "zero"; } else if (port.equals("5671")) { nodeId = "one"; } else if (port.equals("5673")) { nodeId = "two"; } LeaderElection.Builder h = LeaderElection.newBuilder(); h.setDesc("This is an election msg"); h.setVote(VoteAction.ELECTION); h.setBallotId("five"); h.setNodeId(nodeId); Management.Builder m = Management.newBuilder(); m.setElection(h.build()); return m.build(); /*for (NodeDesc nn : conf.getNearest().getNearestNodes().values()) { logger.info("Nearest node is "+nn.getNodeId()); ElectionManager em=new ElectionManager(nn.getNodeId(),1); em.processRequest(h.build()); }*/ }
/** * request the node to send jobProposal. * * @param management * @return did a connect and message succeed */ public boolean startJobBid(Management management) { // the join will initiate the other node's heartbeatMgr to reply to // this node's (caller) listeners. boolean rtn = false; try { Channel ch = connect(); Management.Builder m = Management.newBuilder(); ch.writeAndFlush(management); rtn = true; logger.info("after jobBid manager in jobBid Manager"); } catch (Exception e) { logger.error("could not send connect to node", e); } return rtn; }