public class Instance extends Object implements SlotOwner
TaskManager
registered at a JobManager and ready to receive work.Constructor and Description |
---|
Instance(TaskManagerGateway taskManagerGateway,
TaskManagerLocation location,
InstanceID id,
HardwareDescription resources,
int numberOfSlots)
Constructs an instance reflecting a registered TaskManager.
|
Modifier and Type | Method and Description |
---|---|
SharedSlot |
allocateSharedSlot(JobID jobID,
SlotSharingGroupAssignment sharingGroupAssignment)
Allocates a shared slot on this TaskManager instance.
|
SimpleSlot |
allocateSimpleSlot(JobID jobID)
Allocates a simple slot on this TaskManager instance.
|
void |
cancelAndReleaseAllSlots() |
InstanceID |
getId() |
long |
getLastHeartBeat()
Gets the timestamp of the last heartbeat.
|
int |
getNumberOfAllocatedSlots() |
int |
getNumberOfAvailableSlots() |
HardwareDescription |
getResources() |
TaskManagerGateway |
getTaskManagerGateway()
Returns the InstanceGateway of this Instance.
|
ResourceID |
getTaskManagerID() |
TaskManagerLocation |
getTaskManagerLocation() |
int |
getTotalNumberOfSlots() |
boolean |
hasResourcesAvailable() |
boolean |
isAlive() |
boolean |
isStillAlive(long now,
long cleanUpInterval)
Checks whether the last heartbeat occurred within the last
n milliseconds
before the given timestamp now . |
void |
markDead() |
void |
removeSlotListener()
Removes the listener that receives notifications for slot availability.
|
void |
reportHeartBeat()
Updates the time of last received heart beat to the current system time.
|
boolean |
returnAllocatedSlot(Slot slot)
Returns a slot that has been allocated from this instance.
|
void |
setSlotAvailabilityListener(SlotAvailabilityListener slotAvailabilityListener)
Sets the listener that receives notifications for slot availability.
|
String |
toString() |
public Instance(TaskManagerGateway taskManagerGateway, TaskManagerLocation location, InstanceID id, HardwareDescription resources, int numberOfSlots)
taskManagerGateway
- The actor gateway to communicate with the remote instancelocation
- The remote connection where the task manager receives requests.id
- The id under which the taskManager is registered.resources
- The resources available on the machine.numberOfSlots
- The number of task slots offered by this taskManager.public ResourceID getTaskManagerID()
public InstanceID getId()
public HardwareDescription getResources()
public int getTotalNumberOfSlots()
public boolean isAlive()
public void markDead()
public long getLastHeartBeat()
public void reportHeartBeat()
public boolean isStillAlive(long now, long cleanUpInterval)
n
milliseconds
before the given timestamp now
.now
- The timestamp representing the current time.cleanUpInterval
- The maximum time (in msecs) that the last heartbeat may lie in the past.public SimpleSlot allocateSimpleSlot(JobID jobID) throws InstanceDiedException
null
, if no slot
is available at the moment.jobID
- The ID of the job that the slot is allocated for.InstanceDiedException
- Thrown if the instance is no longer alive by the time the
slot is allocated.public SharedSlot allocateSharedSlot(JobID jobID, SlotSharingGroupAssignment sharingGroupAssignment) throws InstanceDiedException
null
, if no slot
is available at the moment. The shared slot will be managed by the given SlotSharingGroupAssignment.jobID
- The ID of the job that the slot is allocated for.sharingGroupAssignment
- The assignment group that manages this shared slot.InstanceDiedException
- Thrown if the instance is no longer alive by the time the slot is allocated.public boolean returnAllocatedSlot(Slot slot)
The method will transition the slot to the "released" state. If the slot is already in state "released", this method will do nothing.
returnAllocatedSlot
in interface SlotOwner
slot
- The slot to return.public void cancelAndReleaseAllSlots()
public TaskManagerGateway getTaskManagerGateway()
public TaskManagerLocation getTaskManagerLocation()
public int getNumberOfAvailableSlots()
public int getNumberOfAllocatedSlots()
public boolean hasResourcesAvailable()
public void setSlotAvailabilityListener(SlotAvailabilityListener slotAvailabilityListener)
slotAvailabilityListener
- The listener.public void removeSlotListener()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.