1 6 7 package org.drftpd.slave.async; 8 9 import java.rmi.RemoteException ; 10 import java.util.Collection ; 11 import java.util.Hashtable ; 12 import java.util.Iterator ; 13 import java.util.Properties ; 14 15 import net.sf.drftpd.master.ConnectionManager; 16 import net.sf.drftpd.master.RemoteSlave; 17 21 public class AsyncSlaveManager extends java.lang.Thread { 22 23 private ConnectionManager _conman; 24 private String _serverName; 25 private String _socketPass; 26 private int _socketPort; 27 28 29 public AsyncSlaveManager(ConnectionManager conman, Properties cfg) { 30 _conman = conman; 31 _serverName = cfg.getProperty("master.bindname", "slavemaster"); 32 _socketPass = cfg.getProperty("master.socketpass", ""); 33 _socketPort = Integer.parseInt(cfg.getProperty("master.socketport", "1100")); 34 start(); 35 } 36 37 public void run() { 38 AsyncSlaveListener ssl = new AsyncSlaveListener(_conman, _socketPort, _socketPass); 39 40 while (true) { 41 Collection slaves = _conman.getSlaveManager().getSlaves(); 42 for (Iterator i=slaves.iterator(); i.hasNext();) { 43 RemoteSlave rslave = (RemoteSlave)i.next(); 44 Hashtable cfg = rslave.getConfig(); 45 if (rslave.isAvailable()) continue; 46 if (cfg.get("addr") == null) continue; 47 String host = (String )cfg.get("addr"); 48 if (host.equals("Dynamic")) continue; 49 try { 51 AsyncSlave tmp = new AsyncSlave(_conman, rslave.getConfig()); 52 } catch (RemoteException e) { 53 } 54 } 55 try { 56 sleep(60000); 57 } catch (Exception e) {} 58 } 59 } 60 61 } 62 | Popular Tags |