connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null, useBarrier(), getChannelOutboundQueueSize());
getSwitchConnectionHandler().onSwitchConnected(connectionFacade);
-
建立 ConnectionReadyListenerImpl物件給 ConnectionAdapterImpl物件傳入取用( setConnectionReadyListener);
-
ConnectionReadyListenerImpl物件封裝 ConnectionContextImpl和 HandshakeContextImpl;
-
ConnectionReadyListenerImpl物件提供 onConnectionReady()方法,該方法處理是呼叫 HandshakeManagerImpl.shake();
-
-
-
建立 OpenflowProtocolListenerInitialImpl物件,給 ConnectionAdapterImpl物件傳入取用( setMessageListener);
-
OpenflowProtocolListenerInitialImpl物件用於處理底層switch發給控制器的訊息,比如提供 onHelloMessage方法。
-
註意:該物件僅用於處理handshake過程中涉及的基本訊息,在handshake後會被另一物件 OpenflowProtocolListenerFullImpl替換。
-
-
-
建立 SystemNotificationsListenerImpl物件,給 ConnectionAdapterImpl物件傳入取用( setSystemListener
-
SystemNotificationsListenerImpl物件用於處理SwitchIdleEvent和DisconnectEvent事件。提供 onSwitchIdleEvent()方法, 當swich idle傳送echo心跳訊息;提供 onDisconnectEvent方法處理disconnect
-
final ConnectionFacade finalConnectionFacade = connectionFacade;
handshakeFuture.addListener(future -> finalConnectionFacade.fireConnectionReadyNotification());
if (!tlsPresent) {
connectionFacade.fireConnectionReadyNotification();
}
@Override
public void fireConnectionReadyNotification() {
versionDetector = (OFVersionDetector) channel.pipeline().get(PipelineHandlers.OF_VERSION_DETECTOR.name());
Preconditions.checkState(versionDetector != null);
new Thread(() -> connectionReadyListener.onConnectionReady()).start();
}
-
建立 ConnectionAdapterImpl物件,封裝傳入的 SocketChannelchannel物件;
-
呼叫 ConnectionManagerImpl.onSwitchConnected方法,給 ConnectionAdapterImpl物件 setConnectionReadyListener, setMessageListener, setSystemListener;
-
給pipeline設定各種channelHandler
-
呼叫 ConnectionAdapterImpl.fireConnectionReadyNotification()發起handshake。
-
connectionContext狀態設定為HANDSHAKING
-
建立 HandshakeStepWrapper物件,分配執行緒執行:實際上是執行 HandshakeManagerImpl物件的 shake方法(在 ConnectionManagerImpl中建立的)
@Override
public void run() {
if (connectionAdapter.isAlive()) {
handshakeManager.shake(helloMessage);
} else {
LOG.debug("connection is down - skipping handshake step");
}
}
// Delegates translated POJOs into MessageConsumer.
ch.pipeline().addLast(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(),
new DelegatingInboundHandler(connectionFacade));
@Override
public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
consumer.consume((DataObject) msg);
}
-
設定connectionContext狀態為WORKING
-
設定connectionContext.featuresReply為上一步呼叫get-features的傳回
-
設定connectionContext.nodeId為datapathId
-
呼叫 connectionContext.handshakeSuccessful(),建立DeviceInfoImpl物件
-
this.deviceInfo=newDeviceInfoImpl()
-
-
最後,向switch傳送 barrier訊息。如果成功回呼 addBarrierCallback()方法
-
用於保證在switch之前的命令都已經被執行
-
-
https://www.opendaylight.org/what-we-do/current-release/fluorine
-
https://github.com/opendaylight/openflowplugin
朋友會在“發現-看一看”看到你“在看”的內容