Java 类org.projectfloodlight.openflow.protocol.OFRoleRequest 实例源码

项目:fresco_floodlight    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:arscheduler    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:ACAMPController    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        /* 
         * no-op:
         * we can send any request at any time
         */
        break;
    }
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlightLB    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:DSC    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole(null)).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:onos    文件:DefaultOFSwitch.java   
@Override
public void processRoleRequest(Channel channel, OFMessage msg) {
    OFRoleRequest ofRoleRequest = (OFRoleRequest) msg;
    OFControllerRole oldRole = role(channel);
    OFControllerRole newRole = ofRoleRequest.getRole();
    if (oldRole.equals(newRole)) {
        log.trace("No change needed to existing role {}", oldRole);
    } else {
        log.trace("Changing role from {} to {}", oldRole, newRole);
        setRole(channel, newRole);
    }
    OFRoleReply ofRoleReply = FACTORY.buildRoleReply()
            .setRole(role(channel))
            .setXid(msg.getXid())
            .build();
    channel.writeAndFlush(Collections.singletonList(ofRoleReply));
    log.trace("request {}; reply {}", msg, ofRoleReply);
}
项目:athena    文件:AbstractOpenFlowSwitch.java   
@Override
public final void sendRoleRequest(OFMessage msg) {
    if (msg instanceof OFRoleRequest ||
            msg instanceof OFNiciraControllerRoleRequest) {
        sendMsgsOnChannel(Collections.singletonList(msg));
        return;
    }
    throw new IllegalArgumentException("Someone is trying to send " +
                                               "a non role request message");
}
项目:athena    文件:RoleManager.java   
private int sendOF13RoleRequest(RoleState role) throws IOException {
    // Convert the role enum to the appropriate role to send
    OFControllerRole roleToSend = OFControllerRole.ROLE_NOCHANGE;
    switch (role) {
    case EQUAL:
        roleToSend = OFControllerRole.ROLE_EQUAL;
        break;
    case MASTER:
        roleToSend = OFControllerRole.ROLE_MASTER;
        break;
    case SLAVE:
        roleToSend = OFControllerRole.ROLE_SLAVE;
        break;
    default:
        log.warn("Sending default role.noChange to switch {}."
                + " Should only be used for queries.", sw);
    }

    int xid = sw.getNextTransactionId();
    OFRoleRequest rrm = OFFactories.getFactory(OFVersion.OF_13)
            .buildRoleRequest()
            .setRole(roleToSend)
            .setXid(xid)
            //FIXME fix below when we actually use generation ids
            .setGenerationId(U64.ZERO)
            .build();

    sw.sendRoleRequest(rrm);
    return xid;
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        break;
    }
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequestIfNotPending(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequestIfNotPending(role.getRole(), 0);
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequest(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequest(role.getRole(), role.getXid());
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:fresco_floodlight    文件:OFConnectionTest.java   
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
    ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(roleRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
    OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
        .setXid(roleRequest.getXid())
        .setCode(OFRoleRequestFailedCode.STALE)
        .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(roleError),
            equalTo(true));

    OFErrorMsgException e =
            FutureTestUtils.assertFutureFailedWithException(future,
                    OFErrorMsgException.class);
    assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequestIfNotPending(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequestIfNotPending(role.getRole(), 0);
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequest(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequest(role.getRole(), role.getXid());
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:iTAP-controller    文件:OFConnectionTest.java   
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
    ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(roleRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
    OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
        .setXid(roleRequest.getXid())
        .setCode(OFRoleRequestFailedCode.STALE)
        .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(roleError),
            equalTo(true));

    OFErrorMsgException e =
            FutureTestUtils.assertFutureFailedWithException(future,
                    OFErrorMsgException.class);
    assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        break;
    }
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequestIfNotPending(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequestIfNotPending(role.getRole(), 0);
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequest(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequest(role.getRole(), role.getXid());
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:SDN-Multicast    文件:OFConnectionTest.java   
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
    ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(roleRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
    OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
        .setXid(roleRequest.getXid())
        .setCode(OFRoleRequestFailedCode.STALE)
        .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(roleError),
            equalTo(true));

    OFErrorMsgException e =
            FutureTestUtils.assertFutureFailedWithException(future,
                    OFErrorMsgException.class);
    assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}
项目:arscheduler    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        break;
    }
}
项目:arscheduler    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequestIfNotPending(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequestIfNotPending(role.getRole(), 0);
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:arscheduler    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequest(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequest(role.getRole(), role.getXid());
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:arscheduler    文件:OFConnectionTest.java   
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
    ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(roleRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
    OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
        .setXid(roleRequest.getXid())
        .setCode(OFRoleRequestFailedCode.STALE)
        .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(roleError),
            equalTo(true));

    OFErrorMsgException e =
            FutureTestUtils.assertFutureFailedWithException(future,
                    OFErrorMsgException.class);
    assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        break;
    }
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequestIfNotPending(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequestIfNotPending(role.getRole(), 0);
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequest(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequest(role.getRole(), role.getXid());
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:floodlight1.2-delay    文件:OFConnectionTest.java   
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
    ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(roleRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
    OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
        .setXid(roleRequest.getXid())
        .setCode(OFRoleRequestFailedCode.STALE)
        .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(roleError),
            equalTo(true));

    OFErrorMsgException e =
            FutureTestUtils.assertFutureFailedWithException(future,
                    OFErrorMsgException.class);
    assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        break;
    }
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequestIfNotPending(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequestIfNotPending(role.getRole(), 0);
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandler.java   
void sendRoleRequest(OFRoleRequest role) {
    try {
        roleChanger.sendRoleRequest(role.getRole(), role.getXid());
    } catch (IOException e) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                getSwitchInfoString(), e.getMessage());
        mainConnection.disconnect();
    }
}
项目:floodlight-hardware    文件:OFConnectionTest.java   
/** write a request which triggers an OFErrorMsg response */
@Test(timeout = 5000)
public void testWriteRequestOFErrorMsg() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFRoleRequest roleRequest = factory.buildRoleRequest().setRole(OFControllerRole.ROLE_MASTER).build();
    ListenableFuture<OFRoleReply> future = conn.writeRequest(roleRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(roleRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));
    OFRoleRequestFailedErrorMsg roleError = factory.errorMsgs().buildRoleRequestFailedErrorMsg()
        .setXid(roleRequest.getXid())
        .setCode(OFRoleRequestFailedCode.STALE)
        .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(roleError),
            equalTo(true));

    OFErrorMsgException e =
            FutureTestUtils.assertFutureFailedWithException(future,
                    OFErrorMsgException.class);
    assertThat(e.getErrorMessage(), CoreMatchers.<OFErrorMsg>equalTo(roleError));
}
项目:ACAMPController    文件:OFSwitchHandshakeHandler.java   
void processWrittenOFMessage(OFMessage m) {
    switch(m.getType()) {
    case ROLE_REQUEST:
        processOFRoleRequest((OFRoleRequest) m);
        break;
    case EXPERIMENTER:
        if (m instanceof OFNiciraControllerRoleRequest) {
            processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m);
        }
        break;
    default:
        break;
    }
}