CoordinatorListener, ShutdownListener, StorageListenerFetchAndAddpublic class Snark extends Object implements StorageListener, CoordinatorListener, ShutdownListener
| Modifier and Type | Field | Description |
|---|---|---|
protected I2PSnarkUtil |
_util |
|
(package private) static int |
MAX_TOTAL_UPLOADERS |
|
(package private) static int |
MIN_TOTAL_UPLOADERS |
Maintain a configurable total uploader cap
coordinatorListener
|
static String |
PROP_MAX_CONNECTIONS |
max connections
|
| Constructor | Description |
|---|---|
Snark(I2PSnarkUtil util,
String torrent,
byte[] ih,
String trackerURL,
CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
boolean start,
String rootDir) |
multitorrent, magnet
|
Snark(I2PSnarkUtil util,
String torrent,
String ip,
int user_port,
StorageListener slistener,
CoordinatorListener clistener,
CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
boolean start,
String rootDir) |
Deprecated.
|
Snark(I2PSnarkUtil util,
String torrent,
String ip,
int user_port,
StorageListener slistener,
CoordinatorListener clistener,
CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
boolean start,
String rootDir,
File baseFile) |
multitorrent
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
addComments(List<Comment> comments) |
Add to the current comment set for this torrent,
creating it if it didn't previously exist.
|
void |
addMessage(String message) |
StorageListener and CoordinatorListener callback
|
String |
getBaseName() |
|
double |
getCheckingProgress() |
If checking is in progress, return completion 0.0 ...
|
CommentSet |
getComments() |
The current comment set for this torrent.
|
long |
getDownloaded() |
|
long |
getDownloadRate() |
|
byte[] |
getID() |
|
byte[] |
getInfoHash() |
|
MetaInfo |
getMetaInfo() |
|
String |
getName() |
|
long |
getNeeded() |
Does not account (i.e.
|
long |
getNeededLength() |
Bytes still wanted.
|
int |
getPeerCount() |
|
List<Peer> |
getPeerList() |
|
int |
getPieceLength(int p) |
|
int |
getPieces() |
|
long |
getRemainingLength() |
Bytes not yet in storage.
|
int |
getRPCID() |
A unique ID for this torrent, useful for RPC
|
long |
getSkippedLength() |
Bytes not received and set to skipped.
|
long |
getStartedTime() |
When did we start this torrent
For RPC
|
Storage |
getStorage() |
|
long |
getTotalLength() |
|
String |
getTrackerProblems() |
Not HTML escaped.
|
int |
getTrackerSeenPeers() |
|
String |
getTrackerURL() |
|
long |
getUploaded() |
|
long |
getUploadRate() |
|
void |
gotMetaInfo(PeerCoordinator coordinator,
MetaInfo metainfo) |
Called when the PeerCoordinator got the MetaInfo via magnet.
|
boolean |
isAllocating() |
Disk allocation (ballooning) in progress.
|
boolean |
isAutoStoppable() |
|
boolean |
isChecking() |
File checking in progress.
|
boolean |
isStarting() |
Startup in progress.
|
boolean |
isStopped() |
|
boolean |
overUpBWLimit() |
Are we currently over the upstream bandwidth limit?
|
boolean |
overUpBWLimit(long total) |
Is the total (in Bps) over the upstream bandwidth limit?
|
boolean |
overUploadLimit(int uploaders) |
Is this number of uploaders over the per-torrent limit?
|
void |
peerChange(PeerCoordinator coordinator,
Peer peer) |
CoordinatorListener - this does nothing
|
boolean |
restartAcceptor() |
|
void |
setAutoStoppable(boolean yes) |
|
void |
setStarting() |
Set startup in progress.
|
void |
setTrackerProblems(String p) |
|
void |
setTrackerSeenPeers(int p) |
|
void |
setWantedPieces(Storage storage) |
Reset the peer's wanted pieces table
Call after the storage double-check fails
|
void |
shutdown() |
SnarkSnutdown callback unused
|
void |
startTorrent() |
Start up contacting peers and querying the tracker.
|
void |
stopTorrent() |
Stop contacting the tracker and talking with peers
|
void |
stopTorrent(boolean fast) |
Stop contacting the tracker and talking with peers
|
void |
storageAllChecked(Storage storage) |
Called when all pieces in the storage have been checked.
|
void |
storageAllocated(Storage storage,
long length) |
does nothing
|
void |
storageChecked(Storage storage,
int num,
boolean checked) |
Called when storage is being checked and the num piece of that
total pieces has been checked.
|
void |
storageCompleted(Storage storage) |
Called the one time when the data is completely received and checked.
|
void |
storageCreateFile(Storage storage,
String name,
long length) |
does nothing
|
void |
updatePiecePriorities() |
public static final String PROP_MAX_CONNECTIONS
protected final I2PSnarkUtil _util
static final int MIN_TOTAL_UPLOADERS
static final int MAX_TOTAL_UPLOADERS
public Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener, CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, boolean start, String rootDir)
RuntimeException - via fatal()public Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener, CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, boolean start, String rootDir, File baseFile)
baseFile - if null, use rootDir/torrentName; if non-null, use it insteadRuntimeException - via fatal()public Snark(I2PSnarkUtil util, String torrent, byte[] ih, String trackerURL, CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, boolean start, String rootDir)
torrent - a fake name for now (not a file name)ih - 20-byte info hashtrackerURL - may be nullRuntimeException - via fatal()public void startTorrent()
RuntimeException - via fatal()public void stopTorrent()
public void stopTorrent(boolean fast)
fast - if true, limit the life of the unannounce threadspublic String getName()
public String getBaseName()
public byte[] getID()
public byte[] getInfoHash()
public MetaInfo getMetaInfo()
public Storage getStorage()
public boolean isStopped()
public boolean isStarting()
public void setStarting()
public boolean isChecking()
public double getCheckingProgress()
public boolean isAllocating()
public long getDownloadRate()
public long getUploadRate()
public long getDownloaded()
public long getUploaded()
public int getPeerCount()
public String getTrackerProblems()
public void setTrackerProblems(String p)
p - tracker error string or nullpublic int getTrackerSeenPeers()
public void setTrackerSeenPeers(int p)
public void updatePiecePriorities()
public long getTotalLength()
public long getRemainingLength()
public long getNeededLength()
public long getSkippedLength()
public long getNeeded()
public int getPieceLength(int p)
p - the piece numberpublic int getPieces()
public boolean restartAcceptor()
public String getTrackerURL()
public boolean isAutoStoppable()
public void setAutoStoppable(boolean yes)
public void peerChange(PeerCoordinator coordinator, Peer peer)
peerChange in interface CoordinatorListenerpublic void gotMetaInfo(PeerCoordinator coordinator, MetaInfo metainfo)
gotMetaInfo in interface CoordinatorListenerRuntimeException - via fatal()public void storageCreateFile(Storage storage, String name, long length)
storageCreateFile in interface StorageListenerpublic void storageAllocated(Storage storage, long length)
storageAllocated in interface StorageListenerpublic void storageChecked(Storage storage, int num, boolean checked)
StorageListenerstorageChecked in interface StorageListenerpublic void storageAllChecked(Storage storage)
StorageListenerstorageAllChecked in interface StorageListenerpublic void storageCompleted(Storage storage)
StorageListenerstorageCompleted in interface StorageListenerpublic void setWantedPieces(Storage storage)
StorageListenersetWantedPieces in interface StorageListenerpublic void shutdown()
shutdown in interface ShutdownListenerpublic void addMessage(String message)
addMessage in interface CoordinatorListeneraddMessage in interface StorageListenerpublic boolean overUploadLimit(int uploaders)
CoordinatorListeneroverUploadLimit in interface CoordinatorListenerpublic boolean overUpBWLimit()
CoordinatorListeneroverUpBWLimit in interface CoordinatorListenerpublic boolean overUpBWLimit(long total)
CoordinatorListeneroverUpBWLimit in interface CoordinatorListenerpublic int getRPCID()
public long getStartedTime()
public CommentSet getComments()