Collection<LlapServiceInstance> getAllInstancesOrdered(
      boolean consistentIndexes, PathChildrenCache instancesCache) {
    Map<String, Long> slotByWorker = new HashMap<String, Long>();
    Set<LlapServiceInstance> unsorted = Sets.newHashSet();
    for (ChildData childData : instancesCache.getCurrentData()) {
      if (childData == null) continue;
      byte[] data = childData.getData();
      if (data == null) continue;
      String nodeName = extractNodeName(childData);
      if (nodeName.startsWith(WORKER_PREFIX)) {
        LlapServiceInstance instances = getInstanceByPath(childData.getPath());
        if (instances != null) {
          unsorted.add(instances);
        }
      } else if (nodeName.startsWith(SLOT_PREFIX)) {
        slotByWorker.put(extractWorkerIdFromSlot(childData),
            Long.parseLong(nodeName.substring(SLOT_PREFIX.length())));
      } else {
        LOG.info("Ignoring unknown node {}", childData.getPath());
      }
    }

    TreeMap<Long, LlapServiceInstance> sorted = new TreeMap<>();
    long maxSlot = Long.MIN_VALUE;
    for (LlapServiceInstance worker : unsorted) {
      Long slot = slotByWorker.get(worker.getWorkerIdentity());
      if (slot == null) {
        LOG.info("Unknown slot for {}", worker.getWorkerIdentity());
        continue;
      }
      maxSlot = Math.max(maxSlot, slot);
      sorted.put(slot, worker);
    }

    if (consistentIndexes) {
      // Add dummy instances to all slots where LLAPs are MIA... I can haz insert_iterator? 
      TreeMap<Long, LlapServiceInstance> dummies = new TreeMap<>();
      Iterator<Long> keyIter = sorted.keySet().iterator();
      long expected = 0;
      Long ts = null;
      while (keyIter.hasNext()) {
        Long slot = keyIter.next();
        assert slot >= expected;
        while (slot > expected) {
          if (ts == null) {
            ts = System.nanoTime(); // Inactive nodes restart every call!
          }
          dummies.put(expected, new InactiveServiceInstance("inactive-" + expected + "-" + ts));
          ++expected;
        }
        ++expected;
      }
      sorted.putAll(dummies);
    }
    return sorted.values();
  }
A dynamically changing instance in an Llap Service. Can become inactive if failing or can be
blacklisted (set to 0 capacity) if too slow (See: BlacklistingLlapMetricsListener).
llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapZookeeperRegistryImpl.java