#1.
iris를 이용해서 새로운 모듈을 정의하고
initialize() 함수 안에서 다른 서비스를 정의 내립니다.
protected void initialize() {
....
deviceService = (IDeviceService) getModule(IDeviceService.class);
topologyService = (ITopologyService) getModule(ITopologyService.class);
deviceService.addListener(this);
topologyService.addListener(this);
....
}
그런데 여러 스레드에서 동시에 여러모듈을 로드하는 일이 발생하면서 실행이 잘 될 때도 있는데, 문제가 발생할 경우 null pointer exception이 발생합니다.
deviceService.addListener(this); 할 때, OFMDeviceManager 내부에 정의된 Device devices 선언되지 않은상태에서 addlistener를 하면서 null pointer exception이 발생합니다.
다른 모듈을 참조해봐도 제가 구현한 방식과 동일하게 모듈의 서비스를 가져오고 있네요.
Exception in thread "main" java.lang.NullPointerException
at etri.sdn.controller.module.devicemanager.OFMDeviceManager.addListener(OFMDeviceManager.java:453)
at kr.ac.snu.mmlab.raonmanager.OFMRaonManager.initialize(OFMRaonManager.java:100)
at etri.sdn.controller.OFModule.start(OFModule.java:86)
at etri.sdn.controller.OFController.startModules(OFController.java:275)
at etri.sdn.controller.Main.controller_registration_loop(Main.java:182)
at etri.sdn.controller.Main.main(Main.java:86)
#2.
Mininet 을 이용해서 controller에 토폴로지를 정의하게 되면 다음과 같이 처음에 connect 되었다가 disconnect 되고 다시 connect가 진행됩니다.
( mn --topo=tree,2 --controller=remote )
2014-12-09 14:52:46,255] INFO connected with /
127.0.0.1:41087 (etri.sdn.controller.protocol.io.ClientChannelWatcher::handleConnectedEvent:176)
[2014-12-09 14:52:46,345] INFO disconnected with /
127.0.0.1:41087 (etri.sdn.controller.protocol.io.ClientChannelWatcher::handleDisconnectedEvent:211)
[2014-12-09 14:52:46,869] INFO connected with /
127.0.0.1:41088 (etri.sdn.controller.protocol.io.ClientChannelWatcher::handleConnectedEvent:176)
[2014-12-09 14:52:46,992] INFO connected with /
127.0.0.1:41089 (etri.sdn.controller.protocol.io.ClientChannelWatcher::handleConnectedEvent:176)
[2014-12-09 14:52:47,036] INFO connected with /
127.0.0.1:41090 (etri.sdn.controller.protocol.io.ClientChannelWatcher::handleConnectedEvent:176)
정상적으로 동작하고 있는건가요? 기존의 sample controller를 통해서 동일하게 시도했을 때도 동일한 결과를 보입니다.
정확한 이유는 알 수 없으나 직접 만든 미니넷 소스를 실행해서 controller에 연결했을 때 다음과 같은 메시지를 출력한 이후 메시지가 끝나게 됩니다.
2014-12-09 14:52:46,255] INFO connected with /
127.0.0.1:41087 (etri.sdn.controller.protocol.io.ClientChannelWatcher::handleConnectedEvent:176)
[2014-12-09 14:52:46,345] INFO disconnected with /
127.0.0.1:41087 (etri.sdn.controller.protocol.io.ClientChannelWatcher::handleDisconnectedEvent:211)
혹시 이와 관련된 부분은 뭐가 잘못된건가요?
제가 테스트한 소스는 다음과 같습니다.
def emptyNet():
CONTROLLER_IP='localhost'
net = Mininet( topo=None,
build=False)
net.addController( 'c0',
controller=RemoteController,
ip=CONTROLLER_IP,
port=6633)
h1 = net.addHost( 'h1', ip='10.0.0.1', mac='00:00:00:00:00:01' )
h2 = net.addHost( 'h2', ip='10.0.0.2', mac='00:00:00:00:00:02' )
h3 = net.addHost( 'h3', ip='10.0.0.3', mac='00:00:00:00:00:03' )
h4 = net.addHost( 'h4', ip='10.0.0.4', mac='00:00:00:00:00:04' )
h5 = net.addHost( 'h5', ip='10.0.0.5', mac='00:00:00:00:00:05' )
s1 = net.addSwitch( 's1' )
s2 = net.addSwitch( 's2' )
net.addLink( h1, s1 )
net.addLink( h2, s1 )
net.addLink( h3, s1 )
net.addLink( h4, s1 )
net.addLink( h5, s1 )
net.addLink( s1, s2 )
net.start()
CLI( net )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
emptyNet()