Search in sources :

Example 1 with FatalErrorHandler

use of org.apache.flink.runtime.rpc.FatalErrorHandler in project flink by apache.

the class TaskExecutorTest method testImmediatelyRegistersIfLeaderIsKnown.

@Test
public void testImmediatelyRegistersIfLeaderIsKnown() throws Exception {
    final ResourceID resourceID = ResourceID.generate();
    final String resourceManagerAddress = "/resource/manager/address/one";
    final TestingSerialRpcService rpc = new TestingSerialRpcService();
    try {
        final FatalErrorHandler errorHandler = mock(FatalErrorHandler.class);
        // register a mock resource manager gateway
        ResourceManagerGateway rmGateway = mock(ResourceManagerGateway.class);
        when(rmGateway.registerTaskExecutor(any(UUID.class), anyString(), any(ResourceID.class), any(SlotReport.class), any(Time.class))).thenReturn(FlinkCompletableFuture.<RegistrationResponse>completed(new RegistrationResponse.Success()));
        TaskManagerConfiguration taskManagerServicesConfiguration = mock(TaskManagerConfiguration.class);
        when(taskManagerServicesConfiguration.getNumberSlots()).thenReturn(1);
        rpc.registerGateway(resourceManagerAddress, rmGateway);
        TaskManagerLocation taskManagerLocation = mock(TaskManagerLocation.class);
        when(taskManagerLocation.getResourceID()).thenReturn(resourceID);
        NonHaServices haServices = new NonHaServices(resourceManagerAddress);
        final TaskSlotTable taskSlotTable = mock(TaskSlotTable.class);
        final SlotReport slotReport = new SlotReport();
        when(taskSlotTable.createSlotReport(any(ResourceID.class))).thenReturn(slotReport);
        final TestingFatalErrorHandler testingFatalErrorHandler = new TestingFatalErrorHandler();
        TaskExecutor taskManager = new TaskExecutor(taskManagerServicesConfiguration, taskManagerLocation, rpc, mock(MemoryManager.class), mock(IOManager.class), mock(NetworkEnvironment.class), haServices, mock(HeartbeatServices.class, RETURNS_MOCKS), mock(MetricRegistry.class), mock(TaskManagerMetricGroup.class), mock(BroadcastVariableManager.class), mock(FileCache.class), taskSlotTable, mock(JobManagerTable.class), mock(JobLeaderService.class), testingFatalErrorHandler);
        taskManager.start();
        String taskManagerAddress = taskManager.getAddress();
        verify(rmGateway).registerTaskExecutor(any(UUID.class), eq(taskManagerAddress), eq(resourceID), eq(slotReport), any(Time.class));
        // check if a concurrent error occurred
        testingFatalErrorHandler.rethrowError();
    } finally {
        rpc.stopService();
    }
}
Also used : Time(org.apache.flink.api.common.time.Time) JMTMRegistrationSuccess(org.apache.flink.runtime.jobmaster.JMTMRegistrationSuccess) ResourceManagerGateway(org.apache.flink.runtime.resourcemanager.ResourceManagerGateway) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) NonHaServices(org.apache.flink.runtime.highavailability.NonHaServices) BroadcastVariableManager(org.apache.flink.runtime.broadcast.BroadcastVariableManager) TestingSerialRpcService(org.apache.flink.runtime.rpc.TestingSerialRpcService) UUID(java.util.UUID) TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) HeartbeatServices(org.apache.flink.runtime.heartbeat.HeartbeatServices) IOManager(org.apache.flink.runtime.io.disk.iomanager.IOManager) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) TaskManagerMetricGroup(org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup) MemoryManager(org.apache.flink.runtime.memory.MemoryManager) FileCache(org.apache.flink.runtime.filecache.FileCache) TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) FatalErrorHandler(org.apache.flink.runtime.rpc.FatalErrorHandler) TaskSlotTable(org.apache.flink.runtime.taskexecutor.slot.TaskSlotTable) NetworkEnvironment(org.apache.flink.runtime.io.network.NetworkEnvironment) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)1 Time (org.apache.flink.api.common.time.Time)1 BroadcastVariableManager (org.apache.flink.runtime.broadcast.BroadcastVariableManager)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 FileCache (org.apache.flink.runtime.filecache.FileCache)1 HeartbeatServices (org.apache.flink.runtime.heartbeat.HeartbeatServices)1 NonHaServices (org.apache.flink.runtime.highavailability.NonHaServices)1 IOManager (org.apache.flink.runtime.io.disk.iomanager.IOManager)1 NetworkEnvironment (org.apache.flink.runtime.io.network.NetworkEnvironment)1 JMTMRegistrationSuccess (org.apache.flink.runtime.jobmaster.JMTMRegistrationSuccess)1 MemoryManager (org.apache.flink.runtime.memory.MemoryManager)1 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)1 TaskManagerMetricGroup (org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup)1 ResourceManagerGateway (org.apache.flink.runtime.resourcemanager.ResourceManagerGateway)1 FatalErrorHandler (org.apache.flink.runtime.rpc.FatalErrorHandler)1 TestingSerialRpcService (org.apache.flink.runtime.rpc.TestingSerialRpcService)1 TaskSlotTable (org.apache.flink.runtime.taskexecutor.slot.TaskSlotTable)1 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)1 TestingFatalErrorHandler (org.apache.flink.runtime.util.TestingFatalErrorHandler)1 Test (org.junit.Test)1