本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFBadRequestCode类的典型用法代码示例。如果您正苦于以下问题:Java OFBadRequestCode类的具体用法?Java OFBadRequestCode怎么用?Java OFBadRequestCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFBadRequestCode类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFBadRequestCode类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOFError
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
@Override
void processOFError(OFChannelHandler h, OFErrorMsg m)
throws IOException, SwitchStateException {
// if we get here, then the error message is for something else
if (m.getErrType() == OFErrorType.BAD_REQUEST &&
((OFBadRequestErrorMsg) m).getCode() ==
OFBadRequestCode.EPERM) {
// We are the master controller and the switch returned
// a permission error. This is a likely indicator that
// the switch thinks we are slave. Reassert our
// role
// FIXME: this could be really bad during role transitions
// if two controllers are master (even if its only for
// a brief period). We might need to see if these errors
// persist before we reassert
h.sw.reassertRole();
} else if (m.getErrType() == OFErrorType.FLOW_MOD_FAILED &&
((OFFlowModFailedErrorMsg) m).getCode() ==
OFFlowModFailedCode.ALL_TABLES_FULL) {
h.sw.setTableFull(true);
} else {
logError(h, m);
}
h.dispatchMessage(m);
}
示例2: processOFError
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
@Override
void processOFError(OFErrorMsg m) {
/*
* HP ProCurve switches do not support
* the ofpt_barrier_request message.
*
* Look for an error from a bad ofpt_barrier_request,
* log a warning, but proceed.
*/
if (m.getErrType() == OFErrorType.BAD_REQUEST &&
((OFBadRequestErrorMsg) m).getCode() == OFBadRequestCode.BAD_TYPE &&
((OFBadRequestErrorMsg) m).getData().getParsedMessage().get() instanceof OFBarrierRequest) {
log.warn("Switch does not support Barrier Request messages. Could be an HP ProCurve.");
} else {
logErrorDisconnect(m);
}
}
示例3: testReassertMaster
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
/**
* Test re-assert MASTER
*
*/
@Test
public void testReassertMaster() throws Exception {
testInitialMoveToMasterWithRole();
OFMessage err = getBadRequestErrorMessage(OFBadRequestCode.EPERM, 42);
reset(roleManager);
roleManager.reassertRole(switchHandler, HARole.ACTIVE);
expectLastCall().once();
replay(roleManager);
reset(switchManager);
switchManager.handleMessage(sw, err, null);
expectLastCall().once();
replay(switchManager);
switchHandler.processOFMessage(err);
verify(sw);
}
示例4: testReassertMaster
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
/**
* Test re-assert MASTER
*
*/
@Test
public void testReassertMaster() throws Exception {
testInitialMoveToMasterWithRole();
OFMessage err = getBadRequestErrorMessage(OFBadRequestCode.EPERM, 42);
reset(roleManager);
roleManager.reassertRole(switchHandler, HARole.ACTIVE);
expectLastCall().once();
replay(roleManager);
reset(switchManager);
switchManager.handleMessage(sw, err, null);
expectLastCall().once();
replay(switchManager);
switchHandler.processOFMessage(err);
verify(sw);
}
示例5: processOFError
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
@Override
void processOFError(OFErrorMsg m) {
/*
* HP ProCurve switches do not support
* the ofpt_barrier_request message.
*
* Look for an error from a bad ofpt_barrier_request,
* log a warning, but proceed.
*/
if (m.getErrType() == OFErrorType.BAD_REQUEST &&
((OFBadRequestErrorMsg) m).getCode() == OFBadRequestCode.BAD_TYPE &&
((OFBadRequestErrorMsg) m).getData().getParsedMessage().get() instanceof OFBarrierRequest) {
log.warn("Switch does not support Barrier Request messages. Could be an HP ProCurve.");
} else {
logErrorDisconnect(m);
}
}
示例6: ofWireValue
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
public static OFBadRequestCode ofWireValue(short val) {
switch(val) {
case BAD_VERSION_VAL:
return OFBadRequestCode.BAD_VERSION;
case BAD_TYPE_VAL:
return OFBadRequestCode.BAD_TYPE;
case BAD_STAT_VAL:
return OFBadRequestCode.BAD_STAT;
case BAD_EXPERIMENTER_VAL:
return OFBadRequestCode.BAD_EXPERIMENTER;
case BAD_SUBTYPE_VAL:
return OFBadRequestCode.BAD_SUBTYPE;
case EPERM_VAL:
return OFBadRequestCode.EPERM;
case BAD_LEN_VAL:
return OFBadRequestCode.BAD_LEN;
case BUFFER_EMPTY_VAL:
return OFBadRequestCode.BUFFER_EMPTY;
case BUFFER_UNKNOWN_VAL:
return OFBadRequestCode.BUFFER_UNKNOWN;
default:
throw new IllegalArgumentException("Illegal wire value for type OFBadRequestCode in version 1.0: " + val);
}
}
示例7: toWireValue
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
public static short toWireValue(OFBadRequestCode e) {
switch(e) {
case BAD_VERSION:
return BAD_VERSION_VAL;
case BAD_TYPE:
return BAD_TYPE_VAL;
case BAD_STAT:
return BAD_STAT_VAL;
case BAD_EXPERIMENTER:
return BAD_EXPERIMENTER_VAL;
case BAD_SUBTYPE:
return BAD_SUBTYPE_VAL;
case EPERM:
return EPERM_VAL;
case BAD_LEN:
return BAD_LEN_VAL;
case BUFFER_EMPTY:
return BUFFER_EMPTY_VAL;
case BUFFER_UNKNOWN:
return BUFFER_UNKNOWN_VAL;
default:
throw new IllegalArgumentException("Illegal enum value for type OFBadRequestCode in version 1.0: " + e);
}
}
示例8: ofWireValue
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
public static OFBadRequestCode ofWireValue(short val) {
switch(val) {
case BAD_VERSION_VAL:
return OFBadRequestCode.BAD_VERSION;
case BAD_TYPE_VAL:
return OFBadRequestCode.BAD_TYPE;
case BAD_STAT_VAL:
return OFBadRequestCode.BAD_STAT;
case BAD_EXPERIMENTER_VAL:
return OFBadRequestCode.BAD_EXPERIMENTER;
case BAD_SUBTYPE_VAL:
return OFBadRequestCode.BAD_SUBTYPE;
case EPERM_VAL:
return OFBadRequestCode.EPERM;
case BAD_LEN_VAL:
return OFBadRequestCode.BAD_LEN;
case BUFFER_EMPTY_VAL:
return OFBadRequestCode.BUFFER_EMPTY;
case BUFFER_UNKNOWN_VAL:
return OFBadRequestCode.BUFFER_UNKNOWN;
case BAD_TABLE_ID_VAL:
return OFBadRequestCode.BAD_TABLE_ID;
default:
throw new IllegalArgumentException("Illegal wire value for type OFBadRequestCode in version 1.1: " + val);
}
}
示例9: toWireValue
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
public static short toWireValue(OFBadRequestCode e) {
switch(e) {
case BAD_VERSION:
return BAD_VERSION_VAL;
case BAD_TYPE:
return BAD_TYPE_VAL;
case BAD_STAT:
return BAD_STAT_VAL;
case BAD_EXPERIMENTER:
return BAD_EXPERIMENTER_VAL;
case BAD_SUBTYPE:
return BAD_SUBTYPE_VAL;
case EPERM:
return EPERM_VAL;
case BAD_LEN:
return BAD_LEN_VAL;
case BUFFER_EMPTY:
return BUFFER_EMPTY_VAL;
case BUFFER_UNKNOWN:
return BUFFER_UNKNOWN_VAL;
case BAD_TABLE_ID:
return BAD_TABLE_ID_VAL;
default:
throw new IllegalArgumentException("Illegal enum value for type OFBadRequestCode in version 1.1: " + e);
}
}
示例10: processOFError
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
@Override
void processOFError(OFChannelHandler h, OFErrorMsg m) {
if (m.getErrType() == OFErrorType.BAD_REQUEST) {
OFBadRequestErrorMsg badRequest = (OFBadRequestErrorMsg) m;
if (badRequest.getCode() == OFBadRequestCode.BAD_TYPE) {
log.debug("{} does not support GetConfig, moving on", h.getSwitchInfoString());
try {
nextState(h);
return;
} catch (IOException e) {
log.error("Exception thrown transitioning to next", e);
logErrorDisconnect(h, m);
}
}
}
logErrorDisconnect(h, m);
}
示例11: getBadRequestErrorMessage
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
/** Return a bad request error message with the given xid/code */
private OFMessage getBadRequestErrorMessage(OFBadRequestCode code, long xid) {
OFErrorMsg msg = factory.errorMsgs().buildBadRequestErrorMsg()
.setXid(xid)
.setCode(code)
.build();
return msg;
}
示例12: testInitialMoveToSlaveNoRole
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
/** Move the channel from scratch to SLAVE state
* Builds on doMoveToWaitInitialRole()
* adds testing for WAIT_INITAL_ROLE state
*
* This method tests the case that the switch does NOT support roles.
* The channel handler still needs to send the initial request to find
* out that whether the switch supports roles.
*
*/
@Test
public void testInitialMoveToSlaveNoRole() throws Exception {
// first, move us to WAIT_INITIAL_ROLE_STATE
moveToWaitInitialRole();
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
// Set the role
long xid = setupSwitchSendRoleRequestAndVerify(null, OFControllerRole.ROLE_SLAVE);
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
// prepare mocks and inject the role reply message
reset(sw);
sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, false);
expectLastCall().once();
sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
expectLastCall().once();
sw.disconnect(); // Make sure we disconnect
expectLastCall().once();
replay(sw);
// FIXME: shouldn't use ordinal(), but OFError is broken
// Error with incorrect xid and type. Should be ignored.
OFMessage err = getBadActionErrorMessage(OFBadActionCode.BAD_TYPE, xid+1);
// sendMessageToHandler will verify and rest controller mock
switchHandler.processOFMessage(err);
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
// Error with correct xid. Should trigger state transition
err = getBadRequestErrorMessage(OFBadRequestCode.BAD_EXPERIMENTER, xid);
// sendMessageToHandler will verify and rest controller mock
switchHandler.processOFMessage(err);
}
示例13: getBadRequestErrorMessage
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
/** Return a bad request error message with the given xid/code */
private OFMessage getBadRequestErrorMessage(OFBadRequestCode code, long xid) {
OFErrorMsg msg = factory.errorMsgs().buildBadRequestErrorMsg()
.setXid(xid)
.setCode(code)
.build();
return msg;
}
示例14: testInitialMoveToSlaveNoRole
import org.projectfloodlight.openflow.protocol.OFBadRequestCode; //导入依赖的package包/类
/** Move the channel from scratch to SLAVE state
* Builds on doMoveToWaitInitialRole()
* adds testing for WAIT_INITAL_ROLE state
*
* This method tests the case that the switch does NOT support roles.
* The channel handler still needs to send the initial request to find
* out that whether the switch supports roles.
*
*/
@Test
public void testInitialMoveToSlaveNoRole() throws Exception {
// first, move us to WAIT_INITIAL_ROLE_STATE
moveToWaitInitialRole();
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
// Set the role
long xid = setupSwitchSendRoleRequestAndVerify(null, OFControllerRole.ROLE_SLAVE);
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
// prepare mocks and inject the role reply message
reset(sw);
sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, false);
expectLastCall().once();
sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
expectLastCall().once();
sw.disconnect(); // Make sure we disconnect
expectLastCall().once();
replay(sw);
// FIXME: shouldn't use ordinal(), but OFError is broken
// Error with incorrect xid and type. Should be ignored.
OFMessage err = getBadActionErrorMessage(OFBadActionCode.BAD_TYPE, xid+1);
// sendMessageToHandler will verify and rest controller mock
switchHandler.processOFMessage(err);
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
// Error with correct xid. Should trigger state transition
err = getBadRequestErrorMessage(OFBadRequestCode.BAD_EXPERIMENTER, xid);
// sendMessageToHandler will verify and rest controller mock
switchHandler.processOFMessage(err);
}