/** * Stop the Akka actor system. */ void stopResourceManager() throws Exception { rpcService.stopService().get(); }
rmServicesConfiguration, highAvailabilityServices, rpcService.getScheduledExecutor());
/** * Fetches framework/worker information persisted by a prior incarnation of the RM. */ private CompletableFuture<List<MesosWorkerStore.Worker>> getWorkersAsync() { // if this resource manager is recovering from failure, // then some worker tasks are most likely still alive and we can re-obtain them return CompletableFuture.supplyAsync(() -> { try { final List<MesosWorkerStore.Worker> tasksFromPreviousAttempts = workerStore.recoverWorkers(); for (final MesosWorkerStore.Worker worker : tasksFromPreviousAttempts) { if (worker.state() == MesosWorkerStore.WorkerState.New) { // remove new workers because allocation requests are transient workerStore.removeWorker(worker.taskID()); } } return tasksFromPreviousAttempts; } catch (final Exception e) { throw new CompletionException(new ResourceManagerException(e)); } }, getRpcService().getExecutor()); }
protected void setFencingToken(@Nullable F newFencingToken) { // this method should only be called from within the main thread validateRunsInMainThread(); this.fencingToken = newFencingToken; // setting a new fencing token entails that we need a new MainThreadExecutor // which is bound to the new fencing token MainThreadExecutable mainThreadExecutable = getRpcService().fenceRpcServer( rpcServer, newFencingToken); this.fencedMainThreadExecutor = new MainThreadExecutor(mainThreadExecutable); }
config.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 2); final RpcService rpcService = AkkaRpcServiceUtils.createRpcService("localhost", 0, config); UUID leaderId = leaderListener.getLeaderSessionID(); final CompletableFuture<DispatcherGateway> dispatcherGatewayFuture = rpcService.connect( leaderAddress, DispatcherId.fromUuid(leaderId), RpcUtils.terminateRpcService(rpcService, timeout);
config.setInteger(RestOptions.PORT, 0); final RpcService rpcService = AkkaRpcServiceUtils.createRpcService("localhost", 0, config); final int jobManagerPort = rpcService.getPort(); config.setInteger(JobManagerOptions.PORT, jobManagerPort); RpcUtils.terminateRpcService(rpcService, Time.seconds(100L));
/** * Requests the resource overview. The resource overview provides information about the * connected TaskManagers, the total number of slots and the number of available slots. * * @param timeout of the request * @return Future containing the resource overview */ CompletableFuture<ResourceOverview> requestResourceOverview(@RpcTimeout Time timeout);
/** * Helper method to wait until the {@link Dispatcher} has set its fencing token. * * @param rpcService to use to connect to the dispatcher * @param haServices high availability services to connect to the dispatcher * @return {@link DispatcherGateway} * @throws Exception if something goes wrong */ static DispatcherGateway retrieveDispatcherGateway(RpcService rpcService, HighAvailabilityServices haServices) throws Exception { final LeaderConnectionInfo leaderConnectionInfo = LeaderRetrievalUtils.retrieveLeaderConnectionInfo(haServices.getDispatcherLeaderRetriever(), Time.seconds(10L)); return rpcService.connect( leaderConnectionInfo.getAddress(), DispatcherId.fromUuid(leaderConnectionInfo.getLeaderSessionID()), DispatcherGateway.class).get(); }
/** * Stops the rpc endpoint. This tells the underlying rpc server that the rpc endpoint is * no longer ready to process remote procedure calls. */ protected final void stop() { rpcServer.stop(); }
/** * Create mock RM dependencies. */ Context() throws Exception { rpcService = new TestingRpcService(); rmServices = new MockResourceManagerRuntimeServices(); // resource manager rmResourceID = ResourceID.generate(); resourceManager = new TestingYarnResourceManager( rpcService, RM_ADDRESS, rmResourceID, flinkConfig, env, rmServices.highAvailabilityServices, rmServices.heartbeatServices, rmServices.slotManager, rmServices.metricRegistry, rmServices.jobLeaderIdService, new ClusterInformation("localhost", 1234), testingFatalErrorHandler, null, mockResourceManagerClient, mockNMClient, mockJMMetricGroup); }
MockResourceManagerRuntimeServices() throws Exception { scheduledExecutor = mock(ScheduledExecutor.class); highAvailabilityServices = new TestingHighAvailabilityServices(); rmLeaderElectionService = new TestingLeaderElectionService(); highAvailabilityServices.setResourceManagerLeaderElectionService(rmLeaderElectionService); heartbeatServices = new TestingHeartbeatServices(5L, 5L, scheduledExecutor); metricRegistry = NoOpMetricRegistry.INSTANCE; slotManager = new SlotManager( new ScheduledExecutorServiceAdapter(new DirectScheduledExecutorService()), Time.seconds(10), Time.seconds(10), Time.minutes(1)); jobLeaderIdService = new JobLeaderIdService( highAvailabilityServices, rpcService.getScheduledExecutor(), Time.minutes(5L)); }
rpcService.registerGateway(taskHost, mockTaskExecutorGateway);
@RpcMethod public void disconnectResourceManager() { this.resourceManagerLeaderId = null; this.resourceManagerGateway = null; }
rmServicesConfiguration, highAvailabilityServices, rpcService.getScheduledExecutor());
/** * Requests the paths for the TaskManager's {@link MetricQueryService} to query. * * @param timeout for the asynchronous operation * @return Future containing the collection of resource ids and the corresponding metric query service path */ CompletableFuture<Collection<Tuple2<ResourceID, String>>> requestTaskManagerMetricQueryServicePaths(@RpcTimeout Time timeout);
this.workerStore = mesosServices.createMesosWorkerStore(flinkConfig, getRpcService().getExecutor()); workerStore.start(); } catch (Exception e) {
/** * Cancel the given task. * * @param executionAttemptID identifying the task * @param timeout for the cancel operation * @return Future acknowledge if the task is successfully canceled */ CompletableFuture<Acknowledge> cancelTask(ExecutionAttemptID executionAttemptID, @RpcTimeout Time timeout);
/** * Offers the given slots to the job manager. The response contains the set of accepted slots. * * @param taskManagerId identifying the task manager * @param slots to offer to the job manager * @param timeout for the rpc call * @return Future set of accepted slots. */ CompletableFuture<Collection<SlotOffer>> offerSlots( final ResourceID taskManagerId, final Collection<SlotOffer> slots, @RpcTimeout final Time timeout);
/** * Registers the task manager at the job manager. * * @param taskManagerRpcAddress the rpc address of the task manager * @param taskManagerLocation location of the task manager * @param timeout for the rpc call * @return Future registration response indicating whether the registration was successful or not */ CompletableFuture<RegistrationResponse> registerTaskManager( final String taskManagerRpcAddress, final TaskManagerLocation taskManagerLocation, @RpcTimeout final Time timeout);
Future<SimpleSlot> allocateSlot( ScheduledUnit task, ResourceProfile resources, Iterable<TaskManagerLocation> locationPreferences, @RpcTimeout Time timeout);