org.apache.flink.runtime.taskexecutor.slot.TaskSlotTable Java Examples
The following examples show how to use
org.apache.flink.runtime.taskexecutor.slot.TaskSlotTable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 6 votes |
private TaskExecutorTestingContext createTaskExecutorTestingContext(final TaskSlotTable<Task> taskSlotTable) throws IOException { final OneShotLatch offerSlotsLatch = new OneShotLatch(); final TestingJobMasterGateway jobMasterGateway = new TestingJobMasterGatewayBuilder() .setOfferSlotsFunction((resourceID, slotOffers) -> { offerSlotsLatch.trigger(); return CompletableFuture.completedFuture(slotOffers); }).build(); rpc.registerGateway(jobMasterGateway.getAddress(), jobMasterGateway); final JobLeaderService jobLeaderService = new DefaultJobLeaderService( unresolvedTaskManagerLocation, RetryingRegistrationConfiguration.defaultConfiguration()); TaskExecutorLocalStateStoresManager stateStoresManager = createTaskExecutorLocalStateStoresManager(); final TestingTaskExecutor taskExecutor = createTestingTaskExecutor(new TaskManagerServicesBuilder() .setTaskSlotTable(taskSlotTable) .setJobLeaderService(jobLeaderService) .setTaskStateManager(stateStoresManager) .build()); jobManagerLeaderRetriever.notifyListener(jobMasterGateway.getAddress(), jobMasterGateway.getFencingToken().toUUID()); return new TaskExecutorTestingContext(jobMasterGateway, taskSlotTable, taskExecutor); }
Example #2
Source File: TaskManagerServicesBuilder.java From flink with Apache License 2.0 | 6 votes |
public TaskManagerServicesBuilder() { taskManagerLocation = new LocalTaskManagerLocation(); memoryManager = new MemoryManager( MemoryManager.MIN_PAGE_SIZE, 1, MemoryManager.MIN_PAGE_SIZE, MemoryType.HEAP, false); ioManager = mock(IOManager.class); shuffleEnvironment = mock(ShuffleEnvironment.class); kvStateService = new KvStateService(new KvStateRegistry(), null, null); broadcastVariableManager = new BroadcastVariableManager(); taskEventDispatcher = new TaskEventDispatcher(); taskSlotTable = mock(TaskSlotTable.class); jobManagerTable = new JobManagerTable(); jobLeaderService = new JobLeaderService(taskManagerLocation, RetryingRegistrationConfiguration.defaultConfiguration()); taskStateManager = mock(TaskExecutorLocalStateStoresManager.class); }
Example #3
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that we can submit a task to the TaskManager given that we've allocated a slot there. */ @Test(timeout = TEST_TIMEOUT) public void testTaskSubmission() throws Exception { final ExecutionAttemptID eid = new ExecutionAttemptID(); final TaskDeploymentDescriptor tdd = createTestTaskDeploymentDescriptor("test task", eid, FutureCompletingInvokable.class); final CompletableFuture<Void> taskRunningFuture = new CompletableFuture<>(); try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .setSlotSize(1) .addTaskManagerActionListener(eid, ExecutionState.RUNNING, taskRunningFuture) .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd, env.getJobMasterId(), timeout).get(); taskRunningFuture.get(); } }
Example #4
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the TaskManager sends a proper exception back to the sender if the submit task * message fails. */ @Test(timeout = TEST_TIMEOUT) public void testSubmitTaskFailure() throws Exception { final ExecutionAttemptID eid = new ExecutionAttemptID(); final TaskDeploymentDescriptor tdd = createTestTaskDeploymentDescriptor( "test task", eid, BlockingNoOpInvokable.class, 0); // this will make the submission fail because the number of key groups must be >= 1 try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd, env.getJobMasterId(), timeout).get(); } catch (Exception e) { assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); } }
Example #5
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that we can submit a task to the TaskManager given that we've allocated a slot there. */ @Test(timeout = 10000L) public void testTaskSubmission() throws Exception { final ExecutionAttemptID eid = new ExecutionAttemptID(); final TaskDeploymentDescriptor tdd = createTestTaskDeploymentDescriptor("test task", eid, TaskExecutorTest.TestInvokable.class); final CompletableFuture<Void> taskRunningFuture = new CompletableFuture<>(); try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .setSlotSize(1) .addTaskManagerActionListener(eid, ExecutionState.RUNNING, taskRunningFuture) .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd, env.getJobMasterId(), timeout).get(); taskRunningFuture.get(); } }
Example #6
Source File: TaskManagerServices.java From flink with Apache License 2.0 | 6 votes |
TaskManagerServices( TaskManagerLocation taskManagerLocation, MemoryManager memoryManager, IOManager ioManager, ShuffleEnvironment<?, ?> shuffleEnvironment, KvStateService kvStateService, BroadcastVariableManager broadcastVariableManager, TaskSlotTable taskSlotTable, JobManagerTable jobManagerTable, JobLeaderService jobLeaderService, TaskExecutorLocalStateStoresManager taskManagerStateStore, TaskEventDispatcher taskEventDispatcher) { this.taskManagerLocation = Preconditions.checkNotNull(taskManagerLocation); this.memoryManager = Preconditions.checkNotNull(memoryManager); this.ioManager = Preconditions.checkNotNull(ioManager); this.shuffleEnvironment = Preconditions.checkNotNull(shuffleEnvironment); this.kvStateService = Preconditions.checkNotNull(kvStateService); this.broadcastVariableManager = Preconditions.checkNotNull(broadcastVariableManager); this.taskSlotTable = Preconditions.checkNotNull(taskSlotTable); this.jobManagerTable = Preconditions.checkNotNull(jobManagerTable); this.jobLeaderService = Preconditions.checkNotNull(jobLeaderService); this.taskManagerStateStore = Preconditions.checkNotNull(taskManagerStateStore); this.taskEventDispatcher = Preconditions.checkNotNull(taskEventDispatcher); }
Example #7
Source File: TaskManagerServicesBuilder.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public TaskManagerServicesBuilder() { taskManagerLocation = new LocalTaskManagerLocation(); memoryManager = new MemoryManager( MemoryManager.MIN_PAGE_SIZE, 1, MemoryManager.MIN_PAGE_SIZE, MemoryType.HEAP, false); ioManager = mock(IOManager.class); networkEnvironment = mock(NetworkEnvironment.class); broadcastVariableManager = new BroadcastVariableManager(); taskSlotTable = mock(TaskSlotTable.class); jobManagerTable = new JobManagerTable(); jobLeaderService = new JobLeaderService(taskManagerLocation, RetryingRegistrationConfiguration.defaultConfiguration()); taskStateManager = mock(TaskExecutorLocalStateStoresManager.class); }
Example #8
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the TaskManager sends a proper exception back to the sender if the submit task * message fails. */ @Test(timeout = 10000L) public void testSubmitTaskFailure() throws Exception { final ExecutionAttemptID eid = new ExecutionAttemptID(); final TaskDeploymentDescriptor tdd = createTestTaskDeploymentDescriptor( "test task", eid, BlockingNoOpInvokable.class, 0); // this will make the submission fail because the number of key groups must be >= 1 try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd, env.getJobMasterId(), timeout).get(); } catch (Exception e) { assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); } }
Example #9
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that repeated local {@link PartitionNotFoundException}s ultimately fail the receiver. */ @Test(timeout = TEST_TIMEOUT) public void testLocalPartitionNotFound() throws Exception { ResourceID producerLocation = ResourceID.generate(); NettyShuffleDescriptor shuffleDescriptor = createRemoteWithIdAndLocation(new IntermediateResultPartitionID(), producerLocation); TaskDeploymentDescriptor tdd = createReceiver(shuffleDescriptor); ExecutionAttemptID eid = tdd.getExecutionAttemptId(); Configuration config = new Configuration(); config.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_INITIAL, 100); config.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_MAX, 200); final CompletableFuture<Void> taskRunningFuture = new CompletableFuture<>(); final CompletableFuture<Void> taskFailedFuture = new CompletableFuture<>(); try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .setResourceID(producerLocation) .setSlotSize(1) .addTaskManagerActionListener(eid, ExecutionState.RUNNING, taskRunningFuture) .addTaskManagerActionListener(eid, ExecutionState.FAILED, taskFailedFuture) .setConfiguration(config) .useRealNonMockShuffleEnvironment() .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable<Task> taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd, env.getJobMasterId(), timeout).get(); taskRunningFuture.get(); taskFailedFuture.get(); assertSame(taskSlotTable.getTask(eid).getExecutionState(), ExecutionState.FAILED); assertThat(taskSlotTable.getTask(eid).getFailureCause(), instanceOf(PartitionNotFoundException.class)); } }
Example #10
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the {@link TaskExecutor} sends the initial slot report after it * registered at the ResourceManager. */ @Test public void testInitialSlotReport() throws Exception { final TaskSlotTable taskSlotTable = new TaskSlotTable(Collections.singleton(ResourceProfile.UNKNOWN), timerService); final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setTaskSlotTable(taskSlotTable) .setTaskManagerLocation(taskManagerLocation) .build(); final TaskExecutor taskExecutor = createTaskExecutor(taskManagerServices); taskExecutor.start(); try { final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final CompletableFuture<ResourceID> initialSlotReportFuture = new CompletableFuture<>(); testingResourceManagerGateway.setSendSlotReportFunction( resourceIDInstanceIDSlotReportTuple3 -> { initialSlotReportFuture.complete(resourceIDInstanceIDSlotReportTuple3.f0); return CompletableFuture.completedFuture(Acknowledge.get()); }); rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway); resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway.getFencingToken().toUUID()); assertThat(initialSlotReportFuture.get(), equalTo(taskManagerLocation.getResourceID())); } finally { RpcUtils.terminateRpcEndpoint(taskExecutor, timeout); } }
Example #11
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 5 votes |
private TaskExecutorTestingContext( TestingJobMasterGateway jobMasterGateway, TaskSlotTable taskSlotTable, TestingTaskExecutor taskExecutor) { this.jobMasterGateway = jobMasterGateway; this.taskSlotTable = taskSlotTable; this.taskExecutor = taskExecutor; }
Example #12
Source File: TaskExecutorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that the {@link TaskExecutor} sends the initial slot report after it * registered at the ResourceManager. */ @Test public void testInitialSlotReport() throws Exception { final TaskSlotTable taskSlotTable = new TaskSlotTable(Collections.singleton(ResourceProfile.UNKNOWN), timerService); final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setTaskSlotTable(taskSlotTable) .setTaskManagerLocation(taskManagerLocation) .build(); final TaskExecutor taskExecutor = createTaskExecutor(taskManagerServices); taskExecutor.start(); try { final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final CompletableFuture<ResourceID> initialSlotReportFuture = new CompletableFuture<>(); testingResourceManagerGateway.setSendSlotReportFunction( resourceIDInstanceIDSlotReportTuple3 -> { initialSlotReportFuture.complete(resourceIDInstanceIDSlotReportTuple3.f0); return CompletableFuture.completedFuture(Acknowledge.get()); }); rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway); resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway.getFencingToken().toUUID()); assertThat(initialSlotReportFuture.get(), equalTo(taskManagerLocation.getResourceID())); } finally { RpcUtils.terminateRpcEndpoint(taskExecutor, timeout); } }
Example #13
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testImmediatelyRegistersIfLeaderIsKnown() throws Exception { final String resourceManagerAddress = "/resource/manager/address/one"; final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final CountDownLatch taskManagerRegisteredLatch = new CountDownLatch(1); testingResourceManagerGateway.setRegisterTaskExecutorFunction(FunctionUtils.uncheckedFunction( ignored -> { taskManagerRegisteredLatch.countDown(); return CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess( new InstanceID(), new ResourceID(resourceManagerAddress), new ClusterInformation("localhost", 1234))); } )); rpc.registerGateway(resourceManagerAddress, testingResourceManagerGateway); final TaskSlotTable taskSlotTable = TaskSlotUtils.createTaskSlotTable(1); final TaskExecutorLocalStateStoresManager localStateStoresManager = createTaskExecutorLocalStateStoresManager(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setUnresolvedTaskManagerLocation(unresolvedTaskManagerLocation) .setTaskSlotTable(taskSlotTable) .setTaskStateManager(localStateStoresManager) .build(); final TaskExecutor taskManager = createTaskExecutor(taskManagerServices); try { taskManager.start(); resourceManagerLeaderRetriever.notifyListener(resourceManagerAddress, UUID.randomUUID()); assertTrue(taskManagerRegisteredLatch.await(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); } finally { RpcUtils.terminateRpcEndpoint(taskManager, timeout); } }
Example #14
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testImmediatelyRegistersIfLeaderIsKnown() throws Exception { final String resourceManagerAddress = "/resource/manager/address/one"; final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final CountDownLatch taskManagerRegisteredLatch = new CountDownLatch(1); testingResourceManagerGateway.setRegisterTaskExecutorFunction(FunctionUtils.uncheckedFunction( ignored -> { taskManagerRegisteredLatch.countDown(); return CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess( new InstanceID(), new ResourceID(resourceManagerAddress), new ClusterInformation("localhost", 1234))); } )); rpc.registerGateway(resourceManagerAddress, testingResourceManagerGateway); final TaskSlotTable taskSlotTable = new TaskSlotTable(Collections.singleton(ResourceProfile.UNKNOWN), timerService); final TaskExecutorLocalStateStoresManager localStateStoresManager = createTaskExecutorLocalStateStoresManager(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setTaskManagerLocation(taskManagerLocation) .setTaskSlotTable(taskSlotTable) .setTaskStateManager(localStateStoresManager) .build(); final TaskExecutor taskManager = createTaskExecutor(taskManagerServices); try { taskManager.start(); resourceManagerLeaderRetriever.notifyListener(resourceManagerAddress, UUID.randomUUID()); assertTrue(taskManagerRegisteredLatch.await(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); } finally { RpcUtils.terminateRpcEndpoint(taskManager, timeout); } }
Example #15
Source File: TaskManagerServices.java From flink with Apache License 2.0 | 5 votes |
TaskManagerServices( UnresolvedTaskManagerLocation unresolvedTaskManagerLocation, long managedMemorySize, IOManager ioManager, ShuffleEnvironment<?, ?> shuffleEnvironment, KvStateService kvStateService, BroadcastVariableManager broadcastVariableManager, TaskSlotTable<Task> taskSlotTable, JobTable jobTable, JobLeaderService jobLeaderService, TaskExecutorLocalStateStoresManager taskManagerStateStore, TaskEventDispatcher taskEventDispatcher, ExecutorService ioExecutor, LibraryCacheManager libraryCacheManager) { this.unresolvedTaskManagerLocation = Preconditions.checkNotNull(unresolvedTaskManagerLocation); this.managedMemorySize = managedMemorySize; this.ioManager = Preconditions.checkNotNull(ioManager); this.shuffleEnvironment = Preconditions.checkNotNull(shuffleEnvironment); this.kvStateService = Preconditions.checkNotNull(kvStateService); this.broadcastVariableManager = Preconditions.checkNotNull(broadcastVariableManager); this.taskSlotTable = Preconditions.checkNotNull(taskSlotTable); this.jobTable = Preconditions.checkNotNull(jobTable); this.jobLeaderService = Preconditions.checkNotNull(jobLeaderService); this.taskManagerStateStore = Preconditions.checkNotNull(taskManagerStateStore); this.taskEventDispatcher = Preconditions.checkNotNull(taskEventDispatcher); this.ioExecutor = Preconditions.checkNotNull(ioExecutor); this.libraryCacheManager = Preconditions.checkNotNull(libraryCacheManager); }
Example #16
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that repeated remote {@link PartitionNotFoundException}s ultimately fail the receiver. */ @Test(timeout = TEST_TIMEOUT) public void testRemotePartitionNotFound() throws Exception { final int dataPort = NetUtils.getAvailablePort(); Configuration config = new Configuration(); config.setInteger(NettyShuffleEnvironmentOptions.DATA_PORT, dataPort); config.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_INITIAL, 100); config.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_MAX, 200); // Remote location (on the same TM though) for the partition NettyShuffleDescriptor sdd = NettyShuffleDescriptorBuilder.newBuilder().setDataPort(dataPort).buildRemote(); TaskDeploymentDescriptor tdd = createReceiver(sdd); ExecutionAttemptID eid = tdd.getExecutionAttemptId(); final CompletableFuture<Void> taskRunningFuture = new CompletableFuture<>(); final CompletableFuture<Void> taskFailedFuture = new CompletableFuture<>(); try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .setSlotSize(2) .addTaskManagerActionListener(eid, ExecutionState.RUNNING, taskRunningFuture) .addTaskManagerActionListener(eid, ExecutionState.FAILED, taskFailedFuture) .setConfiguration(config) .setLocalCommunication(false) .useRealNonMockShuffleEnvironment() .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable<Task> taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd, env.getJobMasterId(), timeout).get(); taskRunningFuture.get(); taskFailedFuture.get(); assertThat(taskSlotTable.getTask(eid).getFailureCause(), instanceOf(PartitionNotFoundException.class)); } }
Example #17
Source File: TaskExecutorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testImmediatelyRegistersIfLeaderIsKnown() throws Exception { final String resourceManagerAddress = "/resource/manager/address/one"; final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final CountDownLatch taskManagerRegisteredLatch = new CountDownLatch(1); testingResourceManagerGateway.setRegisterTaskExecutorFunction(FunctionUtils.uncheckedFunction( ignored -> { taskManagerRegisteredLatch.countDown(); return CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess( new InstanceID(), new ResourceID(resourceManagerAddress), new ClusterInformation("localhost", 1234))); } )); rpc.registerGateway(resourceManagerAddress, testingResourceManagerGateway); final TaskSlotTable taskSlotTable = new TaskSlotTable(Collections.singleton(ResourceProfile.UNKNOWN), timerService); final TaskExecutorLocalStateStoresManager localStateStoresManager = createTaskExecutorLocalStateStoresManager(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setTaskManagerLocation(taskManagerLocation) .setTaskSlotTable(taskSlotTable) .setTaskStateManager(localStateStoresManager) .build(); final TaskExecutor taskManager = createTaskExecutor(taskManagerServices); try { taskManager.start(); resourceManagerLeaderRetriever.notifyListener(resourceManagerAddress, UUID.randomUUID()); assertTrue(taskManagerRegisteredLatch.await(timeout.toMilliseconds(), TimeUnit.MILLISECONDS)); } finally { RpcUtils.terminateRpcEndpoint(taskManager, timeout); } }
Example #18
Source File: TaskManagerServices.java From flink with Apache License 2.0 | 5 votes |
private static TaskSlotTable<Task> createTaskSlotTable( final int numberOfSlots, final TaskExecutorResourceSpec taskExecutorResourceSpec, final long timerServiceShutdownTimeout, final int pageSize) { final TimerService<AllocationID> timerService = new TimerService<>( new ScheduledThreadPoolExecutor(1), timerServiceShutdownTimeout); return new TaskSlotTableImpl<>( numberOfSlots, TaskExecutorResourceUtils.generateTotalAvailableResourceProfile(taskExecutorResourceSpec), TaskExecutorResourceUtils.generateDefaultSlotResourceProfile(taskExecutorResourceSpec, numberOfSlots), pageSize, timerService); }
Example #19
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that repeated remote {@link PartitionNotFoundException}s ultimately fail the receiver. */ @Test(timeout = 10000L) public void testRemotePartitionNotFound() throws Exception { final int dataPort = NetUtils.getAvailablePort(); Configuration config = new Configuration(); config.setInteger(NettyShuffleEnvironmentOptions.DATA_PORT, dataPort); config.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_INITIAL, 100); config.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_MAX, 200); // Remote location (on the same TM though) for the partition NettyShuffleDescriptor sdd = NettyShuffleDescriptorBuilder.newBuilder().setDataPort(dataPort).buildRemote(); TaskDeploymentDescriptor tdd = createReceiver(sdd); ExecutionAttemptID eid = tdd.getExecutionAttemptId(); final CompletableFuture<Void> taskRunningFuture = new CompletableFuture<>(); final CompletableFuture<Void> taskFailedFuture = new CompletableFuture<>(); try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .setSlotSize(2) .addTaskManagerActionListener(eid, ExecutionState.RUNNING, taskRunningFuture) .addTaskManagerActionListener(eid, ExecutionState.FAILED, taskFailedFuture) .setConfiguration(config) .setLocalCommunication(false) .useRealNonMockShuffleEnvironment() .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd, env.getJobMasterId(), timeout).get(); taskRunningFuture.get(); taskFailedFuture.get(); assertThat(taskSlotTable.getTask(eid).getFailureCause(), instanceOf(PartitionNotFoundException.class)); } }
Example #20
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 5 votes |
private TaskExecutor createTaskExecutor(int numberOFSlots) { final TaskSlotTable<Task> taskSlotTable = TaskSlotUtils.createTaskSlotTable(numberOFSlots); final UnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setTaskSlotTable(taskSlotTable) .setUnresolvedTaskManagerLocation(unresolvedTaskManagerLocation) .build(); configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, numberOFSlots); return createTaskExecutor(taskManagerServices); }
Example #21
Source File: TaskSubmissionTestEnvironment.java From flink with Apache License 2.0 | 5 votes |
private TaskSlotTable generateTaskSlotTable(int numSlot) { Collection<ResourceProfile> resourceProfiles = new ArrayList<>(); for (int i = 0; i < numSlot; i++) { resourceProfiles.add(ResourceProfile.UNKNOWN); } return new TaskSlotTable(resourceProfiles, timerService); }
Example #22
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the {@link TaskExecutor} tries to reconnect if the initial slot report * fails. */ @Test public void testInitialSlotReportFailure() throws Exception { final TaskSlotTable taskSlotTable = new TaskSlotTable(Collections.singleton(ResourceProfile.UNKNOWN), timerService); final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setTaskSlotTable(taskSlotTable) .setTaskManagerLocation(taskManagerLocation) .build(); final TaskExecutor taskExecutor = createTaskExecutor(taskManagerServices); taskExecutor.start(); try { final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final BlockingQueue<CompletableFuture<Acknowledge>> responseQueue = new ArrayBlockingQueue<>(2); testingResourceManagerGateway.setSendSlotReportFunction( resourceIDInstanceIDSlotReportTuple3 -> { try { return responseQueue.take(); } catch (InterruptedException e) { return FutureUtils.completedExceptionally(e); } }); final CompletableFuture<RegistrationResponse> registrationResponse = CompletableFuture.completedFuture( new TaskExecutorRegistrationSuccess( new InstanceID(), testingResourceManagerGateway.getOwnResourceId(), new ClusterInformation("foobar", 1234))); final CountDownLatch numberRegistrations = new CountDownLatch(2); testingResourceManagerGateway.setRegisterTaskExecutorFunction(new Function<Tuple4<String, ResourceID, Integer, HardwareDescription>, CompletableFuture<RegistrationResponse>>() { @Override public CompletableFuture<RegistrationResponse> apply(Tuple4<String, ResourceID, Integer, HardwareDescription> stringResourceIDIntegerHardwareDescriptionTuple4) { numberRegistrations.countDown(); return registrationResponse; } }); responseQueue.offer(FutureUtils.completedExceptionally(new FlinkException("Test exception"))); responseQueue.offer(CompletableFuture.completedFuture(Acknowledge.get())); rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway); resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway.getFencingToken().toUUID()); //wait for the second registration attempt numberRegistrations.await(); } finally { RpcUtils.terminateRpcEndpoint(taskExecutor, timeout); } }
Example #23
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that a job is removed from the JobLeaderService once a TaskExecutor has * no more slots assigned to this job. * * <p>See FLINK-8504 */ @Test public void testRemoveJobFromJobLeaderService() throws Exception { final TaskSlotTable<Task> taskSlotTable = TaskSlotUtils.createTaskSlotTable(1); final TaskExecutorLocalStateStoresManager localStateStoresManager = createTaskExecutorLocalStateStoresManager(); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setUnresolvedTaskManagerLocation(unresolvedTaskManagerLocation) .setTaskSlotTable(taskSlotTable) .setTaskStateManager(localStateStoresManager) .build(); final TestingTaskExecutor taskExecutor = createTestingTaskExecutor(taskManagerServices); try { final TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway(); final CompletableFuture<Void> initialSlotReport = new CompletableFuture<>(); resourceManagerGateway.setSendSlotReportFunction(resourceIDInstanceIDSlotReportTuple3 -> { initialSlotReport.complete(null); return CompletableFuture.completedFuture(Acknowledge.get()); }); final ResourceManagerId resourceManagerId = resourceManagerGateway.getFencingToken(); rpc.registerGateway(resourceManagerGateway.getAddress(), resourceManagerGateway); resourceManagerLeaderRetriever.notifyListener(resourceManagerGateway.getAddress(), resourceManagerId.toUUID()); final CompletableFuture<LeaderRetrievalListener> startFuture = new CompletableFuture<>(); final CompletableFuture<Void> stopFuture = new CompletableFuture<>(); final StartStopNotifyingLeaderRetrievalService jobMasterLeaderRetriever = new StartStopNotifyingLeaderRetrievalService( startFuture, stopFuture); haServices.setJobMasterLeaderRetriever(jobId, jobMasterLeaderRetriever); taskExecutor.start(); taskExecutor.waitUntilStarted(); final TaskExecutorGateway taskExecutorGateway = taskExecutor.getSelfGateway(TaskExecutorGateway.class); final SlotID slotId = new SlotID(unresolvedTaskManagerLocation.getResourceID(), 0); final AllocationID allocationId = new AllocationID(); assertThat(startFuture.isDone(), is(false)); final JobLeaderService jobLeaderService = taskManagerServices.getJobLeaderService(); assertThat(jobLeaderService.containsJob(jobId), is(false)); // wait for the initial slot report initialSlotReport.get(); taskExecutorGateway.requestSlot( slotId, jobId, allocationId, ResourceProfile.ZERO, "foobar", resourceManagerId, timeout).get(); // wait until the job leader retrieval service for jobId is started startFuture.get(); assertThat(jobLeaderService.containsJob(jobId), is(true)); taskExecutorGateway.freeSlot(allocationId, new FlinkException("Test exception"), timeout).get(); // wait that the job leader retrieval service for jobId stopped becaue it should get removed stopFuture.get(); assertThat(jobLeaderService.containsJob(jobId), is(false)); } finally { RpcUtils.terminateRpcEndpoint(taskExecutor, timeout); } }
Example #24
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the TaskExecutor tries to reconnect to a ResourceManager from which it * was explicitly disconnected. */ @Test public void testReconnectionAttemptIfExplicitlyDisconnected() throws Exception { final TaskSlotTable taskSlotTable = new TaskSlotTable(Collections.singleton(ResourceProfile.UNKNOWN), timerService); final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation(); final TaskExecutor taskExecutor = createTaskExecutor(new TaskManagerServicesBuilder() .setTaskSlotTable(taskSlotTable) .setTaskManagerLocation(taskManagerLocation) .build()); taskExecutor.start(); try { final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final ClusterInformation clusterInformation = new ClusterInformation("foobar", 1234); final CompletableFuture<RegistrationResponse> registrationResponseFuture = CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(new InstanceID(), ResourceID.generate(), clusterInformation)); final BlockingQueue<ResourceID> registrationQueue = new ArrayBlockingQueue<>(1); testingResourceManagerGateway.setRegisterTaskExecutorFunction(stringResourceIDSlotReportIntegerHardwareDescriptionTuple5 -> { registrationQueue.offer(stringResourceIDSlotReportIntegerHardwareDescriptionTuple5.f1); return registrationResponseFuture; }); rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway); resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway.getFencingToken().toUUID()); final ResourceID firstRegistrationAttempt = registrationQueue.take(); assertThat(firstRegistrationAttempt, equalTo(taskManagerLocation.getResourceID())); final TaskExecutorGateway taskExecutorGateway = taskExecutor.getSelfGateway(TaskExecutorGateway.class); assertThat(registrationQueue, is(empty())); taskExecutorGateway.disconnectResourceManager(new FlinkException("Test exception")); final ResourceID secondRegistrationAttempt = registrationQueue.take(); assertThat(secondRegistrationAttempt, equalTo(taskManagerLocation.getResourceID())); } finally { RpcUtils.terminateRpcEndpoint(taskExecutor, timeout); } }
Example #25
Source File: TaskManagerServices.java From flink with Apache License 2.0 | 4 votes |
/** * Creates and returns the task manager services. * * @param taskManagerServicesConfiguration task manager configuration * @param permanentBlobService permanentBlobService used by the services * @param taskManagerMetricGroup metric group of the task manager * @param ioExecutor executor for async IO operations * @param fatalErrorHandler to handle class loading OOMs * @return task manager components * @throws Exception */ public static TaskManagerServices fromConfiguration( TaskManagerServicesConfiguration taskManagerServicesConfiguration, PermanentBlobService permanentBlobService, MetricGroup taskManagerMetricGroup, ExecutorService ioExecutor, FatalErrorHandler fatalErrorHandler) throws Exception { // pre-start checks checkTempDirs(taskManagerServicesConfiguration.getTmpDirPaths()); final TaskEventDispatcher taskEventDispatcher = new TaskEventDispatcher(); // start the I/O manager, it will create some temp directories. final IOManager ioManager = new IOManagerAsync(taskManagerServicesConfiguration.getTmpDirPaths()); final ShuffleEnvironment<?, ?> shuffleEnvironment = createShuffleEnvironment( taskManagerServicesConfiguration, taskEventDispatcher, taskManagerMetricGroup, ioExecutor); final int listeningDataPort = shuffleEnvironment.start(); final KvStateService kvStateService = KvStateService.fromConfiguration(taskManagerServicesConfiguration); kvStateService.start(); final UnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new UnresolvedTaskManagerLocation( taskManagerServicesConfiguration.getResourceID(), taskManagerServicesConfiguration.getExternalAddress(), // we expose the task manager location with the listening port // iff the external data port is not explicitly defined taskManagerServicesConfiguration.getExternalDataPort() > 0 ? taskManagerServicesConfiguration.getExternalDataPort() : listeningDataPort); final BroadcastVariableManager broadcastVariableManager = new BroadcastVariableManager(); final TaskSlotTable<Task> taskSlotTable = createTaskSlotTable( taskManagerServicesConfiguration.getNumberOfSlots(), taskManagerServicesConfiguration.getTaskExecutorResourceSpec(), taskManagerServicesConfiguration.getTimerServiceShutdownTimeout(), taskManagerServicesConfiguration.getPageSize()); final JobTable jobTable = DefaultJobTable.create(); final JobLeaderService jobLeaderService = new DefaultJobLeaderService(unresolvedTaskManagerLocation, taskManagerServicesConfiguration.getRetryingRegistrationConfiguration()); final String[] stateRootDirectoryStrings = taskManagerServicesConfiguration.getLocalRecoveryStateRootDirectories(); final File[] stateRootDirectoryFiles = new File[stateRootDirectoryStrings.length]; for (int i = 0; i < stateRootDirectoryStrings.length; ++i) { stateRootDirectoryFiles[i] = new File(stateRootDirectoryStrings[i], LOCAL_STATE_SUB_DIRECTORY_ROOT); } final TaskExecutorLocalStateStoresManager taskStateManager = new TaskExecutorLocalStateStoresManager( taskManagerServicesConfiguration.isLocalRecoveryEnabled(), stateRootDirectoryFiles, ioExecutor); final boolean failOnJvmMetaspaceOomError = taskManagerServicesConfiguration.getConfiguration().getBoolean(CoreOptions.FAIL_ON_USER_CLASS_LOADING_METASPACE_OOM); final LibraryCacheManager libraryCacheManager = new BlobLibraryCacheManager( permanentBlobService, BlobLibraryCacheManager.defaultClassLoaderFactory( taskManagerServicesConfiguration.getClassLoaderResolveOrder(), taskManagerServicesConfiguration.getAlwaysParentFirstLoaderPatterns(), failOnJvmMetaspaceOomError ? fatalErrorHandler : null)); return new TaskManagerServices( unresolvedTaskManagerLocation, taskManagerServicesConfiguration.getManagedMemorySize().getBytes(), ioManager, shuffleEnvironment, kvStateService, broadcastVariableManager, taskSlotTable, jobTable, jobLeaderService, taskStateManager, taskEventDispatcher, ioExecutor, libraryCacheManager); }
Example #26
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that offers slots to job master timeout and retry. */ @Test public void testOfferSlotToJobMasterAfterTimeout() throws Exception { final TaskSlotTable taskSlotTable = new TaskSlotTable( Arrays.asList(ResourceProfile.UNKNOWN, ResourceProfile.UNKNOWN), timerService); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder() .setTaskSlotTable(taskSlotTable) .build(); final TaskExecutor taskExecutor = createTaskExecutor(taskManagerServices); final AllocationID allocationId = new AllocationID(); final CompletableFuture<ResourceID> initialSlotReportFuture = new CompletableFuture<>(); final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); testingResourceManagerGateway.setSendSlotReportFunction(resourceIDInstanceIDSlotReportTuple3 -> { initialSlotReportFuture.complete(null); return CompletableFuture.completedFuture(Acknowledge.get()); }); rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway); resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway.getFencingToken().toUUID()); final CountDownLatch slotOfferings = new CountDownLatch(3); final CompletableFuture<AllocationID> offeredSlotFuture = new CompletableFuture<>(); final TestingJobMasterGateway jobMasterGateway = new TestingJobMasterGatewayBuilder() .setOfferSlotsFunction((resourceID, slotOffers) -> { assertThat(slotOffers.size(), is(1)); slotOfferings.countDown(); if (slotOfferings.getCount() == 0) { offeredSlotFuture.complete(slotOffers.iterator().next().getAllocationId()); return CompletableFuture.completedFuture(slotOffers); } else { return FutureUtils.completedExceptionally(new TimeoutException()); } }) .build(); final String jobManagerAddress = jobMasterGateway.getAddress(); rpc.registerGateway(jobManagerAddress, jobMasterGateway); jobManagerLeaderRetriever.notifyListener(jobManagerAddress, jobMasterGateway.getFencingToken().toUUID()); try { taskExecutor.start(); final TaskExecutorGateway taskExecutorGateway = taskExecutor.getSelfGateway(TaskExecutorGateway.class); // wait for the connection to the ResourceManager initialSlotReportFuture.get(); taskExecutorGateway.requestSlot( new SlotID(taskExecutor.getResourceID(), 0), jobId, allocationId, jobManagerAddress, testingResourceManagerGateway.getFencingToken(), timeout).get(); slotOfferings.await(); assertThat(offeredSlotFuture.get(), is(allocationId)); assertTrue(taskSlotTable.isSlotFree(1)); } finally { RpcUtils.terminateRpcEndpoint(taskExecutor, timeout); } }
Example #27
Source File: TaskExecutorTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the TaskExecutor syncs its slots view with the JobMaster's view * via the AllocatedSlotReport reported by the heartbeat (See FLINK-11059). */ @Test public void testSyncSlotsWithJobMasterByHeartbeat() throws Exception { final CountDownLatch activeSlots = new CountDownLatch(2); final TaskSlotTable taskSlotTable = new ActivateSlotNotifyingTaskSlotTable( Arrays.asList(ResourceProfile.UNKNOWN, ResourceProfile.UNKNOWN), timerService, activeSlots); final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder().setTaskSlotTable(taskSlotTable).build(); final TaskExecutor taskExecutor = createTaskExecutor(taskManagerServices); final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway(); final BlockingQueue<AllocationID> allocationsNotifiedFree = new ArrayBlockingQueue<>(2); OneShotLatch initialSlotReporting = new OneShotLatch(); testingResourceManagerGateway.setSendSlotReportFunction(resourceIDInstanceIDSlotReportTuple3 -> { initialSlotReporting.trigger(); return CompletableFuture.completedFuture(Acknowledge.get()); }); testingResourceManagerGateway.setNotifySlotAvailableConsumer(instanceIDSlotIDAllocationIDTuple3 -> allocationsNotifiedFree.offer(instanceIDSlotIDAllocationIDTuple3.f2)); rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway); resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway.getFencingToken().toUUID()); final BlockingQueue<AllocationID> failedSlotFutures = new ArrayBlockingQueue<>(2); final ResourceID jobManagerResourceId = ResourceID.generate(); final TestingJobMasterGateway jobMasterGateway = new TestingJobMasterGatewayBuilder() .setFailSlotConsumer((resourceID, allocationID, throwable) -> failedSlotFutures.offer(allocationID)) .setOfferSlotsFunction((resourceID, slotOffers) -> CompletableFuture.completedFuture(new ArrayList<>(slotOffers))) .setRegisterTaskManagerFunction((ignoredA, ignoredB) -> CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jobManagerResourceId))) .build(); final String jobManagerAddress = jobMasterGateway.getAddress(); rpc.registerGateway(jobManagerAddress, jobMasterGateway); jobManagerLeaderRetriever.notifyListener(jobManagerAddress, jobMasterGateway.getFencingToken().toUUID()); taskExecutor.start(); try { final TaskExecutorGateway taskExecutorGateway = taskExecutor.getSelfGateway(TaskExecutorGateway.class); initialSlotReporting.await(); final SlotID slotId1 = new SlotID(taskExecutor.getResourceID(), 0); final SlotID slotId2 = new SlotID(taskExecutor.getResourceID(), 1); final AllocationID allocationIdInBoth = new AllocationID(); final AllocationID allocationIdOnlyInJM = new AllocationID(); final AllocationID allocationIdOnlyInTM = new AllocationID(); taskExecutorGateway.requestSlot(slotId1, jobId, allocationIdInBoth, "foobar", testingResourceManagerGateway.getFencingToken(), timeout); taskExecutorGateway.requestSlot(slotId2, jobId, allocationIdOnlyInTM, "foobar", testingResourceManagerGateway.getFencingToken(), timeout); activeSlots.await(); List<AllocatedSlotInfo> allocatedSlotInfos = Arrays.asList( new AllocatedSlotInfo(0, allocationIdInBoth), new AllocatedSlotInfo(1, allocationIdOnlyInJM) ); AllocatedSlotReport allocatedSlotReport = new AllocatedSlotReport(jobId, allocatedSlotInfos); taskExecutorGateway.heartbeatFromJobManager(jobManagerResourceId, allocatedSlotReport); assertThat(failedSlotFutures.take(), is(allocationIdOnlyInJM)); assertThat(allocationsNotifiedFree.take(), is(allocationIdOnlyInTM)); assertThat(failedSlotFutures.poll(5L, TimeUnit.MILLISECONDS), nullValue()); assertThat(allocationsNotifiedFree.poll(5L, TimeUnit.MILLISECONDS), nullValue()); } finally { RpcUtils.terminateRpcEndpoint(taskExecutor, timeout); } }
Example #28
Source File: TaskExecutorSubmissionTest.java From flink with Apache License 2.0 | 4 votes |
@Test(timeout = TEST_TIMEOUT) public void testRunJobWithForwardChannel() throws Exception { ResourceID producerLocation = ResourceID.generate(); NettyShuffleDescriptor sdd = createRemoteWithIdAndLocation(new IntermediateResultPartitionID(), producerLocation); TaskDeploymentDescriptor tdd1 = createSender(sdd); TaskDeploymentDescriptor tdd2 = createReceiver(sdd); ExecutionAttemptID eid1 = tdd1.getExecutionAttemptId(); ExecutionAttemptID eid2 = tdd2.getExecutionAttemptId(); final CompletableFuture<Void> task1RunningFuture = new CompletableFuture<>(); final CompletableFuture<Void> task2RunningFuture = new CompletableFuture<>(); final CompletableFuture<Void> task1FinishedFuture = new CompletableFuture<>(); final CompletableFuture<Void> task2FinishedFuture = new CompletableFuture<>(); final JobMasterId jobMasterId = JobMasterId.generate(); TestingJobMasterGateway testingJobMasterGateway = new TestingJobMasterGatewayBuilder() .setFencingTokenSupplier(() -> jobMasterId) .setScheduleOrUpdateConsumersFunction( resultPartitionID -> CompletableFuture.completedFuture(Acknowledge.get())) .build(); try (TaskSubmissionTestEnvironment env = new TaskSubmissionTestEnvironment.Builder(jobId) .setResourceID(producerLocation) .setSlotSize(2) .addTaskManagerActionListener(eid1, ExecutionState.RUNNING, task1RunningFuture) .addTaskManagerActionListener(eid2, ExecutionState.RUNNING, task2RunningFuture) .addTaskManagerActionListener(eid1, ExecutionState.FINISHED, task1FinishedFuture) .addTaskManagerActionListener(eid2, ExecutionState.FINISHED, task2FinishedFuture) .setJobMasterId(jobMasterId) .setJobMasterGateway(testingJobMasterGateway) .useRealNonMockShuffleEnvironment() .build()) { TaskExecutorGateway tmGateway = env.getTaskExecutorGateway(); TaskSlotTable<Task> taskSlotTable = env.getTaskSlotTable(); taskSlotTable.allocateSlot(0, jobId, tdd1.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd1, jobMasterId, timeout).get(); task1RunningFuture.get(); taskSlotTable.allocateSlot(1, jobId, tdd2.getAllocationId(), Time.seconds(60)); tmGateway.submitTask(tdd2, jobMasterId, timeout).get(); task2RunningFuture.get(); task1FinishedFuture.get(); task2FinishedFuture.get(); assertSame(taskSlotTable.getTask(eid1).getExecutionState(), ExecutionState.FINISHED); assertSame(taskSlotTable.getTask(eid2).getExecutionState(), ExecutionState.FINISHED); } }
Example #29
Source File: TaskSubmissionTestEnvironment.java From flink with Apache License 2.0 | 4 votes |
public TaskSlotTable getTaskSlotTable() { return taskSlotTable; }
Example #30
Source File: TaskManagerServices.java From flink with Apache License 2.0 | 4 votes |
public TaskSlotTable<Task> getTaskSlotTable() { return taskSlotTable; }