|
||||||||||
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 | |
---|---|
(package private) String |
activity
private static final String copyright = "The Hunting of the Snark Project - Copyright (C) 2003 Mark J. |
(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(I2PAppContext ctx,
Properties opts,
String torrent,
StorageListener slistener,
boolean start,
String rootDir)
single torrent - via router |
|
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)
from main() via parseArguments() single torrent |
|
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 |
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 for skipped files. |
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()
|
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 |
isChecking()
File checking in progress. |
boolean |
isStarting()
Startup in progress. |
boolean |
isStopped()
|
boolean |
overUpBWLimit()
|
boolean |
overUpBWLimit(long total)
|
boolean |
overUploadLimit(int uploaders)
|
void |
peerChange(PeerCoordinator coordinator,
Peer peer)
CoordinatorListener - this does nothing |
boolean |
restartAcceptor()
|
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 |
---|
String activity
public static final String PROP_MAX_CONNECTIONS
static final int MIN_TOTAL_UPLOADERS
static final int MAX_TOTAL_UPLOADERS
Constructor Detail |
---|
Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener)
public Snark(I2PAppContext ctx, Properties opts, String torrent, StorageListener slistener, boolean start, String rootDir)
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)
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 nullMethod Detail |
---|
public void startTorrent()
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 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)
overUploadLimit
in interface CoordinatorListener
public boolean overUpBWLimit()
overUpBWLimit
in interface CoordinatorListener
public boolean overUpBWLimit(long total)
overUpBWLimit
in interface CoordinatorListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |