本文整理汇总了Java中org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg类的典型用法代码示例。如果您正苦于以下问题:Java OFBadRequestErrorMsg类的具体用法?Java OFBadRequestErrorMsg怎么用?Java OFBadRequestErrorMsg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFBadRequestErrorMsg类属于org.projectfloodlight.openflow.protocol.errormsg包,在下文中一共展示了OFBadRequestErrorMsg类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOFError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的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.errormsg.OFBadRequestErrorMsg; //导入依赖的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: processOFError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的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);
}
}
示例4: processOFError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的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);
}
示例5: processOFError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的package包/类
@LogMessageDoc(level="WARN",
message="Received permission error from switch {} while" +
"being master. Reasserting master role.",
explanation="The switch has denied an operation likely " +
"indicating inconsistent controller roles",
recommendation="This situation can occurs transiently during role" +
" changes. If, however, the condition persists or happens" +
" frequently this indicates a role inconsistency. " +
LogMessageDoc.CHECK_CONTROLLER )
@Override
void processOFError(OFErrorMsg m) {
// role changer will ignore the error if it isn't for it
boolean didHandle = roleChanger.deliverError(m);
if (didHandle)
return;
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
switchManagerCounters.epermErrorWhileSwitchIsMaster.increment();
log.warn("Received permission error from switch {} while" +
"being master. Reasserting master role.",
getSwitchInfoString());
reassertRole(OFControllerRole.ROLE_MASTER);
}
else if ((m.getErrType() == OFErrorType.FLOW_MOD_FAILED) &&
(((OFFlowModFailedErrorMsg)m).getCode() == OFFlowModFailedCode.ALL_TABLES_FULL)) {
sw.setTableFull(true);
}
else {
logError(m);
}
dispatchMessage(m);
}
示例6: processControllerCommand
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的package包/类
@Override
public void processControllerCommand(Channel channel, OFMessage msg) {
OFControllerRole myRole = role(channel);
if (OFControllerRole.ROLE_SLAVE.equals(myRole)) {
OFBadRequestErrorMsg errorMsg = FACTORY.errorMsgs()
.buildBadRequestErrorMsg()
.setXid(msg.getXid())
.setCode(OFBadRequestCode.IS_SLAVE)
.build();
channel.writeAndFlush(Collections.singletonList(errorMsg));
return;
}
switch (msg.getType()) {
case PORT_MOD:
OFPortMod portMod = (OFPortMod) msg;
processPortMod(portMod);
break;
case FLOW_MOD:
OFFlowMod flowMod = (OFFlowMod) msg;
processFlowMod(flowMod);
break;
case GROUP_MOD:
OFGroupMod groupMod = (OFGroupMod) msg;
processGroupMod(groupMod);
break;
case METER_MOD:
OFMeterMod meterMod = (OFMeterMod) msg;
processMeterMod(meterMod, channel);
break;
case TABLE_MOD:
log.debug("processControllerCommand: {} not yet supported for {}",
msg.getType(), msg);
break;
default:
log.warn("Unexpected message {} received for switch {}",
msg.getType(), this);
}
}
示例7: deliverError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的package包/类
/**
* Called if we receive an error message. If the xid matches the
* pending request we handle it otherwise we ignore it.
*
* Note: since we only keep the last pending request we might get
* error messages for earlier role requests that we won't be able
* to handle
*/
@Override
public synchronized RoleRecvStatus deliverError(OFErrorMsg error)
throws SwitchStateException {
RoleState errorRole = pendingReplies.getIfPresent(error.getXid());
if (errorRole == null) {
if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
log.debug("Received an error msg from sw {} for a role request,"
+ " but not for pending request in role-changer; "
+ " ignoring error {} ...",
sw.getStringId(), error);
} else {
log.debug("Received an error msg from sw {}, but no pending "
+ "requests in role-changer; not handling ...",
sw.getStringId());
}
return RoleRecvStatus.OTHER_EXPECTATION;
}
// it is an error related to a currently pending role request message
if (error.getErrType() == OFErrorType.BAD_REQUEST) {
log.error("Received a error msg {} from sw {} for "
+ "pending role request {}. Switch driver indicates "
+ "role-messaging is supported. Possible issues in "
+ "switch driver configuration?",
((OFBadRequestErrorMsg) error).toString(),
sw.getStringId(),
errorRole);
return RoleRecvStatus.UNSUPPORTED;
}
if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
OFRoleRequestFailedErrorMsg rrerr =
(OFRoleRequestFailedErrorMsg) error;
switch (rrerr.getCode()) {
case BAD_ROLE:
// switch says that current-role-req has bad role?
// for now we disconnect
// fall-thru
case STALE:
// switch says that current-role-req has stale gen-id?
// for now we disconnect
// fall-thru
case UNSUP:
// switch says that current-role-req has role that
// cannot be supported? for now we disconnect
String msgx = String.format("Switch: [%s], "
+ "received Error to for pending role request [%s]. "
+ "Error:[%s]. Disconnecting switch ... ",
sw.getStringId(),
errorRole, rrerr);
throw new SwitchStateException(msgx);
default:
break;
}
}
// This error message was for a role request message but we dont know
// how to handle errors for nicira role request messages
return RoleRecvStatus.OTHER_EXPECTATION;
}
示例8: deliverError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的package包/类
/**
* Called if we receive an error message. If the xid matches the
* pending request we handle it otherwise we ignore it.
*
* Note: since we only keep the last pending request we might get
* error messages for earlier role requests that we won't be able
* to handle
*/
@Override
public synchronized RoleRecvStatus deliverError(OFErrorMsg error)
throws SwitchStateException {
RoleState errorRole = pendingReplies.getIfPresent(error.getXid());
if (errorRole == null) {
if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
log.debug("Received an error msg from sw {} for a role request,"
+ " but not for pending request in role-changer; "
+ " ignoring error {} ...",
sw.getStringId(), error);
} else {
log.debug("Received an error msg from sw {}, but no pending "
+ "requests in role-changer; not handling ...",
sw.getStringId());
}
return RoleRecvStatus.OTHER_EXPECTATION;
}
// it is an error related to a currently pending role request message
if (error.getErrType() == OFErrorType.BAD_REQUEST) {
log.error("Received a error msg {} from sw {} for "
+ "pending role request {}. Switch driver indicates "
+ "role-messaging is supported. Possible issues in "
+ "switch driver configuration?", new Object[] {
((OFBadRequestErrorMsg) error).toString(),
sw.getStringId(), errorRole
});
return RoleRecvStatus.UNSUPPORTED;
}
if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
OFRoleRequestFailedErrorMsg rrerr =
(OFRoleRequestFailedErrorMsg) error;
switch (rrerr.getCode()) {
case BAD_ROLE:
// switch says that current-role-req has bad role?
// for now we disconnect
// fall-thru
case STALE:
// switch says that current-role-req has stale gen-id?
// for now we disconnect
// fall-thru
case UNSUP:
// switch says that current-role-req has role that
// cannot be supported? for now we disconnect
String msgx = String.format("Switch: [%s], "
+ "received Error to for pending role request [%s]. "
+ "Error:[%s]. Disconnecting switch ... ",
sw.getStringId(),
errorRole, rrerr);
throw new SwitchStateException(msgx);
default:
break;
}
}
// This error message was for a role request message but we dont know
// how to handle errors for nicira role request messages
return RoleRecvStatus.OTHER_EXPECTATION;
}
示例9: deliverError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的package包/类
/**
* Called if we receive an error message. If the xid matches the pending
* request we handle it otherwise we ignore it.
*
* Note: since we only keep the last pending request we might get error
* messages for earlier role requests that we won't be able to handle
*/
synchronized RoleRecvStatus deliverError(OFErrorMsg error)
throws SwitchStateException {
if (!requestPending) {
log.debug("Received an error msg from sw {}, but no pending "
+ "requests in role-changer; not handling ...",
getSwitchInfoString());
return RoleRecvStatus.OTHER_EXPECTATION;
}
if (pendingXid != error.getXid()) {
if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
log.debug("Received an error msg from sw {} for a role request,"
+ " but not for pending request in role-changer; "
+ " ignoring error {} ...",
getSwitchInfoString(), error);
}
return RoleRecvStatus.OTHER_EXPECTATION;
}
// it is an error related to a currently pending role request
// message
requestPending = false; // we got a response, even though it is an
// error
if (error.getErrType() == OFErrorType.BAD_REQUEST) {
counters.roleReplyErrorUnsupported.updateCounterWithFlush();
log.error("Received a error msg {} from sw {} in state {} for "
+ "pending role request {}. Switch driver indicates "
+ "role-messaging is supported. Possible issues in "
+ "switch driver configuration?", new Object[] {
((OFBadRequestErrorMsg) error).toString(),
getSwitchInfoString(), state, pendingRole
});
return RoleRecvStatus.UNSUPPORTED;
}
if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
OFRoleRequestFailedErrorMsg rrerr =
(OFRoleRequestFailedErrorMsg) error;
switch (rrerr.getCode()) {
case BAD_ROLE:
// switch says that current-role-req has bad role?
// for now we disconnect
// fall-thru
case STALE:
// switch says that current-role-req has stale gen-id?
// for now we disconnect
// fall-thru
case UNSUP:
// switch says that current-role-req has role that
// cannot be supported? for now we disconnect
String msgx = String.format("Switch: [%s], State: [%s], "
+ "received Error to for pending role request [%s]. "
+ "Error:[%s]. Disconnecting switch ... ",
OFChannelHandler.this.getSwitchInfoString(),
OFChannelHandler.this.state.toString(),
pendingRole, rrerr);
throw new SwitchStateException(msgx);
default:
break;
}
}
// This error message was for a role request message but we dont
// know
// how to handle errors for nicira role request messages
return RoleRecvStatus.OTHER_EXPECTATION;
}
示例10: processOFError
import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; //导入依赖的package包/类
@LogMessageDoc(level = "WARN",
message = "Received permission error from switch {} while" +
"being master. Reasserting master role.",
explanation = "The switch has denied an operation likely " +
"indicating inconsistent controller roles",
recommendation = "This situation can occurs transiently during role" +
" changes. If, however, the condition persists or happens" +
" frequently this indicates a role inconsistency. " +
LogMessageDoc.CHECK_CONTROLLER)
@Override
void processOFError(OFChannelHandler h, OFErrorMsg m)
throws IOException, SwitchStateException {
// first check if the error msg is in response to a role-request
// message
RoleRecvStatus rrstatus = h.roleChanger.deliverError(m);
if (rrstatus != RoleRecvStatus.OTHER_EXPECTATION) {
// rolechanger has handled the error message - we are done
return;
}
// 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.counters.epermErrorWhileSwitchIsMaster.updateCounterWithFlush();
log.warn("Received permission error from switch {} while" +
"being master. Reasserting master role.",
h.getSwitchInfoString());
// h.controller.reassertRole(h, Role.MASTER);
// XXX S reassert in role changer or reconsider if all this
// stuff is really needed
} 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);
}