public synchronized ProxyController popChannelAndCreateProxy(final String hostName) {
ManagementChannel channel = unregisteredHostChannels.remove(hostName);
if (channel == null) {
throw new IllegalArgumentException("No channel for host " + hostName);
}
channel.addCloseHandler(new CloseHandler<Channel>() {
//This does not get called when slave terminates abruptly - see REM3-121
public void handleClose(final Channel closed, final IOException exception) {
//TODO A bit strange doing it here before the proxy is actually registered
unregisterRemoteHost(hostName);
}