protected static Set<Role> getRolesOfTasks(List <HostRoleCommand> hostRoleCommands, final HostRoleStatus status) {

    Predicate<HostRoleCommand> predicate = new Predicate<HostRoleCommand>() {
      @Override
      public boolean apply(HostRoleCommand hrc) {
        return hrc.getStatus() ==  status;
      }
    };

    Function<HostRoleCommand, Role> transform = new Function<HostRoleCommand, Role>() {
      @Override
      public Role apply(HostRoleCommand hrc) {
        return hrc.getRole();
      }
    };
    return FluentIterable.from(hostRoleCommands)
        .filter(predicate)
        .transform(transform)
        .toSet();
  }
Get all {@link Role} any of whose tasks are in given {@code status}
@param hostRoleCommands list of {@link HostRoleCommand}
@param status {@link HostRoleStatus}
@return Set of {@link Role}
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java