Class ThrottledFetcher.ExecuteMethodThread
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.manifoldcf.crawler.connectors.webcrawler.ThrottledFetcher.ExecuteMethodThread
-
- All Implemented Interfaces:
java.lang.Runnable
- Enclosing class:
- ThrottledFetcher
protected static class ThrottledFetcher.ExecuteMethodThread extends java.lang.ThreadThis thread does the actual socket communication with the server. It's set up so that it can be abandoned at shutdown time. The way it works is as follows: - it starts the transaction - it receives the response, and saves that for the calling class to inspect - it transfers the data part to an input stream provided to the calling class - it shuts the connection down If there is an error, the sequence is aborted, and an exception is recorded for the calling class to examine. The calling class basically accepts the sequence above. It starts the thread, and tries to get a response code. If instead an exception is seen, the exception is thrown up the stack.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanabortThreadprotected java.io.InputStreambodyStreamprotected java.lang.ThrowablecookieExceptionprotected LoginCookiescookiesprotected org.apache.http.client.CookieStorecookieStoreprotected booleandeflateprotected org.apache.http.client.methods.HttpRequestBaseexecuteMethodprotected org.apache.manifoldcf.connectorcommon.interfaces.IFetchThrottlerfetchThrottlerThe fetch throttlerprotected java.lang.ThrowablegeneralExceptionprotected booleangzipprotected org.apache.http.client.HttpClienthttpClientClient and method, all preconfiguredprotected org.apache.http.HttpResponseresponseprotected java.lang.ThrowableresponseExceptionprotected java.lang.ThrowableshutdownExceptionprotected booleanstreamCreatedprotected java.lang.ThrowablestreamExceptionprotected org.apache.http.HttpHosttargetprotected ThrottledFetcher.ThrottledConnectiontheConnectionThe connectionprotected org.apache.manifoldcf.connectorcommon.common.XThreadInputStreamthreadStream
-
Constructor Summary
Constructors Constructor Description ExecuteMethodThread(ThrottledFetcher.ThrottledConnection theConnection, org.apache.manifoldcf.connectorcommon.interfaces.IFetchThrottler fetchThrottler, org.apache.http.client.HttpClient httpClient, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestBase executeMethod, org.apache.http.client.CookieStore cookieStore)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()protected voidcheckException(java.lang.Throwable exception)voidfinishUp()LoginCookiesgetCookies()java.lang.StringgetFirstHeader(java.lang.String headerName)intgetResponseCode()java.util.Map<java.lang.String,java.util.List<java.lang.String>>getResponseHeaders()java.io.InputStreamgetSafeInputStream()booleanisDeflateStream()booleanisGZipStream()voidrun()-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
theConnection
protected final ThrottledFetcher.ThrottledConnection theConnection
The connection
-
fetchThrottler
protected final org.apache.manifoldcf.connectorcommon.interfaces.IFetchThrottler fetchThrottler
The fetch throttler
-
httpClient
protected final org.apache.http.client.HttpClient httpClient
Client and method, all preconfigured
-
target
protected final org.apache.http.HttpHost target
-
executeMethod
protected final org.apache.http.client.methods.HttpRequestBase executeMethod
-
cookieStore
protected final org.apache.http.client.CookieStore cookieStore
-
response
protected org.apache.http.HttpResponse response
-
responseException
protected java.lang.Throwable responseException
-
cookies
protected LoginCookies cookies
-
cookieException
protected java.lang.Throwable cookieException
-
threadStream
protected org.apache.manifoldcf.connectorcommon.common.XThreadInputStream threadStream
-
bodyStream
protected java.io.InputStream bodyStream
-
streamCreated
protected boolean streamCreated
-
streamException
protected java.lang.Throwable streamException
-
abortThread
protected boolean abortThread
-
gzip
protected boolean gzip
-
deflate
protected boolean deflate
-
shutdownException
protected java.lang.Throwable shutdownException
-
generalException
protected java.lang.Throwable generalException
-
-
Constructor Detail
-
ExecuteMethodThread
public ExecuteMethodThread(ThrottledFetcher.ThrottledConnection theConnection, org.apache.manifoldcf.connectorcommon.interfaces.IFetchThrottler fetchThrottler, org.apache.http.client.HttpClient httpClient, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestBase executeMethod, org.apache.http.client.CookieStore cookieStore)
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
getResponseCode
public int getResponseCode() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getResponseHeaders
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getFirstHeader
public java.lang.String getFirstHeader(java.lang.String headerName) throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getCookies
public LoginCookies getCookies() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException
- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
isGZipStream
public boolean isGZipStream() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
isDeflateStream
public boolean isDeflateStream() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getSafeInputStream
public java.io.InputStream getSafeInputStream() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
abort
public void abort()
-
finishUp
public void finishUp() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
checkException
protected void checkException(java.lang.Throwable exception) throws java.io.IOException, org.apache.http.HttpException- Throws:
java.io.IOExceptionorg.apache.http.HttpException
-
-