await closing sockets on shutdown

This commit is contained in:
kimchy 2010-12-29 12:49:37 +02:00
parent f993c4b72b
commit e764f41341
1 changed files with 19 additions and 1 deletions

View File

@ -324,7 +324,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
for (Iterator<NodeChannels> it = connectedNodes.values().iterator(); it.hasNext();) { for (Iterator<NodeChannels> it = connectedNodes.values().iterator(); it.hasNext();) {
NodeChannels nodeChannels = it.next(); NodeChannels nodeChannels = it.next();
it.remove(); it.remove();
nodeChannels.close(); nodeChannels.closeAndWait();
} }
if (clientBootstrap != null) { if (clientBootstrap != null) {
@ -615,5 +615,23 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
} }
} }
} }
public void closeAndWait() {
closeChannelsAndWait(low);
closeChannelsAndWait(med);
closeChannelsAndWait(high);
}
private void closeChannelsAndWait(Channel[] channels) {
for (Channel channel : channels) {
try {
if (channel != null && channel.isOpen()) {
channel.close().awaitUninterruptibly();
}
} catch (Exception e) {
//ignore
}
}
}
} }
} }