boolean registerForUpdates(FinishableStateUpdateHandler handler,
                                         List<String> sources, QueryFragmentInfo fragmentInfo,
                                         boolean lastFinishableState) {
      lock.lock();
      try {
        EntityInfo entityInfo =
            new EntityInfo(handler, sources, fragmentInfo, lastFinishableState);
        if (trackedEntities.put(handler, entityInfo) != null) {
          throw new IllegalStateException(
              "Only a single registration allowed per entity. Duplicate for " + handler.toString());
        }
        for (String source : sources) {
          sourceToEntity.put(source, entityInfo);
        }

        boolean canFinish = QueryFragmentInfo.canFinish(fragmentInfo);
        if (lastFinishableState == canFinish) {
          // State has not changed.
          return true;
        } else {
          entityInfo.setLastFinishableState(canFinish);
          return false;
        }
      } finally {
        lock.unlock();
      }
    }
@param handler
@param sources
@param fragmentInfo
@param lastFinishableState
@return true if the current state is the same as the lastFinishableState. false if the state has already changed.
llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/QueryInfo.java