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

The following are Jave code examples for showing how to use getRequestURL() of the org.apache.catalina.connector.Request class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: tomcat7   File: StuckThreadDetectionValve.java   Source Code and License Vote up 6 votes
/**
 * {@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
Project: apache-tomcat-7.0.73-with-comment   File: StuckThreadDetectionValve.java   Source Code and License Vote up 6 votes
/**
 * {@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
Project: lazycat   File: StuckThreadDetectionValve.java   Source Code and License Vote up 6 votes
/**
 * {@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()));
		}
	}
}