use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class EventPumper method startPumping.
public synchronized void startPumping() {
if (_log.shouldLog(Log.INFO))
_log.info("Starting pumper");
try {
_selector = Selector.open();
_alive = true;
new I2PThread(this, "NTCP Pumper", true).start();
} catch (IOException ioe) {
_log.log(Log.CRIT, "Error opening the NTCP selector", ioe);
} catch (java.lang.InternalError jlie) {
// "unable to get address of epoll functions, pre-2.6 kernel?"
_log.log(Log.CRIT, "Error opening the NTCP selector", jlie);
}
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class UPnP method registerPorts.
/**
* postControlAction() can take many seconds, especially if it's failing,
* and onChangePublicPorts() may be called from threads we don't want to slow down,
* so throw this in a thread.
*/
private void registerPorts(Set<ForwardPort> portsToForwardNow) {
if (_serviceLacksAPM) {
if (_log.shouldLog(Log.WARN))
_log.warn("UPnP device does not support port forwarding");
Map<ForwardPort, ForwardPortStatus> map = new HashMap<ForwardPort, ForwardPortStatus>(portsToForwardNow.size());
for (ForwardPort port : portsToForwardNow) {
ForwardPortStatus fps = new ForwardPortStatus(ForwardPortStatus.DEFINITE_FAILURE, "UPnP device does not support port forwarding", port.portNumber);
map.put(port, fps);
}
forwardCallback.portForwardStatus(map);
return;
}
if (_log.shouldLog(Log.INFO))
_log.info("Starting thread to forward " + portsToForwardNow.size() + " ports");
Thread t = new I2PThread(new RegisterPortsThread(portsToForwardNow));
t.setName("UPnP Port Opener " + __id.incrementAndGet());
t.setDaemon(true);
t.start();
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class UDPEndpointTestStandalone method runTest.
public void runTest(int numPeers) {
_log.debug("Run test(" + numPeers + ")");
_endpoints = new UDPEndpoint[numPeers];
int base = 44000 + _context.random().nextInt(10000);
for (int i = 0; i < numPeers; i++) {
_log.debug("Building " + i);
UDPEndpoint endpoint = new UDPEndpoint(_context, null, base + i, null);
_endpoints[i] = endpoint;
try {
endpoint.startup();
} catch (SocketException se) {
_log.error("die", se);
throw new RuntimeException(se);
}
I2PThread read = new I2PThread(new TestRead(endpoint), "Test read " + i);
I2PThread write = new I2PThread(new TestWrite(endpoint), "Test write " + i);
// read.setDaemon(true);
read.start();
// write.setDaemon(true);
write.start();
}
_beginTest = true;
_log.debug("Test begin");
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class AdminRunner method shutdown.
private String shutdown(String cmd) {
String password = _context.router().getConfigSetting(SHUTDOWN_PASSWORD_PROP);
if (password == null)
password = _context.getProperty(SHUTDOWN_PASSWORD_PROP);
if (password == null)
return "No shutdown password specified in the config or context - <b>REFUSING SHUTDOWN</b>." + "<a href=\"/routerConsole.html\">back</a>";
if (cmd.indexOf(password) > 0) {
I2PThread t = new I2PThread(new Runnable() {
public void run() {
try {
Thread.sleep(30 * 1000);
} catch (InterruptedException ie) {
}
_context.router().shutdown(Router.EXIT_HARD);
}
});
t.start();
return "Shutdown request accepted. Killing the router in 30 seconds";
} else {
return "Incorrect shutdown password specified. Please edit your router.config appropriately." + "<a href=\"/routerConsole.html\">back</a>";
}
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class ClientManager method startListeners.
/**
* Call from synchronized method
* Todo: Start a 3rd listener for IPV6?
*/
protected void startListeners() {
ClientListenerRunner listener;
if (SystemVersion.isAndroid()) {
try {
Class<? extends ClientListenerRunner> clazz = Class.forName("net.i2p.router.client.DomainClientListenerRunner").asSubclass(ClientListenerRunner.class);
Constructor<? extends ClientListenerRunner> ctor = clazz.getDeclaredConstructor(RouterContext.class, ClientManager.class);
listener = ctor.newInstance(_ctx, this);
Thread t = new I2PThread(listener, "DomainClientListener", true);
t.start();
_listeners.add(listener);
} catch (ClassNotFoundException e) {
_log.warn("Could not find DomainClientListenerRunner class", e);
} catch (ClassCastException e) {
_log.error("Error creating DomainClientListenerRunner", e);
} catch (NoSuchMethodException e) {
_log.error("Error creating DomainClientListenerRunner", e);
} catch (InstantiationException e) {
_log.error("Error creating DomainClientListenerRunner", e);
} catch (IllegalAccessException e) {
_log.error("Error creating DomainClientListenerRunner", e);
} catch (InvocationTargetException e) {
_log.error("Error creating DomainClientListenerRunner", e);
}
}
if (!_ctx.getBooleanProperty(PROP_DISABLE_EXTERNAL)) {
// there's no option to start both an SSL and non-SSL listener
if (_ctx.getBooleanProperty(PROP_ENABLE_SSL))
listener = new SSLClientListenerRunner(_ctx, this, _port);
else
listener = new ClientListenerRunner(_ctx, this, _port);
Thread t = new I2PThread(listener, "ClientListener:" + _port, true);
t.start();
_listeners.add(listener);
_clientTimestamper.schedule(ClientTimestamper.LOOP_TIME);
}
_isStarted = true;
}
Aggregations