public class Instance extends Object
TaskManager
registered at a JobManager and ready to receive work.Constructor and Description |
---|
Instance(ActorGateway actorGateway,
InstanceConnectionInfo connectionInfo,
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() |
ActorGateway |
getActorGateway()
Returns the InstanceGateway of this Instance.
|
InstanceID |
getId() |
InstanceConnectionInfo |
getInstanceConnectionInfo() |
long |
getLastHeartBeat()
Gets the timestamp of the last heartbeat.
|
byte[] |
getLastMetricsReport() |
int |
getNumberOfAllocatedSlots() |
int |
getNumberOfAvailableSlots() |
HardwareDescription |
getResources() |
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 |
setMetricsReport(byte[] lastMetricsReport) |
void |
setSlotAvailabilityListener(SlotAvailabilityListener slotAvailabilityListener)
Sets the listener that receives notifications for slot availability.
|
String |
toString() |
public Instance(ActorGateway actorGateway, InstanceConnectionInfo connectionInfo, InstanceID id, HardwareDescription resources, int numberOfSlots)
actorGateway
- The actor gateway to communicate with the remote instanceconnectionInfo
- 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 InstanceID getId()
public HardwareDescription getResources()
public int getTotalNumberOfSlots()
public boolean isAlive()
public void markDead()
public long getLastHeartBeat()
public void reportHeartBeat()
public void setMetricsReport(byte[] lastMetricsReport)
public byte[] getLastMetricsReport()
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.
slot
- The slot to return.public void cancelAndReleaseAllSlots()
public ActorGateway getActorGateway()
public InstanceConnectionInfo getInstanceConnectionInfo()
public int getNumberOfAvailableSlots()
public int getNumberOfAllocatedSlots()
public boolean hasResourcesAvailable()
public void setSlotAvailabilityListener(SlotAvailabilityListener slotAvailabilityListener)
slotAvailabilityListener
- The listener.public void removeSlotListener()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.