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

项目:athena    文件:RoleManager.java   
/**
 * Extract the role information from an OF1.3 Role Reply Message.
 *
 * @param rrmsg the role message
 * @return RoleReplyInfo object
 * @throws SwitchStateException if the role information could not be extracted.
 */
@Override
public RoleReplyInfo extractOFRoleReply(OFRoleReply rrmsg)
        throws SwitchStateException {
    OFControllerRole cr = rrmsg.getRole();
    RoleState role = null;
    switch (cr) {
    case ROLE_EQUAL:
        role = RoleState.EQUAL;
        break;
    case ROLE_MASTER:
        role = RoleState.MASTER;
        break;
    case ROLE_SLAVE:
        role = RoleState.SLAVE;
        break;
    case ROLE_NOCHANGE: // switch should send current role
    default:
        String msg = String.format("Unknown controller role %s "
                + "received from switch %s", cr, sw);
        throw new SwitchStateException(msg);
    }

    return new RoleReplyInfo(role, rrmsg.getGenerationId(), rrmsg.getXid());
}
项目:arscheduler    文件:FT.java   
public void setSwitchRole(OFControllerRole role, String swId){

        IOFSwitch sw = switchService.getActiveSwitch(DatapathId.of(swId));
        OFRoleReply reply=null;
        UtilDurable utilDurable = new UtilDurable();
        reply = utilDurable.setSwitchRole(sw, role);

        if(reply!=null){
            logger.info("DEFINED {} as {}, reply.getRole:{}!", 
                    new Object[]{
                    sw.getId(), 
                    role,
                    reply.getRole()});
        }
        else
            logger.info("Reply NULL!");
    }
项目:ravikumaran201504    文件:AbstractOpenFlowSwitch.java   
@Override
public void handleRole(OFMessage m) throws SwitchStateException {
    RoleReplyInfo rri = roleMan.extractOFRoleReply((OFRoleReply) m);
    RoleRecvStatus rrs = roleMan.deliverRoleReply(rri);
    if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
        if (rri.getRole() == RoleState.MASTER) {
            this.role = rri.getRole();
            this.transitionToMasterSwitch();
        } else if (rri.getRole() == RoleState.EQUAL ||
                rri.getRole() == RoleState.SLAVE) {
            this.transitionToEqualSwitch();
        }
    }  else {
        log.warn("Failed to set role for {}", this.getStringId());
    }
}
项目:ravikumaran201504    文件:RoleManager.java   
/**
 * Extract the role information from an OF1.3 Role Reply Message.
 *
 * @param rrmsg the role message
 * @return RoleReplyInfo object
 * @throws SwitchStateException if the role information could not be extracted.
 */
@Override
public RoleReplyInfo extractOFRoleReply(OFRoleReply rrmsg)
        throws SwitchStateException {
    OFControllerRole cr = rrmsg.getRole();
    RoleState role = null;
    switch (cr) {
    case ROLE_EQUAL:
        role = RoleState.EQUAL;
        break;
    case ROLE_MASTER:
        role = RoleState.MASTER;
        break;
    case ROLE_SLAVE:
        role = RoleState.SLAVE;
        break;
    case ROLE_NOCHANGE: // switch should send current role
    default:
        String msg = String.format("Unknown controller role %s "
                + "received from switch %s", cr, sw);
        throw new SwitchStateException(msg);
    }

    return new RoleReplyInfo(role, rrmsg.getGenerationId(), rrmsg.getXid());
}
项目:spring-open    文件:OFChannelHandler.java   
/**
 * Extract the role information from an OF1.3 Role Reply Message
 *
 * @param h
 * @param rrmsg
 * @return RoleReplyInfo object
 * @throws SwitchStateException
 */
protected RoleReplyInfo extractOFRoleReply(OFChannelHandler h,
        OFRoleReply rrmsg) throws SwitchStateException {
    OFControllerRole cr = rrmsg.getRole();
    Role role = null;
    switch (cr) {
    case ROLE_EQUAL:
        role = Role.EQUAL;
        break;
    case ROLE_MASTER:
        role = Role.MASTER;
        break;
    case ROLE_SLAVE:
        role = Role.SLAVE;
        break;
    case ROLE_NOCHANGE: // switch should send current role
    default:
        String msg = String.format("Unknown controller role {} "
                + "received from switch {}", cr, h.sw);
        throw new SwitchStateException(msg);
    }

    return new RoleReplyInfo(role, rrmsg.getGenerationId(), rrmsg.getXid());
}
项目:onos    文件:RoleManager.java   
/**
 * Extract the role information from an OF1.3 Role Reply Message.
 *
 * @param rrmsg the role message
 * @return RoleReplyInfo object
 * @throws SwitchStateException if the role information could not be extracted.
 */
@Override
public RoleReplyInfo extractOFRoleReply(OFRoleReply rrmsg)
        throws SwitchStateException {
    OFControllerRole cr = rrmsg.getRole();
    RoleState role = null;
    switch (cr) {
    case ROLE_EQUAL:
        role = RoleState.EQUAL;
        break;
    case ROLE_MASTER:
        role = RoleState.MASTER;
        break;
    case ROLE_SLAVE:
        role = RoleState.SLAVE;
        break;
    case ROLE_NOCHANGE: // switch should send current role
    default:
        String msg = String.format("Unknown controller role %s "
                + "received from switch %s", cr, sw);
        throw new SwitchStateException(msg);
    }

    return new RoleReplyInfo(role, rrmsg.getGenerationId(), rrmsg.getXid());
}
项目: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 void handleRole(OFMessage m) throws SwitchStateException {
    RoleReplyInfo rri = roleMan.extractOFRoleReply((OFRoleReply) m);
    RoleRecvStatus rrs = roleMan.deliverRoleReply(rri);
    if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
        if (rri.getRole() == RoleState.MASTER) {
            this.transitionToMasterSwitch();
        } else if (rri.getRole() == RoleState.EQUAL ||
                   rri.getRole() == RoleState.SLAVE) {
            this.transitionToEqualSwitch();
        }
    }  else {
        log.warn("Failed to set role for {}", this.getStringId());
    }
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目: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   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目: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));
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目: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    文件:UtilDurable.java   
public OFRoleReply setSwitchRole(IOFSwitch sw, OFControllerRole role) {
    try {   
        ListenableFuture<OFRoleReply> future = sw.writeRequest(sw.getOFFactory().buildRoleRequest()
                .setGenerationId(U64.ZERO)
                .setRole(role)
                .build());
        return future.get(10, TimeUnit.SECONDS);

    } catch (Exception e) {
        logger.error("Failure setting switch {} role to {}.", sw.toString(), role.toString());
        logger.error(e.getMessage());
    }
    return null;
}
项目:arscheduler    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目: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   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目: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   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目: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   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:ACAMPController    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目:ACAMPController    文件: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));
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:fast-failover-demo    文件: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));
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目:floodlightLB    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:floodlightLB    文件: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));
}
项目:floodlightLB    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目:DSC    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *  处理从管道接收的OF报文并更新状态
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *  处理接收报文,如果需要发送跟踪报文和更新状态
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:DSC    文件: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));
}
项目:DSC    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
项目:floodlight    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目: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));

    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));
}