use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class I2PTunnelServer method startRunning.
/**
* Copy input stream to a byte array, so we can retry
* @since 0.7.10
*/
/**
**
* private static ByteArrayInputStream copyOfInputStream(InputStream is) throws IOException {
* byte[] buf = new byte[128];
* ByteArrayOutputStream os = new ByteArrayOutputStream(768);
* try {
* int read;
* while ((read = is.read(buf)) >= 0) {
* os.write(buf, 0, read);
* }
* } finally {
* try { is.close(); } catch (IOException ioe) {}
* // don't need to close BAOS
* }
* return new ByteArrayInputStream(os.toByteArray());
* }
***
*/
/**
* Start running the I2PTunnelServer.
* Warning, blocks while connecting to router and building tunnels;
*
* @throws IllegalArgumentException if the I2CP configuration is b0rked so
* badly that we cant create a socketManager
*/
public synchronized void startRunning() {
connectManager();
// prevent JVM exit when running outside the router
boolean isDaemon = getTunnel().getContext().isRouterContext();
Thread t = new I2PAppThread(this, "Server " + remoteHost + ':' + remotePort, isDaemon);
t.start();
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class SnarkManager method start.
/**
* Caller _must_ call loadConfig(file) before this if setting new values
* for i2cp host/port or i2psnark.dir
*/
public void start() {
_running = true;
if ("i2psnark".equals(_contextName)) {
// Register with the ClientAppManager so the rpc plugin can find us
// only if default instance
ClientAppManager cmgr = _context.clientAppManager();
if (cmgr != null)
cmgr.register(this);
}
_peerCoordinatorSet = new PeerCoordinatorSet();
_connectionAcceptor = new ConnectionAcceptor(_util, _peerCoordinatorSet);
_monitor = new I2PAppThread(new DirMonitor(), "Snark DirMonitor", true);
_monitor.start();
// only if default instance
if (_context.isRouterContext() && "i2psnark".equals(_contextName))
// delay until UpdateManager is there
_context.simpleTimer2().addEvent(new Register(), 4 * 60 * 1000);
// Not required, Jetty has a shutdown hook
// _context.addShutdownTask(new SnarkManagerShutdown());
_idleChecker = new IdleChecker(this, _peerCoordinatorSet);
_idleChecker.schedule(5 * 60 * 1000);
if (!_context.isRouterContext()) {
String lang = _config.getProperty(PROP_LANG);
if (lang != null) {
String country = _config.getProperty(PROP_COUNTRY, "");
Translate.setLanguage(lang, country);
}
}
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class TrackerClient method unannounce.
/**
* Creates a thread for each tracker in parallel if tunnel is still open
* @since 0.9.1
*/
private void unannounce() {
// Local DHT tracker unannounce
DHT dht = _util.getDHT();
if (dht != null)
dht.unannounce(snark.getInfoHash());
int i = 0;
for (TCTracker tr : trackers) {
if (_util.connected() && tr.started && (!tr.stop) && tr.trackerProblems == null) {
try {
(new I2PAppThread(new Unannouncer(tr), _threadName + " U" + (++i), true)).start();
} catch (OutOfMemoryError oom) {
// probably ran out of threads, ignore
tr.reset();
}
} else {
tr.reset();
}
}
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class TunnelControllerGroup method startControllers.
/**
* Start all of the tunnels. Must call loadControllers() first.
* @since 0.9.20
*/
private synchronized void startControllers() {
changeState(STARTING);
I2PAppThread startupThread = new I2PAppThread(new StartControllers(), "Startup tunnels");
startupThread.start();
changeState(RUNNING);
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class RouterConsoleRunner method shutdown.
/**
* @since 0.9.4
*/
public synchronized void shutdown(String[] args) {
if (_state == STOPPED)
return;
changeState(STOPPING);
if (PluginStarter.pluginsEnabled(_context))
(new I2PAppThread(new PluginStopper(_context), "PluginStopper")).start();
stopAllWebApps();
try {
_server.stop();
} catch (Exception ie) {
}
PortMapper portMapper = _context.portMapper();
portMapper.unregister(PortMapper.SVC_CONSOLE);
portMapper.unregister(PortMapper.SVC_HTTPS_CONSOLE);
synchronized (RouterConsoleRunner.class) {
if (_jettyTimer != null) {
try {
_jettyTimer.stop();
} catch (Exception e) {
}
_jettyTimer = null;
}
}
changeState(STOPPED);
}
Aggregations