use of org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRejected in project flink by apache.
the class ResourceManager method requestSlot.
/**
* Requests a slot from the resource manager.
*
* @param slotRequest Slot request
* @return Slot assignment
*/
@RpcMethod
public RMSlotRequestReply requestSlot(UUID jobMasterLeaderID, UUID resourceManagerLeaderID, SlotRequest slotRequest) {
log.info("Request slot with profile {} for job {} with allocation id {}.", slotRequest.getResourceProfile(), slotRequest.getJobId(), slotRequest.getAllocationId());
JobID jobId = slotRequest.getJobId();
JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);
if (jobManagerRegistration != null && jobMasterLeaderID.equals(jobManagerRegistration.getLeaderID()) && resourceManagerLeaderID.equals(leaderSessionId)) {
return slotManager.requestSlot(slotRequest);
} else {
log.info("Ignoring slot request for unknown JobMaster with JobID {}", jobId);
return new RMSlotRequestRejected(slotRequest.getAllocationId());
}
}
use of org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRejected in project flink by apache.
the class SlotPool method requestSlotFromResourceManager.
private void requestSlotFromResourceManager(final AllocationID allocationID, final FlinkCompletableFuture<SimpleSlot> future, final ResourceProfile resources) {
LOG.info("Requesting slot with profile {} from resource manager (request = {}).", resources, allocationID);
pendingRequests.put(allocationID, new PendingRequest(allocationID, future, resources));
Future<RMSlotRequestReply> rmResponse = resourceManagerGateway.requestSlot(jobManagerLeaderId, resourceManagerLeaderId, new SlotRequest(jobId, allocationID, resources), resourceManagerRequestsTimeout);
// on success, trigger let the slot pool know
rmResponse.thenAcceptAsync(new AcceptFunction<RMSlotRequestReply>() {
@Override
public void accept(RMSlotRequestReply reply) {
if (reply.getAllocationID() != null && reply.getAllocationID().equals(allocationID)) {
if (reply instanceof RMSlotRequestRegistered) {
slotRequestToResourceManagerSuccess(allocationID);
} else if (reply instanceof RMSlotRequestRejected) {
slotRequestToResourceManagerFailed(allocationID, new Exception("ResourceManager rejected slot request"));
} else {
slotRequestToResourceManagerFailed(allocationID, new Exception("Unknown ResourceManager response: " + reply));
}
} else {
future.completeExceptionally(new Exception(String.format("Bug: ResourceManager response had wrong AllocationID. Request: %s , Response: %s", allocationID, reply.getAllocationID())));
}
}
}, getMainThreadExecutor());
// on failure, fail the request future
rmResponse.exceptionallyAsync(new ApplyFunction<Throwable, Void>() {
@Override
public Void apply(Throwable failure) {
slotRequestToResourceManagerFailed(allocationID, failure);
return null;
}
}, getMainThreadExecutor());
}
Aggregations