本文整理汇总了Java中org.openflow.protocol.OFError类的典型用法代码示例。如果您正苦于以下问题:Java OFError类的具体用法?Java OFError怎么用?Java OFError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFError类属于org.openflow.protocol包,在下文中一共展示了OFError类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logError
import org.openflow.protocol.OFError; //导入依赖的package包/类
/**
* Log an OpenFlow error message from a switch
* @param sw The switch that sent the error
* @param error The error message
*/
@LogMessageDoc(level="ERROR",
message="Error {error type} {error code} from {switch} " +
"in state {state}",
explanation="The switch responded with an unexpected error" +
"to an OpenFlow message from the controller",
recommendation="This could indicate improper network operation. " +
"If the problem persists restarting the switch and " +
"controller may help."
)
protected void logError(OFChannelHandler h, OFError error) {
log.error("{} from switch {} in state {}",
new Object[] {
getErrorString(error),
h.getSwitchInfoString(),
this.toString()});
}
示例2: testReassertMaster
import org.openflow.protocol.OFError; //导入依赖的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);
}
示例3: receive
import org.openflow.protocol.OFError; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
case FLOW_REMOVED:
return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
case ERROR:
log.info("received an error {} from switch {}", (OFError) msg, sw);
return Command.CONTINUE;
default:
break;
}
log.error("received an unexpected message {} from switch {}", msg, sw);
return Command.CONTINUE;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:17,代码来源:LearningSwitch.java
示例4: processOFError
import org.openflow.protocol.OFError; //导入依赖的package包/类
@Override
void processOFError(final SwitchChannelHandler h, final OFError m) {
try {
if (m.getOffendingMsg().getType() != OFType.BARRIER_REQUEST) {
h.log.error(
"Error waiting for features (type:{}, code:{})",
m.getErrorType(), m.getErrorCode());
if (h.channel.isOpen()) {
h.channel.close();
}
} else {
h.log.warn(
"Barrier Request message not understood by switch {}; "
+ "if it's an HP switch you are probably ok.",
HexString.toHexString(h.featuresReply
.getDatapathId()));
}
} catch (MessageParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例5: receive
import org.openflow.protocol.OFError; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, ListenerContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
case FLOW_REMOVED:
return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
case ERROR:
log.info("received an error {} from switch {}", (OFError) msg, sw);
return Command.CONTINUE;
default:
break;
}
log.error("received an unexpected message {} from switch {}", msg, sw);
return Command.CONTINUE;
}
示例6: handleErrorMessage
import org.openflow.protocol.OFError; //导入依赖的package包/类
protected void handleErrorMessage(OFError err, long dpid, int xid) {
short errorType = err.getErrorType();
short errorCode = err.getErrorCode();
if (errorType == OFError.OFErrorType.OFPET_BAD_REQUEST.getValue() &&
errorCode == (short)OFError.OFBadRequestCode.OFPBRC_EPERM.ordinal()) {
Set<Integer> xids = sentIPRequests.get(dpid);
if (xids != null && xids.contains(xid)) {
logger.warn("Switch {} not configured with tunnel-endpoint " +
"information (missing /etc/bsn_tunnel_interface file)",
HexString.toHexString(dpid));
xids.remove(xid);
return;
}
} else {
// ignoring all other error messages
}
}
示例7: testDeliverRoleRequestError
import org.openflow.protocol.OFError; //导入依赖的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());
}
示例8: testDeliverRoleRequestErrorNonePending
import org.openflow.protocol.OFError; //导入依赖的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());
}
示例9: testDeliverRoleRequestErrorWrongXid
import org.openflow.protocol.OFError; //导入依赖的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());
}
示例10: getStatusInternal
import org.openflow.protocol.OFError; //导入依赖的package包/类
/**
* Convert various result into Status
*
* @param result
* The returned result from previous action
* @param action
* add/modify/delete flow action
* @param rid
* The Request ID associated with the flow message
* @return Status
*/
private Status getStatusInternal(Object result, String action, long rid) {
if (result instanceof Boolean) {
return ((Boolean) result == Boolean.TRUE) ? new Status(
StatusCode.SUCCESS, rid) : new Status(
StatusCode.TIMEOUT, errorString(null, action,
"Request Timed Out"));
} else if (result instanceof Status) {
return (Status) result;
} else if (result instanceof OFError) {
OFError res = (OFError) result;
return new Status(StatusCode.INTERNALERROR, errorString(
"program", action, Utils.getOFErrorString(res)));
} else {
return new Status(StatusCode.INTERNALERROR, errorString(
"send", action, "Internal Error"));
}
}
示例11: processErrorReply
import org.openflow.protocol.OFError; //导入依赖的package包/类
private void processErrorReply(OFError errorMsg) {
OFMessage offendingMsg = errorMsg.getOffendingMsg();
Integer xid;
if (offendingMsg != null) {
xid = offendingMsg.getXid();
} else {
xid = errorMsg.getXid();
}
/*
* the error can be a reply to a synchronous message or to a statistic
* request message
*/
Callable<?> worker = messageWaitingDone.remove(xid);
if (worker == null) {
return;
}
if (worker instanceof SynchronousMessage) {
((SynchronousMessage) worker).wakeup(errorMsg);
} else {
((StatisticsCollector) worker).wakeup(errorMsg);
}
}
示例12: processOFError
import org.openflow.protocol.OFError; //导入依赖的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);
}
示例13: getErrorString
import org.openflow.protocol.OFError; //导入依赖的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;
}
示例14: getErrorMessage
import org.openflow.protocol.OFError; //导入依赖的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;
}