Methods Summary |
---|
public void | announceResult(org.gudy.azureus2.plugins.download.DownloadAnnounceResult result)
checkRules();
|
protected void | checkRules()
work_sem.release();
|
public void | downloadAdded(org.gudy.azureus2.plugins.download.Download download)
log( "added: " + download.getName() + ", state = " + Download.ST_NAMES[ download.getState()]);
downloadData dd = new downloadData( download );
try{
downloads_mon.enter();
downloads.put( download, dd );
}finally{
downloads_mon.exit();
}
download.addListener( this );
checkRules();
|
public void | downloadRemoved(org.gudy.azureus2.plugins.download.Download download)
try{
downloads_mon.enter();
downloads.remove( download );
}finally{
downloads_mon.exit();
}
download.removeListener( this );
checkRules();
|
public void | initialize(org.gudy.azureus2.plugins.PluginInterface _pi)
plugin_interface = _pi;
logger = plugin_interface.getLogger().getChannel( "RunEverythingSeedingRules" );
plugin_interface.addListener(
new PluginListener()
{
public void
initializationComplete()
{
}
public void
closedownInitiated()
{
closing = true;
}
public void
closedownComplete()
{
}
});
downloads = new HashMap();
downloads_mon = plugin_interface.getUtilities().getMonitor();
work_sem = plugin_interface.getUtilities().getSemaphore();
plugin_interface.getDownloadManager().addListener( this );
plugin_interface.getUtilities().createTimer("DownloadRules", true ).addPeriodicEvent(
10000,
new UTTimerEventPerformer()
{
public void
perform(
UTTimerEvent event)
{
checkRules();
}
});
plugin_interface.getUtilities().createThread(
"DownloadRules",
new Runnable()
{
public void
run()
{
processLoop();
}
});
|
public static void | load(org.gudy.azureus2.plugins.PluginInterface _plugin_interface)
PluginManagerDefaults defaults = PluginManager.getDefaults();
defaults.setDefaultPluginEnabled( PluginManagerDefaults.PID_START_STOP_RULES, false );
|
protected void | log(java.lang.String str)
logger.log( str );
|
public void | positionChanged(org.gudy.azureus2.plugins.download.Download download, int oldPosition, int newPosition)
checkRules();
|
protected void | processLoop()
while( !closing ){
work_sem.reserve();
while( work_sem.reserveIfAvailable()){
}
try{
processSupport();
Thread.sleep( 250 );
}catch( Throwable e ){
e.printStackTrace();
}
}
|
protected void | processSupport()
if ( closing ){
return;
}
try{
downloads_mon.enter();
List dls = new ArrayList( downloads.values());
// remove any ignored ones
Iterator it = dls.iterator();
while (it.hasNext()){
downloadData dd = (downloadData)it.next();
if ( dd.ignore()){
it.remove();
}
}
// execute an "initialize" on any waiting ones
it = dls.iterator();
while (it.hasNext()){
downloadData dd = (downloadData)it.next();
if ( dd.getState() == Download.ST_WAITING ){
it.remove();
try{
log( "initialising " + dd.getName());
dd.getDownload().initialize();
}catch( DownloadException e ){
e.printStackTrace();
}
}
}
// execute a "start" on any READY ones
it = dls.iterator();
while (it.hasNext()){
downloadData dd = (downloadData)it.next();
if ( dd.getState() == Download.ST_READY ){
it.remove();
try{
log( "starting " + dd.getName());
dd.getDownload().start();
}catch( DownloadException e ){
e.printStackTrace();
}
}
}
// start downloads
it = dls.iterator();
while (it.hasNext()){
downloadData dd = (downloadData)it.next();
if ( dd.getState() == Download.ST_QUEUED && !dd.isComplete()){
try{
it.remove();
log( "restarting download " + dd.getName());
dd.getDownload().restart();
}catch( DownloadException e ){
e.printStackTrace();
}
}
}
// start seeds
it = dls.iterator();
while ( it.hasNext()){
downloadData dd = (downloadData)it.next();
if ( dd.isComplete() && dd.getState() == Download.ST_QUEUED ){
try{
it.remove();
log( "restarting seed " + dd.getName());
dd.getDownload().restart();
}catch( DownloadException e ){
e.printStackTrace();
}
}
}
}finally{
downloads_mon.exit();
}
|
public void | scrapeResult(org.gudy.azureus2.plugins.download.DownloadScrapeResult result)
checkRules();
|
public void | stateChanged(org.gudy.azureus2.plugins.download.Download download, int old_state, int new_state)
log( "Rules: state change for " + download.getName() + ": " + Download.ST_NAMES[old_state] + "->" + Download.ST_NAMES[new_state]);
checkRules();
|