Search in sources :

Example 1 with TaskExecutorRegistrationRejection

use of org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationRejection in project flink by apache.

the class ResourceManager method registerTaskExecutorInternal.

/**
 * Registers a new TaskExecutor.
 *
 * @param taskExecutorRegistration task executor registration parameters
 * @return RegistrationResponse
 */
private RegistrationResponse registerTaskExecutorInternal(TaskExecutorGateway taskExecutorGateway, TaskExecutorRegistration taskExecutorRegistration) {
    ResourceID taskExecutorResourceId = taskExecutorRegistration.getResourceId();
    WorkerRegistration<WorkerType> oldRegistration = taskExecutors.remove(taskExecutorResourceId);
    if (oldRegistration != null) {
        // TODO :: suggest old taskExecutor to stop itself
        log.debug("Replacing old registration of TaskExecutor {}.", taskExecutorResourceId.getStringWithMetadata());
        // remove old task manager registration from slot manager
        slotManager.unregisterTaskManager(oldRegistration.getInstanceID(), new ResourceManagerException(String.format("TaskExecutor %s re-connected to the ResourceManager.", taskExecutorResourceId.getStringWithMetadata())));
    }
    final WorkerType newWorker = workerStarted(taskExecutorResourceId);
    String taskExecutorAddress = taskExecutorRegistration.getTaskExecutorAddress();
    if (newWorker == null) {
        log.warn("Discard registration from TaskExecutor {} at ({}) because the framework did " + "not recognize it", taskExecutorResourceId.getStringWithMetadata(), taskExecutorAddress);
        return new TaskExecutorRegistrationRejection("The ResourceManager does not recognize this TaskExecutor.");
    } else {
        WorkerRegistration<WorkerType> registration = new WorkerRegistration<>(taskExecutorGateway, newWorker, taskExecutorRegistration.getDataPort(), taskExecutorRegistration.getJmxPort(), taskExecutorRegistration.getHardwareDescription(), taskExecutorRegistration.getMemoryConfiguration(), taskExecutorRegistration.getTotalResourceProfile(), taskExecutorRegistration.getDefaultSlotResourceProfile());
        log.info("Registering TaskManager with ResourceID {} ({}) at ResourceManager", taskExecutorResourceId.getStringWithMetadata(), taskExecutorAddress);
        taskExecutors.put(taskExecutorResourceId, registration);
        taskManagerHeartbeatManager.monitorTarget(taskExecutorResourceId, new TaskExecutorHeartbeatSender(taskExecutorGateway));
        return new TaskExecutorRegistrationSuccess(registration.getInstanceID(), resourceId, clusterInformation);
    }
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TaskExecutorRegistrationRejection(org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationRejection) TaskExecutorRegistrationSuccess(org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationSuccess) WorkerRegistration(org.apache.flink.runtime.resourcemanager.registration.WorkerRegistration) ResourceManagerException(org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException)

Aggregations

ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 ResourceManagerException (org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException)1 WorkerRegistration (org.apache.flink.runtime.resourcemanager.registration.WorkerRegistration)1 TaskExecutorRegistrationRejection (org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationRejection)1 TaskExecutorRegistrationSuccess (org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationSuccess)1