/** * Stops the alluxio job service threads. * * @throws Exception when the operation fails */ public void stop() throws Exception { LOG.info("Stop Alluxio job service"); mWorker.stop(); mMaster.stop(); }
/** * Creates a new instance of {@link JobMasterClientRestServiceHandler}. * * @param context context for the servlet */ public JobMasterClientRestServiceHandler(@Context ServletContext context) { // Poor man's dependency injection through the Jersey application scope. mJobMaster = ((AlluxioJobMasterProcess) context .getAttribute(JobMasterWebServer.ALLUXIO_JOB_MASTER_SERVLET_RESOURCE_KEY)).getJobMaster(); }
/** * Stops the Alluxio job master server. * * @throws Exception if stopping the master fails */ @Override public void stop() throws Exception { if (isServing()) { stopServing(); stopMaster(); mJournalSystem.stop(); } }
/** * @summary get the Alluxio job master information * @param rawConfiguration if it's true, raw configuration values are returned, * otherwise, they are looked up; if it's not provided in URL queries, then * it is null, which means false. * @return the response object */ @GET @Path(GET_INFO) @ReturnType("alluxio.wire.AlluxioJobMasterInfo") public Response getInfo(@QueryParam(QUERY_RAW_CONFIGURATION) final Boolean rawConfiguration) { // TODO(jiri): Add a mechanism for retrieving only a subset of the fields. return RestUtils.call(() -> { boolean rawConfig = false; if (rawConfiguration != null) { rawConfig = rawConfiguration; } AlluxioJobMasterInfo result = new AlluxioJobMasterInfo() .setConfiguration(getConfigurationInternal(rawConfig)) .setStartTimeMs(mJobMaster.getStartTimeMs()) .setUptimeMs(mJobMaster.getUptimeMs()) .setVersion(RuntimeConstants.VERSION) .setWorkers(mJobMaster.getJobMaster().getWorkerInfoList()); return result; }, ServerConfiguration.global()); }
/** * Starts the gRPC server. The AlluxioMaster registers the Services of registered * {@link Master}s and meta services. */ protected void startServingRPCServer() { // TODO(ggezer) Executor threads not reused until thread capacity is hit. //ExecutorService executorService = Executors.newFixedThreadPool(mMaxWorkerThreads); try { SocketAddress bindAddress = getRpcAddressFromBindSocket(); LOG.info("Starting gRPC server on address {}", bindAddress); GrpcServerBuilder serverBuilder = GrpcServerBuilder.forAddress(bindAddress, ServerConfiguration.global()); registerServices(serverBuilder, mJobMaster.getServices()); mGrpcServer = serverBuilder.build().start(); LOG.info("Started gRPC server on address {}", bindAddress); // Wait until the server is shut down. mGrpcServer.awaitTermination(); } catch (IOException e) { throw new RuntimeException(e); } }
protected void stopServing() throws Exception { if (isServing()) { LOG.info("Stopping RPC server on {} @ {}", this, mRpcBindSocket.getInetAddress()); if (!mGrpcServer.shutdown()) { LOG.warn("RPC Server shutdown timed out."); } } if (mWebServer != null) { mWebServer.stop(); mWebServer = null; } }
/** * Runs a master. * * @throws IOException if an I/O error occurs * @throws ConnectionFailedException if network connection failed */ private void startMaster() throws IOException, ConnectionFailedException { if (mRpcBindSocket != null && mWebBindSocket != null) { mMaster = AlluxioJobMasterProcess.Factory.create(mRpcBindSocket, mWebBindSocket); } else { mMaster = AlluxioJobMasterProcess.Factory.create(); } ServerConfiguration .set(PropertyKey.JOB_MASTER_RPC_PORT, String.valueOf(mMaster.getRpcAddress().getPort())); Runnable runMaster = new Runnable() { @Override public void run() { try { mMaster.start(); } catch (Exception e) { throw new RuntimeException(e + " \n Start Master Error \n" + e.getMessage(), e); } } }; mMasterThread = new Thread(runMaster); mMasterThread.start(); }
protected void startServingWebServer() { try { mWebServer = new JobMasterWebServer(ServiceType.JOB_MASTER_WEB.getServiceName(), getWebAddressFromBindSocket(), this); mWebServer.addHandler(mMetricsServlet.getHandler()); mWebServer.start(); } catch (IOException e) { throw new RuntimeException(e); } }
/** * @return a new instance of {@link AlluxioJobMasterProcess} */ public static AlluxioJobMasterProcess create(ServerSocket rpcBindSocket, ServerSocket webBindSocket) { URI journalLocation = JournalUtils.getJournalLocation(); JournalSystem journalSystem = new JournalSystem.Builder() .setLocation(URIUtils.appendPathOrDie(journalLocation, Constants.JOB_JOURNAL_NAME)) .build(); if (ServerConfiguration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { Preconditions.checkState(!(journalSystem instanceof RaftJournalSystem), "Raft journal cannot be used with Zookeeper enabled"); PrimarySelector primarySelector = PrimarySelector.Factory.createZkJobPrimarySelector(); return new FaultTolerantAlluxioJobMasterProcess(journalSystem, primarySelector, rpcBindSocket, webBindSocket); } else if (journalSystem instanceof RaftJournalSystem) { PrimarySelector primarySelector = ((RaftJournalSystem) journalSystem).getPrimarySelector(); return new FaultTolerantAlluxioJobMasterProcess(journalSystem, primarySelector, rpcBindSocket, webBindSocket); } return new AlluxioJobMasterProcess(journalSystem, rpcBindSocket, webBindSocket); }
@Override public void stop() throws Exception { super.stop(); if (mLeaderSelector != null) { mLeaderSelector.stop(); } }