コード例 #1
0
ファイル: NetServer.java プロジェクト: ewingcode/ewingcenter
  public void run() {
    boolean bError = false;
    while (!bError) {
      try {
        clientSocket = serverSocket.accept();
        synchronized (clientSocket) {
          InputStream ins = clientSocket.getInputStream();
          try {
            StringBuffer out = new StringBuffer();
            byte[] b = new byte[4096];
            for (int n; (n = ins.read(b)) != -1; ) {
              out.append(new String(b, 0, n));
            }
            System.out.println(out.toString());
          } catch (Exception e) {
            System.err.println("Exception in close, " + e.getMessage());
          } finally {
            if (ins != null) ins.close();
          }
        }
      } catch (IOException e) {
        bError = true;
      }
    }

    try {
      serverSocket.close();
    } catch (Exception e) {
      JobLogger.error("Exception in close, " + e.getMessage());
    }
  }
コード例 #2
0
ファイル: NetServer.java プロジェクト: ewingcode/ewingcenter
 public void stop() {
   listener.interrupt();
   try {
     serverSocket.close();
   } catch (Exception e) {
     JobLogger.error("Exception in close, " + e.getMessage());
   }
 }
コード例 #3
0
ファイル: NetServer.java プロジェクト: ewingcode/ewingcenter
 public void disconnect() {
   if (clientSocket == null) {
     return;
   }
   synchronized (clientSocket) {
     try {
       clientSocket.notify();
     } catch (Exception e) {
       JobLogger.error("Exception in notify, " + e.getMessage());
     }
   }
 }
コード例 #4
0
 private void flush(List<JobLogPo> batch) {
   boolean flushSuccess = false;
   try {
     jobLogger.log(batch);
     flushSuccess = true;
   } finally {
     if (!flushSuccess) {
       memoryQueue.addAll(batch);
     }
     batch.clear();
   }
 }
コード例 #5
0
 @Override
 public void log(JobLogPo jobLogPo) {
   if (jobLogPo == null) {
     return;
   }
   if (lazyLog) {
     checkOverflowSize();
     memoryQueue.offer(jobLogPo);
     checkCapacity();
   } else {
     jobLogger.log(jobLogPo);
   }
 }
コード例 #6
0
 @Override
 public void log(List<JobLogPo> jobLogPos) {
   if (CollectionUtils.isEmpty(jobLogPos)) {
     return;
   }
   if (lazyLog) {
     checkOverflowSize();
     for (JobLogPo jobLogPo : jobLogPos) {
       memoryQueue.offer(jobLogPo);
     }
     // checkCapacity
     checkCapacity();
   } else {
     jobLogger.log(jobLogPos);
   }
 }
コード例 #7
0
 @Override
 public PageResponse<JobLogPo> search(JobLoggerRequest request) {
   return jobLogger.search(request);
 }