下面列出了怎么用io.netty.channel.ChannelOutboundInvoker的API类实例代码及写法,或者点击链接到github查看源代码。
private void deleteOFSwitch(DeviceId deviceId) {
OFSwitch ofSwitch = ofSwitchMap.get(deviceId);
ofSwitch.controllerChannels().forEach(ChannelOutboundInvoker::disconnect);
ofSwitchMap.remove(deviceId);
log.info("Removed virtual OFSwitch for {}", deviceId);
}
private void disconnectController(OFSwitch ofSwitch, Set<OFController> controllers) {
Set<SocketAddress> controllerAddrs = controllers.stream()
.map(ctrl -> new InetSocketAddress(
ctrl.ip().toInetAddress(), ctrl.port().toInt()))
.collect(Collectors.toSet());
ofSwitch.controllerChannels().stream()
.filter(channel -> controllerAddrs.contains(channel.remoteAddress()))
.forEach(ChannelOutboundInvoker::disconnect);
}
/**
* Close all registered child channels, and prohibit new streams from being created on this connection.
*/
void closeChildChannels() {
closeAndExecuteOnChildChannels(ChannelOutboundInvoker::close);
}
/**
* Close all registered child channels, and prohibit new streams from being created on this connection.
*/
void closeChildChannels() {
closeAndExecuteOnChildChannels(ChannelOutboundInvoker::close);
}
/**
* 主动断开特定 Channel 的连接
*
* @param i Channel 的 ID
*/
public void removeChannel(int i) {
touchChannel(i).ifPresent(ChannelOutboundInvoker::disconnect);
}