use of org.apache.flink.runtime.clusterframework.types.SlotID in project flink by apache.
the class TaskExecutor method freeSlot.
private void freeSlot(AllocationID allocationId, Throwable cause) {
Preconditions.checkNotNull(allocationId);
try {
int freedSlotIndex = taskSlotTable.freeSlot(allocationId, cause);
if (freedSlotIndex != -1 && isConnectedToResourceManager()) {
// the slot was freed. Tell the RM about it
ResourceManagerGateway resourceManagerGateway = resourceManagerConnection.getTargetGateway();
resourceManagerGateway.notifySlotAvailable(resourceManagerConnection.getTargetLeaderId(), resourceManagerConnection.getRegistrationId(), new SlotID(getResourceID(), freedSlotIndex));
}
} catch (SlotNotFoundException e) {
log.debug("Could not free slot for allocation id {}.", allocationId, e);
}
}
use of org.apache.flink.runtime.clusterframework.types.SlotID in project flink by apache.
the class SlotManager method notifySlotAvailable.
/**
* Notifies the SlotManager that a slot is available again after being allocated.
* @param slotID slot id of available slot
*/
public void notifySlotAvailable(ResourceID resourceID, SlotID slotID) {
if (!allocationMap.isAllocated(slotID)) {
throw new IllegalStateException("Slot was not previously allocated but " + "TaskManager reports it as available again");
}
allocationMap.removeAllocation(slotID);
final Map<SlotID, ResourceSlot> slots = registeredSlots.get(resourceID);
ResourceSlot freeSlot = slots.get(slotID);
if (freeSlot == null) {
throw new IllegalStateException("Slot was not registered with SlotManager but " + "TaskManager reported it to be available.");
}
handleFreeSlot(freeSlot);
}
use of org.apache.flink.runtime.clusterframework.types.SlotID in project flink by apache.
the class SlotManager method notifyTaskManagerFailure.
/**
* Callback for TaskManager failures. In case that a TaskManager fails, we have to clean up all its slots.
*
* @param resourceId The ResourceID of the TaskManager
*/
public void notifyTaskManagerFailure(final ResourceID resourceId) {
LOG.info("Resource:{} been notified failure", resourceId);
taskManagers.remove(resourceId);
final Map<SlotID, ResourceSlot> slotIdsToRemove = registeredSlots.remove(resourceId);
if (slotIdsToRemove != null) {
for (SlotID slotId : slotIdsToRemove.keySet()) {
LOG.info("Removing Slot: {} upon resource failure", slotId);
if (freeSlots.containsKey(slotId)) {
freeSlots.remove(slotId);
} else if (allocationMap.isAllocated(slotId)) {
allocationMap.removeAllocation(slotId);
} else {
LOG.error("BUG! {} is neither in free pool nor in allocated pool", slotId);
}
}
}
}
use of org.apache.flink.runtime.clusterframework.types.SlotID in project flink by apache.
the class SlotManager method addFreeSlot.
/**
* Add free slots directly to the free pool, this will not trigger pending requests allocation
*
* @param slot The resource slot
*/
@VisibleForTesting
void addFreeSlot(final ResourceSlot slot) {
final ResourceID resourceId = slot.getResourceID();
final SlotID slotId = slot.getSlotId();
if (!registeredSlots.containsKey(resourceId)) {
registeredSlots.put(resourceId, new HashMap<SlotID, ResourceSlot>());
}
registeredSlots.get(resourceId).put(slot.getSlotId(), slot);
freeSlots.put(slotId, slot);
}
use of org.apache.flink.runtime.clusterframework.types.SlotID in project flink by apache.
the class SlotManager method registerNewSlot.
/**
* Registers a new slot with the SlotManager.
*
* @param slot The ResourceSlot which will be registered
*/
private void registerNewSlot(final ResourceSlot slot) {
final SlotID slotId = slot.getSlotId();
final ResourceID resourceId = slotId.getResourceID();
if (!registeredSlots.containsKey(resourceId)) {
registeredSlots.put(resourceId, new HashMap<SlotID, ResourceSlot>());
}
registeredSlots.get(resourceId).put(slotId, slot);
}
Aggregations