close connections on shutdown
This commit is contained in:
@@ -197,6 +197,10 @@ public class Core {
|
|||||||
hostCache.waitForLoad()
|
hostCache.waitForLoad()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
connectionManager.shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
static main(args) {
|
static main(args) {
|
||||||
def home = System.getProperty("user.home") + File.separator + ".MuWire"
|
def home = System.getProperty("user.home") + File.separator + ".MuWire"
|
||||||
home = new File(home)
|
home = new File(home)
|
||||||
|
@@ -82,7 +82,6 @@ abstract class Connection implements Closeable {
|
|||||||
read()
|
read()
|
||||||
}
|
}
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
close()
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.log(Level.WARNING,"unhandled exception in reader",e)
|
log.log(Level.WARNING,"unhandled exception in reader",e)
|
||||||
} finally {
|
} finally {
|
||||||
|
@@ -59,6 +59,8 @@ abstract class ConnectionManager {
|
|||||||
|
|
||||||
abstract void onDisconnectionEvent(DisconnectionEvent e)
|
abstract void onDisconnectionEvent(DisconnectionEvent e)
|
||||||
|
|
||||||
|
abstract void shutdown()
|
||||||
|
|
||||||
protected void sendPings() {
|
protected void sendPings() {
|
||||||
final long now = System.currentTimeMillis()
|
final long now = System.currentTimeMillis()
|
||||||
getConnections().each {
|
getConnections().each {
|
||||||
|
@@ -71,4 +71,8 @@ class LeafConnectionManager extends ConnectionManager {
|
|||||||
log.severe("removed destination not present in connection manager ${e.destination.toBase32()}")
|
log.severe("removed destination not present in connection manager ${e.destination.toBase32()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void shutdown() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,14 @@ class UltrapeerConnectionManager extends ConnectionManager {
|
|||||||
log.severe("Removed connection not present in either leaf or peer map ${e.destination.toBase32()}")
|
log.severe("Removed connection not present in either leaf or peer map ${e.destination.toBase32()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void shutdown() {
|
||||||
|
peerConnections.each {k,v -> v.close() }
|
||||||
|
leafConnections.each {k,v -> v.close() }
|
||||||
|
peerConnections.clear()
|
||||||
|
leafConnections.clear()
|
||||||
|
}
|
||||||
|
|
||||||
void forwardQueryToLeafs(QueryEvent e) {
|
void forwardQueryToLeafs(QueryEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
25
gui/griffon-app/lifecycle/Shutdown.groovy
Normal file
25
gui/griffon-app/lifecycle/Shutdown.groovy
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
import org.codehaus.griffon.runtime.core.AbstractLifecycleHandler
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
|
||||||
|
import griffon.core.GriffonApplication
|
||||||
|
import groovy.util.logging.Log
|
||||||
|
|
||||||
|
@Log
|
||||||
|
class Shutdown extends AbstractLifecycleHandler {
|
||||||
|
@Inject
|
||||||
|
Shutdown(@Nonnull GriffonApplication application) {
|
||||||
|
super(application)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void execute() {
|
||||||
|
log.info("shutting down")
|
||||||
|
Core core = application.context.get("core")
|
||||||
|
core.shutdown()
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user