public static NimbusInfo toNimbusInfo(Participant participant) { String id = participant.getId(); if (StringUtils.isBlank(id)) { throw new RuntimeException("No nimbus leader participant host found, have you started your nimbus hosts?"); } NimbusInfo nimbusInfo = NimbusInfo.parse(id); nimbusInfo.setLeader(participant.isLeader()); return nimbusInfo; }
public static Set<NimbusInfo> getNimbodesWithLatestSequenceNumberOfBlob(CuratorFramework zkClient, String key) throws Exception { List<String> stateInfoList; try { stateInfoList = zkClient.getChildren().forPath("/blobstore/" + key); } catch (KeeperException.NoNodeException e) { // there's a race condition with a delete: blobstore // this should be thrown to the caller to indicate that the key is invalid now throw new WrappedKeyNotFoundException(key); } Set<NimbusInfo> nimbusInfoSet = new HashSet<NimbusInfo>(); int latestSeqNumber = getLatestSequenceNumber(stateInfoList); LOG.debug("getNimbodesWithLatestSequenceNumberOfBlob stateInfo {} version {}", stateInfoList, latestSeqNumber); // Get the nimbodes with the latest version for (String state : stateInfoList) { BlobKeySequenceInfo sequenceInfo = normalizeNimbusHostPortSequenceNumberInfo(state); if (latestSeqNumber == Integer.parseInt(sequenceInfo.getSequenceNumber())) { nimbusInfoSet.add(NimbusInfo.parse(sequenceInfo.getNimbusHostPort())); } } LOG.debug("nimbusInfoList {}", nimbusInfoSet); return nimbusInfoSet; }
public static NimbusInfo toNimbusInfo(Participant participant) { String id = participant.getId(); if (StringUtils.isBlank(id)) { throw new RuntimeException("No nimbus leader participant host found, have you started your nimbus hosts?"); } NimbusInfo nimbusInfo = NimbusInfo.parse(id); nimbusInfo.setLeader(participant.isLeader()); return nimbusInfo; }
public static Set<NimbusInfo> getNimbodesWithLatestSequenceNumberOfBlob(CuratorFramework zkClient, String key) throws Exception { List<String> stateInfoList; try { stateInfoList = zkClient.getChildren().forPath("/blobstore/" + key); } catch (KeeperException.NoNodeException e) { // there's a race condition with a delete: blobstore // this should be thrown to the caller to indicate that the key is invalid now throw new KeyNotFoundException(key); } Set<NimbusInfo> nimbusInfoSet = new HashSet<NimbusInfo>(); int latestSeqNumber = getLatestSequenceNumber(stateInfoList); LOG.debug("getNimbodesWithLatestSequenceNumberOfBlob stateInfo {} version {}", stateInfoList, latestSeqNumber); // Get the nimbodes with the latest version for(String state : stateInfoList) { BlobKeySequenceInfo sequenceInfo = normalizeNimbusHostPortSequenceNumberInfo(state); if (latestSeqNumber == Integer.parseInt(sequenceInfo.getSequenceNumber())) { nimbusInfoSet.add(NimbusInfo.parse(sequenceInfo.getNimbusHostPort())); } } LOG.debug("nimbusInfoList {}", nimbusInfoSet); return nimbusInfoSet; }