public class Snark extends Object implements StorageListener, CoordinatorListener, ShutdownListener
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
Snark.RouterException
A unique exception class to blame the router that can be caught by SnarkManager
|
| 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
|
boolean |
storageCompleted |
| Modifier | Constructor and Description |
|---|---|
protected |
Snark(I2PSnarkUtil util,
String torrent,
byte[] ih,
String trackerURL,
CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
boolean ignored,
String rootDir)
multitorrent, magnet, Used by snark-rpc plugin
|
|
Snark(I2PSnarkUtil util,
String torrent,
byte[] ih,
String trackerURL,
CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
String rootDir)
multitorrent, magnet
|
|
Snark(I2PSnarkUtil util,
String torrent,
String ip,
int user_port,
StorageListener slistener,
CoordinatorListener clistener,
CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
String rootDir)
multitorrent
|
|
Snark(I2PSnarkUtil util,
String torrent,
String ip,
int user_port,
StorageListener slistener,
CoordinatorListener clistener,
CompleteListener complistener,
PeerCoordinatorSet peerCoordinatorSet,
ConnectionAcceptor connectionAcceptor,
String rootDir,
File baseFile)
multitorrent
|
| Modifier and Type | Method and 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()
Get the progress of file checking as a percentage.
|
CommentSet |
getComments()
The current comment set for this torrent.
|
long |
getDownloaded()
Get the total number of bytes downloaded.
|
long |
getDownloadRate()
Get the current download rate in bytes per second.
|
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()
Get the total number of bytes uploaded.
|
long |
getUploadRate()
Get the current upload rate in bytes per second.
|
void |
gotMetaInfo(PeerCoordinator coordinator,
MetaInfo metainfo)
Called when the PeerCoordinator got the MetaInfo via magnet.
|
boolean |
isAllocating()
Check if disk allocation (ballooning) is in progress.
|
boolean |
isAutoStoppable() |
boolean |
isChecking()
Check if file checking is in progress.
|
boolean |
isNotificationSent() |
boolean |
isStarting()
Startup in progress.
|
boolean |
isStopped() |
boolean |
isStorageCompleted() |
boolean |
overUploadLimit(int uploaders)
Is this number of uploaders over the per-torrent limit?
|
void |
peerChange(PeerCoordinator coordinator,
Peer peer)
CoordinatorListener - this does nothing
|
void |
replaceMetaInfo(MetaInfo metainfo)
Call after editing torrent.
|
boolean |
restartAcceptor() |
void |
setAutoStoppable(boolean yes) |
void |
setNotificationSent(boolean sent) |
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()
SnarkShutdown 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() |
protected final I2PSnarkUtil _util
static final int MAX_TOTAL_UPLOADERS
static final int MIN_TOTAL_UPLOADERS
public static final String PROP_MAX_CONNECTIONS
public boolean storageCompleted
protected Snark(I2PSnarkUtil util, String torrent, byte[] ih, String trackerURL, CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, boolean ignored, String rootDir)
Will not start itself. Caller must call startTorrent() if desired.
ignored - used to be autostartRuntimeException - via fatal()Snark.RouterException - via fatalRouter()public Snark(I2PSnarkUtil util, String torrent, byte[] ih, String trackerURL, CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, String rootDir)
Will not start itself. Caller must call startTorrent() if desired.
torrent - a fake name for now (not a file name)ih - 20-byte info hashtrackerURL - may be nullRuntimeException - via fatal()Snark.RouterException - via fatalRouter()public Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener, CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, String rootDir)
Will not start itself. Caller must call startTorrent() if desired.
RuntimeException - via fatal()Snark.RouterException - via fatalRouter()public Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener, CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, String rootDir, File baseFile)
Will not start itself. Caller must call startTorrent() if desired.
baseFile - if null, use rootDir/torrentName; if non-null, use it insteadRuntimeException - via fatal()Snark.RouterException - via fatalRouter()public boolean addComments(List<Comment> comments)
public void addMessage(String message)
addMessage in interface CoordinatorListeneraddMessage in interface StorageListenerpublic String getBaseName()
public double getCheckingProgress()
public CommentSet getComments()
public long getDownloaded()
public long getDownloadRate()
public byte[] getID()
public byte[] getInfoHash()
public MetaInfo getMetaInfo()
public String getName()
public long getNeeded()
public long getNeededLength()
public int getPeerCount()
public int getPieceLength(int p)
p - the piece numberpublic int getPieces()
public long getRemainingLength()
public int getRPCID()
public long getSkippedLength()
public long getStartedTime()
public Storage getStorage()
public long getTotalLength()
public String getTrackerProblems()
public int getTrackerSeenPeers()
public String getTrackerURL()
public long getUploaded()
public long getUploadRate()
public void gotMetaInfo(PeerCoordinator coordinator, MetaInfo metainfo)
gotMetaInfo in interface CoordinatorListenerRuntimeException - via fatal()public boolean isAllocating()
public boolean isAutoStoppable()
public boolean isChecking()
public boolean isNotificationSent()
public boolean isStarting()
public boolean isStopped()
public boolean isStorageCompleted()
public boolean overUploadLimit(int uploaders)
CoordinatorListeneroverUploadLimit in interface CoordinatorListenerpublic void peerChange(PeerCoordinator coordinator, Peer peer)
peerChange in interface CoordinatorListenerpublic void replaceMetaInfo(MetaInfo metainfo)
public boolean restartAcceptor()
public void setAutoStoppable(boolean yes)
public void setNotificationSent(boolean sent)
public void setStarting()
public void setTrackerProblems(String p)
p - tracker error string or nullpublic void setTrackerSeenPeers(int p)
public void setWantedPieces(Storage storage)
StorageListenersetWantedPieces in interface StorageListenerpublic void shutdown()
shutdown in interface ShutdownListenerpublic void startTorrent()
RuntimeException - via fatal()Snark.RouterException - via fatalRouter()public void stopTorrent()
public void stopTorrent(boolean fast)
fast - if true, limit the life of the unannounce threadspublic void storageAllChecked(Storage storage)
StorageListenerstorageAllChecked 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 storageCompleted(Storage storage)
StorageListenerstorageCompleted in interface StorageListenerpublic void storageCreateFile(Storage storage, String name, long length)
storageCreateFile in interface StorageListenerpublic void updatePiecePriorities()