alshabib

removing log message doc craziness

......@@ -74,6 +74,10 @@ public class ReactiveForwarding {
@Override
public void process(PacketContext context) {
/*
* stop processing if the packet has been handled,
* we can't do any more to it
*/
if (context.isHandled()) {
return;
}
......
......@@ -20,7 +20,7 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
private final Logger log = getLogger(getClass());
private final AtomicBoolean free = new AtomicBoolean(true);
private boolean isBuilt = false;
private final AtomicBoolean isBuilt = new AtomicBoolean(false);
private final OpenFlowSwitch sw;
private final OFPacketIn pktin;
private OFPacketOut pktout = null;
......@@ -32,14 +32,14 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
@Override
public void send() {
if (block() && isBuilt) {
if (block() && isBuilt.get()) {
sw.sendMsg(pktout);
}
}
@Override
public synchronized void build(OFPort outPort) {
if (isBuilt) {
public void build(OFPort outPort) {
if (isBuilt.getAndSet(true)) {
return;
}
OFPacketOut.Builder builder = sw.factory().buildPacketOut();
......@@ -49,12 +49,11 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
.setBufferId(pktin.getBufferId())
.setActions(Collections.singletonList(act))
.build();
isBuilt = true;
}
@Override
public synchronized void build(Ethernet ethFrame, OFPort outPort) {
if (isBuilt) {
public void build(Ethernet ethFrame, OFPort outPort) {
if (isBuilt.getAndSet(true)) {
return;
}
OFPacketOut.Builder builder = sw.factory().buildPacketOut();
......@@ -65,7 +64,6 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
.setActions(Collections.singletonList(act))
.setData(ethFrame.serialize())
.build();
isBuilt = true;
}
@Override
......
......@@ -32,8 +32,6 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.onlab.onos.of.controller.Dpid;
import org.onlab.onos.of.controller.driver.OpenFlowAgent;
import org.onlab.onos.of.controller.driver.OpenFlowSwitchDriver;
import org.onlab.onos.of.controller.impl.annotations.LogMessageDoc;
import org.onlab.onos.of.controller.impl.annotations.LogMessageDocs;
import org.onlab.onos.of.drivers.impl.DriverManager;
import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
import org.projectfloodlight.openflow.protocol.OFFactories;
......@@ -119,19 +117,6 @@ public class Controller {
/**
* Tell controller that we're ready to accept switches loop.
*/
@LogMessageDocs({
@LogMessageDoc(message = "Listening for switch connections on {address}",
explanation = "The controller is ready and listening for new" +
" switch connections"),
@LogMessageDoc(message = "Storage exception in controller " +
"updates loop; terminating process",
explanation = ERROR_DATABASE,
recommendation = LogMessageDoc.CHECK_CONTROLLER),
@LogMessageDoc(level = "ERROR",
message = "Exception in controller updates loop",
explanation = "Failed to dispatch controller event",
recommendation = LogMessageDoc.GENERIC_ACTION)
})
public void run() {
try {
......
......@@ -17,11 +17,8 @@ import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
import org.jboss.netty.handler.timeout.IdleStateEvent;
import org.jboss.netty.handler.timeout.ReadTimeoutException;
import org.onlab.onos.of.controller.RoleState;
import org.onlab.onos.of.controller.driver.OpenFlowSwitchDriver;
import org.onlab.onos.of.controller.driver.SwitchStateException;
import org.onlab.onos.of.controller.impl.annotations.LogMessageDoc;
import org.onlab.onos.of.controller.impl.annotations.LogMessageDocs;
import org.projectfloodlight.openflow.exceptions.OFParseError;
import org.projectfloodlight.openflow.protocol.OFAsyncGetReply;
import org.projectfloodlight.openflow.protocol.OFBadRequestCode;
......@@ -75,9 +72,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
// needs to check if the handshake is complete
private volatile ChannelState state;
// Used to coordinate between the controller and the cleanup thread(?)
// for access to the global registry on a per switch basis.
volatile Boolean controlRequested;
// When a switch with a duplicate dpid is found (i.e we already have a
// connected switch with the same dpid), the new switch is immediately
// disconnected. At that point netty callsback channelDisconnected() which
......@@ -113,7 +107,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
this.pendingPortStatusMsg = new CopyOnWriteArrayList<OFPortStatus>();
factory13 = controller.getOFMessageFactory13();
factory10 = controller.getOFMessageFactory10();
controlRequested = Boolean.FALSE;
duplicateDpidFound = Boolean.FALSE;
}
......@@ -316,16 +309,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
*/
WAIT_CONFIG_REPLY(false) {
@Override
@LogMessageDocs({
@LogMessageDoc(level = "WARN",
message = "Config Reply from {switch} has "
+ "miss length set to {length}",
explanation = "The controller requires that the switch "
+ "use a miss length of 0xffff for correct "
+ "function",
recommendation = "Use a different switch to ensure "
+ "correct function")
})
void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m)
throws IOException {
if (m.getMissSendLen() == 0xffff) {
......@@ -395,11 +378,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
* All following states will have a h.sw instance!
*/
WAIT_DESCRIPTION_STAT_REPLY(false) {
@LogMessageDoc(message = "Switch {switch info} bound to class "
+ "{switch driver}, description {switch description}",
explanation = "The specified switch has been bound to "
+ "a switch driver based on the switch description"
+ "received from the switch")
@Override
void processOFStatisticsReply(OFChannelHandler h, OFStatsReply m)
throws SwitchStateException {
......@@ -528,15 +506,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
* SLAVE.
*/
ACTIVE(true) {
@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 {
......@@ -685,15 +654,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
* @param h 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, OFErrorMsg error) {
log.error("{} from switch {} in state {}",
new Object[] {
......@@ -1003,9 +963,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
//*************************
@Override
@LogMessageDoc(message = "New switch connection from {ip address}",
explanation = "A new switch has connected from the "
+ "specified IP address")
public void channelConnected(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
channel = e.getChannel();
......@@ -1016,8 +973,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
}
@Override
@LogMessageDoc(message = "Disconnected switch {switch information}",
explanation = "The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
log.info("Switch disconnected callback for sw:{}. Cleaning up ...",
......@@ -1044,47 +999,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
}
@Override
@LogMessageDocs({
@LogMessageDoc(level = "ERROR",
message = "Disconnecting switch {switch} due to read timeout",
explanation = "The connected switch has failed to send any "
+ "messages or respond to echo requests",
recommendation = LogMessageDoc.CHECK_SWITCH),
@LogMessageDoc(level = "ERROR",
message = "Disconnecting switch {switch}: failed to "
+ "complete handshake",
explanation = "The switch did not respond correctly "
+ "to handshake messages",
recommendation = LogMessageDoc.CHECK_SWITCH),
@LogMessageDoc(level = "ERROR",
message = "Disconnecting switch {switch} due to IO Error: {}",
explanation = "There was an error communicating with the switch",
recommendation = LogMessageDoc.CHECK_SWITCH),
@LogMessageDoc(level = "ERROR",
message = "Disconnecting switch {switch} due to switch "
+ "state error: {error}",
explanation = "The switch sent an unexpected message",
recommendation = LogMessageDoc.CHECK_SWITCH),
@LogMessageDoc(level = "ERROR",
message = "Disconnecting switch {switch} due to "
+ "message parse failure",
explanation = "Could not parse a message from the switch",
recommendation = LogMessageDoc.CHECK_SWITCH),
@LogMessageDoc(level = "ERROR",
message = "Terminating controller due to storage exception",
explanation = Controller.ERROR_DATABASE,
recommendation = LogMessageDoc.CHECK_CONTROLLER),
@LogMessageDoc(level = "ERROR",
message = "Could not process message: queue full",
explanation = "OpenFlow messages are arriving faster than "
+ "the controller can process them.",
recommendation = LogMessageDoc.CHECK_CONTROLLER),
@LogMessageDoc(level = "ERROR",
message = "Error while processing message "
+ "from switch {switch} {cause}",
explanation = "An error occurred processing the switch message",
recommendation = LogMessageDoc.GENERIC_ACTION)
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
if (e.getCause() instanceof ReadTimeoutException) {
......@@ -1248,10 +1162,6 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
channel.write(Collections.singletonList(m));
}
private void setSwitchRole(RoleState role) {
sw.setRole(role);
}
/**
* Send the configuration requests to tell the switch we want full
* packets.
......
/**
* Copyright 2012, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package org.onlab.onos.of.controller.impl.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Annotation used to set the category for log messages for a class.
*
*/
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface LogMessageCategory {
/**
* The category for the log messages for this class.
*
* @return category
*/
String value() default "Core";
}
/**
* Copyright 2012, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package org.onlab.onos.of.controller.impl.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Annotation used to document log messages. This can be used to generate
* documentation on syslog output.
*
*/
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface LogMessageDoc {
public static final String NO_ACTION = "No action is required.";
public static final String UNKNOWN_ERROR = "An unknown error occured";
public static final String GENERIC_ACTION =
"Examine the returned error or exception and take " +
"appropriate action.";
public static final String CHECK_SWITCH =
"Check the health of the indicated switch. " +
"Test and troubleshoot IP connectivity.";
public static final String CHECK_CONTROLLER =
"Verify controller system health, CPU usage, and memory. " +
"Rebooting the controller node may help if the controller " +
"node is in a distressed state.";
public static final String REPORT_CONTROLLER_BUG =
"This is likely a defect in the controller. Please report this " +
"issue. Restarting the controller or switch may help to " +
"alleviate.";
public static final String REPORT_SWITCH_BUG =
"This is likely a defect in the switch. Please report this " +
"issue. Restarting the controller or switch may help to " +
"alleviate.";
/**
* The log level for the log message.
*
* @return the log level as a tring
*/
String level() default "INFO";
/**
* The message that will be printed.
*
* @return the message
*/
String message() default UNKNOWN_ERROR;
/**
* An explanation of the meaning of the log message.
*
* @return the explanation
*/
String explanation() default UNKNOWN_ERROR;
/**
* The recommendated action associated with the log message.
*
* @return the recommendation
*/
String recommendation() default NO_ACTION;
}
/**
* Copyright 2012, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package org.onlab.onos.of.controller.impl.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Annotation used to document log messages. This can be used to generate
* documentation on syslog output. This version allows multiple log messages
* to be documentated on an interface.
*
*/
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface LogMessageDocs {
/**
* A list of {@link LogMessageDoc} elements.
*
* @return the list of log message doc
*/
LogMessageDoc[] value();
}
/**
* Controller logging annotations - do be deprecated.
*/
package org.onlab.onos.of.controller.impl.annotations;
......@@ -87,7 +87,8 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr
pktCtx.parsed(), ByteBuffer.wrap(pktCtx.unparsed()));
OpenFlowCorePacketContext corePktCtx =
new OpenFlowCorePacketContext(0, inPkt, null, pktCtx.isHandled(), pktCtx);
new OpenFlowCorePacketContext(System.currentTimeMillis(),
inPkt, null, pktCtx.isHandled(), pktCtx);
providerService.processPacket(corePktCtx);
}
......