Methods Summary |
---|
public void | addListener(TRHostTorrentListener l)
try{
this_mon.enter();
List new_listeners = new ArrayList( listeners_cow );
new_listeners.add(l);
listeners_cow = new_listeners;
}finally{
this_mon.exit();
}
host.torrentListenerRegistered();
|
public void | addRemovalListener(TRHostTorrentWillBeRemovedListener l)
try{
this_mon.enter();
removal_listeners.add(l);
}finally{
this_mon.exit();
}
|
public boolean | canBeRemoved()
ArrayList listeners_copy;
try{
this_mon.enter();
listeners_copy = new ArrayList( removal_listeners );
}finally{
this_mon.exit();
}
for (int i=0;i<listeners_copy.size();i++){
((TRHostTorrentWillBeRemovedListener)listeners_copy.get(i)).torrentWillBeRemoved( this );
}
return( true );
|
public void | disableReplyCaching()
TRTrackerServerTorrent st = server_torrent;
disable_reply_caching = true;
if ( st != null ){
st.disableCaching();
}
|
public long | getAnnounceCount()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( sos_announce + stats.getAnnounceCount());
}
return( sos_announce );
|
public long | getAverageAnnounceCount()
return( average_announce.getAverage());
|
public long | getAverageBytesIn()
return( average_bytes_in.getAverage());
|
public long | getAverageBytesOut()
return( average_bytes_out.getAverage() );
|
public long | getAverageDownloaded()
return( average_downloaded.getAverage() );
|
public long | getAverageScrapeCount()
return( average_scrape.getAverage());
|
public long | getAverageUploaded()
return( average_uploaded.getAverage() );
|
public int | getBadNATCount()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( stats.getBadNATPeerCount());
}
return( 0 );
|
public long | getCompletedCount()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( sos_complete + stats.getCompletedCount());
}
return( sos_complete );
|
public java.lang.Object | getData(java.lang.String key)To retreive arbitrary objects against this object.
if (data == null) return null;
return data.get(key);
|
public long | getDateAdded()
return( date_added );
|
public int | getLeecherCount()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( stats.getLeecherCount());
}
return( 0 );
|
public TRHostPeer[] | getPeers()
try{
TRTrackerServerPeer[] peers = server.getPeers( torrent.getHash());
if ( peers != null ){
TRHostPeer[] res = new TRHostPeer[peers.length];
for (int i=0;i<peers.length;i++){
res[i] = new TRHostPeerHostImpl(peers[i]);
}
return( res );
}
}catch( TOTorrentException e ){
Debug.printStackTrace( e );
}
return( new TRHostPeer[0] );
|
public int | getPort()
return( port );
|
public long | getScrapeCount()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( sos_scrape + stats.getScrapeCount());
}
return( sos_scrape );
|
public int | getSeedCount()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( stats.getSeedCount());
}
return( 0 );
|
protected TRTrackerServer | getServer()
return( server );
|
protected TRTrackerServerTorrentStats | getStats()
TRTrackerServerTorrent st = server_torrent;
if ( st != null ){
return( st.getStats());
}
return( null );
|
public int | getStatus()
return( status );
|
public TOTorrent | getTorrent()
return( torrent );
|
public long | getTotalBytesIn()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( sos_bytes_in + stats.getBytesIn());
}
return( sos_bytes_in );
|
public long | getTotalBytesOut()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( sos_bytes_out + stats.getBytesOut());
}
return( sos_bytes_out );
|
public long | getTotalDownloaded()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( sos_downloaded + stats.getDownloaded());
}
return( sos_downloaded );
|
public long | getTotalLeft()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( stats.getAmountLeft());
}
return( 0 );
|
public long | getTotalUploaded()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
return( sos_uploaded + stats.getUploaded());
}
return( sos_uploaded );
|
public boolean | isPassive()
return( passive );
|
public boolean | isPersistent()
return( persistent );
|
protected void | postProcess(TRHostTorrentRequest req)
List listeners_ref = listeners_cow;
for (int i=0;i<listeners_ref.size();i++){
try{
((TRHostTorrentListener)listeners_ref.get(i)).postProcess(req);
}catch( TRHostException e ){
throw( e );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
|
protected void | preProcess(TRHostTorrentRequest req)
List listeners_ref = listeners_cow;
for (int i=0;i<listeners_ref.size();i++){
try{
((TRHostTorrentListener)listeners_ref.get(i)).preProcess(req);
}catch( TRHostException e ){
throw( e );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
|
public void | remove()
canBeRemoved();
stop();
host.remove( this );
|
public void | removeListener(TRHostTorrentListener l)
try{
this_mon.enter();
List new_listeners = new ArrayList( listeners_cow );
new_listeners.remove(l);
listeners_cow = new_listeners;
}finally{
this_mon.exit();
}
|
public void | removeRemovalListener(TRHostTorrentWillBeRemovedListener l)
try{
this_mon.enter();
removal_listeners.remove(l);
}finally{
this_mon.exit();
}
|
public void | setData(java.lang.String key, java.lang.Object value)To store arbitrary objects against this object.
try{
this_mon.enter();
if (data == null) {
data = new HashMap();
}
if (value == null) {
if (data.containsKey(key))
data.remove(key);
} else {
data.put(key, value);
}
}finally{
this_mon.exit();
}
|
public void | setPassive(boolean b)
passive = b;
|
protected void | setPersistent(boolean _persistent)
persistent = _persistent;
|
protected void | setStartOfDayValues(long _date_added, long completed, long announces, long scrapes, long uploaded, long downloaded, long bytes_in, long bytes_out)
date_added = _date_added;
sos_complete = completed;
sos_announce = announces;
sos_scrape = scrapes;
sos_uploaded = uploaded;
sos_downloaded = downloaded;
sos_bytes_in = bytes_in;
sos_bytes_out = bytes_out;
|
protected void | setTorrent(TOTorrent _torrent)
torrent = _torrent;
|
public void | start()
// there's a potential deadlock situation if we call the server while holding
// the torrent lock, as the server then calls back to the host and we get
// a torrent -> host monitor chain. We already have a host->torrent chain.
// easiest solution is to delegate call to the host, which will grab the host
// monitor and then call back out to startSupport. Hence the chain is in the
// right direction
host.startTorrent( this );
|
protected void | startSupport()
try{
this_mon.enter();
// System.out.println( "TRHostTorrentHostImpl::start");
status = TS_STARTED;
server_torrent = server.permit( "", torrent.getHash(), true);
if ( disable_reply_caching ){
server_torrent.disableCaching();
}
}catch( Throwable e ){
Debug.printStackTrace( e );
}finally{
this_mon.exit();
}
host.hostTorrentStateChange( this );
|
public void | stop()
host.stopTorrent( this );
|
protected void | stopSupport()
try{
this_mon.enter();
// System.out.println( "TRHostTorrentHostImpl::stop");
status = TS_STOPPED;
server.deny( torrent.getHash(), true);
TRTrackerServerTorrent st = server_torrent;
TRTrackerServerTorrentStats torrent_stats = st==null?null:st.getStats();
if ( torrent_stats != null ){
sos_uploaded = sos_uploaded + torrent_stats.getUploaded();
sos_downloaded = sos_downloaded + torrent_stats.getDownloaded();
sos_bytes_in = sos_bytes_in + torrent_stats.getBytesIn();
sos_bytes_out = sos_bytes_out + torrent_stats.getBytesOut();
sos_announce = sos_announce + torrent_stats.getAnnounceCount();
sos_scrape = sos_scrape + torrent_stats.getScrapeCount();
sos_complete = sos_complete + torrent_stats.getCompletedCount();
torrent_stats = null;
}
last_uploaded = 0;
last_downloaded = 0;
last_bytes_in = 0;
last_bytes_out = 0;
last_announce = 0;
last_scrape = 0;
}catch( Throwable e ){
Debug.printStackTrace( e );
}finally{
this_mon.exit();
}
host.hostTorrentStateChange( this );
|
protected void | updateStats()
TRTrackerServerTorrentStats stats = getStats();
if ( stats != null ){
long current_uploaded = stats.getUploaded();
long ul_diff = current_uploaded - last_uploaded;
if ( ul_diff < 0 ){
ul_diff = 0;
}
average_uploaded.addValue(ul_diff);
last_uploaded = current_uploaded;
// downloaded
long current_downloaded = stats.getDownloaded();
long dl_diff = current_downloaded - last_downloaded;
if ( dl_diff < 0 ){
dl_diff = 0;
}
average_downloaded.addValue(dl_diff);
last_downloaded = current_downloaded;
// bytes in
long current_bytes_in = stats.getBytesIn();
long bi_diff = current_bytes_in - last_bytes_in;
if ( bi_diff < 0 ){
bi_diff = 0;
}
average_bytes_in.addValue(bi_diff);
last_bytes_in = current_bytes_in;
// bytes out
long current_bytes_out = stats.getBytesOut();
long bo_diff = current_bytes_out - last_bytes_out;
if ( bo_diff < 0 ){
bo_diff = 0;
}
average_bytes_out.addValue(bo_diff);
last_bytes_out = current_bytes_out;
// announce
long current_announce = stats.getAnnounceCount();
long an_diff = current_announce - last_announce;
if ( an_diff < 0 ){
an_diff = 0;
}
average_announce.addValue(an_diff);
last_announce = current_announce;
// scrape
long current_scrape = stats.getScrapeCount();
long sc_diff = current_scrape - last_scrape;
if ( sc_diff < 0 ){
sc_diff = 0;
}
average_scrape.addValue(sc_diff);
last_scrape = current_scrape;
}
|