77 }
78
79 /**
80 * @return log which was processed
81 */
82 public String getLog() {
83 return log;
84 }
85
86 /**
87 * Returns the GC log entries for Survivor and Old stats.
88 * The entries are represented as a map of gcID to the StatMap.
89 *
90 * @return The log entries for the Survivor and Old stats.
91 */
92 public PlabReport getEntries() {
93 return report;
94 }
95
96 private PlabReport parseLines() throws NumberFormatException {
97 Scanner lineScanner = new Scanner(log);
98 PlabReport plabReport = new PlabReport();
99 Optional<Long> gc_id;
100 while (lineScanner.hasNextLine()) {
101 String line = lineScanner.nextLine();
102 gc_id = getGcId(line, GC_ID_PATTERN);
103 if (gc_id.isPresent()) {
104 Matcher matcher = PAIRS_PATTERN.matcher(line);
105 if (matcher.find()) {
106 if (!plabReport.containsKey(gc_id.get())) {
107 plabReport.put(gc_id.get(), new PlabGCStatistics());
108 }
109 ReportType reportType = line.contains("Young") ? ReportType.SURVIVOR_STATS : ReportType.OLD_STATS;
110
111 PlabGCStatistics gcStat = plabReport.get(gc_id.get());
112 if (!gcStat.containsKey(reportType)) {
113 gcStat.put(reportType, new PlabInfo());
114 }
115
116 // Extract all pairs from log.
117 PlabInfo plabInfo = gcStat.get(reportType);
118 do {
119 String pair = matcher.group();
120 String[] nameValue = pair.replaceAll(": ", ":").split(":");
121 plabInfo.put(nameValue[0].trim(), Long.parseLong(nameValue[1]));
122 } while (matcher.find());
123 }
124 }
125 }
126 return plabReport;
127 }
128
129 private static Optional<Long> getGcId(String line, Pattern pattern) {
130 Matcher number = pattern.matcher(line);
131 if (number.find()) {
132 return Optional.of(Long.parseLong(number.group(1)));
133 }
134 return Optional.empty();
135 }
136
137 /**
138 * Extracts GC ID from log.
139 *
140 * @param line - one line of log.
141 * @return GC ID
142 */
143 public static Long getGcIdFromLine(String line, Pattern pattern) {
144 Optional<Long> gcId = getGcId(line, pattern);
145 if (!gcId.isPresent()) {
|
77 }
78
79 /**
80 * @return log which was processed
81 */
82 public String getLog() {
83 return log;
84 }
85
86 /**
87 * Returns the GC log entries for Survivor and Old stats.
88 * The entries are represented as a map of gcID to the StatMap.
89 *
90 * @return The log entries for the Survivor and Old stats.
91 */
92 public PlabReport getEntries() {
93 return report;
94 }
95
96 private PlabReport parseLines() throws NumberFormatException {
97 try (Scanner lineScanner = new Scanner(log)) {
98 PlabReport plabReport = new PlabReport();
99 Optional<Long> gc_id;
100 while (lineScanner.hasNextLine()) {
101 String line = lineScanner.nextLine();
102 gc_id = getGcId(line, GC_ID_PATTERN);
103 if (gc_id.isPresent()) {
104 Matcher matcher = PAIRS_PATTERN.matcher(line);
105 if (matcher.find()) {
106 if (!plabReport.containsKey(gc_id.get())) {
107 plabReport.put(gc_id.get(), new PlabGCStatistics());
108 }
109 ReportType reportType = line.contains("Young") ? ReportType.SURVIVOR_STATS : ReportType.OLD_STATS;
110
111 PlabGCStatistics gcStat = plabReport.get(gc_id.get());
112 if (!gcStat.containsKey(reportType)) {
113 gcStat.put(reportType, new PlabInfo());
114 }
115
116 // Extract all pairs from log.
117 PlabInfo plabInfo = gcStat.get(reportType);
118 do {
119 String pair = matcher.group();
120 String[] nameValue = pair.replaceAll(": ", ":").split(":");
121 plabInfo.put(nameValue[0].trim(), Long.parseLong(nameValue[1]));
122 } while (matcher.find());
123 }
124 }
125 }
126 return plabReport;
127 }
128 }
129
130 private static Optional<Long> getGcId(String line, Pattern pattern) {
131 Matcher number = pattern.matcher(line);
132 if (number.find()) {
133 return Optional.of(Long.parseLong(number.group(1)));
134 }
135 return Optional.empty();
136 }
137
138 /**
139 * Extracts GC ID from log.
140 *
141 * @param line - one line of log.
142 * @return GC ID
143 */
144 public static Long getGcIdFromLine(String line, Pattern pattern) {
145 Optional<Long> gcId = getGcId(line, pattern);
146 if (!gcId.isPresent()) {
|