■ ■ ■ ■ ■ ■
src/main/java/com/nccgroup/loggerplusplus/logview/processor/LogProcessor.java
| skipped 49 lines |
50 | 50 | | this.proxyIdToUUIDMap = new ConcurrentHashMap<>(); |
51 | 51 | | this.entriesPendingProcessing = new ConcurrentHashMap<>(); |
52 | 52 | | this.entryProcessingFutures = new ConcurrentHashMap<>(); |
53 | | - | this.entryProcessExecutor = new PausableThreadPoolExecutor(10, 10, |
54 | | - | 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("LPP-LogManager")); |
55 | | - | this.entryImportExecutor = new PausableThreadPoolExecutor(10, 10, 0L, |
| 53 | + | this.entryProcessExecutor = new PausableThreadPoolExecutor(0, 2147483647, |
| 54 | + | 30L, TimeUnit.SECONDS, new SynchronousQueue<>(), new NamedThreadFactory("LPP-LogManager")); |
| 55 | + | this.entryImportExecutor = new PausableThreadPoolExecutor(0, 10, 60L, |
56 | 56 | | TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("LPP-Import")); |
57 | 57 | | |
58 | 58 | | //Create incomplete request cleanup thread so map doesn't get too big. |
59 | 59 | | this.cleanupExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("LPP-LogManager-Cleanup")); |
60 | | - | this.cleanupExecutor.scheduleAtFixedRate(new AbandonedRequestCleanupRunnable(),30000L, 30000L, TimeUnit.MILLISECONDS); |
| 60 | + | this.cleanupExecutor.scheduleAtFixedRate(new AbandonedRequestCleanupRunnable(),30, 30, TimeUnit.SECONDS); |
61 | 61 | | |
62 | 62 | | LoggerPlusPlus.callbacks.registerHttpListener(this); |
63 | 63 | | LoggerPlusPlus.callbacks.registerProxyListener(this); |
| skipped 155 lines |
219 | 219 | | private RunnableFuture<LogEntry> createEntryUpdateRunnable(final Future<LogEntry> processingFuture, |
220 | 220 | | final IHttpRequestResponse requestResponse, |
221 | 221 | | final Date arrivalTime){ |
222 | | - | return new SwingWorker<LogEntry, Void>(){ |
223 | | - | @Override |
224 | | - | protected LogEntry doInBackground() throws Exception { |
225 | | - | //Block until initial processing is complete. |
226 | | - | LogEntry logEntry = processingFuture.get(); |
227 | | - | if(logEntry == null){ |
228 | | - | return null; //Request to an ignored host. Stop processing. |
229 | | - | } |
230 | | - | logEntry.addResponse(requestResponse, arrivalTime); |
231 | | - | processEntry(logEntry); |
| 222 | + | return new FutureTask<>(() -> { |
| 223 | + | //Block until initial processing is complete. |
| 224 | + | LogEntry logEntry = processingFuture.get(); |
| 225 | + | if (logEntry == null) { |
| 226 | + | return null; //Request to an ignored host. Stop processing. |
| 227 | + | } |
| 228 | + | logEntry.addResponse(requestResponse, arrivalTime); |
| 229 | + | processEntry(logEntry); |
232 | 230 | | |
233 | | - | if(logEntry.getStatus() == Status.PROCESSED) { |
234 | | - | //If the entry was fully processed, remove it from the processing list. |
235 | | - | entryProcessingFutures.remove(logEntry.getIdentifier()); |
236 | | - | } |
237 | | - | |
238 | | - | return logEntry; |
| 231 | + | if (logEntry.getStatus() == Status.PROCESSED) { |
| 232 | + | //If the entry was fully processed, remove it from the processing list. |
| 233 | + | entryProcessingFutures.remove(logEntry.getIdentifier()); |
239 | 234 | | } |
240 | 235 | | |
241 | | - | @Override |
242 | | - | protected void done() { |
243 | | - | try{ |
244 | | - | LogEntry logEntry = get(); |
245 | | - | logTableController.getLogTableModel().updateEntry(logEntry); |
246 | | - | } catch (InterruptedException | ExecutionException e) { |
247 | | - | e.printStackTrace(); |
248 | | - | } |
249 | | - | } |
250 | | - | }; |
| 236 | + | updateExistingEntry(logEntry); |
| 237 | + | |
| 238 | + | return logEntry; |
| 239 | + | }); |
251 | 240 | | } |
252 | 241 | | |
253 | 242 | | public EntryImportWorker.Builder createEntryImportBuilder(){ |
| skipped 39 lines |
293 | 282 | | void addProcessedEntry(LogEntry logEntry){ |
294 | 283 | | SwingUtilities.invokeLater(() -> { |
295 | 284 | | logTableController.getLogTableModel().addEntry(logEntry); |
| 285 | + | }); |
| 286 | + | } |
| 287 | + | |
| 288 | + | void updateExistingEntry(LogEntry logEntry){ |
| 289 | + | SwingUtilities.invokeLater(() -> { |
| 290 | + | logTableController.getLogTableModel().updateEntry(logEntry); |
296 | 291 | | }); |
297 | 292 | | } |
298 | 293 | | |
| skipped 68 lines |