org.apache.flink.runtime.jobmaster.JobMasterId Java Examples
The following examples show how to use
org.apache.flink.runtime.jobmaster.JobMasterId.
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: TestingTaskExecutorGateway.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
TestingTaskExecutorGateway( String address, String hostname, BiConsumer<ResourceID, AllocatedSlotReport> heartbeatJobManagerConsumer, BiConsumer<JobID, Throwable> disconnectJobManagerConsumer, BiFunction<TaskDeploymentDescriptor, JobMasterId, CompletableFuture<Acknowledge>> submitTaskConsumer, Function<Tuple5<SlotID, JobID, AllocationID, String, ResourceManagerId>, CompletableFuture<Acknowledge>> requestSlotFunction, BiFunction<AllocationID, Throwable, CompletableFuture<Acknowledge>> freeSlotFunction, Consumer<ResourceID> heartbeatResourceManagerConsumer, Consumer<Exception> disconnectResourceManagerConsumer, Function<ExecutionAttemptID, CompletableFuture<Acknowledge>> cancelTaskFunction, Supplier<Boolean> canBeReleasedSupplier) { this.address = Preconditions.checkNotNull(address); this.hostname = Preconditions.checkNotNull(hostname); this.heartbeatJobManagerConsumer = Preconditions.checkNotNull(heartbeatJobManagerConsumer); this.disconnectJobManagerConsumer = Preconditions.checkNotNull(disconnectJobManagerConsumer); this.submitTaskConsumer = Preconditions.checkNotNull(submitTaskConsumer); this.requestSlotFunction = Preconditions.checkNotNull(requestSlotFunction); this.freeSlotFunction = Preconditions.checkNotNull(freeSlotFunction); this.heartbeatResourceManagerConsumer = heartbeatResourceManagerConsumer; this.disconnectResourceManagerConsumer = disconnectResourceManagerConsumer; this.cancelTaskFunction = cancelTaskFunction; this.canBeReleasedSupplier = canBeReleasedSupplier; }
Example #2
Source File: ResourceManager.java From flink with Apache License 2.0 | 6 votes |
/** * This method should be called by the framework once it detects that a currently registered * job manager has failed. * * @param jobId identifying the job whose leader shall be disconnected. * @param cause The exception which cause the JobManager failed. */ protected void closeJobManagerConnection(JobID jobId, Exception cause) { JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.remove(jobId); if (jobManagerRegistration != null) { final ResourceID jobManagerResourceId = jobManagerRegistration.getJobManagerResourceID(); final JobMasterGateway jobMasterGateway = jobManagerRegistration.getJobManagerGateway(); final JobMasterId jobMasterId = jobManagerRegistration.getJobMasterId(); log.info("Disconnect job manager {}@{} for job {} from the resource manager.", jobMasterId, jobMasterGateway.getAddress(), jobId); jobManagerHeartbeatManager.unmonitorTarget(jobManagerResourceId); jmResourceIdRegistrations.remove(jobManagerResourceId); // tell the job manager about the disconnect jobMasterGateway.disconnectResourceManager(getFencingToken(), cause); } else { log.debug("There was no registered job manager for job {}.", jobId); } }
Example #3
Source File: DefaultJobLeaderService.java From flink with Apache License 2.0 | 6 votes |
@GuardedBy("lock") private void openRpcConnectionTo(String leaderAddress, JobMasterId jobMasterId) { Preconditions.checkState( currentJobMasterId == null && rpcConnection == null, "Cannot open a new rpc connection if the previous connection has not been closed."); currentJobMasterId = jobMasterId; rpcConnection = new JobManagerRegisteredRpcConnection( LOG, leaderAddress, jobMasterId, rpcService.getExecutor()); LOG.info("Try to register at job manager {} with leader id {}.", leaderAddress, jobMasterId.toUUID()); rpcConnection.start(); }
Example #4
Source File: ResourceManager.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * This method should be called by the framework once it detects that a currently registered * job manager has failed. * * @param jobId identifying the job whose leader shall be disconnected. * @param cause The exception which cause the JobManager failed. */ protected void closeJobManagerConnection(JobID jobId, Exception cause) { JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.remove(jobId); if (jobManagerRegistration != null) { final ResourceID jobManagerResourceId = jobManagerRegistration.getJobManagerResourceID(); final JobMasterGateway jobMasterGateway = jobManagerRegistration.getJobManagerGateway(); final JobMasterId jobMasterId = jobManagerRegistration.getJobMasterId(); log.info("Disconnect job manager {}@{} for job {} from the resource manager.", jobMasterId, jobMasterGateway.getAddress(), jobId); jobManagerHeartbeatManager.unmonitorTarget(jobManagerResourceId); jmResourceIdRegistrations.remove(jobManagerResourceId); // tell the job manager about the disconnect jobMasterGateway.disconnectResourceManager(getFencingToken(), cause); } else { log.debug("There was no registered job manager for job {}.", jobId); } }
Example #5
Source File: JobLeaderService.java From flink with Apache License 2.0 | 6 votes |
public void reconnect() { if (stopped) { LOG.debug("Cannot reconnect because the JobManagerLeaderListener has already been stopped."); } else { final RegisteredRpcConnection<JobMasterId, JobMasterGateway, JMTMRegistrationSuccess> currentRpcConnection = rpcConnection; if (currentRpcConnection != null) { if (currentRpcConnection.isConnected()) { if (currentRpcConnection.tryReconnect()) { // double check for concurrent stop operation if (stopped) { currentRpcConnection.close(); } } else { LOG.debug("Could not reconnect to the JobMaster {}.", currentRpcConnection.getTargetAddress()); } } else { LOG.debug("Ongoing registration to JobMaster {}.", currentRpcConnection.getTargetAddress()); } } else { LOG.debug("Cannot reconnect to an unknown JobMaster."); } } }
Example #6
Source File: SlotPoolImpl.java From flink with Apache License 2.0 | 6 votes |
/** * Start the slot pool to accept RPC calls. * * @param jobMasterId The necessary leader id for running the job. * @param newJobManagerAddress for the slot requests which are sent to the resource manager * @param componentMainThreadExecutor The main thread executor for the job master's main thread. */ public void start( @Nonnull JobMasterId jobMasterId, @Nonnull String newJobManagerAddress, @Nonnull ComponentMainThreadExecutor componentMainThreadExecutor) throws Exception { this.jobMasterId = jobMasterId; this.jobManagerAddress = newJobManagerAddress; this.componentMainThreadExecutor = componentMainThreadExecutor; scheduleRunAsync(this::checkIdleSlot, idleSlotTimeout); scheduleRunAsync(this::checkBatchSlotTimeout, batchSlotTimeout); if (log.isDebugEnabled()) { scheduleRunAsync(this::scheduledLogStatus, STATUS_LOG_INTERVAL_MS, TimeUnit.MILLISECONDS); } }
Example #7
Source File: TestingTaskExecutorGateway.java From flink with Apache License 2.0 | 6 votes |
TestingTaskExecutorGateway( String address, String hostname, BiConsumer<ResourceID, AllocatedSlotReport> heartbeatJobManagerConsumer, BiConsumer<JobID, Throwable> disconnectJobManagerConsumer, BiFunction<TaskDeploymentDescriptor, JobMasterId, CompletableFuture<Acknowledge>> submitTaskConsumer, Function<Tuple5<SlotID, JobID, AllocationID, String, ResourceManagerId>, CompletableFuture<Acknowledge>> requestSlotFunction, BiFunction<AllocationID, Throwable, CompletableFuture<Acknowledge>> freeSlotFunction, Consumer<ResourceID> heartbeatResourceManagerConsumer, Consumer<Exception> disconnectResourceManagerConsumer, Function<ExecutionAttemptID, CompletableFuture<Acknowledge>> cancelTaskFunction, Supplier<CompletableFuture<Boolean>> canBeReleasedSupplier, BiConsumer<JobID, Collection<ResultPartitionID>> releasePartitionsConsumer) { this.address = Preconditions.checkNotNull(address); this.hostname = Preconditions.checkNotNull(hostname); this.heartbeatJobManagerConsumer = Preconditions.checkNotNull(heartbeatJobManagerConsumer); this.disconnectJobManagerConsumer = Preconditions.checkNotNull(disconnectJobManagerConsumer); this.submitTaskConsumer = Preconditions.checkNotNull(submitTaskConsumer); this.requestSlotFunction = Preconditions.checkNotNull(requestSlotFunction); this.freeSlotFunction = Preconditions.checkNotNull(freeSlotFunction); this.heartbeatResourceManagerConsumer = heartbeatResourceManagerConsumer; this.disconnectResourceManagerConsumer = disconnectResourceManagerConsumer; this.cancelTaskFunction = cancelTaskFunction; this.canBeReleasedSupplier = canBeReleasedSupplier; this.releasePartitionsConsumer = releasePartitionsConsumer; }
Example #8
Source File: DefaultJobLeaderService.java From flink with Apache License 2.0 | 6 votes |
JobManagerRetryingRegistration( Logger log, RpcService rpcService, String targetName, Class<JobMasterGateway> targetType, String targetAddress, JobMasterId jobMasterId, RetryingRegistrationConfiguration retryingRegistrationConfiguration, String taskManagerRpcAddress, UnresolvedTaskManagerLocation unresolvedTaskManagerLocation) { super( log, rpcService, targetName, targetType, targetAddress, jobMasterId, retryingRegistrationConfiguration); this.taskManagerRpcAddress = taskManagerRpcAddress; this.unresolvedTaskManagerLocation = Preconditions.checkNotNull(unresolvedTaskManagerLocation); }
Example #9
Source File: TestingResourceManagerGateway.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Acknowledge> requestSlot(JobMasterId jobMasterId, SlotRequest slotRequest, Time timeout) { Consumer<SlotRequest> currentRequestSlotConsumer = requestSlotConsumer; if (currentRequestSlotConsumer != null) { currentRequestSlotConsumer.accept(slotRequest); } CompletableFuture<Acknowledge> slotFuture = slotFutureReference.getAndSet(null); if (slotFuture != null) { return slotFuture; } else { return CompletableFuture.completedFuture(Acknowledge.get()); } }
Example #10
Source File: SlotPoolImpl.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Start the slot pool to accept RPC calls. * * @param jobMasterId The necessary leader id for running the job. * @param newJobManagerAddress for the slot requests which are sent to the resource manager * @param componentMainThreadExecutor The main thread executor for the job master's main thread. */ public void start( @Nonnull JobMasterId jobMasterId, @Nonnull String newJobManagerAddress, @Nonnull ComponentMainThreadExecutor componentMainThreadExecutor) throws Exception { this.jobMasterId = jobMasterId; this.jobManagerAddress = newJobManagerAddress; this.componentMainThreadExecutor = componentMainThreadExecutor; scheduleRunAsync(this::checkIdleSlot, idleSlotTimeout); if (log.isDebugEnabled()) { scheduleRunAsync(this::scheduledLogStatus, STATUS_LOG_INTERVAL_MS, TimeUnit.MILLISECONDS); } }
Example #11
Source File: JobLeaderIdService.java From flink with Apache License 2.0 | 5 votes |
public CompletableFuture<JobMasterId> getLeaderId(JobID jobId) throws Exception { if (!jobLeaderIdListeners.containsKey(jobId)) { addJob(jobId); } JobLeaderIdListener listener = jobLeaderIdListeners.get(jobId); return listener.getLeaderIdFuture().thenApply(JobMasterId::fromUuidOrNull); }
Example #12
Source File: ResourceManager.java From flink with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Acknowledge> requestSlot( JobMasterId jobMasterId, SlotRequest slotRequest, final Time timeout) { JobID jobId = slotRequest.getJobId(); JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId); if (null != jobManagerRegistration) { if (Objects.equals(jobMasterId, jobManagerRegistration.getJobMasterId())) { log.info("Request slot with profile {} for job {} with allocation id {}.", slotRequest.getResourceProfile(), slotRequest.getJobId(), slotRequest.getAllocationId()); try { slotManager.registerSlotRequest(slotRequest); } catch (ResourceManagerException e) { return FutureUtils.completedExceptionally(e); } return CompletableFuture.completedFuture(Acknowledge.get()); } else { return FutureUtils.completedExceptionally(new ResourceManagerException("The job leader's id " + jobManagerRegistration.getJobMasterId() + " does not match the received id " + jobMasterId + '.')); } } else { return FutureUtils.completedExceptionally(new ResourceManagerException("Could not find registered job manager for job " + jobId + '.')); } }
Example #13
Source File: ResourceManager.java From flink with Apache License 2.0 | 5 votes |
@Override public void jobLeaderLostLeadership(final JobID jobId, final JobMasterId oldJobMasterId) { runAsync(new Runnable() { @Override public void run() { ResourceManager.this.jobLeaderLostLeadership(jobId, oldJobMasterId); } }); }
Example #14
Source File: ResourceManager.java From flink with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Acknowledge> requestSlot( JobMasterId jobMasterId, SlotRequest slotRequest, final Time timeout) { JobID jobId = slotRequest.getJobId(); JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId); if (null != jobManagerRegistration) { if (Objects.equals(jobMasterId, jobManagerRegistration.getJobMasterId())) { log.info("Request slot with profile {} for job {} with allocation id {}.", slotRequest.getResourceProfile(), slotRequest.getJobId(), slotRequest.getAllocationId()); try { slotManager.registerSlotRequest(slotRequest); } catch (ResourceManagerException e) { return FutureUtils.completedExceptionally(e); } return CompletableFuture.completedFuture(Acknowledge.get()); } else { return FutureUtils.completedExceptionally(new ResourceManagerException("The job leader's id " + jobManagerRegistration.getJobMasterId() + " does not match the received id " + jobMasterId + '.')); } } else { return FutureUtils.completedExceptionally(new ResourceManagerException("Could not find registered job manager for job " + jobId + '.')); } }
Example #15
Source File: ResourceManagerJobMasterTest.java From flink with Apache License 2.0 | 5 votes |
/** * Test receive registration with unmatched leadershipId from job master. */ @Test public void testRegisterJobMasterWithUnmatchedLeaderSessionId2() throws Exception { // test throw exception when receive a registration from job master which takes unmatched leaderSessionId JobMasterId differentJobMasterId = JobMasterId.generate(); CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = resourceManagerGateway.registerJobManager( differentJobMasterId, jobMasterResourceId, jobMasterGateway.getAddress(), jobId, TIMEOUT); assertTrue(unMatchedLeaderFuture.get() instanceof RegistrationResponse.Decline); }
Example #16
Source File: SlotPoolBuilder.java From flink with Apache License 2.0 | 5 votes |
public TestingSlotPoolImpl build() throws Exception { final TestingSlotPoolImpl slotPool = new TestingSlotPoolImpl( new JobID(), clock, TestingUtils.infiniteTime(), TestingUtils.infiniteTime(), batchSlotTimeout); slotPool.start(JobMasterId.generate(), "foobar", componentMainThreadExecutor); CompletableFuture.runAsync(() -> slotPool.connectToResourceManager(resourceManagerGateway), componentMainThreadExecutor).join(); return slotPool; }
Example #17
Source File: SlotPoolResource.java From flink with Apache License 2.0 | 5 votes |
@Override protected void before() throws Throwable { if (slotPool != null) { terminateSlotPool(); } testingResourceManagerGateway = new TestingResourceManagerGateway(); slotPool = new TestingSlotPoolImpl(new JobID()); scheduler = new SchedulerImpl(schedulingStrategy, slotPool); slotPool.start(JobMasterId.generate(), "foobar", mainThreadExecutor); scheduler.start(mainThreadExecutor); slotPool.connectToResourceManager(testingResourceManagerGateway); }
Example #18
Source File: SlotPoolInteractionsTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that a slot allocation times out wrt to the specified time out. */ @Test public void testSlotAllocationTimeout() throws Exception { final JobID jid = new JobID(); try (TestingSlotPool pool = createTestingSlotPool(jid)) { pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor()); final CompletableFuture<SlotRequestId> slotRequestTimeoutFuture = new CompletableFuture<>(); pool.setTimeoutPendingSlotRequestConsumer(slotRequestTimeoutFuture::complete); ResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway(); pool.connectToResourceManager(resourceManagerGateway); Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.createDefault(), pool); scheduler.start(testMainThreadExecutor.getMainThreadExecutor()); SlotRequestId requestId = new SlotRequestId(); CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot( requestId, new DummyScheduledUnit(), SlotProfile.noLocality(DEFAULT_TESTING_PROFILE), fastTimeout)); try { future.get(); fail("We expected a TimeoutException."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof TimeoutException); } // wait until we have timed out the slot request slotRequestTimeoutFuture.get(); assertEquals(0L, pool.getNumberOfPendingRequests()); } }
Example #19
Source File: TestingResourceManagerGateway.java From flink with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<RegistrationResponse> registerJobManager(JobMasterId jobMasterId, ResourceID jobMasterResourceId, String jobMasterAddress, JobID jobId, Time timeout) { final QuadFunction<JobMasterId, ResourceID, String, JobID, CompletableFuture<RegistrationResponse>> currentConsumer = registerJobManagerFunction; if (currentConsumer != null) { return currentConsumer.apply(jobMasterId, jobMasterResourceId, jobMasterAddress, jobId); } return CompletableFuture.completedFuture(getJobMasterRegistrationSuccess()); }
Example #20
Source File: JobLeaderService.java From flink with Apache License 2.0 | 5 votes |
@Override protected RetryingRegistration<JobMasterId, JobMasterGateway, JMTMRegistrationSuccess> generateRegistration() { return new JobLeaderService.JobManagerRetryingRegistration( LOG, rpcService, "JobManager", JobMasterGateway.class, getTargetAddress(), getTargetLeaderId(), retryingRegistrationConfiguration, ownerAddress, ownLocation); }
Example #21
Source File: SlotPoolInteractionsTest.java From flink with Apache License 2.0 | 5 votes |
/** * This case make sure when allocateSlot in ProviderAndOwner timeout, * it will automatically call cancelSlotAllocation as will inject future.whenComplete in ProviderAndOwner. */ @Test public void testProviderAndOwnerSlotAllocationTimeout() throws Exception { final JobID jid = new JobID(); try (TestingSlotPool pool = createTestingSlotPool(jid)) { final CompletableFuture<SlotRequestId> releaseSlotFuture = new CompletableFuture<>(); pool.setReleaseSlotConsumer(releaseSlotFuture::complete); pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor()); ResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway(); pool.connectToResourceManager(resourceManagerGateway); Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.createDefault(), pool); scheduler.start(testMainThreadExecutor.getMainThreadExecutor()); // test the pending request is clear when timed out CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot( new DummyScheduledUnit(), SlotProfile.noRequirements(), fastTimeout)); try { future.get(); fail("We expected a TimeoutException."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof TimeoutException); } // wait for the cancel call on the SlotPoolImpl releaseSlotFuture.get(); assertEquals(0L, pool.getNumberOfPendingRequests()); } }
Example #22
Source File: JobLeaderIdService.java From flink with Apache License 2.0 | 5 votes |
public CompletableFuture<JobMasterId> getLeaderId(JobID jobId) throws Exception { if (!jobLeaderIdListeners.containsKey(jobId)) { addJob(jobId); } JobLeaderIdListener listener = jobLeaderIdListeners.get(jobId); return listener.getLeaderIdFuture().thenApply(JobMasterId::fromUuidOrNull); }
Example #23
Source File: SlotPoolInteractionsTest.java From flink with Apache License 2.0 | 5 votes |
/** * This case make sure when allocateSlot in ProviderAndOwner timeout, * it will automatically call cancelSlotAllocation as will inject future.whenComplete in ProviderAndOwner. */ @Test public void testProviderAndOwnerSlotAllocationTimeout() throws Exception { final JobID jid = new JobID(); try (TestingSlotPool pool = createTestingSlotPool(jid)) { final CompletableFuture<SlotRequestId> releaseSlotFuture = new CompletableFuture<>(); pool.setReleaseSlotConsumer(releaseSlotFuture::complete); pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor()); ResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway(); pool.connectToResourceManager(resourceManagerGateway); Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.INSTANCE, pool); scheduler.start(testMainThreadExecutor.getMainThreadExecutor()); // test the pending request is clear when timed out CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot( new DummyScheduledUnit(), true, SlotProfile.noRequirements(), fastTimeout)); try { future.get(); fail("We expected a TimeoutException."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof TimeoutException); } // wait for the cancel call on the SlotPoolImpl releaseSlotFuture.get(); assertEquals(0L, pool.getNumberOfPendingRequests()); } }
Example #24
Source File: SlotPoolInteractionsTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSlotAllocationNoResourceManager() throws Exception { final JobID jid = new JobID(); try (SlotPool pool = new SlotPoolImpl( jid, SystemClock.getInstance(), TestingUtils.infiniteTime(), TestingUtils.infiniteTime(), TestingUtils.infiniteTime() )) { pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor()); Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.createDefault(), pool); scheduler.start(testMainThreadExecutor.getMainThreadExecutor()); CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot( new SlotRequestId(), new ScheduledUnit(getExecution()), SlotProfile.noLocality(DEFAULT_TESTING_PROFILE), fastTimeout)); try { future.get(); fail("We expected an ExecutionException."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.stripExecutionException(e) instanceof TimeoutException); } } }
Example #25
Source File: ResourceManagerJobMasterTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Test receive registration with invalid address from job master. */ @Test public void testRegisterJobMasterFromInvalidAddress() throws Exception { // test throw exception when receive a registration from job master which takes invalid address String invalidAddress = "/jobMasterAddress2"; CompletableFuture<RegistrationResponse> invalidAddressFuture = resourceManagerGateway.registerJobManager( new JobMasterId(HighAvailabilityServices.DEFAULT_LEADER_ID), jobMasterResourceId, invalidAddress, jobId, TIMEOUT); assertTrue(invalidAddressFuture.get(5, TimeUnit.SECONDS) instanceof RegistrationResponse.Decline); }
Example #26
Source File: ResourceManagerJobMasterTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Test receive registration with unmatched leadershipId from job master. */ @Test public void testRegisterJobMasterWithUnmatchedLeaderSessionId2() throws Exception { // test throw exception when receive a registration from job master which takes unmatched leaderSessionId JobMasterId differentJobMasterId = JobMasterId.generate(); CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = resourceManagerGateway.registerJobManager( differentJobMasterId, jobMasterResourceId, jobMasterGateway.getAddress(), jobId, TIMEOUT); assertTrue(unMatchedLeaderFuture.get() instanceof RegistrationResponse.Decline); }
Example #27
Source File: MesosResourceManagerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
MockJobMaster(JobID jobID) { this.jobID = jobID; this.resourceID = new ResourceID(jobID.toString()); this.address = "/" + jobID; this.gateway = mock(JobMasterGateway.class); this.jobMasterId = JobMasterId.generate(); this.leaderRetrievalService = new SettableLeaderRetrievalService(this.address, this.jobMasterId.toUUID()); }
Example #28
Source File: TestingResourceManagerGateway.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<RegistrationResponse> registerJobManager(JobMasterId jobMasterId, ResourceID jobMasterResourceId, String jobMasterAddress, JobID jobId, Time timeout) { final Consumer<Tuple4<JobMasterId, ResourceID, String, JobID>> currentConsumer = registerJobManagerConsumer; if (currentConsumer != null) { currentConsumer.accept(Tuple4.of(jobMasterId, jobMasterResourceId, jobMasterAddress, jobId)); } return CompletableFuture.completedFuture( new JobMasterRegistrationSuccess( resourceManagerId, ownResourceId)); }
Example #29
Source File: SlotPoolResource.java From flink with Apache License 2.0 | 5 votes |
@Override protected void before() throws Throwable { if (slotPool != null) { terminateSlotPool(); } testingResourceManagerGateway = new TestingResourceManagerGateway(); slotPool = new TestingSlotPoolImpl(new JobID()); scheduler = new SchedulerImpl(schedulingStrategy, slotPool); slotPool.start(JobMasterId.generate(), "foobar", mainThreadExecutor); scheduler.start(mainThreadExecutor); slotPool.connectToResourceManager(testingResourceManagerGateway); }
Example #30
Source File: TaskExecutor.java From flink with Apache License 2.0 | 5 votes |
private void internalOfferSlotsToJobManager(JobTable.Connection jobManagerConnection) { final JobID jobId = jobManagerConnection.getJobId(); if (taskSlotTable.hasAllocatedSlots(jobId)) { log.info("Offer reserved slots to the leader of job {}.", jobId); final JobMasterGateway jobMasterGateway = jobManagerConnection.getJobManagerGateway(); final Iterator<TaskSlot<Task>> reservedSlotsIterator = taskSlotTable.getAllocatedSlots(jobId); final JobMasterId jobMasterId = jobManagerConnection.getJobMasterId(); final Collection<SlotOffer> reservedSlots = new HashSet<>(2); while (reservedSlotsIterator.hasNext()) { SlotOffer offer = reservedSlotsIterator.next().generateSlotOffer(); reservedSlots.add(offer); } CompletableFuture<Collection<SlotOffer>> acceptedSlotsFuture = jobMasterGateway.offerSlots( getResourceID(), reservedSlots, taskManagerConfiguration.getTimeout()); acceptedSlotsFuture.whenCompleteAsync( handleAcceptedSlotOffers(jobId, jobMasterGateway, jobMasterId, reservedSlots), getMainThreadExecutor()); } else { log.debug("There are no unassigned slots for the job {}.", jobId); } }