@Test public void getGClog(){ System.gc();System.gc();System.gc(); GCLogEndpoint gcLogEndpoint=new GCLogEndpoint(); System.out.println(gcLogEndpoint.getGClog(1,100)); }
@GetMapping public GCLog getGClog(@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "size", required = false, defaultValue = "100") int size){ Optional<String> gcLogPath = getGCLogPath(); GCLog.GCLogBuilder builder = GCLog.builder().page(page).size(size); if(gcLogPath.isPresent()){ String path= gcLogPath.get(); File gcFile=new File(path); long length = gcFile.length(); try (LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(gcFile))) { lineNumberReader.skip(length); builder.total(lineNumberReader.getLineNumber()); builder.log(Files.lines(gcFile.toPath()).skip((page - 1) * size) .limit(size) .collect(Collectors.toList())); } catch (FileNotFoundException e) { builder.error("Can not found [-Xloggc]"); } catch (IOException e) { builder.error("Read file error : "+e.getMessage()); } }else { builder.error("GClog file can not be found"); } return builder.build(); }
GCLogEndpoint { @GetMapping public GCLog getGClog(@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "size", required = false, defaultValue = "100") int size){ Optional<String> gcLogPath = getGCLogPath(); GCLog.GCLogBuilder builder = GCLog.builder().page(page).size(size); if(gcLogPath.isPresent()){ String path= gcLogPath.get(); File gcFile=new File(path); long length = gcFile.length(); try (LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(gcFile))) { lineNumberReader.skip(length); builder.total(lineNumberReader.getLineNumber()); builder.log(Files.lines(gcFile.toPath()).skip((page - 1) * size) .limit(size) .collect(Collectors.toList())); } catch (FileNotFoundException e) { builder.error("Can not found [-Xloggc]"); } catch (IOException e) { builder.error("Read file error : "+e.getMessage()); } }else { builder.error("GClog file can not be found"); } return builder.build(); } }
GCLogEndpoint { @GetMapping public GCLog getGClog(@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "size", required = false, defaultValue = "100") int size){ Optional<String> gcLogPath = getGCLogPath(); GCLog.GCLogBuilder builder = GCLog.builder().page(page).size(size); if(gcLogPath.isPresent()){ String path= gcLogPath.get(); File gcFile=new File(path); long length = gcFile.length(); try (LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(gcFile))) { lineNumberReader.skip(length); builder.total(lineNumberReader.getLineNumber()); builder.log(Files.lines(gcFile.toPath()).skip((page - 1) * size) .limit(size) .collect(Collectors.toList())); } catch (FileNotFoundException e) { builder.error("Can not found [-Xloggc]"); } catch (IOException e) { builder.error("Read file error : "+e.getMessage()); } }else { builder.error("GClog file can not be found"); } return builder.build(); }  }
GCLogEndpoint { @GetMapping public GCLog getGClog(@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "size", required = false, defaultValue = "100") int size){ Optional<String> gcLogPath = getGCLogPath(); GCLog.GCLogBuilder builder = GCLog.builder().page(page).size(size); if(gcLogPath.isPresent()){ String path= gcLogPath.get(); File gcFile=new File(path); long length = gcFile.length(); try (LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(gcFile))) { lineNumberReader.skip(length); builder.total(lineNumberReader.getLineNumber()); builder.log(Files.lines(gcFile.toPath()).skip((page - 1) * size) .limit(size) .collect(Collectors.toList())); } catch (FileNotFoundException e) { builder.error("Can not found [-Xloggc]"); } catch (IOException e) { builder.error("Read file error : "+e.getMessage()); } }else { builder.error("GClog file can not be found"); } return builder.build(); }  @GetMapping GCLog getGClog(@RequestParam(value = "page", required = false, defaultValue = "1") int page,
                          @RequestParam(value = "size", required = false, defaultValue = "100") int size); }
GCLogEndpoint { @GetMapping public GCLog getGClog(@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "size", required = false, defaultValue = "100") int size){ Optional<String> gcLogPath = getGCLogPath(); GCLog.GCLogBuilder builder = GCLog.builder().page(page).size(size); if(gcLogPath.isPresent()){ String path= gcLogPath.get(); File gcFile=new File(path); long length = gcFile.length(); try (LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(gcFile))) { lineNumberReader.skip(length); builder.total(lineNumberReader.getLineNumber()); builder.log(Files.lines(gcFile.toPath()).skip((page - 1) * size) .limit(size) .collect(Collectors.toList())); } catch (FileNotFoundException e) { builder.error("Can not found [-Xloggc]"); } catch (IOException e) { builder.error("Read file error : "+e.getMessage()); } }else { builder.error("GClog file can not be found"); } return builder.build(); }  @GetMapping GCLog getGClog(@RequestParam(value = "page", required = false, defaultValue = "1") int page,
                          @RequestParam(value = "size", required = false, defaultValue = "100") int size);  }