当前位置: 首页>>代码示例>>Java>>正文


Java OFRoleReply类代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFRoleReply的典型用法代码示例。如果您正苦于以下问题:Java OFRoleReply类的具体用法?Java OFRoleReply怎么用?Java OFRoleReply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OFRoleReply类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFRoleReply类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractOFRoleReply

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:RoleManager.java

示例2: setSwitchRole

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
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!");
	}
 
开发者ID:DylanAPDavis,项目名称:arscheduler,代码行数:18,代码来源:FT.java

示例3: handleRole

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:17,代码来源:AbstractOpenFlowSwitch.java

示例4: extractOFRoleReply

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:32,代码来源:OFChannelHandler.java

示例5: processRoleRequest

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
@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);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:DefaultOFSwitch.java

示例6: handleRole

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:AbstractOpenFlowSwitch.java

示例7: processOFMessage

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:58,代码来源:OFSwitchHandshakeHandler.java

示例8: getRoleReply

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
@Override
protected OFMessage getRoleReply(long xid, OFControllerRole role) {
    OFRoleReply roleReply = factory.buildRoleReply()
            .setXid(xid)
            .setRole(role)
            .build();
    return roleReply;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:9,代码来源:OFSwitchHandshakeHandlerVer13Test.java

示例9: testWriteRequestOFErrorMsg

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
/** 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));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:30,代码来源:OFConnectionTest.java

示例10: testWriteRequestOFErrorMsg

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
/** 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));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:29,代码来源:OFConnectionTest.java

示例11: setSwitchRole

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
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;
}
 
开发者ID:DylanAPDavis,项目名称:arscheduler,代码行数:15,代码来源:UtilDurable.java

示例12: processOFMessage

import org.projectfloodlight.openflow.protocol.OFRoleReply; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:DaiDongLiang,项目名称:DSC,代码行数:58,代码来源:OFSwitchHandshakeHandler.java


注:本文中的org.projectfloodlight.openflow.protocol.OFRoleReply类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。