コード例 #1
0
 private void serveRequest(Socket connectionSocket) {
   try {
     GeneralRequestHandler handler =
         new GeneralRequestHandler(connectionSocket, config_map, cache);
     handler.processRequest();
   } catch (Exception e) {
     Debug.debug(e.toString());
     System.out.println("Exception happened in Thread " + this);
   }
 }
コード例 #2
0
  public ThreadPoolServer(Type type, HashMap<String, String> config_map, ThreadSafeCache cache)
      throws Exception {
    try {
      this.concurrent_type = type;
      this.config_map = config_map;
      this.cache = cache;

      // making welcome socket
      int port = Integer.parseInt(config_map.get("port"));
      welcomeSocket = new ServerSocket(port);

      this.thread_count = Integer.parseInt(config_map.get("ThreadPoolSize"));
      System.out.println(
          "Starting the server with thread pool size of "
              + thread_count
              + " and listening at: "
              + welcomeSocket);
    } catch (Exception e) {
      Debug.debug(e.getMessage());
      throw new Exception("ThreadPool Server initial construction failed.");
    }
  }