|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.limegroup.gnutella.HTTPUploadManager
public class HTTPUploadManager
Manages HTTPUploader objects that are created by
HttpRequestHandlers through the HTTPUploadSessionManager
interface. Since HTTP 1.1 allows multiple requests for a single connection an
HTTPUploadSession is created for each connection. It keeps track of
queuing (which is per connection) and bandwidth and has a reference to the
HTTPUploader that represents the current request.
The state of HTTPUploader follows this pattern:
|->---- THEX_REQUEST ------->--|
|->---- UNAVAILABLE_RANGE -->--|
|->---- PUSH_PROXY --------->--|
/-->---- FILE NOT FOUND ----->--|
/--->---- MALFORMED REQUEST -->--|
/---->---- BROWSE HOST -------->--|
/----->---- UPDATE FILE -------->--|
/------>---- QUEUED ------------->--|
/------->---- LIMIT REACHED ------>--|
/-------->---- UPLOADING ---------->--|
-->--CONNECTING-->--/ |
| \|/
| |
/|\ |--->INTERRUPTED
|--------<---COMPLETE-<------<-------<-------<------/ (done)
|
|
(done)
COMPLETE uploaders may be using HTTP/1.1, in which case the HTTPUploader
recycles back to CONNECTING upon receiving the next GET/HEAD request and
repeats.
INTERRUPTED HTTPUploaders are never reused. However, it is possible that the
socket may be reused. This case is only possible when a requester is queued
for one file and sends a subsequent request for another file. The first
HTTPUploader is set as interrupted and a second one is created
for the new file, using the same connection as the first one.
To initialize the upload manager #start(HTTPAcceptor) needs to be
invoked which registers handlers with an HTTPAcceptor.
HTTPUploader,
HTTPAcceptor| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.limegroup.gnutella.uploader.HTTPUploadSessionManager |
|---|
HTTPUploadSessionManager.QueueStatus |
| Field Summary | |
|---|---|
static int |
TRANSFER_SOCKET_TIMEOUT
|
| Constructor Summary | |
|---|---|
HTTPUploadManager(UploadSlotManager slotManager,
HttpRequestHandlerFactory httpRequestHandlerFactory,
com.google.inject.Provider<HTTPAcceptor> httpAcceptor,
com.google.inject.Provider<FileManager> fileManager,
com.google.inject.Provider<ActivityCallback> activityCallback,
TcpBandwidthStatistics tcpBandwidthStatistics,
com.google.inject.Provider<GnutellaUploadFileListProvider> gnutellaFileListProvider,
com.google.inject.Provider<GnutellaBrowseFileListProvider> gnutellaBrowseFileListProvider,
UrnValidator urnValidator)
|
|
| Method Summary | |
|---|---|
void |
addAcceptedUploader(HTTPUploader uploader,
org.apache.http.protocol.HttpContext context)
Adds an accepted HTTPUploader to the internal list of active downloads. |
int |
calculateBandwidth()
Calculates the appropriate burst size for the allocating bandwidth on the upload. |
void |
cleanup()
For testing: removes all uploaders and clears the request cache. |
void |
cleanupFinishedUploader(HTTPUploader uploader)
Cleans up a finished uploader. |
HTTPUploadSessionManager.QueueStatus |
enqueue(org.apache.http.protocol.HttpContext context,
org.apache.http.HttpRequest request)
Add request to the queue of uploaders. |
float |
getAverageBandwidth()
Returns the overall averaged bandwidth between all calls of measureBandwidth. |
float |
getLastMeasuredBandwidth()
Return the last value that was measured by BandwidthTracker.getMeasuredBandwidth(). |
float |
getMeasuredBandwidth()
Returns the throughput of this in kilobytes/sec (KB/s) between the last two calls to measureBandwidth, or 0.0 if unknown. |
int |
getNumQueuedUploads()
Returns the number of queued uploads. |
HTTPUploadSession |
getOrCreateSession(org.apache.http.protocol.HttpContext context)
|
HTTPUploader |
getOrCreateUploader(org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context,
UploadType type,
String filename)
Returns an uploader for request. |
String |
getServiceName()
|
HTTPUploadSession |
getSession(org.apache.http.protocol.HttpContext context)
Returns the session stored in context. |
UploadSlotManager |
getSlotManager()
|
HTTPUploader |
getUploader(org.apache.http.protocol.HttpContext context)
|
boolean |
hadSuccesfulUpload()
Returns true if this has ever successfully uploaded a file during this session. |
void |
handleFreeLoader(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context,
HTTPUploader uploader)
Sets a response code and entity on response for handling
requests from unsupported clients. |
void |
initialize()
|
boolean |
isConnectedTo(InetAddress addr)
Returns true if any uploader is conneected to addr. |
boolean |
isServiceable()
Returns whether or not an upload request can be serviced immediately. |
boolean |
killUploadsForFileDesc(FileDesc fd)
Stops all uploads that are uploading fd. |
boolean |
mayBeServiceable()
Returns if an incoming query (not actual upload request) may be serviceable. |
void |
measureBandwidth()
Measures the data throughput since the last call to measureBandwidth. |
int |
measuredUploadSpeed()
Returns the estimated upload speed in KILOBITS/s [sic] of the next transfer, assuming the client (i.e., downloader) has infinite |
boolean |
releaseLock(File file)
Returns true if the lock was released on the file. |
void |
sendResponse(HTTPUploader uploader,
org.apache.http.HttpResponse response)
Adds uploader to the GUI if it is not visible, yet, and
increments the attempted uploads. |
void |
start()
Registers the upload manager at acceptor. |
void |
stop()
Unregisters the upload manager at acceptor. |
int |
uploadsInProgress()
Returns the number of uploads excluding forced uploads. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TRANSFER_SOCKET_TIMEOUT
| Constructor Detail |
|---|
@Inject
public HTTPUploadManager(UploadSlotManager slotManager,
HttpRequestHandlerFactory httpRequestHandlerFactory,
com.google.inject.Provider<HTTPAcceptor> httpAcceptor,
com.google.inject.Provider<FileManager> fileManager,
com.google.inject.Provider<ActivityCallback> activityCallback,
TcpBandwidthStatistics tcpBandwidthStatistics,
com.google.inject.Provider<GnutellaUploadFileListProvider> gnutellaFileListProvider,
com.google.inject.Provider<GnutellaBrowseFileListProvider> gnutellaBrowseFileListProvider,
UrnValidator urnValidator)
| Method Detail |
|---|
public String getServiceName()
getServiceName in interface Servicepublic void initialize()
initialize in interface Servicepublic void start()
acceptor.
start in interface UploadManagerstart in interface ServiceIllegalStateException - if uploadmanager was already started#stop(HTTPAcceptor)public void stop()
acceptor.
stop in interface UploadManagerstop in interface Service#start(HTTPAcceptor)
public void handleFreeLoader(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context,
HTTPUploader uploader)
throws org.apache.http.HttpException,
IOException
HTTPUploadSessionManagerresponse for handling
requests from unsupported clients.
handleFreeLoader in interface HTTPUploadSessionManagerorg.apache.http.HttpException
IOExceptionpublic void cleanupFinishedUploader(HTTPUploader uploader)
public void addAcceptedUploader(HTTPUploader uploader,
org.apache.http.protocol.HttpContext context)
HTTPUploadSessionManager
addAcceptedUploader in interface HTTPUploadSessionManager
public void sendResponse(HTTPUploader uploader,
org.apache.http.HttpResponse response)
HTTPUploadSessionManageruploader to the GUI if it is not visible, yet, and
increments the attempted uploads.
sendResponse in interface HTTPUploadSessionManagerpublic boolean isServiceable()
UploadManager
isServiceable in interface UploadManagerpublic boolean mayBeServiceable()
UploadManager
mayBeServiceable in interface UploadManagerpublic int uploadsInProgress()
UploadManager
uploadsInProgress in interface UploadManagerpublic int getNumQueuedUploads()
UploadManager
getNumQueuedUploads in interface UploadManagerpublic boolean hadSuccesfulUpload()
UploadManagerThis method was added to adopt more of the BearShare QHD standard.
hadSuccesfulUpload in interface UploadManagerpublic boolean isConnectedTo(InetAddress addr)
UploadManageraddr.
isConnectedTo in interface UploadManagerpublic boolean releaseLock(File file)
FileLocker
releaseLock in interface FileLockerpublic boolean killUploadsForFileDesc(FileDesc fd)
UploadManagerfd.
killUploadsForFileDesc in interface UploadManagerpublic int calculateBandwidth()
public int measuredUploadSpeed()
UploadManager
measuredUploadSpeed in interface UploadManagerpublic void measureBandwidth()
BandwidthTrackermeasureBandwidth.
This value can be read by calling getMeasuredBandwidth.
measureBandwidth in interface BandwidthTrackerpublic float getMeasuredBandwidth()
BandwidthTrackermeasureBandwidth, or 0.0 if unknown.
getMeasuredBandwidth in interface BandwidthTrackerpublic float getAverageBandwidth()
BandwidthTrackermeasureBandwidth.
getAverageBandwidth in interface BandwidthTrackerpublic float getLastMeasuredBandwidth()
UploadManagerBandwidthTracker.getMeasuredBandwidth().
getLastMeasuredBandwidth in interface UploadManagerpublic UploadSlotManager getSlotManager()
public HTTPUploadSession getOrCreateSession(org.apache.http.protocol.HttpContext context)
public HTTPUploadSession getSession(org.apache.http.protocol.HttpContext context)
context.
public HTTPUploader getOrCreateUploader(org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context,
UploadType type,
String filename)
HTTPUploadSessionManagerrequest. If the previous request
was for filename as well an existing uploader is returned;
otherwise a new uploader is created.
getOrCreateUploader in interface HTTPUploadSessionManagerpublic HTTPUploader getUploader(org.apache.http.protocol.HttpContext context)
public HTTPUploadSessionManager.QueueStatus enqueue(org.apache.http.protocol.HttpContext context,
org.apache.http.HttpRequest request)
HTTPUploadSessionManagerrequest to the queue of uploaders.
enqueue in interface HTTPUploadSessionManagerUploadSlotManagerpublic void cleanup()
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||