Java Code Examples for io.airlift.units.Duration#succinctNanos()

The following examples show how to use io.airlift.units.Duration#succinctNanos() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskExecutor.java    From presto with Apache License 2.0 5 votes vote down vote up
public String getMaxActiveSplitsInfo()
{
    // Sample output:
    //
    // 2 splits have been continuously active for more than 600.00ms seconds
    //
    // "20180907_054754_00000_88xi4.1.0-2" tid=99
    // at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2708)
    // at java.util.Formatter.parse(Formatter.java:2560)
    // at java.util.Formatter.format(Formatter.java:2501)
    // at ... (more lines of stacktrace)
    //
    // "20180907_054754_00000_88xi4.1.0-3" tid=106
    // at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2709)
    // at java.util.Formatter.parse(Formatter.java:2560)
    // at java.util.Formatter.format(Formatter.java:2501)
    // at ... (more line of stacktrace)
    StringBuilder stackTrace = new StringBuilder();
    int maxActiveSplitCount = 0;
    String message = "%s splits have been continuously active for more than %s seconds\n";
    for (RunningSplitInfo splitInfo : runningSplitInfos) {
        Duration duration = Duration.succinctNanos(ticker.read() - splitInfo.getStartTime());
        if (duration.compareTo(LONG_SPLIT_WARNING_THRESHOLD) >= 0) {
            maxActiveSplitCount++;
            stackTrace.append("\n");
            stackTrace.append(format("\"%s\" tid=%s", splitInfo.getThreadId(), splitInfo.getThread().getId())).append("\n");
            for (StackTraceElement traceElement : splitInfo.getThread().getStackTrace()) {
                stackTrace.append("\tat ").append(traceElement).append("\n");
            }
        }
    }

    return format(message, maxActiveSplitCount, LONG_SPLIT_WARNING_THRESHOLD).concat(stackTrace.toString());
}
 
Example 2
Source File: TaskExecutor.java    From presto with Apache License 2.0 5 votes vote down vote up
@Managed
public long getRunAwaySplitCount()
{
    int count = 0;
    for (RunningSplitInfo splitInfo : runningSplitInfos) {
        Duration duration = Duration.succinctNanos(ticker.read() - splitInfo.getStartTime());
        if (duration.compareTo(LONG_SPLIT_WARNING_THRESHOLD) > 0) {
            count++;
        }
    }
    return count;
}
 
Example 3
Source File: TestingTransactionManager.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public TransactionInfo getTransactionInfo(TransactionId transactionId)
{
    checkArgument(transactions.containsKey(transactionId), "Unknown transaction");
    return new TransactionInfo(
            transactionId,
            IsolationLevel.READ_UNCOMMITTED,
            false, //read only
            false, // auto commit
            DateTime.now(), // created
            Duration.succinctNanos(0), // idle
            ImmutableList.of(), // catalogs
            Optional.empty()); // write catalog
}