private boolean updateCurrent(LeaderElection req) { boolean isNew = false; if (current == null) { current = new ElectionState(); isNew = true; } else { if (req.getExpires() > current.maxDuration) { isNew = false; // If this election was started after the current election, dont do anything! logger.info("Ignoring this election - older election already in progress! Not voting!"); return isNew; } else { isNew = true; } } if (req.getCandidateId() == this.nodeId) { // logger.info("Updating election details in RAFT Election"); isNew = false; } current.electionID = req.getElectId(); current.candidate = req.getCandidateId(); current.desc = req.getDesc(); current.maxDuration = req.getExpires(); current.startedOn = System.currentTimeMillis(); current.state = req.getAction(); current.id = -1; // TODO me or sender? current.active = true; return isNew; }