close connections in parallel, more shutdown fixes

pull/5/head
Zlatin Balevsky 2019-06-14 21:25:22 +01:00
parent a388eaec1d
commit db7e21e343
4 changed files with 8 additions and 3 deletions

View File

@ -234,9 +234,13 @@ public class Core {
}
public void shutdown() {
log.info("shutting down connection manager")
connectionManager.shutdown()
log.info("shutting down download manageer")
downloadManager.shutdown()
log.info("shutting down connection acceeptor")
connectionAcceptor.stop()
log.info("shutting down connection establisher")
connectionEstablisher.stop()
}

View File

@ -76,9 +76,9 @@ abstract class Connection implements Closeable {
return
}
log.info("closing $name")
endpoint.close()
reader.interrupt()
writer.interrupt()
endpoint.close()
eventBus.publish(new DisconnectionEvent(destination: endpoint.destination))
}

View File

@ -104,8 +104,8 @@ class UltrapeerConnectionManager extends ConnectionManager {
@Override
void shutdown() {
peerConnections.each {k,v -> v.close() }
leafConnections.each {k,v -> v.close() }
peerConnections.values().stream().parallel().forEach({v -> v.close()})
leafConnections.values().stream().parallel().forEach({v -> v.close()})
peerConnections.clear()
leafConnections.clear()
}

View File

@ -138,5 +138,6 @@ public class DownloadManager {
public void shutdown() {
downloaders.each { it.stop() }
Downloader.executorService.shutdownNow()
}
}