|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.klomp.snark.Snark
public class Snark
Main Snark program startup class.
Field Summary | |
---|---|
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
No, not maintaining a command-line client public static void main(String[] args) { System.out.println(copyright); System.out.println(); if ( (args.length > 0) && ("--config".equals(args[0])) ) { I2PThread.addOOMEventListener(new OOMListener()); SnarkManager sm = SnarkManager.instance(); if (args.length > 1) sm.loadConfig(args[1]); System.out.println("Running in multitorrent mode"); while (true) { try { synchronized (sm) { sm.wait(); } } catch (InterruptedException ie) {} } } // Parse debug, share/ip and torrent file options. |
Constructor Summary | |
---|---|
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 |
Method Summary | |
---|---|
void |
addMessage(String message)
StorageListener and CoordinatorListener callback |
String |
getBaseName()
|
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. |
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROP_MAX_CONNECTIONS
protected final I2PSnarkUtil _util
static final int MIN_TOTAL_UPLOADERS
static final int MAX_TOTAL_UPLOADERS
Constructor Detail |
---|
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 instead
RuntimeException
- 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 null
RuntimeException
- via fatal()Method Detail |
---|
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 boolean isAllocating()
public long getDownloadRate()
public long getUploadRate()
public long getDownloaded()
public long getUploaded()
public int getPeerCount()
public List<Peer> getPeerList()
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 getNeeded()
public int getPieceLength(int p)
p
- the piece number
public 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |