private void logSlowOperation(SlowOperationLog log, int totalInvocations) { if (isStackTraceLoggingEnabled) { logWithStackTrace(log, totalInvocations); } else if (!isFirstLog) { logWithoutStackTrace(log, totalInvocations); } else { logWithConfigHint(log); } }
@Override public List<SlowOperationDTO> getSlowOperationDTOs() { return slowOperationDetector.getSlowOperationDTOs(); }
private CurrentOperationData[] initCurrentOperationData(OperationRunner[] operationRunners) { CurrentOperationData[] currentOperationDataArray = new CurrentOperationData[operationRunners.length]; for (int i = 0; i < currentOperationDataArray.length; i++) { currentOperationDataArray[i] = new CurrentOperationData(); currentOperationDataArray[i].operationHashCode = -1; } return currentOperationDataArray; }
private void shutdown() { running = false; detectorThread.interrupt(); try { detectorThread.join(SLOW_OPERATION_THREAD_MAX_WAIT_TIME_TO_FINISH); } catch (InterruptedException ignored) { currentThread().interrupt(); } } }
@Override public void run() { long lastLogPurge = System.nanoTime(); while (running) { long nowNanos = System.nanoTime(); long nowMillis = System.currentTimeMillis(); scan(nowNanos, nowMillis, genericOperationRunners, genericCurrentOperationData); scan(nowNanos, nowMillis, partitionOperationRunners, partitionCurrentOperationData); if (purge(nowNanos, lastLogPurge)) { lastLogPurge = nowNanos; } if (running) { sleepInterval(nowNanos); } } }
private void scan(long nowNanos, long nowMillis, OperationRunner[] operationRunners, CurrentOperationData[] currentOperationDataArray) { for (int i = 0; i < operationRunners.length && running; i++) { scanOperationRunner(nowNanos, nowMillis, operationRunners[i], currentOperationDataArray[i]); } }
private DetectorThread newDetectorThread(String hzName) { DetectorThread thread = new DetectorThread(hzName); return thread; }
public void start() { if (enabled) { detectorThread.start(); } else { logger.warning("The SlowOperationDetector is disabled! Slow operations will not be reported."); } }
public void shutdownOperationExecutor() { logger.finest("Shutting down operation executors"); operationExecutor.shutdown(); slowOperationDetector.shutdown(); } }
private boolean purge(long nowNanos, long lastLogPurge) { if (nowNanos - lastLogPurge <= logPurgeIntervalNanos) { return false; } for (SlowOperationLog log : slowOperationLogs.values()) { if (!running) { return false; } if (log.purgeInvocations(nowNanos, logRetentionNanos)) { slowOperationLogs.remove(log.stackTrace.hashCode()); } } return true; }
private SlowOperationLog getOrCreate(String stackTrace, Object operation) { Integer stackTraceHashCode = stackTrace.hashCode(); SlowOperationLog candidate = slowOperationLogs.get(stackTraceHashCode); if (candidate != null) { return candidate; } candidate = new SlowOperationLog(stackTrace, operation); slowOperationLogs.put(stackTraceHashCode, candidate); return candidate; }
private void logSlowOperation(SlowOperationLog log, int totalInvocations) { if (isStackTraceLoggingEnabled) { logWithStackTrace(log, totalInvocations); } else if (!isFirstLog) { logWithoutStackTrace(log, totalInvocations); } else { logWithConfigHint(log); } }
private void shutdown() { running = false; detectorThread.interrupt(); try { detectorThread.join(SLOW_OPERATION_THREAD_MAX_WAIT_TIME_TO_FINISH); } catch (InterruptedException ignored) { currentThread().interrupt(); } } }
@Override public void run() { long lastLogPurge = System.nanoTime(); while (running) { long nowNanos = System.nanoTime(); long nowMillis = System.currentTimeMillis(); scan(nowNanos, nowMillis, genericOperationRunners, genericCurrentOperationData); scan(nowNanos, nowMillis, partitionOperationRunners, partitionCurrentOperationData); if (purge(nowNanos, lastLogPurge)) { lastLogPurge = nowNanos; } if (running) { sleepInterval(nowNanos); } } }
@Override public List<SlowOperationDTO> getSlowOperationDTOs() { return slowOperationDetector.getSlowOperationDTOs(); }
private CurrentOperationData[] initCurrentOperationData(OperationRunner[] operationRunners) { CurrentOperationData[] currentOperationDataArray = new CurrentOperationData[operationRunners.length]; for (int i = 0; i < currentOperationDataArray.length; i++) { currentOperationDataArray[i] = new CurrentOperationData(); currentOperationDataArray[i].operationHashCode = -1; } return currentOperationDataArray; }
private void scan(long nowNanos, long nowMillis, OperationRunner[] operationRunners, CurrentOperationData[] currentOperationDataArray) { for (int i = 0; i < operationRunners.length && running; i++) { scanOperationRunner(nowNanos, nowMillis, operationRunners[i], currentOperationDataArray[i]); } }
private DetectorThread newDetectorThread(String hzName) { DetectorThread thread = new DetectorThread(hzName); return thread; }
public void start() { if (enabled) { detectorThread.start(); } else { logger.warning("The SlowOperationDetector is disabled! Slow operations will not be reported."); } }
public void shutdownOperationExecutor() { logger.finest("Shutting down operation executors"); operationExecutor.shutdown(); slowOperationDetector.shutdown(); } }