Ejemplo n.º 1
0
  public void shutdown() {
    shutdownRequested = true;

    // Shut down the submission queue size monitor thread
    healthMonitorThread.interrupt();

    // close server sockets (so no new clients can attach)
    try {
      serverSocket.close(); // a bit rude, but effective
    } catch (IOException e) {
      logger.error("Exception closing ServerTask's socket", e);
    }

    // shut down worker tasks and wait for them to exit
    workerTaskSet.shutdownAll();
    workerTaskSet.waitForAll();
  }
Ejemplo n.º 2
0
  @Override
  public void run() {
    healthMonitorThread = new Thread(new HealthMonitorTask());
    healthMonitorThread.start();

    try {
      while (!shutdownRequested) {
        Socket clientSocket = serverSocket.accept();

        // FIXME: we should support whitelisting of client IPs

        // create worker task and thread
        workerTaskSet.createWorker(clientSocket, submissionQueue);
      }

    } catch (IOException e) {
      if (!shutdownRequested) {
        logger.error("IOException waiting for connections", e);
      }
    }
  }
Ejemplo n.º 3
0
 public int getNumWorkerTasks() {
   return workerTaskSet.getNumWorkerTasks();
 }