Java Code Examples for org.apache.catalina.connector.Request#getRequestURL()

The following examples show how to use org.apache.catalina.connector.Request#getRequestURL() . 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: StuckThreadDetectionValve.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void invoke(Request request, Response response)
        throws IOException, ServletException {

    if (threshold <= 0) {
        // short-circuit if not monitoring stuck threads
        getNext().invoke(request, response);
        return;
    }

    // Save the thread/runnable
    // Keeping a reference to the thread object here does not prevent
    // GC'ing, as the reference is removed from the Map in the finally clause

    Long key = Long.valueOf(Thread.currentThread().getId());
    StringBuffer requestUrl = request.getRequestURL();
    if(request.getQueryString()!=null) {
        requestUrl.append("?");
        requestUrl.append(request.getQueryString());
    }
    MonitoredThread monitoredThread = new MonitoredThread(Thread.currentThread(),
        requestUrl.toString(), interruptThreadThreshold > 0);
    activeThreads.put(key, monitoredThread);

    try {
        getNext().invoke(request, response);
    } finally {
        activeThreads.remove(key);
        if (monitoredThread.markAsDone() == MonitoredThreadState.STUCK) {
            if(monitoredThread.wasInterrupted()) {
                interruptedThreadsCount.incrementAndGet();
            }
            completedStuckThreadsQueue.add(
                    new CompletedStuckThread(monitoredThread.getThread(),
                        monitoredThread.getActiveTimeInMillis()));
        }
    }
}
 
Example 2
Source File: StuckThreadDetectionValve.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void invoke(Request request, Response response)
        throws IOException, ServletException {

    if (threshold <= 0) {
        // short-circuit if not monitoring stuck threads
        getNext().invoke(request, response);
        return;
    }

    // Save the thread/runnable
    // Keeping a reference to the thread object here does not prevent
    // GC'ing, as the reference is removed from the Map in the finally clause

    Long key = Long.valueOf(Thread.currentThread().getId());
    StringBuffer requestUrl = request.getRequestURL();
    if(request.getQueryString()!=null) {
        requestUrl.append("?");
        requestUrl.append(request.getQueryString());
    }
    MonitoredThread monitoredThread = new MonitoredThread(Thread.currentThread(),
        requestUrl.toString(), interruptThreadThreshold > 0);
    activeThreads.put(key, monitoredThread);

    try {
        getNext().invoke(request, response);
    } finally {
        activeThreads.remove(key);
        if (monitoredThread.markAsDone() == MonitoredThreadState.STUCK) {
            if(monitoredThread.wasInterrupted()) {
                interruptedThreadsCount.incrementAndGet();
            }
            completedStuckThreadsQueue.add(
                    new CompletedStuckThread(monitoredThread.getThread(),
                        monitoredThread.getActiveTimeInMillis()));
        }
    }
}
 
Example 3
Source File: StuckThreadDetectionValve.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void invoke(Request request, Response response)
        throws IOException, ServletException {

    if (threshold <= 0) {
        // short-circuit if not monitoring stuck threads
        getNext().invoke(request, response);
        return;
    }

    // Save the thread/runnable
    // Keeping a reference to the thread object here does not prevent
    // GC'ing, as the reference is removed from the Map in the finally clause

    Long key = Long.valueOf(Thread.currentThread().getId());
    StringBuffer requestUrl = request.getRequestURL();
    if(request.getQueryString()!=null) {
        requestUrl.append("?");
        requestUrl.append(request.getQueryString());
    }
    MonitoredThread monitoredThread = new MonitoredThread(Thread.currentThread(),
        requestUrl.toString(), interruptThreadThreshold > 0);
    activeThreads.put(key, monitoredThread);

    try {
        getNext().invoke(request, response);
    } finally {
        activeThreads.remove(key);
        if (monitoredThread.markAsDone() == MonitoredThreadState.STUCK) {
            if(monitoredThread.wasInterrupted()) {
                interruptedThreadsCount.incrementAndGet();
            }
            completedStuckThreadsQueue.add(
                    new CompletedStuckThread(monitoredThread.getThread(),
                        monitoredThread.getActiveTimeInMillis()));
        }
    }
}