private void connectWithPeers() { if (_peerDestFiles != null) { for (int i = 0; i < _peerDestFiles.length; i++) { try { FileInputStream fin = new FileInputStream(_peerDestFiles[i]); byte dest[] = new byte[1024]; int read = DataHelper.read(fin, dest); String remDest = new String(dest, 0, read); int con = 0; Flooder flooder = null; synchronized (_remotePeers) { con = _remotePeers.size() + 1; flooder = new Flooder(con, remDest); _remotePeers.put(new Integer(con), flooder); } byte msg[] = (DataHelper.getUTF8("STREAM CONNECT ID=" + con + " DESTINATION=" + remDest + "\n")); synchronized (_samOut) { _samOut.write(msg); _samOut.flush(); } I2PThread flood = new I2PThread(flooder, "Flood " + con); flood.start(); _log.debug("Starting flooder with peer from " + _peerDestFiles[i] + ": " + con); } catch (IOException ioe) { _log.error("Unable to read the peer from " + _peerDestFiles[i]); } } } }
public JobQueue(RouterContext context) { _context = context; _log = context.logManager().getLog(JobQueue.class); _context .statManager() .createRateStat( "jobQueue.readyJobs", "How many ready and waiting jobs there are?", "JobQueue", new long[] {60 * 1000l, 60 * 60 * 1000l, 24 * 60 * 60 * 1000l}); _context .statManager() .createRateStat( "jobQueue.droppedJobs", "How many jobs do we drop due to insane overload?", "JobQueue", new long[] {60 * 1000l, 60 * 60 * 1000l, 24 * 60 * 60 * 1000l}); // following are for JobQueueRunner _context .statManager() .createRateStat( "jobQueue.jobRun", "How long jobs take", "JobQueue", new long[] {60 * 60 * 1000l, 24 * 60 * 60 * 1000l}); _context .statManager() .createRateStat( "jobQueue.jobRunSlow", "How long jobs that take over a second take", "JobQueue", new long[] {60 * 60 * 1000l, 24 * 60 * 60 * 1000l}); _context .statManager() .createRequiredRateStat( "jobQueue.jobLag", "Job run delay (ms)", "JobQueue", new long[] {60 * 1000l, 60 * 60 * 1000l, 24 * 60 * 60 * 1000l}); _context .statManager() .createRateStat( "jobQueue.jobWait", "How long does a job sit on the job queue?", "JobQueue", new long[] {60 * 60 * 1000l, 24 * 60 * 60 * 1000l}); // _context.statManager().createRateStat("jobQueue.jobRunnerInactive", "How long are runners // inactive?", "JobQueue", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l }); _alive = true; _readyJobs = new LinkedBlockingQueue(); _timedJobs = new TreeSet(new JobComparator()); _jobLock = new Object(); _queueRunners = new ConcurrentHashMap(RUNNERS); _jobStats = new ConcurrentHashMap(); _pumper = new QueuePumper(); I2PThread pumperThread = new I2PThread(_pumper, "Job Queue Pumper", true); // pumperThread.setPriority(I2PThread.NORM_PRIORITY+1); pumperThread.start(); }
/** Handle the connection by passing it off to an AdminRunner */ protected void runConnection(Socket socket) throws IOException { AdminRunner runner = new AdminRunner(_context, socket); I2PThread t = new I2PThread(runner); t.setName("Admin Runner"); // t.setPriority(Thread.MIN_PRIORITY); t.setDaemon(true); t.start(); }
public void streamConnectedReceived(String dest, int id) { _log.debug("Connection " + id + " received from " + dest); Flooder flooder = new Flooder(id, dest); synchronized (_remotePeers) { _remotePeers.put(new Integer(id), flooder); } I2PThread t = new I2PThread(flooder, "Flood " + id); t.start(); }
private void startup(int port) { if (_listener == null) { _listener = new AdminListener(_context, port); I2PThread t = new I2PThread(_listener); t.setName("Admin Listener:" + port); t.setDaemon(true); // t.setPriority(Thread.MIN_PRIORITY); t.start(); } else { _listener.setPort(port); _listener.restart(); } }
/** * Actually run the connection - listen for I2CP messages and respond. This is the main driver for * this class, though it gets all its meat from the {@link net.i2p.data.i2cp.I2CPMessageReader * I2CPMessageReader} */ public synchronized void startRunning() throws IOException { if (_dead || _reader != null) throw new IllegalStateException(); _reader = new I2CPMessageReader( new BufferedInputStream(_socket.getInputStream(), BUF_SIZE), new ClientMessageEventListener(_context, this, true)); _writer = new ClientWriterRunner(_context, this); I2PThread t = new I2PThread(_writer); t.setName("I2CP Writer " + __id.incrementAndGet()); t.setDaemon(true); t.start(); _out = new BufferedOutputStream(_socket.getOutputStream()); _reader.startReading(); // TODO need a cleaner for unclaimed items in _messages, but we have no timestamps... }
public synchronized void startup() { // adjustDropProbability(); _keepRunning = true; I2PThread t = new I2PThread(_runner, _name, true); t.start(); }