public class SharedSlot extends Slot implements LogicalSlot
SimpleSlot
instances within itself. This allows to
schedule multiple tasks simultaneously to the same resource. Sharing a resource with multiple
tasks is crucial for simple pipelined / streamed execution, where both the sender and the receiver
are typically active at the same time.
IMPORTANT: This class contains no synchronization. Thus, the caller has to guarantee proper
synchronization. In the current implementation, all concurrently modifying operations are
passed through a SlotSharingGroupAssignment
object which is responsible for
synchronization.
LogicalSlot.Payload
NO_ALLOCATION_ID, NO_SLOT_REQUEST_ID, NO_SLOT_SHARING_GROUP_ID
TERMINATED_PAYLOAD
Constructor and Description |
---|
SharedSlot(SlotContext slotContext,
SlotOwner owner,
SlotSharingGroupAssignment assignmentGroup)
Creates a new shared slot that has no parent (is a root slot) and does not belong to any task group.
|
SharedSlot(SlotOwner owner,
TaskManagerLocation location,
int slotNumber,
TaskManagerGateway taskManagerGateway,
SlotSharingGroupAssignment assignmentGroup)
Creates a new shared slot that has no parent (is a root slot) and does not belong to any task group.
|
SharedSlot(SlotOwner owner,
TaskManagerLocation location,
int slotNumber,
TaskManagerGateway taskManagerGateway,
SlotSharingGroupAssignment assignmentGroup,
SharedSlot parent,
AbstractID groupId)
Creates a new shared slot that has is a sub-slot of the given parent shared slot, and that belongs
to the given task group.
|
Modifier and Type | Method and Description |
---|---|
AllocationID |
getAllocationId()
Gets the allocation id of this slot.
|
Locality |
getLocality()
Gets the locality of this slot.
|
int |
getNumberLeaves()
Gets the number of simple slots that are at the leaves of the tree of slots.
|
LogicalSlot.Payload |
getPayload()
Returns the set payload or null if none.
|
int |
getPhysicalSlotNumber()
Gets the slot number on the TaskManager.
|
SlotRequestId |
getSlotRequestId()
Gets the slot request id uniquely identifying the request with which this
slot has been allocated.
|
SlotSharingGroupId |
getSlotSharingGroupId()
Gets the slot sharing group id to which this slot belongs.
|
boolean |
hasChildren()
Checks whether this shared slot has any sub slots.
|
boolean |
isRootAndEmpty()
Checks whether this slot is a root slot that has not yet added any child slots.
|
CompletableFuture<?> |
releaseSlot(Throwable cause)
This method cancels and releases the slot and all its sub-slots.
|
String |
toString() |
boolean |
tryAssignPayload(LogicalSlot.Payload payload)
Tries to assign a payload to this slot.
|
equals, getGroupID, getOwner, getParent, getRoot, getRootSlotNumber, getSlotContext, getSlotNumber, getTaskManagerGateway, getTaskManagerID, getTaskManagerLocation, hashCode, hierarchy, isAlive, isCanceled, isReleased
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getTaskManagerGateway, getTaskManagerLocation, isAlive, releaseSlot
public SharedSlot(SlotOwner owner, TaskManagerLocation location, int slotNumber, TaskManagerGateway taskManagerGateway, SlotSharingGroupAssignment assignmentGroup)
owner
- The component from which this slot is allocated.location
- The location info of the TaskManager where the slot was allocated fromslotNumber
- The number of the slot.taskManagerGateway
- The gateway to communicate with the TaskManagerassignmentGroup
- The assignment group that this shared slot belongs to.public SharedSlot(SlotOwner owner, TaskManagerLocation location, int slotNumber, TaskManagerGateway taskManagerGateway, SlotSharingGroupAssignment assignmentGroup, @Nullable SharedSlot parent, @Nullable AbstractID groupId)
owner
- The component from which this slot is allocated.location
- The location info of the TaskManager where the slot was allocated fromslotNumber
- The number of the slot.taskManagerGateway
- The gateway to communicate with the TaskManagerassignmentGroup
- The assignment group that this shared slot belongs to.parent
- The parent slot of this slot.groupId
- The assignment group of this slot.public SharedSlot(SlotContext slotContext, SlotOwner owner, SlotSharingGroupAssignment assignmentGroup)
slotContext
- The slot context of this shared slotowner
- The component from which this slot is allocated.assignmentGroup
- The assignment group that this shared slot belongs to.public int getNumberLeaves()
Slot
getNumberLeaves
in class Slot
public boolean isRootAndEmpty()
public boolean hasChildren()
public Locality getLocality()
LogicalSlot
getLocality
in interface LogicalSlot
public boolean tryAssignPayload(LogicalSlot.Payload payload)
LogicalSlot
tryAssignPayload
in interface LogicalSlot
payload
- to be assigned to this slot.@Nullable public LogicalSlot.Payload getPayload()
LogicalSlot
getPayload
in interface LogicalSlot
public CompletableFuture<?> releaseSlot(@Nullable Throwable cause)
Slot
Slot.isReleased()
method will return true
.
If this slot is a simple slot, it will be returned to its instance. If it is a shared slot,
it will release all of its sub-slots and release itself.releaseSlot
in interface LogicalSlot
releaseSlot
in class Slot
cause
- why the slot was released or null if nonepublic int getPhysicalSlotNumber()
LogicalSlot
getPhysicalSlotNumber
in interface LogicalSlot
public AllocationID getAllocationId()
LogicalSlot
getAllocationId
in interface LogicalSlot
public SlotRequestId getSlotRequestId()
LogicalSlot
getSlotRequestId
in interface LogicalSlot
@Nullable public SlotSharingGroupId getSlotSharingGroupId()
LogicalSlot
getSlotSharingGroupId
in interface LogicalSlot
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.