public class Scheduler extends Object implements InstanceListener, SlotAvailabilityListener
| Constructor and Description |
|---|
Scheduler() |
Scheduler(ExecutorService executorService) |
| Modifier and Type | Method and Description |
|---|---|
protected AllocatedSlot |
getFreeSlotForTask(ExecutionVertex vertex,
Iterable<Instance> requestedLocations)
Gets a suitable instance to schedule the vertex execution to.
|
int |
getNumberOfAvailableInstances() |
int |
getNumberOfAvailableSlots()
NOTE: In the presence of multi-threaded operations, this number may be inexact.
|
int |
getNumberOfInstancesWithAvailableSlots() |
int |
getNumberOfLocalizedAssignments() |
int |
getNumberOfNonLocalizedAssignments() |
int |
getNumberOfUnconstrainedAssignments() |
int |
getTotalNumberOfSlots() |
void |
instanceDied(Instance instance)
Called when an instance died.
|
void |
newInstanceAvailable(Instance instance)
Called when a new instance becomes available.
|
void |
newSlotAvailable(Instance instance) |
AllocatedSlot |
scheduleImmediately(ScheduledUnit task) |
SlotAllocationFuture |
scheduleQueued(ScheduledUnit task) |
void |
shutdown()
Shuts the scheduler down.
|
public Scheduler()
public Scheduler(ExecutorService executorService)
public void shutdown()
public int getNumberOfAvailableSlots()
public int getTotalNumberOfSlots()
public AllocatedSlot scheduleImmediately(ScheduledUnit task) throws NoResourceAvailableException
NoResourceAvailableExceptionpublic SlotAllocationFuture scheduleQueued(ScheduledUnit task) throws NoResourceAvailableException
NoResourceAvailableExceptionprotected AllocatedSlot getFreeSlotForTask(ExecutionVertex vertex, Iterable<Instance> requestedLocations)
NOTE: This method does is not thread-safe, it needs to be synchronized by the caller.
vertex - The task to run.null, if no instance is available.public void newSlotAvailable(Instance instance)
newSlotAvailable in interface SlotAvailabilityListenerpublic void newInstanceAvailable(Instance instance)
InstanceListenernewInstanceAvailable in interface InstanceListenerinstance - The instance that became available.public void instanceDied(Instance instance)
InstanceListenerinstanceDied in interface InstanceListenerinstance - The instance that died.public int getNumberOfAvailableInstances()
public int getNumberOfInstancesWithAvailableSlots()
public int getNumberOfUnconstrainedAssignments()
public int getNumberOfLocalizedAssignments()
public int getNumberOfNonLocalizedAssignments()
Copyright © 2015 The Apache Software Foundation. All rights reserved.