Java 类net.floodlightcontroller.core.internal.OFChannelState.HandshakeState 实例源码

项目:Multipath-Hedera-system-in-Floodlight-controller    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the 
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:smartenit    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the 
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:floodlight-qosmanager    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the 
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:floodlight-nfv    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
            roleChanger.removePendingRequests(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:HederaInFloodlight    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the 
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:floodlight-oss    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
            roleChanger.removePendingRequests(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:my-floodlight    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the 
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:FL_HAND    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
            roleChanger.removePendingRequests(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:sdn-project    文件:Controller.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    if (sw != null && state.hsState == HandshakeState.READY) {
        if (activeSwitches.containsKey(sw.getId())) {
            // It's safe to call removeSwitch even though the map might
            // not contain this particular switch but another with the 
            // same DPID
            removeSwitch(sw);
        }
        synchronized(roleChanger) {
            connectedSwitches.remove(sw);
        }
        sw.setConnected(false);
    }
    log.info("Disconnected switch {}", sw);
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:ControllerTest.java   
@Test 
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    chdlr.processOFMessage(msg);
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(OFSwitchImpl.class);
    return chdlr;
}
项目:smartenit    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:smartenit    文件:ControllerTest.java   
@Test 
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    chdlr.processOFMessage(msg);
}
项目:smartenit    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(OFSwitchImpl.class);
    return chdlr;
}
项目:floodlight-qosmanager    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:floodlight-qosmanager    文件:ControllerTest.java   
@Test 
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    chdlr.processOFMessage(msg);
}
项目:floodlight-qosmanager    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(OFSwitchImpl.class);
    return chdlr;
}
项目:floodlight-nfv    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:floodlight-nfv    文件:ControllerTest.java   
@Test
 public void testBindSwitchOrder() {
     List<String> order = new ArrayList<String>(3);
     controller.addOFSwitchDriver("", this);
     controller.addOFSwitchDriver("test switch", this);
     controller.addOFSwitchDriver("test", this);
     order.add("test switch");
     order.add("test");
     order.add("");
     test_bind_order = true;

     OFChannelState state = new OFChannelState();
     Controller.OFChannelHandler chdlr =
             controller.new OFChannelHandler(state);
     chdlr.sw = null;

     // Swith should be bound of OFSwitchImpl (default)
     state.hsState = OFChannelState.HandshakeState.HELLO;
     state.hasDescription = true;
     state.hasGetConfigReply = true;
     state.switchBindingDone = false;
     OFDescriptionStatistics desc = new OFDescriptionStatistics();
     desc.setManufacturerDescription("test switch");
     desc.setHardwareDescription("version 0.9");
     state.description = desc;
     OFFeaturesReply featuresReply = new OFFeaturesReply();
     featuresReply.setPorts(new ArrayList<OFPhysicalPort>());
     state.featuresReply = featuresReply;

     chdlr.bindSwitchToDriver();
     assertTrue(chdlr.sw instanceof OFSwitchImpl);
     assertTrue(!(chdlr.sw instanceof TestSwitchClass));
     // Verify bind_order is called as expected
     assertTrue(order.equals(bind_order));
     test_bind_order = false;
     bind_order = null;
}
项目:floodlight-nfv    文件:ControllerTest.java   
@Test
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    // Ensure that vendor message listeners get called, even for Vendors
    // unknown to floodlight. It is the responsibility of the listener to
    // discard unknown vendors.
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    IOFSwitch sw = createMock(IOFSwitch.class);
    chdlr.sw = sw;
    controller.activeSwitches.put(1L, sw);

    // prepare the Vendor Message Listener expectations
    ListenerDispatcher<OFType, IOFMessageListener> ld =
            new ListenerDispatcher<OFType, IOFMessageListener>();
    IOFMessageListener ml = createMock(IOFMessageListener.class);
    expect(ml.getName()).andReturn("Dummy").anyTimes();
    expect(ml.isCallbackOrderingPrereq((OFType)anyObject(),
            (String)anyObject())).andReturn(false).anyTimes();
    expect(ml.isCallbackOrderingPostreq((OFType)anyObject(),
            (String)anyObject())).andReturn(false).anyTimes();
    expect(ml.receive(eq(sw), eq(msg), isA(FloodlightContext.class))).
            andReturn(Command.CONTINUE).once();
    controller.messageListeners.put(OFType.VENDOR, ld);

    // prepare the switch and lock expectations
    Lock lock = createNiceMock(Lock.class);
    expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
    expect(sw.isConnected()).andReturn(true).anyTimes();
    expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
    expect(sw.getId()).andReturn(1L).anyTimes();

    // test
    replay(chdlr.sw, lock, ml);
    ld.addListener(OFType.VENDOR, ml);
    chdlr.processOFMessage(msg);
}
项目:floodlight-nfv    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(IOFSwitch.class);
    return chdlr;
}
项目:HederaInFloodlight    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:HederaInFloodlight    文件:ControllerTest.java   
@Test 
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    chdlr.processOFMessage(msg);
}
项目:HederaInFloodlight    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(OFSwitchImpl.class);
    return chdlr;
}
项目:floodlight-oss    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:floodlight-oss    文件:ControllerTest.java   
@Test
 public void testBindSwitchOrder() {
     List<String> order = new ArrayList<String>(3);
     controller.addOFSwitchDriver("", this);
     controller.addOFSwitchDriver("test switch", this);
     controller.addOFSwitchDriver("test", this);
     order.add("test switch");
     order.add("test");
     order.add("");
     test_bind_order = true;

     OFChannelState state = new OFChannelState();
     Controller.OFChannelHandler chdlr =
             controller.new OFChannelHandler(state);
     chdlr.sw = null;

     // Swith should be bound of OFSwitchImpl (default)
     state.hsState = OFChannelState.HandshakeState.HELLO;
     state.hasDescription = true;
     state.hasGetConfigReply = true;
     state.switchBindingDone = false;
     OFDescriptionStatistics desc = new OFDescriptionStatistics();
     desc.setManufacturerDescription("test switch");
     desc.setHardwareDescription("version 0.9");
     state.description = desc;
     OFFeaturesReply featuresReply = new OFFeaturesReply();
     featuresReply.setPorts(new ArrayList<OFPhysicalPort>());
     state.featuresReply = featuresReply;

     chdlr.bindSwitchToDriver();
     assertTrue(chdlr.sw instanceof OFSwitchImpl);
     assertTrue(!(chdlr.sw instanceof TestSwitchClass));
     // Verify bind_order is called as expected
     assertTrue(order.equals(bind_order));
     test_bind_order = false;
     bind_order = null;
}
项目:floodlight-oss    文件:ControllerTest.java   
@Test
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    // Ensure that vendor message listeners get called, even for Vendors
    // unknown to floodlight. It is the responsibility of the listener to
    // discard unknown vendors.
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    IOFSwitch sw = createMock(IOFSwitch.class);
    chdlr.sw = sw;
    controller.activeSwitches.put(1L, sw);

    // prepare the Vendor Message Listener expectations
    ListenerDispatcher<OFType, IOFMessageListener> ld =
            new ListenerDispatcher<OFType, IOFMessageListener>();
    IOFMessageListener ml = createMock(IOFMessageListener.class);
    expect(ml.getName()).andReturn("Dummy").anyTimes();
    expect(ml.isCallbackOrderingPrereq((OFType)anyObject(),
            (String)anyObject())).andReturn(false).anyTimes();
    expect(ml.isCallbackOrderingPostreq((OFType)anyObject(),
            (String)anyObject())).andReturn(false).anyTimes();
    expect(ml.receive(eq(sw), eq(msg), isA(FloodlightContext.class))).
            andReturn(Command.CONTINUE).once();
    controller.messageListeners.put(OFType.VENDOR, ld);

    // prepare the switch and lock expectations
    Lock lock = createNiceMock(Lock.class);
    expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
    expect(sw.isConnected()).andReturn(true).anyTimes();
    expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
    expect(sw.getId()).andReturn(1L).anyTimes();

    // test
    replay(chdlr.sw, lock, ml);
    ld.addListener(OFType.VENDOR, ml);
    chdlr.processOFMessage(msg);
}
项目:floodlight-oss    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(IOFSwitch.class);
    return chdlr;
}
项目:my-floodlight    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:my-floodlight    文件:ControllerTest.java   
@Test 
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    chdlr.processOFMessage(msg);
}
项目:my-floodlight    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(OFSwitchImpl.class);
    return chdlr;
}
项目:FL_HAND    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:FL_HAND    文件:ControllerTest.java   
@Test
 public void testBindSwitchOrder() {
     List<String> order = new ArrayList<String>(3);
     controller.addOFSwitchDriver("", this);
     controller.addOFSwitchDriver("test switch", this);
     controller.addOFSwitchDriver("test", this);
     order.add("test switch");
     order.add("test");
     order.add("");
     test_bind_order = true;

     OFChannelState state = new OFChannelState();
     Controller.OFChannelHandler chdlr =
             controller.new OFChannelHandler(state);
     chdlr.sw = null;

     // Swith should be bound of OFSwitchImpl (default)
     state.hsState = OFChannelState.HandshakeState.HELLO;
     state.hasDescription = true;
     state.hasGetConfigReply = true;
     state.switchBindingDone = false;
     OFDescriptionStatistics desc = new OFDescriptionStatistics();
     desc.setManufacturerDescription("test switch");
     desc.setHardwareDescription("version 0.9");
     state.description = desc;
     OFFeaturesReply featuresReply = new OFFeaturesReply();
     featuresReply.setPorts(new ArrayList<OFPhysicalPort>());
     state.featuresReply = featuresReply;

     chdlr.bindSwitchToDriver();
     assertTrue(chdlr.sw instanceof OFSwitchImpl);
     assertTrue(!(chdlr.sw instanceof TestSwitchClass));
     // Verify bind_order is called as expected
     assertTrue(order.equals(bind_order));
     test_bind_order = false;
     bind_order = null;
}
项目:FL_HAND    文件:ControllerTest.java   
@Test 
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    // Ensure that vendor message listeners get called, even for Vendors 
    // unknown to floodlight. It is the responsibility of the listener to
    // discard unknown vendors.
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    IOFSwitch sw = createMock(IOFSwitch.class);
    chdlr.sw = sw;
    controller.activeSwitches.put(1L, sw);

    // prepare the Vendor Message Listener expectations
    ListenerDispatcher<OFType, IOFMessageListener> ld = 
            new ListenerDispatcher<OFType, IOFMessageListener>();
    IOFMessageListener ml = createMock(IOFMessageListener.class);
    expect(ml.getName()).andReturn("Dummy").anyTimes();
    expect(ml.isCallbackOrderingPrereq((OFType)anyObject(), 
            (String)anyObject())).andReturn(false).anyTimes();
    expect(ml.isCallbackOrderingPostreq((OFType)anyObject(), 
            (String)anyObject())).andReturn(false).anyTimes();
    expect(ml.receive(eq(sw), eq(msg), isA(FloodlightContext.class))).
            andReturn(Command.CONTINUE).once();
    controller.messageListeners.put(OFType.VENDOR, ld);

    // prepare the switch and lock expectations
    Lock lock = createNiceMock(Lock.class);
    expect(sw.getListenerReadLock()).andReturn(lock).anyTimes();
    expect(sw.isConnected()).andReturn(true).anyTimes();
    expect(sw.getHARole()).andReturn(Role.MASTER).anyTimes();
    expect(sw.getId()).andReturn(1L).anyTimes();

    // test
    replay(chdlr.sw, lock, ml);
    ld.addListener(OFType.VENDOR, ml);
    chdlr.processOFMessage(msg);
}
项目:FL_HAND    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(IOFSwitch.class);
    return chdlr;
}
项目:sdn-project    文件:HandshakeTimeoutHandler.java   
@Override
public void run(Timeout timeout) throws Exception {
    if (timeout.isCancelled()) {
        return;
    }

    if (!ctx.getChannel().isOpen()) {
        return;
    }
    if (!state.hsState.equals(HandshakeState.READY))
        Channels.fireExceptionCaught(ctx, EXCEPTION);
}
项目:sdn-project    文件:ControllerTest.java   
@Test 
public void testVendorMessageUnknown() throws Exception {
    // Check behavior with an unknown vendor id
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    OFVendor msg = new OFVendor();
    msg.setVendor(0);
    chdlr.processOFMessage(msg);
}
项目:sdn-project    文件:ControllerTest.java   
protected Controller.OFChannelHandler getChannelHandlerForRoleReplyTest() {
    OFChannelState state = new OFChannelState();
    state.hsState = HandshakeState.READY;
    Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
    chdlr.sw = createMock(OFSwitchImpl.class);
    return chdlr;
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:Controller.java   
protected void checkSwitchReady() {
    if (state.hsState == HandshakeState.FEATURES_REPLY &&
            state.hasDescription && state.hasGetConfigReply) {

        state.hsState = HandshakeState.READY;

        synchronized(roleChanger) {
            // We need to keep track of all of the switches that are connected
            // to the controller, in any role, so that we can later send the 
            // role request messages when the controller role changes.
            // We need to be synchronized while doing this: we must not 
            // send a another role request to the connectedSwitches until
            // we were able to add this new switch to connectedSwitches 
            // *and* send the current role to the new switch.
            connectedSwitches.add(sw);

            if (role != null) {
                // Send a role request if role support is enabled for the controller
                // This is a probe that we'll use to determine if the switch
                // actually supports the role request message. If it does we'll
                // get back a role reply message. If it doesn't we'll get back an
                // OFError message. 
                // If role is MASTER we will promote switch to active
                // list when we receive the switch's role reply messages
                log.debug("This controller's role is {}, " + 
                        "sending initial role request msg to {}",
                        role, sw);
                Collection<OFSwitchImpl> swList = new ArrayList<OFSwitchImpl>(1);
                swList.add(sw);
                roleChanger.submitRequest(swList, role);
            } 
            else {
                // Role supported not enabled on controller (for now)
                // automatically promote switch to active state. 
                log.debug("This controller's role is null, " + 
                        "not sending role request msg to {}",
                        role, sw);
                // Need to clear FlowMods before we add the switch
                // and dispatch updates otherwise we have a race condition.
                sw.clearAllFlowMods();
                addSwitch(sw);
                state.firstRoleReplyReceived = true;
            }
        }
    }
}