Check whether target destination task has free room to receive more tuples
181582
protected boolean isSendTuplesToInstance(List<Integer> taskIds) {
    for (Integer taskId : taskIds) {
      if (taskIdToInstanceExecutor.get(taskId).getStreamInQueue().remainingCapacity() <= 0) {
        return false;
      }
    }

    return true;
  }
472620
public static boolean isPathContained(List<String> allowedPaths, String targetPath) {

        if (allowedPaths == null || allowedPaths.isEmpty() || targetPath == null) {
            return false;
        }

        //Remove trailing slashes, if applicable
        if (!targetPath.isEmpty() &&
            targetPath.charAt(targetPath.length() - 1) == '/' &&
            targetPath.length() > 1 &&
            !isWindowsRootDirectory(targetPath)) {
            targetPath = targetPath.substring(0, targetPath.length() - 1);
        }

        while (targetPath != null) {

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Target path: " + targetPath);
            }

            for (int i = 0; i < allowedPaths.size(); i++) {

                //String allowedPath = it.next();
                String allowedPath = allowedPaths.get(i);

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Checking path: " + allowedPath);
                }

                //When we have a configuration that explicitly sets an empty read or write list, then we get a non-empty set
                //with a single empty string.  So we must catch empty cases here, otherwise the comparisons below might be incorrect.
                if ("".equals(allowedPath)) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Skipping an empty path");
                    }

                    continue;
                }

                //We are always doing case-insensitive comparisons because we can't reliably find out
                //if the windows machine has changed its registry key to allow sensitivity, nor do we
                //know if the remote host is a certain OS.  For the purposes of this method (checking for access
                //to a directory) it is safe to assume case insensitivity.
                if (allowedPath.equalsIgnoreCase(targetPath)) {
                    return true;
                }

            }

            // We'll check 'up' the target path's parent chain to see if that's
            // covered by the allowed paths.
            targetPath = getNormalizedParent(targetPath);
        }

        return false;
    }
320754
function(destination, source, name_list) {
		for (var i = 0, count = name_list.length; i < count; i++) {
			var name = name_list[i];
			if (name in source) destination[name] = source[name];
		}
	}
1332763
private TaskInProgress removeMatchingTipUnprotectedUnconditional(
      List<TaskInProgress> taskList, TaskInProgress intendedTip) {
    for (Iterator<TaskInProgress> iter = taskList.iterator(); iter.hasNext();) {
      TaskInProgress t = iter.next();
      if (t.getTIPId().equals(intendedTip.getTIPId())) {
        iter.remove();
        return t;
      }
    }
    return null;
  }
301523
@VisibleForTesting
  void checkSegmentsAndSubmitTasks()
  {
    synchronized (taskLock) {
      List<Interval> intervalsToRemove = new ArrayList<>();
      for (Map.Entry<Interval, HadoopIndexTask> entry : runningTasks.entrySet()) {
        Optional<TaskStatus> taskStatus = taskStorage.getStatus(entry.getValue().getId());
        if (!taskStatus.isPresent() || !taskStatus.get().isRunnable()) {
          intervalsToRemove.add(entry.getKey());
        }
      }
      for (Interval interval : intervalsToRemove) {
        runningTasks.remove(interval);
        runningVersion.remove(interval);
      }

      if (runningTasks.size() == maxTaskCount) {
        //if the number of running tasks reach the max task count, supervisor won't submit new tasks.
        return;
      }
      Pair<SortedMap<Interval, String>, Map<Interval, List<DataSegment>>> toBuildIntervalAndBaseSegments = checkSegments();
      SortedMap<Interval, String> sortedToBuildVersion = toBuildIntervalAndBaseSegments.lhs;
      Map<Interval, List<DataSegment>> baseSegments = toBuildIntervalAndBaseSegments.rhs;
      missInterval = sortedToBuildVersion.keySet();
      submitTasks(sortedToBuildVersion, baseSegments);
    }
  }
371909
def NoCache(self, *targets):
        """"""
        tlist = []
        for t in targets:
            tlist.extend(self.arg2nodes(t, self.fs.Entry))
        for t in tlist:
            t.set_nocache()
        return tlist
935509
def ncores_allocated(self):
        
        return sum(task.manager.num_cores for task in self if task.status in [task.S_SUB, task.S_RUN])
1013485
private boolean inHostsList(TaskTrackerStatus status) {
    Set<String> hostsList = hostsReader.getHosts();
    return (hostsList.isEmpty() || hostsList.contains(status.getHost()));
  }
129718
function hasTrailingSpace(token) {
            const tokenAfter = sourceCode.getTokenAfter(token);

            return tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter) && sourceCode.isSpaceBetweenTokens(token, tokenAfter);
        }
64079
def tuple_partial_cmp(target_tuple, tuple_list, ducktype):
    
    for called_tuple in tuple_list:
        # ignore invalid test case
        if len(target_tuple) > len(called_tuple):
            continue
        # loop all argument from "current arguments"
        dst = len(target_tuple)
        for idx, part_target_tuple in enumerate(target_tuple):
            # test current argument one by one, if matched to previous record, counter-1
            dtype = ducktype(part_target_tuple)
            if hasattr(dtype, "mtest"):
                if dtype.mtest(called_tuple[idx]):
                    dst = dst - 1
            else:
                if dtype == called_tuple[idx]:
                    dst = dst - 1
        # if counter is zero => arguments is partial matched => return True
        if not dst:
            return True
    # if no any arguments matched to called_tuple, return False
    return False
764611
public boolean inspectAnotherSameInfo(@NonNull DownloadTask task, @NonNull BreakpointInfo info,
                                          long instanceLength) {
        if (!task.isFilenameFromResponse()) return false;

        final BreakpointStore store = OkDownload.with().breakpointStore();
        final BreakpointInfo anotherInfo = store.findAnotherInfoFromCompare(task, info);
        if (anotherInfo == null) return false;

        store.remove(anotherInfo.getId());

        if (anotherInfo.getTotalOffset()
                <= OkDownload.with().downloadStrategy().reuseIdledSameInfoThresholdBytes()) {
            return false;
        }

        if (anotherInfo.getEtag() != null && !anotherInfo.getEtag().equals(info.getEtag())) {
            return false;
        }

        if (anotherInfo.getTotalLength() != instanceLength) {
            return false;
        }

        if (anotherInfo.getFile() == null || !anotherInfo.getFile().exists()) return false;

        info.reuseBlocks(anotherInfo);

        Util.d(TAG, "Reuse another same info: " + info);
        return true;
    }
1191468
def count(self, task):
        
        return len([c for c in task.corrections if c["event"]["@class"] == self.event_class])
347830
private void doPreemptionNow() {
    int totalShare = nodeManager.getAllocatedCpuForType(type);
    poolGroupManager.distributeShare(totalShare);
    for (PoolGroupSchedulable poolGroup : poolGroupManager.getPoolGroups()) {
      poolGroup.distributeShare();
    }
    int tasksToPreempt = countTasksShouldPreempt();
    if (tasksToPreempt > 0) {
      LOG.info("Found " + tasksToPreempt + " " + type + " tasks to preempt");
      preemptTasks(tasksToPreempt);
    }
  }
1203998
def iterable(target):
    '''  '''
    if any(i in ('next', '__next__', '__iter__') for i in dir(target)):
        return True
    else:
        try:
            iter(target)
            return True
        except:
            return False
613555
public static void verifyTargets(
			ITargetHandlerResolver targetHandlerResolver,
			ManagedApplication ma,
			ITargetsMngr targetsMngr ) {

		Logger logger = Logger.getLogger( TargetHelpers.class.getName());
		for( Instance inst : InstanceHelpers.getAllInstances( ma.getApplication())) {
			if( ! InstanceHelpers.isTarget( inst ))
				continue;

			try {
				String path = InstanceHelpers.computeInstancePath( inst );
				Map<String,String> targetProperties = targetsMngr.findTargetProperties( ma.getApplication(), path ).asMap();
				targetHandlerResolver.findTargetHandler( targetProperties );

			} catch( TargetException e ) {
				logger.warning( e.getMessage());
			}
		}
	}
36158
private boolean incSlotLimit(JobInfo info, TaskType type, LimitType limit) {
    switch (limit) {
      case MIN:
        if (type == TaskType.MAP) {
          if (info.minMaps < runnableTasks(info, type)) {
            info.minMaps += 1;
            return true;
          }
        } else {
          if (info.minReduces < runnableTasks(info, type)) {
            info.minReduces += 1;
            return true;
          }
        }
        return false;
      case MAX:
        if (type == TaskType.MAP) {
          if (info.maxMaps < runnableTasks(info, type)) {
            info.maxMaps += 1;
            return true;
          }
        } else {
          if (info.maxReduces < runnableTasks(info, type)) {
            info.maxReduces += 1;
            return true;
          }
        }
        return false;
    }
    // Never come here
    return false;
  }
200937
def task(self) -> Tuple[str, Any]:
        
        try:
            items, = self.configuration.items()
        except ValueError:
            raise MultipleTaskDefinitions(
                'Multiple tasks defined in scenario configuration!',
            )
        return items