Search in sources :

Example 26 with TaskExecutorGateway

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

the class JobMasterQueryableStateTest method registerSlotsRequiredForJobExecution.

private static void registerSlotsRequiredForJobExecution(JobMasterGateway jobMasterGateway, JobID jobId) throws ExecutionException, InterruptedException {
    final OneShotLatch oneTaskSubmittedLatch = new OneShotLatch();
    final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setSubmitTaskConsumer((taskDeploymentDescriptor, jobMasterId) -> {
        oneTaskSubmittedLatch.trigger();
        return CompletableFuture.completedFuture(Acknowledge.get());
    }).createTestingTaskExecutorGateway();
    JobMasterTestUtils.registerTaskExecutorAndOfferSlots(rpcService, jobMasterGateway, jobId, PARALLELISM, taskExecutorGateway, testingTimeout);
    oneTaskSubmittedLatch.await();
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) BeforeClass(org.junit.BeforeClass) TestingRpcService(org.apache.flink.runtime.rpc.TestingRpcService) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobMasterBuilder(org.apache.flink.runtime.jobmaster.utils.JobMasterBuilder) ExceptionUtils(org.apache.flink.util.ExceptionUtils) CompletableFuture(java.util.concurrent.CompletableFuture) CoreMatchers.either(org.hamcrest.CoreMatchers.either) JobStatus(org.apache.flink.api.common.JobStatus) JobType(org.apache.flink.runtime.jobgraph.JobType) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) InetAddress(java.net.InetAddress) Assert.assertThat(org.junit.Assert.assertThat) After(org.junit.After) JobGraphTestUtils(org.apache.flink.runtime.jobgraph.JobGraphTestUtils) TestLogger(org.apache.flink.util.TestLogger) Assert.fail(org.junit.Assert.fail) KeyGroupRange(org.apache.flink.runtime.state.KeyGroupRange) AfterClass(org.junit.AfterClass) UnknownKvStateLocation(org.apache.flink.runtime.query.UnknownKvStateLocation) KvStateLocation(org.apache.flink.runtime.query.KvStateLocation) FlinkMatchers.containsCause(org.apache.flink.core.testutils.FlinkMatchers.containsCause) AbstractInvokable(org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) RpcUtils(org.apache.flink.runtime.rpc.RpcUtils) InetSocketAddress(java.net.InetSocketAddress) UnknownHostException(java.net.UnknownHostException) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) ExecutionException(java.util.concurrent.ExecutionException) JobID(org.apache.flink.api.common.JobID) FlinkJobNotFoundException(org.apache.flink.runtime.messages.FlinkJobNotFoundException) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder) Time(org.apache.flink.api.common.time.Time) KvStateID(org.apache.flink.queryablestate.KvStateID) Assert.assertEquals(org.junit.Assert.assertEquals) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder)

Example 27 with TaskExecutorGateway

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

the class JobMasterTestUtils method registerTaskExecutorAndOfferSlots.

public static void registerTaskExecutorAndOfferSlots(TestingRpcService rpcService, JobMasterGateway jobMasterGateway, JobID jobId, int numSlots, TaskExecutorGateway taskExecutorGateway, Time testingTimeout) throws ExecutionException, InterruptedException {
    final UnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
    rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
    jobMasterGateway.registerTaskManager(jobId, TaskManagerRegistrationInformation.create(taskExecutorGateway.getAddress(), unresolvedTaskManagerLocation, TestingUtils.zeroUUID()), testingTimeout).get();
    Collection<SlotOffer> slotOffers = IntStream.range(0, numSlots).mapToObj(index -> new SlotOffer(new AllocationID(), index, ResourceProfile.ANY)).collect(Collectors.toList());
    jobMasterGateway.offerSlots(unresolvedTaskManagerLocation.getResourceID(), slotOffers, testingTimeout).get();
}
Also used : IntStream(java.util.stream.IntStream) LocalUnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalUnresolvedTaskManagerLocation) TestingRpcService(org.apache.flink.runtime.rpc.TestingRpcService) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) ExecutionException(java.util.concurrent.ExecutionException) TestingUtils(org.apache.flink.testutils.TestingUtils) JobID(org.apache.flink.api.common.JobID) UnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.UnresolvedTaskManagerLocation) Time(org.apache.flink.api.common.time.Time) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) LocalUnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalUnresolvedTaskManagerLocation) UnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.UnresolvedTaskManagerLocation) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) LocalUnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalUnresolvedTaskManagerLocation)

Example 28 with TaskExecutorGateway

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

the class ResourceManagerTest method testRequestTaskManagerInfo.

/**
 * Tests that we can retrieve the correct {@link TaskManagerInfo} from the {@link
 * ResourceManager}.
 */
@Test
public void testRequestTaskManagerInfo() throws Exception {
    final ResourceID taskManagerId = ResourceID.generate();
    final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setAddress(UUID.randomUUID().toString()).createTestingTaskExecutorGateway();
    rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
    resourceManager = new ResourceManagerBuilder().buildAndStart();
    final ResourceManagerGateway resourceManagerGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
    registerTaskExecutor(resourceManagerGateway, taskManagerId, taskExecutorGateway.getAddress());
    CompletableFuture<TaskManagerInfoWithSlots> taskManagerInfoFuture = resourceManagerGateway.requestTaskManagerDetailsInfo(taskManagerId, TestingUtils.TIMEOUT);
    TaskManagerInfoWithSlots taskManagerInfoWithSlots = taskManagerInfoFuture.get();
    TaskManagerInfo taskManagerInfo = taskManagerInfoWithSlots.getTaskManagerInfo();
    assertEquals(taskManagerId, taskManagerInfo.getResourceId());
    assertEquals(hardwareDescription, taskManagerInfo.getHardwareDescription());
    assertEquals(taskExecutorGateway.getAddress(), taskManagerInfo.getAddress());
    assertEquals(dataPort, taskManagerInfo.getDataPort());
    assertEquals(jmxPort, taskManagerInfo.getJmxPort());
    assertEquals(0, taskManagerInfo.getNumberSlots());
    assertEquals(0, taskManagerInfo.getNumberAvailableSlots());
    assertThat(taskManagerInfoWithSlots.getAllocatedSlots(), is(empty()));
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TaskManagerInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder) Test(org.junit.Test)

Example 29 with TaskExecutorGateway

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

the class ResourceManagerTest method testDisconnectTaskManager.

@Test
public void testDisconnectTaskManager() throws Exception {
    final ResourceID taskExecutorId = ResourceID.generate();
    final CompletableFuture<Exception> disconnectFuture = new CompletableFuture<>();
    final CompletableFuture<ResourceID> stopWorkerFuture = new CompletableFuture<>();
    final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setDisconnectResourceManagerConsumer(disconnectFuture::complete).createTestingTaskExecutorGateway();
    rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
    resourceManager = new ResourceManagerBuilder().withStopWorkerFunction(stopWorkerFuture::complete).buildAndStart();
    registerTaskExecutor(resourceManager, taskExecutorId, taskExecutorGateway.getAddress());
    resourceManager.disconnectTaskManager(taskExecutorId, new FlinkException("Test exception"));
    assertThat(disconnectFuture.get(), instanceOf(FlinkException.class));
    assertThat(stopWorkerFuture.get(), is(taskExecutorId));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder) TimeoutException(java.util.concurrent.TimeoutException) FlinkException(org.apache.flink.util.FlinkException) ResourceManagerException(org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException) RecipientUnreachableException(org.apache.flink.runtime.rpc.exceptions.RecipientUnreachableException) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 30 with TaskExecutorGateway

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

the class ResourceManagerTest method testRequestTaskExecutorGateway.

/**
 * Tests that we can retrieve the correct {@link TaskExecutorGateway} from the {@link
 * ResourceManager}.
 */
@Test
public void testRequestTaskExecutorGateway() throws Exception {
    final ResourceID taskManagerId = ResourceID.generate();
    final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setAddress(UUID.randomUUID().toString()).createTestingTaskExecutorGateway();
    rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
    resourceManager = new ResourceManagerBuilder().buildAndStart();
    final ResourceManagerGateway resourceManagerGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
    registerTaskExecutor(resourceManagerGateway, taskManagerId, taskExecutorGateway.getAddress());
    CompletableFuture<TaskExecutorThreadInfoGateway> taskExecutorGatewayFuture = resourceManagerGateway.requestTaskExecutorThreadInfoGateway(taskManagerId, TestingUtils.TIMEOUT);
    TaskExecutorThreadInfoGateway taskExecutorGatewayResult = taskExecutorGatewayFuture.get();
    assertEquals(taskExecutorGateway, taskExecutorGatewayResult);
}
Also used : TaskExecutorThreadInfoGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorThreadInfoGateway) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder) Test(org.junit.Test)

Aggregations

TaskExecutorGateway (org.apache.flink.runtime.taskexecutor.TaskExecutorGateway)45 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)36 Test (org.junit.Test)34 CompletableFuture (java.util.concurrent.CompletableFuture)29 JobID (org.apache.flink.api.common.JobID)29 TestingTaskExecutorGatewayBuilder (org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder)29 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)27 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)27 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)25 ArrayList (java.util.ArrayList)22 Matchers.is (org.hamcrest.Matchers.is)22 TestingTaskExecutorGateway (org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGateway)21 Matchers.empty (org.hamcrest.Matchers.empty)21 Matchers.equalTo (org.hamcrest.Matchers.equalTo)21 Collections (java.util.Collections)20 List (java.util.List)20 SlotID (org.apache.flink.runtime.clusterframework.types.SlotID)20 TimeoutException (java.util.concurrent.TimeoutException)19 ResourceManagerId (org.apache.flink.runtime.resourcemanager.ResourceManagerId)19 Collection (java.util.Collection)18