Increment each of the schedulables' share by
the minimum demand. Note that each pool has to be guaranteed
at least its MIN value according to PRIORITY scheduling.

@param schedulableVector: The collection of schedulables
(all with the same priority)
432236
private static void distributeShareMin(
      Collection<? extends Schedulable> schedulableVector) {
    for (Schedulable schedulable : schedulableVector) {
      schedulable.share += schedulable.getMinimum();
    }
  }
850412
private void schedule(TaskScheduler scheduler) {
        scheduledFuture = scheduler.scheduleAtFixedRate(
                createTask(), (int)delayTime, (int)period, TimeUnit.MILLISECONDS);
    }
1149871
private Object scheduleTask(ScheduledUnit task, boolean queueIfNoResource, Iterable<TaskManagerLocation> preferredLocations) throws NoResourceAvailableException {
		if (task == null) {
			throw new NullPointerException();
		}
		if (LOG.isDebugEnabled()) {
			LOG.debug("Scheduling task " + task);
		}

		final ExecutionVertex vertex = task.getTaskToExecute().getVertex();
		
		final boolean forceExternalLocation = false &&
									preferredLocations != null && preferredLocations.iterator().hasNext();
	
		synchronized (globalLock) {
			
			SlotSharingGroup sharingUnit = vertex.getJobVertex().getSlotSharingGroup();
			
			if (sharingUnit != null) {

				// 1)  === If the task has a slot sharing group, schedule with shared slots ===
				
				if (queueIfNoResource) {
					throw new IllegalArgumentException(
							"A task with a vertex sharing group was scheduled in a queued fashion.");
				}
				
				final SlotSharingGroupAssignment assignment = sharingUnit.getTaskAssignment();
				final CoLocationConstraint constraint = task.getCoLocationConstraint();
				
				// sanity check that we do not use an externally forced location and a co-location constraint together
				if (constraint != null && forceExternalLocation) {
					throw new IllegalArgumentException("The scheduling cannot be constrained simultaneously by a "
							+ "co-location constraint and an external location constraint.");
				}
				
				// get a slot from the group, if the group has one for us (and can fulfill the constraint)
				final SimpleSlot slotFromGroup;
				if (constraint == null) {
					slotFromGroup = assignment.getSlotForTask(vertex.getJobvertexId(), preferredLocations);
				}
				else {
					slotFromGroup = assignment.getSlotForTask(constraint, preferredLocations);
				}

				SimpleSlot newSlot = null;
				SimpleSlot toUse = null;

				// the following needs to make sure any allocated slot is released in case of an error
				try {
					
					// check whether the slot from the group is already what we want.
					// any slot that is local, or where the assignment was unconstrained is good!
					if (slotFromGroup != null && slotFromGroup.getLocality() != Locality.NON_LOCAL) {
						
						// if this is the first slot for the co-location constraint, we lock
						// the location, because we are quite happy with the slot
						if (constraint != null && !constraint.isAssigned()) {
							constraint.lockLocation();
						}
						
						updateLocalityCounters(slotFromGroup, vertex);
						return slotFromGroup;
					}
					
					// the group did not have a local slot for us. see if we can one (or a better one)
					
					// our location preference is either determined by the location constraint, or by the
					// vertex's preferred locations
					final Iterable<TaskManagerLocation> locations;
					final boolean localOnly;
					if (constraint != null && constraint.isAssigned()) {
						locations = Collections.singleton(constraint.getLocation());
						localOnly = true;
					}
					else {
						locations = preferredLocations;
						localOnly = forceExternalLocation;
					}
					
					newSlot = getNewSlotForSharingGroup(vertex, locations, assignment, constraint, localOnly);

					if (newSlot == null) {
						if (slotFromGroup == null) {
							// both null, which means there is nothing available at all
							
							if (constraint != null && constraint.isAssigned()) {
								// nothing is available on the node where the co-location constraint forces us to
								throw new NoResourceAvailableException("Could not allocate a slot on instance " +
										constraint.getLocation() + ", as required by the co-location constraint.");
							}
							else if (forceExternalLocation) {
								// could not satisfy the external location constraint
								String hosts = getHostnamesFromInstances(preferredLocations);
								throw new NoResourceAvailableException("Could not schedule task " + vertex
										+ " to any of the required hosts: " + hosts);
							}
							else {
								// simply nothing is available
								throw new NoResourceAvailableException(task, getNumberOfAvailableInstances(),
										getTotalNumberOfSlots(), getNumberOfAvailableSlots());
							}
						}
						else {
							// got a non-local from the group, and no new one, so we use the non-local
							// slot from the sharing group
							toUse = slotFromGroup;
						}
					}
					else if (slotFromGroup == null || !slotFromGroup.isAlive() || newSlot.getLocality() == Locality.LOCAL) {
						// if there is no slot from the group, or the new slot is local,
						// then we use the new slot
						if (slotFromGroup != null) {
							slotFromGroup.releaseSlot(null);
						}
						toUse = newSlot;
					}
					else {
						// both are available and usable. neither is local. in that case, we may
						// as well use the slot from the sharing group, to minimize the number of
						// instances that the job occupies
						newSlot.releaseSlot(null);
						toUse = slotFromGroup;
					}

					// if this is the first slot for the co-location constraint, we lock
					// the location, because we are going to use that slot
					if (constraint != null && !constraint.isAssigned()) {
						constraint.lockLocation();
					}
					
					updateLocalityCounters(toUse, vertex);
				}
				catch (NoResourceAvailableException e) {
					throw e;
				}
				catch (Throwable t) {
					if (slotFromGroup != null) {
						slotFromGroup.releaseSlot(t);
					}
					if (newSlot != null) {
						newSlot.releaseSlot(t);
					}

					ExceptionUtils.rethrow(t, "An error occurred while allocating a slot in a sharing group");
				}

				return toUse;
			}
			else {
				
				// 2) === schedule without hints and sharing ===
				
				SimpleSlot slot = getFreeSlotForTask(vertex, preferredLocations, forceExternalLocation);
				if (slot != null) {
					updateLocalityCounters(slot, vertex);
					return slot;
				}
				else {
					// no resource available now, so queue the request
					if (queueIfNoResource) {
						CompletableFuture<LogicalSlot> future = new CompletableFuture<>();
						this.taskQueue.add(new QueuedTask(task, future));
						return future;
					}
					else if (forceExternalLocation) {
						String hosts = getHostnamesFromInstances(preferredLocations);
						throw new NoResourceAvailableException("Could not schedule task " + vertex
								+ " to any of the required hosts: " + hosts);
					}
					else {
						throw new NoResourceAvailableException(getNumberOfAvailableInstances(),
								getTotalNumberOfSlots(), getNumberOfAvailableSlots());
					}
				}
			}
		}
	}
343804
void scheduleHeronWorkers(Set<ContainerPlan> containers) throws ContainerAllocationException {
    for (ContainerPlan containerPlan : containers) {
      int id = containerPlan.getId();
      if (containerPlans.containsKey(containerPlan.getId())) {
        throw new ContainerAllocationException("Received duplicate allocation request for " + id);
      }
      Resource reqResource = containerPlan.getRequiredResource();
      containerPlans.put(id, containerPlan);
      requestContainerForWorker(id, new HeronWorker(id, reqResource));
    }
  }
250276
public boolean schedule(Runnable task)
  {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    boolean isPriority = false;
    boolean isQueue = true;
    boolean isWake = true;

    return scheduleImpl(task, loader, MAX_EXPIRE, isPriority, isQueue, isWake);
  }
1198358
public void schedule() {
        // randomize the scheduling so that multiple Hudson instances will write at the file at different time
        long MINUTE = 1000*60;

        Timer.get()
            .schedule(new SafeTimerTask() {
                protected void doRun() {
                    execute();
                }
            }, (random.nextInt(30) + 60) * MINUTE, TimeUnit.MILLISECONDS);
    }
521216
void sendDeltaScheduleWorkRejected()
   {
      scheduleWorkRejected.incrementAndGet();

      if (trace)
         log.tracef("sendDeltaScheduleWorkRejected: %s", workManagers);

      if (own != null && transport != null && transport.isInitialized())
      {
         for (Address address : workManagers)
         {
            if (!own.equals(address))
               transport.deltaScheduleWorkRejected(address);
         }
      }
   }
470767
@GuardedBy("evictionLock")
    void runTasks(Task[] tasks, int maxTaskIndex) {
        for (int i = 0; i <= maxTaskIndex; i++) {
            runTasksInChain(tasks[i]);
        }
    }
367468
public void addTaskRunOnce(int startDelayTime, Runnable runnable) {
        scheduledExecutorService.schedule(runnable, startDelayTime, TimeUnit.SECONDS);
    }
600069
@Override
    public void run() {
        // Check for a pending exception.  A CancellationException could be set if a cancel() was driven while this Runnable
        // was being re-scheduled.
        if (this.m_pendingException != null) {
            return;
        }

        // NOTE: Already running in Default Executor thread.
        try {
            this.m_runnable.run();
        } catch (Exception e) {
            this.m_pendingException = new ExecutionException(e);
            this.m_coordinationLatch.countDown();
            return;
        }

        try {
            long scheduleTime = this.m_periodInterval;
            if (!this.m_scheduledWithDelay) {
                this.m_myNextExecutionTime = this.m_myNextExecutionTime + this.m_periodInterval;
                long currentTime = System.nanoTime();

                scheduleTime = (this.m_myNextExecutionTime > currentTime) ? (this.m_myNextExecutionTime - currentTime) : 0;
            }

            m_schedFuture = this.m_scheduledExecutor.schedule(this, scheduleTime, TimeUnit.NANOSECONDS);
        } catch (Exception e) {
            this.m_pendingException = e;
            this.m_coordinationLatch.countDown();
        }
    }
148946
public void runPendingTasks() {
        try {
            loop.runTasks();
        } catch (Exception e) {
            recordException(e);
        }

        try {
            loop.runScheduledTasks();
        } catch (Exception e) {
            recordException(e);
        }
    }
69143
public void createVolatileScheduler (final int nMaxThreads) throws SchedulerException
  {
    final SimpleThreadPool aThreadPool = new SimpleThreadPool (nMaxThreads, Thread.NORM_PRIORITY);
    aThreadPool.initialize ();
    final IJobStore jobStore = new RAMJobStore ();
    createScheduler (aThreadPool, jobStore);
  }
1180269
public void runNextPendingCommand() {
        ScheduledTask<?> scheduledTask = deltaQueue.pop();
        
        scheduledTask.run();
        
        if (!scheduledTask.isCancelled() && scheduledTask.repeats()) {
            deltaQueue.add(scheduledTask.repeatDelay, scheduledTask);
        }
    }
1204414
protected void schedule() {
    try (LockResource r = new LockResource(mLock)) {
      Preconditions.checkState(!mScheduled, "Called schedule twice without waiting for any ticks");
      mScheduled = true;
      mTickCondition.signal();
      HeartbeatScheduler.removeTimer(this);
    }
  }
232816
public static void runInFiber(FiberScheduler scheduler, SuspendableRunnable target) throws ExecutionException, InterruptedException {
        FiberUtil.runInFiber(scheduler, target);
    }
925589
public void saveLater() {
        if (executor.isShutdown() || savePending.getAndSet(true))
            return;   // Already pending.
        executor.schedule(saver, delay, delayTimeUnit);
    }
890678
public void distributeShare() {
    if (needRedistributed) {
      ScheduleComparator sc = configManager.getPoolGroupComparator(getName());
      Schedulable.distributeShare(getShare(), snapshotPools, sc);
    }
    needRedistributed = false;
  }