Created on Jul 16, 2007
Created by Alan Snyder
Copyright (C) 2007 Aelitis, All Rights Reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
AELITIS, SAS au capital de 63.529,40 euros
8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France. |
Methods Summary |
---|
public void | addListener(PSMonitorListener listener)//List<PSMonitorListener>
//don't register the same listener twice.
for(int i=0; i<listeners.size(); i++){
PSMonitorListener t = (PSMonitorListener) listeners.get(i);
if( t==listener ){
SpeedManagerLogger.trace("Not logging same listener twice. listener="+listener.toString());
return;
}
}
listeners.add( listener );
|
boolean | checkForLowerLimits()
long curr = SystemTime.getCurrentTime();
if( curr > nextCheck ){
SpeedManagerLogger.trace("PingSpaceMon checking for lower limits.");
for(int i=0; i<listeners.size(); i++ ){
PSMonitorListener l =(PSMonitorListener) listeners.get(i);
if(l!=null){
l.notifyUpload( getUploadEstCapacity() );
}else{
SpeedManagerLogger.trace("listener index _"+i+"_ was null.");
}
}
resetTimer();
return true;
}
return false;
|
public static com.aelitis.azureus.core.speedmanager.SpeedManagerLimitEstimate | getDownloadEstCapacity()Get the estimated download capacity from the SpeedManager.
try{
SMInstance pm = SMInstance.getInstance();
SpeedManagerAlgorithmProviderAdapter adapter = pm.getAdapter();
SpeedManager sm = adapter.getSpeedManager();
SpeedManagerLimitEstimate downEstCapacity = sm.getEstimatedDownloadCapacityBytesPerSec();
return downEstCapacity;
}catch(Throwable t){
//log this event and
SpeedManagerLogger.log( t.toString() );
t.printStackTrace();
//something to return 0 and -1.0f results.
return new DefaultLimitEstimate();
}
|
public static com.aelitis.azureus.core.speedmanager.SpeedManagerLimitEstimate | getDownloadLimit()Get the current estimated download limit from the ping mapper.
try{
SMInstance pm = SMInstance.getInstance();
SpeedManagerAlgorithmProviderAdapter adapter = pm.getAdapter();
SpeedManagerPingMapper persistentMap = adapter.getPingMapper();
SpeedManagerLimitEstimate downEst = persistentMap.getEstimatedDownloadLimit(true);
return downEst;
}catch(Throwable t){
//log this event and
SpeedManagerLogger.log( t.toString() );
t.printStackTrace();
//something to return 0 and -1.0f results.
return new DefaultLimitEstimate();
}
|
public static com.aelitis.azureus.core.speedmanager.SpeedManagerLimitEstimate | getUploadEstCapacity()
try{
SMInstance pm = SMInstance.getInstance();
SpeedManagerAlgorithmProviderAdapter adapter = pm.getAdapter();
SpeedManager sm = adapter.getSpeedManager();
SpeedManagerLimitEstimate upEstCapacity = sm.getEstimatedUploadCapacityBytesPerSec();
return upEstCapacity;
}catch(Throwable t){
//log this event and
SpeedManagerLogger.log( t.toString() );
t.printStackTrace();
//something to return 1 and -1.0f results.
return new DefaultLimitEstimate();
}
|
public static com.aelitis.azureus.core.speedmanager.SpeedManagerLimitEstimate | getUploadLimit(boolean persistent)Get the current estimated upload limit from the ping mapper.
try{
SMInstance pm = SMInstance.getInstance();
SpeedManagerAlgorithmProviderAdapter adapter = pm.getAdapter();
SpeedManagerPingMapper persistentMap = adapter.getPingMapper();
SpeedManagerLimitEstimate upEst = persistentMap.getEstimatedUploadLimit(true);
return upEst;
}catch(Throwable t){
//log this event and
SpeedManagerLogger.log( t.toString() );
t.printStackTrace();
//something to return 1 and -1.0f results.
return new DefaultLimitEstimate();
}
|
public boolean | removeListener(PSMonitorListener listener)
return listeners.remove(listener);
|
void | resetTimer()
long curr = SystemTime.getCurrentTime();
nextCheck = curr + INTERVAL;
SpeedManagerLogger.trace("Monitor resetting time. Next check in interval.");
|
boolean | updateStatus(TransferMode tMode)
if(mode==null){
mode=tMode;
return true;
}
if( mode.getMode() != tMode.getMode() ){
mode = tMode;
resetTimer();
return true;
}
return checkForLowerLimits();
|