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()); } }
public void stop() { listener.interrupt(); try { serverSocket.close(); } catch (Exception e) { JobLogger.error("Exception in close, " + e.getMessage()); } }
public void disconnect() { if (clientSocket == null) { return; } synchronized (clientSocket) { try { clientSocket.notify(); } catch (Exception e) { JobLogger.error("Exception in notify, " + e.getMessage()); } } }
private void flush(List<JobLogPo> batch) { boolean flushSuccess = false; try { jobLogger.log(batch); flushSuccess = true; } finally { if (!flushSuccess) { memoryQueue.addAll(batch); } batch.clear(); } }
@Override public void log(JobLogPo jobLogPo) { if (jobLogPo == null) { return; } if (lazyLog) { checkOverflowSize(); memoryQueue.offer(jobLogPo); checkCapacity(); } else { jobLogger.log(jobLogPo); } }
@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); } }
@Override public PageResponse<JobLogPo> search(JobLoggerRequest request) { return jobLogger.search(request); }