1 6 7 package org.drftpd.slave.socket; 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 SocketSlaveManager 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 SocketSlaveManager(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 { 39 SocketSlaveListener ssl = new SocketSlaveListener(_conman, _socketPort, _socketPass); 40 41 while (true) { 42 Collection slaves = _conman.getSlaveManager().getSlaves(); 43 for (Iterator i=slaves.iterator(); i.hasNext();) { 44 RemoteSlave rslave = (RemoteSlave)i.next(); 45 Hashtable cfg = rslave.getConfig(); 46 if (rslave.isAvailable()) continue; 47 if (cfg.get("addr") == null) continue; 48 String host = (String )cfg.get("addr"); 49 if (host.equals("Dynamic")) continue; 50 try { 52 SocketSlaveImpl tmp = new SocketSlaveImpl(_conman, rslave.getConfig()); 53 } catch (RemoteException e) { 54 } 55 } 56 try { 57 sleep(60000); 58 } catch (Exception e) {} 59 } 60 } 61 62 } 63 | Popular Tags |