Java Code Examples for net.openhft.chronicle.core.Jvm#trimStackTrace()

The following examples show how to use net.openhft.chronicle.core.Jvm#trimStackTrace() . 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: TcpChannelHub.java    From Chronicle-Network with Apache License 2.0 6 votes vote down vote up
private void writeTimeout(@Nullable ByteBuffer outBuffer, long writeTime) {
    for (@NotNull Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) {
        Thread thread = entry.getKey();
        if (thread.getThreadGroup().getName().equals("system"))
            continue;
        @NotNull StringBuilder sb = new StringBuilder();
        sb.append("\n========= THREAD DUMP =========\n");
        sb.append(thread).append(" ").append(thread.getState());
        Jvm.trimStackTrace(sb, entry.getValue());
        sb.append("\n");
        Jvm.warn().on(TcpChannelHub.class, sb.toString());
    }

    closeSocket();

    throw new IORuntimeException("Took " + writeTime + " ms " +
            "to perform a write, remaining= " + outBuffer.remaining());
}
 
Example 2
Source File: Monitor.java    From Chronicle-Queue with Apache License 2.0 6 votes vote down vote up
@Override
public boolean action() {
    long time = timeSupplier.getAsLong();
    if (time == Long.MIN_VALUE)
        return false;
    long latency = System.nanoTime() - time;
    if (latency > timeLimit) {
        Thread thread = threadSupplier.get();
        if (thread != null && thread.isAlive() && LOG.isInfoEnabled()) {
            String type = (time == lastTime) ? "re-reporting" : "new report";
            StringBuilder out = new StringBuilder().append("THIS IS NOT AN ERROR, but a profile of the thread, ").append(description).append(" thread ").append(thread.getName()).append(" blocked for ").append(latency / 1000000).append(" ms. ").append(type);
            Jvm.trimStackTrace(out, thread.getStackTrace());

            LOG.info(out.toString());
            lastTime = time;
        }
    }
    return false;
}
 
Example 3
Source File: TcpEventHandler.java    From Chronicle-Network with Apache License 2.0 4 votes vote down vote up
@Override
public boolean action() throws InvalidEventHandlerException {
    if (TcpEventHandler.this.isClosed())
        throw InvalidEventHandlerException.reusable();

    if (!logs.isEmpty()) {
        ThreadLogTypeElapsedRecord msg;
        while ((msg = logs.poll()) != null) {
            messageBuilder.setLength(0);
            messageBuilder
                    .append("Non blocking ")
                    .append(className)
                    .append(" (")
                    .append(msg.thread.getName())
                    .append(") ")
                    .append(msg.logType.label())
                    .append(" took ")
                    .append(msg.elapsedNs / 1000)
                    .append(" us");

            Jvm.trimStackTrace(messageBuilder, msg.thread.getStackTrace());

            Jvm.warn().on(getClass(), messageBuilder.toString());
        }
    }

    final long now = System.currentTimeMillis();
    if (now > lastMonitor + (MONITOR_POLL_EVERY_SEC * 1000)) {
        final NetworkStatsListener<T> networkStatsListener = nc.networkStatsListener();
        if (networkStatsListener != null && !networkStatsListener.isClosed()) {
            if (lastMonitor == 0) {
                networkStatsListener.onNetworkStats(0, 0, 0);
            } else {
                networkStatsListener.onNetworkStats(
                        bytesWriteCount.get() / MONITOR_POLL_EVERY_SEC,
                        bytesReadCount.get() / MONITOR_POLL_EVERY_SEC,
                        socketPollCount.get() / MONITOR_POLL_EVERY_SEC);
                bytesWriteCount.set(0);
                bytesReadCount.set(0);
                socketPollCount.set(0);
            }
        }
        lastMonitor = now;
    }
    return false;
}