public class Snark extends Object implements StorageListener, CoordinatorListener, ShutdownListener
Modifier and Type | Field and 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 and 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)
multitorrent
|
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 and Description |
---|---|
void |
addMessage(String message)
StorageListener and CoordinatorListener callback
|
String |
getBaseName() |
double |
getCheckingProgress()
If checking is in progress, return completion 0.0 ...
|
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 CoordinatorListener
public void gotMetaInfo(PeerCoordinator coordinator, MetaInfo metainfo)
gotMetaInfo
in interface CoordinatorListener
RuntimeException
- via fatal()public void storageCreateFile(Storage storage, String name, long length)
storageCreateFile
in interface StorageListener
public void storageAllocated(Storage storage, long length)
storageAllocated
in interface StorageListener
public void storageChecked(Storage storage, int num, boolean checked)
StorageListener
storageChecked
in interface StorageListener
public void storageAllChecked(Storage storage)
StorageListener
storageAllChecked
in interface StorageListener
public void storageCompleted(Storage storage)
StorageListener
storageCompleted
in interface StorageListener
public void setWantedPieces(Storage storage)
StorageListener
setWantedPieces
in interface StorageListener
public void shutdown()
shutdown
in interface ShutdownListener
public void addMessage(String message)
addMessage
in interface CoordinatorListener
addMessage
in interface StorageListener
public boolean overUploadLimit(int uploaders)
CoordinatorListener
overUploadLimit
in interface CoordinatorListener
public boolean overUpBWLimit()
CoordinatorListener
overUpBWLimit
in interface CoordinatorListener
public boolean overUpBWLimit(long total)
CoordinatorListener
overUpBWLimit
in interface CoordinatorListener
public int getRPCID()
public long getStartedTime()