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


Java OFRoleRequest类代码示例

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


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

示例1: moveToWaitInitialRole

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

示例2: processWrittenOFMessage

import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的package包/类
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;
	}
}
 
开发者ID:rizard,项目名称:fast-failover-demo,代码行数:19,代码来源:OFSwitchHandshakeHandler.java

示例3: moveToWaitInitialRole

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

示例4: processRoleRequest

import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的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

示例5: sendRoleRequest

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

示例6: sendOF13RoleRequest

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

示例7: processWrittenOFMessage

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

示例8: sendRoleRequestIfNotPending

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

示例9: sendRoleRequest

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

示例10: testWriteRequestOFErrorMsg

import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的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

示例11: processWrittenOFMessage

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

示例12: testWriteRequestOFErrorMsg

import org.projectfloodlight.openflow.protocol.OFRoleRequest; //导入依赖的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


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