|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.klomp.snark.Snark
org.klomp.snark.web.FetchAndAdd
public class FetchAndAdd
A cancellable torrent file downloader. We extend Snark so its status may be easily listed in the web table without adding a lot of code there. Upon successful download, this Snark will be deleted and a "real" Snark created. The methods return values similar to a Snark in magnet mode. A fake info hash, which is the SHA1 of the URL, is returned to prevent duplicates. This Snark may be stopped and restarted, although a partially downloaded file is discarded.
| Field Summary |
|---|
| Fields inherited from class org.klomp.snark.Snark |
|---|
PROP_MAX_CONNECTIONS |
| Constructor Summary | |
|---|---|
FetchAndAdd(I2PAppContext ctx,
SnarkManager mgr,
String url)
Caller should call _mgr.addDownloader(this), which will start things off. |
|
| Method Summary | |
|---|---|
void |
attemptFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt,
int numRetries,
Exception cause)
|
void |
attempting(String url)
|
void |
bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)
alreadyTransferred - total of all attempts, not including currentWrite If nonzero on the first call, a partial file of that length was found, _and_ the server supports resume. |
String |
getBaseName()
|
long |
getDownloaded()
|
long |
getDownloadRate()
|
byte[] |
getInfoHash()
|
String |
getName()
|
long |
getNeededLength()
Bytes still wanted. |
int |
getPeerCount()
|
long |
getRemainingLength()
Bytes not yet in storage. |
long |
getTotalLength()
|
int |
getTrackerSeenPeers()
|
void |
headerReceived(String url,
int attemptNum,
String key,
String val)
Note: Headers are not processed, and this is not called, for most error response codes, unless setWriteErrorToOutput() is called before fetch(). |
boolean |
isStopped()
|
void |
run()
Set off by startTorrent() |
void |
startTorrent()
Start up contacting peers and querying the tracker. |
void |
stopTorrent()
Stop contacting the tracker and talking with peers |
void |
transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified)
|
void |
transferFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt)
|
| Methods inherited from class org.klomp.snark.Snark |
|---|
addMessage, getID, getMetaInfo, getNeeded, getPeerList, getPieceLength, getPieces, getStorage, getTrackerProblems, getTrackerURL, getUploaded, getUploadRate, gotMetaInfo, isAllocating, isChecking, isStarting, overUpBWLimit, overUpBWLimit, overUploadLimit, peerChange, restartAcceptor, setStarting, setTrackerProblems, setTrackerSeenPeers, setWantedPieces, shutdown, stopTorrent, storageAllChecked, storageAllocated, storageChecked, storageCompleted, storageCreateFile, updatePiecePriorities |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FetchAndAdd(I2PAppContext ctx,
SnarkManager mgr,
String url)
| Method Detail |
|---|
public void run()
run in interface Runnablepublic void startTorrent()
Snark
startTorrent in class Snarkpublic void stopTorrent()
Snark
stopTorrent in class Snarkpublic boolean isStopped()
isStopped in class Snarkpublic String getName()
getName in class Snarkpublic String getBaseName()
getBaseName in class Snarkpublic byte[] getInfoHash()
getInfoHash in class Snarkpublic long getTotalLength()
getTotalLength in class Snarkpublic long getRemainingLength()
Snark
getRemainingLength in class Snarkpublic long getNeededLength()
Snark
getNeededLength in class Snarkpublic long getDownloadRate()
getDownloadRate in class Snarkpublic long getDownloaded()
getDownloaded in class Snarkpublic int getPeerCount()
getPeerCount in class Snarkpublic int getTrackerSeenPeers()
getTrackerSeenPeers in class Snark
public void attemptFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt,
int numRetries,
Exception cause)
attemptFailed in interface EepGet.StatusListener
public void bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)
EepGet.StatusListener
bytesTransferred in interface EepGet.StatusListener
public void transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified)
transferComplete in interface EepGet.StatusListener
public void transferFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt)
transferFailed in interface EepGet.StatusListener
public void headerReceived(String url,
int attemptNum,
String key,
String val)
EepGet.StatusListener
headerReceived in interface EepGet.StatusListenerpublic void attempting(String url)
attempting in interface EepGet.StatusListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||