本文整理汇总了Java中org.openflow.protocol.OFError.OFErrorType类的典型用法代码示例。如果您正苦于以下问题:Java OFErrorType类的具体用法?Java OFErrorType怎么用?Java OFErrorType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFErrorType类属于org.openflow.protocol.OFError包,在下文中一共展示了OFErrorType类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReassertMaster
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
/**
* Test re-assert MASTER
*
*/
@Test
public void testReassertMaster() throws Exception {
testInitialMoveToMasterWithRole();
OFError err = (OFError)
BasicFactory.getInstance().getMessage(OFType.ERROR);
err.setXid(42);
err.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
err.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
reset(controller);
controller.reassertRole(handler, Role.MASTER);
expectLastCall().once();
controller.handleMessage(sw, err, null);
expectLastCall().once();
sendMessageToHandlerNoControllerReset(
Collections.<OFMessage>singletonList(err));
verify(sw);
verify(controller);
}
示例2: testDeliverRoleRequestError
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
@Test
public void testDeliverRoleRequestError() {
// normal case. xid is pending
int xid = (int) System.currentTimeMillis();
long cookie = System.nanoTime();
Role role = Role.MASTER;
OFSwitchImpl sw = new OFSwitchImpl();
Channel ch = createMock(Channel.class);
SocketAddress sa = new InetSocketAddress(42);
expect(ch.getRemoteAddress()).andReturn(sa).anyTimes();
sw.setChannel(ch);
setupPendingRoleRequest(sw, xid, role, cookie);
OFError error = new OFError();
error.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
error.setXid(xid);
replay(ch);
roleChanger.deliverRoleRequestError(sw, error);
verify(ch);
assertEquals(false, sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE));
assertEquals(role, sw.getHARole());
assertEquals(0, roleChanger.pendingRequestMap.get(sw).size());
}
示例3: testDeliverRoleRequestErrorNonePending
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
@Test
public void testDeliverRoleRequestErrorNonePending() {
// nothing pending
OFSwitchImpl sw = new OFSwitchImpl();
Channel ch = createMock(Channel.class);
SocketAddress sa = new InetSocketAddress(42);
expect(ch.getRemoteAddress()).andReturn(sa).anyTimes();
sw.setChannel(ch);
OFError error = new OFError();
error.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
error.setXid(1);
replay(ch);
roleChanger.deliverRoleRequestError(sw, error);
verify(ch);
assertEquals(null, sw.getHARole());
}
示例4: testDeliverRoleRequestErrorWrongXid
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
@Test
public void testDeliverRoleRequestErrorWrongXid() {
// wrong xid received
// wrong xid received
int xid = (int) System.currentTimeMillis();
long cookie = System.nanoTime();
Role role = Role.MASTER;
OFSwitchImpl sw = new OFSwitchImpl();
setupPendingRoleRequest(sw, xid, role, cookie);
Channel ch = createMock(Channel.class);
SocketAddress sa = new InetSocketAddress(42);
expect(ch.getRemoteAddress()).andReturn(sa).anyTimes();
expect(ch.close()).andReturn(null);
sw.setChannel(ch);
replay(ch);
OFError error = new OFError();
error.setErrorCode(OFError.OFErrorType.OFPET_BAD_REQUEST.getValue());
error.setXid(xid + 1);
roleChanger.deliverRoleRequestError(sw, error);
verify(ch);
assertEquals(null, sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE));
assertEquals(1, roleChanger.pendingRequestMap.get(sw).size());
}
示例5: processOFError
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
@Override
void processOFError(OFChannelHandler h, OFError m) {
if (m.getErrorType() == OFErrorType.OFPET_BAD_REQUEST.getValue()
&& m.getErrorCode() ==
OFBadRequestCode.OFPBRC_BAD_VENDOR.ordinal()) {
log.debug("Switch {} has multiple tables but does not " +
"support L2 table extension",
h.getSwitchInfoString());
return;
}
logErrorDisconnect(h, m);
}
示例6: getErrorString
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
/**
* Get a useable error string from the OFError.
* @param error
* @return
*/
public static String getErrorString(OFError error) {
// TODO: this really should be OFError.toString. Sigh.
int etint = 0xffff & error.getErrorType();
if (etint < 0 || etint >= OFErrorType.values().length) {
return String.format("Unknown error type %d", etint);
}
OFErrorType et = OFErrorType.values()[etint];
switch (et) {
case OFPET_HELLO_FAILED:
OFHelloFailedCode hfc =
OFHelloFailedCode.values()[0xffff & error.getErrorCode()];
return String.format("Error %s %s", et, hfc);
case OFPET_BAD_REQUEST:
OFBadRequestCode brc =
OFBadRequestCode.values()[0xffff & error.getErrorCode()];
return String.format("Error %s %s", et, brc);
case OFPET_BAD_ACTION:
OFBadActionCode bac =
OFBadActionCode.values()[0xffff & error.getErrorCode()];
return String.format("Error %s %s", et, bac);
case OFPET_FLOW_MOD_FAILED:
OFFlowModFailedCode fmfc =
OFFlowModFailedCode.values()[0xffff & error.getErrorCode()];
return String.format("Error %s %s", et, fmfc);
case OFPET_PORT_MOD_FAILED:
OFPortModFailedCode pmfc =
OFPortModFailedCode.values()[0xffff & error.getErrorCode()];
return String.format("Error %s %s", et, pmfc);
case OFPET_QUEUE_OP_FAILED:
OFQueueOpFailedCode qofc =
OFQueueOpFailedCode.values()[0xffff & error.getErrorCode()];
return String.format("Error %s %s", et, qofc);
case OFPET_VENDOR_ERROR:
// no codes known for vendor error
return String.format("Error %s", et);
}
return null;
}
示例7: testWriteRead
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
public void testWriteRead() throws Exception {
OFError msg = (OFError) messageFactory.getMessage(OFType.ERROR);
msg.setMessageFactory(messageFactory);
msg.setErrorType(OFErrorType.OFPET_HELLO_FAILED.getValue());
msg.setErrorCode((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
.ordinal());
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
bb.clear();
msg.writeTo(bb);
msg.readFrom(bb);
TestCase.assertEquals(OFErrorType.OFPET_HELLO_FAILED.getValue(),
msg.getErrorType());
TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
.ordinal(), msg.getErrorType());
TestCase.assertNull(msg.getOffendingMsg());
msg.setOffendingMsg(new OFHello());
bb.clear();
msg.writeTo(bb);
msg.readFrom(bb);
TestCase.assertEquals(OFErrorType.OFPET_HELLO_FAILED.getValue(),
msg.getErrorType());
TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
.ordinal(), msg.getErrorType());
TestCase.assertNotNull(msg.getOffendingMsg());
TestCase.assertEquals(OFHello.MINIMUM_LENGTH,
msg.getOffendingMsg().length);
}
示例8: getErrorMessage
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
/** Return an OFError of the given type with the given xid */
private OFMessage getErrorMessage(OFErrorType type,
int i,
int xid) {
OFError e = (OFError) BasicFactory.getInstance()
.getMessage(OFType.ERROR);
e.setErrorType(type);
e.setErrorCode((short)i);
e.setXid(xid);
return e;
}
示例9: testInitialRoleChangeOtherError
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
/** Start from scratch and reply with an unexpected error to the role
* change request
* Builds on doMoveToWaitInitialRole()
* adds testing for WAIT_INITAL_ROLE state
*/
@Test
public void testInitialRoleChangeOtherError() throws Exception {
int xid = 4343;
// first, move us to WAIT_INITIAL_ROLE_STATE
MockStorageSourceConfig cfg = new MockStorageSourceConfig();
cfg.dpid = HexString.toHexString(featuresReply.getDatapathId());
cfg.isPresent = false;
doMoveToWaitInitialRole(cfg);
assertEquals(OFChannelHandler.ChannelState.WAIT_INITIAL_ROLE,
handler.getStateForTesting());
// Set the role
setupSwitchSendRoleRequestAndVerify(null, xid, Role.MASTER);
assertEquals(OFChannelHandler.ChannelState.WAIT_INITIAL_ROLE,
handler.getStateForTesting());
// FIXME: shouldn't use ordinal(), but OFError is broken
OFMessage err = getErrorMessage(OFErrorType.OFPET_BAD_ACTION,
0,
xid);
verify(sw);
reset(sw);
expect(sw.inputThrottled(anyObject(OFMessage.class)))
.andReturn(false).anyTimes();
replay(sw);
sendMessageToHandlerWithControllerReset(Collections.singletonList(err));
verifyExceptionCaptured(SwitchStateException.class);
}
示例10: testWriteRead
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
public void testWriteRead() throws Exception {
OFError msg = (OFError) messageFactory.getMessage(OFType.ERROR);
msg.setMessageFactory(messageFactory);
msg.setErrorType((short) OFErrorType.OFPET_HELLO_FAILED.getValue());
msg.setErrorCode((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
.ordinal());
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
bb.clear();
msg.writeTo(bb);
msg.readFrom(bb);
TestCase.assertEquals((short) OFErrorType.OFPET_HELLO_FAILED.getValue(),
msg.getErrorType());
TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
.ordinal(), msg.getErrorType());
TestCase.assertNull(msg.getOffendingMsg());
msg.setOffendingMsg(new OFHello());
bb.clear();
msg.writeTo(bb);
msg.readFrom(bb);
TestCase.assertEquals((short) OFErrorType.OFPET_HELLO_FAILED.getValue(),
msg.getErrorType());
TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
.ordinal(), msg.getErrorType());
TestCase.assertNotNull(msg.getOffendingMsg());
TestCase.assertEquals(OFHello.MINIMUM_LENGTH,
msg.getOffendingMsg().length);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:29,代码来源:OFErrorTest.java
示例11: makeError
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
/**
* Makes an OpenFlow error message for a bad action and
* given OpenFlow message.
*
* @param code the bad action code
* @param msg the OpenFlow message
* @return the OpenFlow error message
*/
public static OFMessage makeError(final OFBadActionCode code,
final OFMessage msg) {
final OVXError err = new OVXError();
err.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
err.setErrorCode(code);
err.setOffendingMsg(msg);
err.setXid(msg.getXid());
return err;
}
示例12: makeErrorMsg
import org.openflow.protocol.OFError.OFErrorType; //导入依赖的package包/类
/**
* Makes an OpenFlow error message for a failed flow mod and
* given OpenFlow message.
*
* @param code the failed flow mod code
* @param msg the OpenFlow message
* @return the OpenFlow error message
*/
public static OFMessage makeErrorMsg(final OFFlowModFailedCode code,
final OFMessage msg) {
final OVXError err = new OVXError();
err.setErrorType(OFErrorType.OFPET_FLOW_MOD_FAILED);
err.setErrorCode(code);
err.setOffendingMsg(msg);
err.setXid(msg.getXid());
return err;
}