コード例 #1
0
ファイル: BlockWorker.java プロジェクト: Intellifora/tachyon
 /**
  * Stops the block worker. This method should only be called to terminate the worker.
  *
  * @throws IOException if the data server fails to close
  */
 public void stop() throws IOException {
   mDataServer.close();
   mThriftServer.stop();
   mThriftServerSocket.close();
   mSessionCleanerThread.stop();
   mBlockMasterClient.close();
   if (mSpaceReserver != null) {
     mSpaceReserver.stop();
   }
   mFileSystemMasterClient.close();
   // Use shutdownNow because HeartbeatThreads never finish until they are interrupted
   getExecutorService().shutdownNow();
   mWorkerMetricsSystem.stop();
   try {
     mWebServer.shutdownWebServer();
   } catch (Exception e) {
     LOG.error("Failed to stop web server", e);
   }
   mBlockDataManager.stop();
   while (!mDataServer.isClosed() || mThriftServer.isServing()) {
     // The reason to stop and close again is due to some issues in Thrift.
     mDataServer.close();
     mThriftServer.stop();
     mThriftServerSocket.close();
     CommonUtils.sleepMs(100);
   }
 }
コード例 #2
0
  @Override
  public void start() {
    try {
      log.info("ThriftServer starting....");
      TServerSocket socket = new TServerSocket(Const.THRIFT_PORT);

      NewsServiceHandler newsServiceHandler =
          (NewsServiceHandler) SpringContextUtil.getBean("newsServiceHandler");
      final kevin.news.thrift.NewsService.Processor processor =
          new kevin.news.thrift.NewsService.Processor(newsServiceHandler);

      TThreadPoolServer.Args args = new TThreadPoolServer.Args(socket);
      args.protocolFactory(new TBinaryProtocol.Factory(true, true));
      //            args.transportFactory(new TFramedTransport.Factory());
      args.processor(processor);
      args.minWorkerThreads = Const.work_thread_num;
      args.maxWorkerThreads = Const.work_thread_num;

      log.info("ThriftServer starting, listening on " + Const.THRIFT_PORT);
      TThreadPoolServer server = new TThreadPoolServer(args);

      server.serve();

    } catch (Exception e) {
      log.error("thrift server 启动出错", e);
    }
  }
コード例 #3
0
ファイル: BlockWorker.java プロジェクト: Intellifora/tachyon
  /**
   * Runs the block worker. The thread calling this will be blocked until the thrift server shuts
   * down.
   */
  public void process() {
    getExecutorService()
        .submit(
            new HeartbeatThread(
                HeartbeatContext.WORKER_BLOCK_SYNC,
                mBlockMasterSync,
                WorkerContext.getConf().getInt(Constants.WORKER_BLOCK_HEARTBEAT_INTERVAL_MS)));

    // Start the pinlist syncer to perform the periodical fetching
    getExecutorService()
        .submit(
            new HeartbeatThread(
                HeartbeatContext.WORKER_PIN_LIST_SYNC,
                mPinListSync,
                WorkerContext.getConf().getInt(Constants.WORKER_BLOCK_HEARTBEAT_INTERVAL_MS)));

    // Start the session cleanup checker to perform the periodical checking
    getExecutorService().submit(mSessionCleanerThread);

    // Start the space reserver
    if (mSpaceReserver != null) {
      getExecutorService().submit(mSpaceReserver);
    }

    mThriftServer.serve();
  }
コード例 #4
0
ファイル: ThriftTestServer.java プロジェクト: tonydeng/tcp4j
  //    @Test
  public void testThreadServerStart() {
    try {
      TServerTransport serverTransport = serverTransport = new TServerSocket(port);

      TThreadPoolServer.Args processor =
          new TThreadPoolServer.Args(serverTransport)
              .inputTransportFactory(new TFramedTransport.Factory())
              .outputTransportFactory(new TFramedTransport.Factory())
              .protocolFactory(new TCompactProtocol.Factory())
              .processor(new PingPongService.Processor<>(pingPongService));
      //            processor.maxWorkerThreads = 20;
      TThreadPoolServer server = new TThreadPoolServer(processor);

      log.info("Starting the server...");
      server.serve();
    } catch (TTransportException e) {
      e.printStackTrace();
    }
  }
コード例 #5
0
ファイル: ThriftTestServer.java プロジェクト: tonydeng/tcp4j
  @Test
  public void echoStart() {
    try {
      TServerTransport serverTransport = new TServerSocket(port);

      TThreadPoolServer.Args processor =
          new TThreadPoolServer.Args(serverTransport)
              .inputTransportFactory(new TFramedTransport.Factory())
              .outputTransportFactory(new TFramedTransport.Factory())
              .protocolFactory(new TCompactProtocol.Factory())
              .processor(new TestThriftService.Processor<>(new TestThriftServiceHandler()));
      //            processor.maxWorkerThreads = 20;
      TThreadPoolServer server = new TThreadPoolServer(processor);

      System.out.println("Starting the server...");
      server.serve();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #6
0
ファイル: TachyonWorker.java プロジェクト: pecbali/tachyon
 private void stopServing() {
   mThriftServer.stop();
   mThriftServerSocket.close();
   mWorkerMetricsSystem.stop();
   try {
     mWebServer.shutdownWebServer();
   } catch (Exception e) {
     LOG.error("Failed to stop web server", e);
   }
   mWorkerMetricsSystem.stop();
 }
コード例 #7
0
ファイル: TachyonWorker.java プロジェクト: pecbali/tachyon
  /**
   * Starts the Tachyon worker server.
   *
   * @throws Exception if the workers fail to start
   */
  public void start() throws Exception {
    // NOTE: the order to start different services is sensitive. If you change it, do it cautiously.

    // Start serving metrics system, this will not block
    mWorkerMetricsSystem.start();

    // Start serving the web server, this will not block
    // Requirement: metrics system started so we could add the metrics servlet to the web server
    // Consequence: when starting webserver, the webport will be updated.
    mWebServer.addHandler(mWorkerMetricsSystem.getServletHandler());
    mWebServer.startWebServer();

    // Set updated net address for this worker in context
    // Requirement: RPC, web, and dataserver ports are updated
    // Consequence: create a NetAddress object and set it into WorkerContext
    mNetAddress =
        new NetAddress(
            NetworkAddressUtils.getConnectHost(ServiceType.WORKER_RPC, mTachyonConf),
            mTachyonConf.getInt(Constants.WORKER_RPC_PORT),
            getDataLocalPort(),
            mTachyonConf.getInt(Constants.WORKER_WEB_PORT));
    WorkerContext.setWorkerNetAddress(mNetAddress);

    // Start each worker
    // Requirement: NetAddress set in WorkerContext, so block worker can initialize BlockMasterSync
    // Consequence: worker id is granted
    startWorkers();
    LOG.info("Started worker with id {}", WorkerIdRegistry.getWorkerId());

    mIsServingRPC = true;

    // Start serving RPC, this will block
    LOG.info("Tachyon Worker version {} started @ {}", Version.VERSION, mWorkerAddress);
    mThriftServer.serve();
    LOG.info("Tachyon Worker version {} ended @ {}", Version.VERSION, mWorkerAddress);
  }
コード例 #8
0
 /** To stop the server */
 public void stop() {
   stormManagerServer.stop();
 }
コード例 #9
0
 public void run() {
   server.serve();
 }
コード例 #10
0
 /** hook for JSVC */
 public void stop() {
   logger.info("Cassandra shutting down...");
   serverEngine.stop();
 }
コード例 #11
0
 /** hook for JSVC */
 public void start() {
   logger.info("Cassandra starting up...");
   serverEngine.serve();
 }