public class Scheduler extends Object implements InstanceListener, SlotAvailabilityListener
The scheduler supports two scheduling modes:
NoResourceAvailableException
.Constructor and Description |
---|
Scheduler(scala.concurrent.ExecutionContext executionContext)
Creates a new scheduler.
|
Modifier and Type | Method and Description |
---|---|
protected SimpleSlot |
getFreeSlotForTask(ExecutionVertex vertex,
Iterable<Instance> requestedLocations,
boolean localOnly)
Gets a suitable instance to schedule the vertex execution to.
|
Map<String,List<Instance>> |
getInstancesByHost() |
protected SimpleSlot |
getNewSlotForSharingGroup(ExecutionVertex vertex,
Iterable<Instance> requestedLocations,
SlotSharingGroupAssignment groupAssignment,
CoLocationConstraint constraint,
boolean localOnly)
Tries to allocate a new slot for a vertex that is part of a slot sharing group.
|
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) |
SimpleSlot |
scheduleImmediately(ScheduledUnit task) |
SlotAllocationFuture |
scheduleQueued(ScheduledUnit task) |
void |
shutdown()
Shuts the scheduler down.
|
public Scheduler(scala.concurrent.ExecutionContext executionContext)
public void shutdown()
public SimpleSlot scheduleImmediately(ScheduledUnit task) throws NoResourceAvailableException
NoResourceAvailableException
public SlotAllocationFuture scheduleQueued(ScheduledUnit task) throws NoResourceAvailableException
NoResourceAvailableException
protected SimpleSlot getFreeSlotForTask(ExecutionVertex vertex, Iterable<Instance> requestedLocations, boolean localOnly)
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.protected SimpleSlot getNewSlotForSharingGroup(ExecutionVertex vertex, Iterable<Instance> requestedLocations, SlotSharingGroupAssignment groupAssignment, CoLocationConstraint constraint, boolean localOnly)
This method will try to allocate a slot from one of the local instances, and fall back to non-local instances, if permitted.
vertex
- The vertex to allocate the slot for.requestedLocations
- The locations that are considered local. May be null or empty, if the
vertex has no location preferences.groupAssignment
- The slot sharing group of the vertex. Mandatory parameter.constraint
- The co-location constraint of the vertex. May be null.localOnly
- Flag to indicate if non-local choices are acceptable.null
, if no slot is available.public void newSlotAvailable(Instance instance)
newSlotAvailable
in interface SlotAvailabilityListener
public void newInstanceAvailable(Instance instance)
InstanceListener
newInstanceAvailable
in interface InstanceListener
instance
- The instance that became available.public void instanceDied(Instance instance)
InstanceListener
instanceDied
in interface InstanceListener
instance
- The instance that died.public int getNumberOfAvailableSlots()
public int getTotalNumberOfSlots()
public int getNumberOfAvailableInstances()
public int getNumberOfInstancesWithAvailableSlots()
public int getNumberOfUnconstrainedAssignments()
public int getNumberOfLocalizedAssignments()
public int getNumberOfNonLocalizedAssignments()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.