Search in sources :

Example 1 with RMSlotRequestRejected

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());
    }
}
Also used : RMSlotRequestRejected(org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRejected) JobID(org.apache.flink.api.common.JobID) JobManagerRegistration(org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration) RpcMethod(org.apache.flink.runtime.rpc.RpcMethod)

Example 2 with RMSlotRequestRejected

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());
}
Also used : RMSlotRequestRejected(org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRejected) RMSlotRequestRegistered(org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRegistered) RMSlotRequestReply(org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestReply) SlotRequest(org.apache.flink.runtime.resourcemanager.SlotRequest) NoResourceAvailableException(org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

RMSlotRequestRejected (org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRejected)2 TimeoutException (java.util.concurrent.TimeoutException)1 JobID (org.apache.flink.api.common.JobID)1 NoResourceAvailableException (org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException)1 SlotRequest (org.apache.flink.runtime.resourcemanager.SlotRequest)1 RMSlotRequestRegistered (org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRegistered)1 RMSlotRequestReply (org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestReply)1 JobManagerRegistration (org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration)1 RpcMethod (org.apache.flink.runtime.rpc.RpcMethod)1