@SuppressWarnings("unchecked")
  public MigrationIterator<Pair<String, List<String>>> listAllHFileRefs() throws KeeperException {
    List<String> peerIds = ZKUtil.listChildrenNoWatch(zookeeper, hfileRefsZNode);
    if (peerIds == null || peerIds.isEmpty()) {
      ZKUtil.deleteNodeRecursively(zookeeper, hfileRefsZNode);
      return EMPTY_ITER;
    }
    Iterator<String> iter = peerIds.iterator();
    return new MigrationIterator<Pair<String, List<String>>>() {

      private String previousPeerId;

      @Override
      public Pair<String, List<String>> next() throws KeeperException {
        if (previousPeerId != null) {
          ZKUtil.deleteNodeRecursively(zookeeper, getHFileRefsPeerNode(previousPeerId));
        }
        if (!iter.hasNext()) {
          ZKUtil.deleteNodeRecursively(zookeeper, hfileRefsZNode);
          return null;
        }
        String peerId = iter.next();
        List<String> refs = ZKUtil.listChildrenNoWatch(zookeeper, getHFileRefsPeerNode(peerId));
        previousPeerId = peerId;
        return Pair.newPair(peerId, refs != null ? refs : Collections.emptyList());
      }
    };
  }
Pair&lt;PeerId, List&lt;HFileRefs&gt;&gt;
hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationQueueStorageForMigration.java