NetIdeModule.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:Engine 作者:
private void addNewSwitch(DummySwitch dummySwitch) {
    final SwitchChannelHandler switchHandler = new SwitchChannelHandler(coreConnector, aggreedVersion, moduleName);
    switchHandler.setDummySwitch(dummySwitch); // CONTAINS ALL THE INFO
                                                // ABOUT THIS SWITCH
    ChannelFactory factory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool());
    ClientBootstrap bootstrap = new ClientBootstrap(factory);
    bootstrap.setOption("tcpNoDelay", true);
    bootstrap.setOption("keepAlive", true);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        @Override
        public ChannelPipeline getPipeline() {
            return Channels.pipeline(switchHandler);
        }
    });

    // CONNECT AND ADD TO HASHMAP OF MANAGED SWITCHES
    ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", 7753));
    managedSwitchesChannel.put(dummySwitch.getDatapathId(), future);
    managedBootstraps.put(dummySwitch.getDatapathId(), bootstrap);
    managedSwitches.put(dummySwitch.getDatapathId(), dummySwitch);
    switchHandler.registerSwitchConnection(future);
    switchHandler.setModuleHandler(moduleHandler);

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号