Hi guys,

When I look at these lines,

if(joinAtHead){
  log.debug("Node {} trying to join election at the head", id);
  List<String> nodes =
OverseerTaskProcessor.getSortedElectionNodes(zkClient,
shardsElectZkPath);
  if(nodes.size() <2){
    leaderSeqPath = zkClient.create(shardsElectZkPath + "/" + id + "-n_", null,
        CreateMode.EPHEMERAL_SEQUENTIAL, false);
  } else {
    String firstInLine = nodes.get(1);
    log.debug("The current head: {}", firstInLine);
    Matcher m = LEADER_SEQ.matcher(firstInLine);
    if (!m.matches()) {
      throw new IllegalStateException("Could not find regex match in:"
          + firstInLine);
    }
    leaderSeqPath = shardsElectZkPath + "/" + id + "-n_"+ m.group(1);
    zkClient.create(leaderSeqPath, null, CreateMode.EPHEMERAL, false);
  }
} else {

the line firstInLine = nodes.get(1) seems problematic to me. Why do we get
the middle of a sorted list and say that it is the first thing in line?
Should I open an issue for this?

Thanks

Reply via email to