public void init(ConfigDataIF config) throws Exception { mgr = config.getManager(); mySink = config.getStage().getSink(); myName = config.getStage().getName(); // reading the config params String s; s = config.getString("server"); if (s != null) SERVER_HOSTNAME = s; int port = config.getInt("port"); if (port == -1) port = GnutellaConst.DEFAULT_GNUTELLA_PORT; packetTable = new Hashtable(); try { gs = new GnutellaServer(mgr, mySink, port); if (DO_CATCHER) doCatcher(); } catch (IOException ioe) { System.err.println("Could not start server: " + ioe.getMessage()); return; } System.err.println("Created GnutellaServer: " + gs); if (DO_CLEANER) { timer = new ssTimer(); timer.registerEvent(CLEAN_TIMER_FREQUENCY, new timerEvent(1), mySink); } }
private void doClean(timerEvent ev) { // Cleaner event if (VERBOSE) System.err.println("-- Cleaning up packetTable"); // Might cause some recent packets to be dropped packetTable.clear(); if (VERBOSE) { Runtime r = Runtime.getRuntime(); System.err.println( "TOTAL: " + r.totalMemory() / 1024 + "KB FREE: " + r.freeMemory() / 1024 + "KB"); } // Reregister timer event timer.registerEvent(CLEAN_TIMER_FREQUENCY, ev, mySink); }