From c45051bb8bcef52a848166674d695b42d6591634 Mon Sep 17 00:00:00 2001 From: Saurav Das <saurav.das@bigswitch.com> Date: Sun, 2 Jun 2013 12:17:16 -0700 Subject: [PATCH] More code cleanup, better exception handling, use of package names as counter namespace, moving counter registration to init() methods, and use of metadata constants --- .../floodlightcontroller/core/IOFSwitch.java | 7 +- .../core/OFSwitchBase.java | 23 +++-- .../core/internal/Controller.java | 85 +++++++++++------- .../debugcounter/DebugCounter.java | 26 +++--- .../debugcounter/IDebugCounterService.java | 45 ++++++++-- .../debugcounter/NullDebugCounter.java | 17 ++-- .../debugevent/DebugEvent.java | 6 +- .../internal/DeviceManagerImpl.java | 89 +++++++++---------- .../internal/LinkDiscoveryManager.java | 28 +++--- .../topology/TopologyManager.java | 14 +-- .../sync/internal/SyncManager.java | 50 ++++++----- .../devicemanager/test/MockDeviceManager.java | 2 +- 12 files changed, 234 insertions(+), 158 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java index 112f30c8d..593bf0f8a 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.concurrent.Future; import net.floodlightcontroller.core.IFloodlightProviderService.Role; import net.floodlightcontroller.core.internal.Controller; +import net.floodlightcontroller.core.module.FloodlightModuleException; import net.floodlightcontroller.debugcounter.IDebugCounterService; import net.floodlightcontroller.threadpool.IThreadPoolService; import net.floodlightcontroller.util.OrderedCollection; @@ -62,7 +63,7 @@ public interface IOFSwitch { MANAGEMENT("management"), // for in-band management TUNNEL_LOOPBACK("tunnel-loopback"); - private String value; + private final String value; OFPortType(String v) { value = v; } @@ -159,8 +160,10 @@ public interface IOFSwitch { * Set debug counter service for per-switch counters * Called immediately after instantiation * @param debugCounters + * @throws FloodlightModuleException */ - public void setDebugCounterService(IDebugCounterService debugCounters); + public void setDebugCounterService(IDebugCounterService debugCounters) + throws FloodlightModuleException; /** * Set the netty Channel this switch instance is associated with diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java index 5c9dee0aa..ccf8b4961 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java @@ -40,10 +40,12 @@ import net.floodlightcontroller.core.annotations.LogMessageDocs; import net.floodlightcontroller.core.internal.Controller; import net.floodlightcontroller.core.internal.OFFeaturesReplyFuture; import net.floodlightcontroller.core.internal.OFStatisticsFuture; +import net.floodlightcontroller.core.module.FloodlightModuleException; import net.floodlightcontroller.core.util.AppCookie; import net.floodlightcontroller.core.web.serializers.DPIDSerializer; import net.floodlightcontroller.debugcounter.IDebugCounter; import net.floodlightcontroller.debugcounter.IDebugCounterService; +import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException; import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterType; import net.floodlightcontroller.debugcounter.NullDebugCounter; import net.floodlightcontroller.devicemanager.SwitchPort; @@ -147,6 +149,8 @@ public abstract class OFSwitchBase implements IOFSwitch { private IDebugCounter ctrSwitch, ctrSwitchPktin, ctrSwitchWrite; private IDebugCounter ctrSwitchPktinDrops, ctrSwitchWriteDrops; + private static final String PACKAGE = OFSwitchBase.class.getPackage().getName(); + protected final static ThreadLocal<Map<IOFSwitch,List<OFMessage>>> local_msg_buffer = new ThreadLocal<Map<IOFSwitch,List<OFMessage>>>() { @@ -1056,7 +1060,8 @@ public abstract class OFSwitchBase implements IOFSwitch { @Override @JsonIgnore - public void setDebugCounterService(IDebugCounterService debugCounters) { + public void setDebugCounterService(IDebugCounterService debugCounters) + throws FloodlightModuleException { this.debugCounters = debugCounters; registerOverloadCounters(); } @@ -1388,7 +1393,7 @@ public abstract class OFSwitchBase implements IOFSwitch { currentRate, this); } - private void registerOverloadCounters() { + private void registerOverloadCounters() throws FloodlightModuleException { if (debugCountersRegistered) { return; } @@ -1401,27 +1406,27 @@ public abstract class OFSwitchBase implements IOFSwitch { // every level of the hierarchical counter has to be registered // even if they are not used ctrSwitch = debugCounters.registerCounter( - "switch", stringId, + PACKAGE , stringId, "Counter for this switch", CounterType.ALWAYS_COUNT); ctrSwitchPktin = debugCounters.registerCounter( - "switch", stringId + "/pktin", + PACKAGE, stringId + "/pktin", "Packet in counter for this switch", CounterType.ALWAYS_COUNT); ctrSwitchWrite = debugCounters.registerCounter( - "switch", stringId + "/write", + PACKAGE, stringId + "/write", "Write counter for this switch", CounterType.ALWAYS_COUNT); ctrSwitchPktinDrops = debugCounters.registerCounter( - "switch", stringId + "/pktin/drops", + PACKAGE, stringId + "/pktin/drops", "Packet in throttle drop count", CounterType.ALWAYS_COUNT); ctrSwitchWriteDrops = debugCounters.registerCounter( - "switch", stringId + "/write/drops", + PACKAGE, stringId + "/write/drops", "Switch write throttle drop count", CounterType.ALWAYS_COUNT); - } catch (Exception e) { - e.printStackTrace(); + } catch (CounterException e) { + throw new FloodlightModuleException(e.getMessage()); } } diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 866148d03..827cfdb40 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -72,6 +72,7 @@ import net.floodlightcontroller.core.web.CoreWebRoutable; import net.floodlightcontroller.counter.ICounterStoreService; import net.floodlightcontroller.debugcounter.IDebugCounter; import net.floodlightcontroller.debugcounter.IDebugCounterService; +import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException; import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterType; import net.floodlightcontroller.debugevent.IDebugEventService; import net.floodlightcontroller.debugevent.IDebugEventService.EventColumn; @@ -250,7 +251,7 @@ public class Controller implements IFloodlightProviderService, protected final LoadMonitor loadmonitor = new LoadMonitor(log); public static class Counters { - public static final String prefix = "controller"; + public static final String prefix = Controller.class.getPackage().getName(); public IDebugCounter setRoleEqual; public IDebugCounter setSameRole; public IDebugCounter setRoleMaster; @@ -298,10 +299,7 @@ public class Controller implements IFloodlightProviderService, public IDebugCounter roleReplyReceived; // expected RoleReply received public IDebugCounter roleReplyErrorUnsupported; - private static final String WARN = "warn"; - private static final String ERROR = "error"; - - void createCounters(IDebugCounterService debugCounters) throws Exception { + void createCounters(IDebugCounterService debugCounters) throws CounterException { setRoleEqual = debugCounters.registerCounter( prefix, "setRoleEqual", @@ -313,7 +311,8 @@ public class Controller implements IFloodlightProviderService, prefix, "setSameRole", "Controller received a role request for the same " + "role the controller already had", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); setRoleMaster = debugCounters.registerCounter( @@ -335,7 +334,8 @@ public class Controller implements IFloodlightProviderService, "Received an unexpected ports changed " + "notification while the controller was in " + "SLAVE role.", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); invalidSwitchActivatedWhileSlave = debugCounters.registerCounter( @@ -343,7 +343,8 @@ public class Controller implements IFloodlightProviderService, "Received an unexpected switchActivated " + "notification while the controller was in " + "SLAVE role.", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); invalidStoreEventWhileMaster = debugCounters.registerCounter( @@ -351,14 +352,16 @@ public class Controller implements IFloodlightProviderService, "Received an unexpected notification from " + "the sync store while the controller was in " + "MASTER role.", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); switchDisconnectedWhileSlave = debugCounters.registerCounter( prefix, "switchDisconnectedWhileSlave", "A switch disconnected and the controller was " + "in SLAVE role.", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); switchActivated = debugCounters.registerCounter( @@ -373,7 +376,9 @@ public class Controller implements IFloodlightProviderService, "A switch that was already in active state " + "was activated again. This indicates a " + "controller defect", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); + switchWithSameDpidActivated = // warn debugCounters.registerCounter( prefix, "switchWithSameDpidActivated", @@ -382,7 +387,8 @@ public class Controller implements IFloodlightProviderService, "caused by multiple switches configured with " + "the same DPID or by a switch reconnecting very " + "quickly.", - CounterType.COUNT_ON_DEMAND, WARN); + CounterType.COUNT_ON_DEMAND, + IDebugCounterService.CTR_MDATA_WARN); newSwitchActivated = // new switch debugCounters.registerCounter( @@ -441,6 +447,7 @@ public class Controller implements IFloodlightProviderService, "cluster. This controller instance has " + "received a notification for it", CounterType.ALWAYS_COUNT); + unknownSwitchRemovedFromStore = debugCounters.registerCounter( prefix, "unknownSwitchRemovedFromStore", @@ -449,7 +456,9 @@ public class Controller implements IFloodlightProviderService, "disconnected but this controller instance " + "did not have the any information about the " + "switch", // might be less than warning - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); + consolidateStoreRunCount = debugCounters.registerCounter( prefix, "consolidateStoreRunCount", @@ -459,6 +468,7 @@ public class Controller implements IFloodlightProviderService, "reconciled switch entries in the sync store " + "with live state", CounterType.ALWAYS_COUNT); + consolidateStoreInconsistencies = debugCounters.registerCounter( prefix, "consolidateStoreInconsistencies", @@ -480,7 +490,8 @@ public class Controller implements IFloodlightProviderService, "Number of times a sync store operation failed " + "due to a store sync exception or an entry in " + "in the store had invalid data.", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); switchesNotReconnectingToNewMaster = debugCounters.registerCounter( @@ -490,6 +501,7 @@ public class Controller implements IFloodlightProviderService, "did not reconnect to this controller after it " + "transitioned to MASTER", // might be less than warning CounterType.ALWAYS_COUNT); + switchPortChanged = debugCounters.registerCounter( prefix, "switchPortChanged", @@ -510,6 +522,7 @@ public class Controller implements IFloodlightProviderService, "controller was in SLAVE role and the message " + "was not dispatched", CounterType.ALWAYS_COUNT); + dispatchMessage = // does this cnt make sense? more specific?? per type? count stops? debugCounters.registerCounter( prefix, "dispatchMessage", @@ -536,7 +549,8 @@ public class Controller implements IFloodlightProviderService, prefix, "messageInputThrottled", "Number of OpenFlow messages that were " + "throttled due to high load from the sender", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); // TODO: more counters in messageReceived ?? switchDisconnectReadTimeout = @@ -545,27 +559,31 @@ public class Controller implements IFloodlightProviderService, "Number of times a switch was disconnected due " + "due the switch failing to send OpenFlow " + "messages or responding to OpenFlow ECHOs", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); switchDisconnectHandshakeTimeout = debugCounters.registerCounter( prefix, "switchDisconnectHandshakeTimeout", "Number of times a switch was disconnected " + "because it failed to complete the handshake " + "in time.", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); switchDisconnectIOError = debugCounters.registerCounter( prefix, "switchDisconnectIOError", "Number of times a switch was disconnected " + "due to IO errors on the switch connection.", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); switchDisconnectParseError = debugCounters.registerCounter( prefix, "switchDisconnectParseError", "Number of times a switch was disconnected " + "because it sent an invalid packet that could " + "not be parsed", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); switchDisconnectSwitchStateException = debugCounters.registerCounter( @@ -573,12 +591,14 @@ public class Controller implements IFloodlightProviderService, "Number of times a switch was disconnected " + "because it sent messages that were invalid " + "given the switch connection's state.", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); rejectedExecutionException = debugCounters.registerCounter( prefix, "rejectedExecutionException", "TODO", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); switchDisconnectOtherException = debugCounters.registerCounter( @@ -586,7 +606,8 @@ public class Controller implements IFloodlightProviderService, "Number of times a switch was disconnected " + "due to an exceptional situation not covered " + "by other counters", - CounterType.ALWAYS_COUNT, ERROR); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_ERROR); switchConnected = debugCounters.registerCounter( @@ -602,7 +623,8 @@ public class Controller implements IFloodlightProviderService, "received that the controller ignored because " + "it was inapproriate given the switch " + "connection's state.", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); // might be less than warning packetInWhileSwitchIsSlave = @@ -618,7 +640,8 @@ public class Controller implements IFloodlightProviderService, "Number of times a permission error was " + "received while the switch was in MASTER role. " + "Possibly inidicates inconsistent roles.", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); roleNotResentBecauseRolePending = debugCounters.registerCounter( @@ -638,13 +661,16 @@ public class Controller implements IFloodlightProviderService, prefix, "roleReplyTimeout", "Number of times a role request message did not " + "receive the expected reply from a switch", - CounterType.ALWAYS_COUNT, WARN); + CounterType.ALWAYS_COUNT, + IDebugCounterService.CTR_MDATA_WARN); + roleReplyReceived = // expected RoleReply received debugCounters.registerCounter( prefix, "roleReplyReceived", "Number of times the controller received the " + "expected role reply message from a switch", CounterType.ALWAYS_COUNT); + roleReplyErrorUnsupported = debugCounters.registerCounter( prefix, "roleReplyErrorUnsupported", @@ -2289,8 +2315,8 @@ public class Controller implements IFloodlightProviderService, try { this.counters.createCounters(debugCounters); - } catch (Exception e) { - e.printStackTrace(); + } catch (CounterException e) { + throw new FloodlightModuleException(e.getMessage()); } registerControllerDebugEvents(); @@ -2337,10 +2363,9 @@ public class Controller implements IFloodlightProviderService, } - private void registerControllerDebugEvents() { + private void registerControllerDebugEvents() throws FloodlightModuleException { if (debugEvents == null) { debugEvents = new NullDebugEvent(); - return; } try { evSwitch = debugEvents.registerEvent( @@ -2348,7 +2373,7 @@ public class Controller implements IFloodlightProviderService, "Switch connected, disconnected or port changed", EventType.ALWAYS_LOG, SwitchEvent.class, 100); } catch (MaxEventsRegistered e) { - e.printStackTrace(); + throw new FloodlightModuleException("Max events registered", e); } } diff --git a/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java b/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java index 7577d32c5..754323d0a 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/DebugCounter.java @@ -61,11 +61,11 @@ public class DebugCounter implements IFloodlightModule, IDebugCounterService { String counterHierarchy; int counterId; boolean enabled; - Object[] metaData; + String[] metaData; public CounterInfo(int counterId, boolean enabled, String moduleName, String counterHierarchy, - String desc, CounterType ctype, Object... metaData) { + String desc, CounterType ctype, String... metaData) { this.moduleCounterHierarchy = moduleName + "/" + counterHierarchy; this.moduleName = moduleName; this.counterHierarchy = counterHierarchy; @@ -83,7 +83,7 @@ public class DebugCounter implements IFloodlightModule, IDebugCounterService { public String getCounterHierarchy() { return counterHierarchy; } public int getCounterId() { return counterId; } public boolean isEnabled() { return enabled; } - public Object[] getMetaData() { return metaData; } + public String[] getMetaData() { return metaData; } } //****************** @@ -239,7 +239,7 @@ public class DebugCounter implements IFloodlightModule, IDebugCounterService { @Override public IDebugCounter registerCounter(String moduleName, String counterHierarchy, String counterDescription, CounterType counterType, - Object... metaData) + String... metaData) throws MaxCountersRegistered, MaxHierarchyRegistered, MissingHierarchicalLevel { // check if counter already exists @@ -257,25 +257,25 @@ public class DebugCounter implements IFloodlightModule, IDebugCounterService { } // check for validity of counter if (rci.levels.length > MAX_HIERARCHY) { - log.error("Registry of counterHierarchy {} exceeds max hierachy {}.. aborting", - counterHierarchy, MAX_HIERARCHY); - throw new MaxHierarchyRegistered(); + String err = "Registry of counterHierarchy " + counterHierarchy + + " exceeds max hierachy " + MAX_HIERARCHY + ".. aborting"; + throw new MaxHierarchyRegistered(err); } if (rci.foundUptoLevel < rci.levels.length-1) { String needToRegister = ""; for (int i=0; i<=rci.foundUptoLevel; i++) { needToRegister += rci.levels[i]; } - log.error("Attempting to register hierarchical counterHierarchy {}, "+ - "but parts of hierarchy missing. Please register {} first ", - counterHierarchy, needToRegister); - throw new MissingHierarchicalLevel(); + String err = "Attempting to register hierarchical counterHierarchy " + + counterHierarchy + " but parts of hierarchy missing. " + + "Please register " + needToRegister + " first"; + throw new MissingHierarchicalLevel(err); } // get a new counter id int counterId = counterIdCounter.getAndIncrement(); if (counterId >= MAX_COUNTERS) { - throw new MaxCountersRegistered(); + throw new MaxCountersRegistered("max counters reached"); } // create storage for counter boolean enabled = (counterType == CounterType.ALWAYS_COUNT) ? true : false; @@ -457,7 +457,7 @@ public class DebugCounter implements IFloodlightModule, IDebugCounterService { if (!rci.allLevelsFound) { String missing = rci.levels[rci.foundUptoLevel]; log.error("Cannot fetch counter - counter not found {}", missing); - return null; + return Collections.emptyList(); } ArrayList<DebugCounterInfo> dcilist = new ArrayList<DebugCounterInfo>(); // get counter and all below it diff --git a/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java b/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java index 20586a5a4..b61c8449c 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/IDebugCounterService.java @@ -16,6 +16,12 @@ public interface IDebugCounterService extends IFloodlightService { COUNT_ON_DEMAND } + /** + * Debug Counter Qualifiers + */ + public static final String CTR_MDATA_WARN = "warn"; + public static final String CTR_MDATA_ERROR = "error"; + /** * A limit on the maximum number of counters that can be created */ @@ -24,21 +30,49 @@ public interface IDebugCounterService extends IFloodlightService { /** * Exception thrown when MAX_COUNTERS have been registered */ - public class MaxCountersRegistered extends Exception { + public class MaxCountersRegistered extends CounterException { private static final long serialVersionUID = 3173747663719376745L; + String errormsg; + public MaxCountersRegistered(String errormsg) { + this.errormsg = errormsg; + } + @Override + public String getMessage() { + return this.errormsg; + } } /** * Exception thrown when MAX_HIERARCHY has been reached */ - public class MaxHierarchyRegistered extends Exception { + public class MaxHierarchyRegistered extends CounterException { private static final long serialVersionUID = 967431358683523871L; + String errormsg; + public MaxHierarchyRegistered(String errormsg) { + this.errormsg = errormsg; + } + @Override + public String getMessage() { + return this.errormsg; + } } /** * Exception thrown when attempting to register a hierarchical counter * where higher levels of the hierarchy have not been pre-registered */ - public class MissingHierarchicalLevel extends Exception { + public class MissingHierarchicalLevel extends CounterException { private static final long serialVersionUID = 517315311533995739L; + String errormsg; + public MissingHierarchicalLevel(String errormsg) { + this.errormsg = errormsg; + } + @Override + public String getMessage() { + return this.errormsg; + } + } + + public class CounterException extends Exception { + private static final long serialVersionUID = 2219781500857866035L; } /** @@ -85,7 +119,7 @@ public interface IDebugCounterService extends IFloodlightService { */ public IDebugCounter registerCounter(String moduleName, String counterHierarchy, String counterDescription, CounterType counterType, - Object... metaData) + String... metaData) throws MaxCountersRegistered, MaxHierarchyRegistered, MissingHierarchicalLevel; @@ -163,7 +197,8 @@ public interface IDebugCounterService extends IFloodlightService { * get call will return information on the 'pktin' as well as the 'drops' * counters for the switch dpid specified. * - * @return A list of DebugCounterInfo or null if the counter could not be found + * @return A list of DebugCounterInfo or an empty list if the counter + * could not be found */ public List<DebugCounterInfo> getCounterHierarchy(String moduleName, String counterHierarchy); diff --git a/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java b/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java index 0b8ed679f..9aed19510 100644 --- a/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java +++ b/src/main/java/net/floodlightcontroller/debugcounter/NullDebugCounter.java @@ -2,6 +2,7 @@ package net.floodlightcontroller.debugcounter; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -87,17 +88,17 @@ public class NullDebugCounter implements IFloodlightModule, IDebugCounterService @Override public List<DebugCounterInfo> getCounterHierarchy(String moduleName, String counterHierarchy) { - return null; + return Collections.emptyList(); } @Override public List<DebugCounterInfo> getAllCounterValues() { - return null; + return Collections.emptyList(); } @Override public List<DebugCounterInfo> getModuleCounterValues(String moduleName) { - return null; + return Collections.emptyList(); } @Override @@ -116,7 +117,7 @@ public class NullDebugCounter implements IFloodlightModule, IDebugCounterService IDebugCounter registerCounter(String moduleName, String counterHierarchy, String counterDescription, - CounterType counterType, Object... metaData) + CounterType counterType, String... metaData) throws MaxCountersRegistered { return new NullCounterImpl(); } @@ -125,32 +126,26 @@ public class NullDebugCounter implements IFloodlightModule, IDebugCounterService @Override public void updateCounterWithFlush() { - // TODO Auto-generated method stub } @Override public void updateCounterNoFlush() { - // TODO Auto-generated method stub } @Override public void updateCounterWithFlush(int incr) { - // TODO Auto-generated method stub - } @Override public void updateCounterNoFlush(int incr) { - // TODO Auto-generated method stub } @Override public long getCounterValue() { - // TODO Auto-generated method stub - return 0; + return -1; } } diff --git a/src/main/java/net/floodlightcontroller/debugevent/DebugEvent.java b/src/main/java/net/floodlightcontroller/debugevent/DebugEvent.java index 54218d6ed..f669cee78 100644 --- a/src/main/java/net/floodlightcontroller/debugevent/DebugEvent.java +++ b/src/main/java/net/floodlightcontroller/debugevent/DebugEvent.java @@ -341,8 +341,10 @@ public class DebugEvent implements IFloodlightModule, IDebugEventService { // sync thread local currently enabled set of eventIds with global set. Sets.SetView<Integer> sv = Sets.difference(currentEvents, thisset); for (int eventId : sv) { - if (thishist[eventId] != null) thishist[eventId].enabled = true; - thisset.add(eventId); + if (thishist[eventId] != null) { + thishist[eventId].enabled = true; + thisset.add(eventId); + } } //printEvents(); diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java index 884618191..ddc4e77fd 100755 --- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java @@ -54,6 +54,7 @@ import net.floodlightcontroller.core.util.ListenerDispatcher; import net.floodlightcontroller.core.util.SingletonTask; import net.floodlightcontroller.debugcounter.IDebugCounter; import net.floodlightcontroller.debugcounter.IDebugCounterService; +import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException; import net.floodlightcontroller.debugcounter.NullDebugCounter; import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterType; import net.floodlightcontroller.devicemanager.IDevice; @@ -131,7 +132,7 @@ IFlowReconcileListener, IInfoProvider { * Debug Counters */ public static final String MODULE_NAME = "devicemanager"; - public static final String WARN = "warn"; + public static final String PACKAGE = DeviceManagerImpl.class.getPackage().getName(); public IDebugCounter cntIncoming; public IDebugCounter cntReconcileRequest; public IDebugCounter cntReconcileNoSource; @@ -191,7 +192,6 @@ IFlowReconcileListener, IInfoProvider { private final int syncStoreConsolidateIntervalMs = DEFAULT_SYNC_STORE_CONSOLIDATE_INTERVAL_MS; - /** * Time in milliseconds before entities will expire */ @@ -811,7 +811,7 @@ IFlowReconcileListener, IInfoProvider { } @Override - public void init(FloodlightModuleContext fmc) { + public void init(FloodlightModuleContext fmc) throws FloodlightModuleException { this.perClassIndices = new HashSet<EnumSet<DeviceField>>(); addIndex(true, EnumSet.of(DeviceField.IPV4)); @@ -835,6 +835,7 @@ IFlowReconcileListener, IInfoProvider { this.syncService = fmc.getServiceImpl(ISyncService.class); this.deviceSyncManager = new DeviceSyncManager(); this.haListenerDelegate = new HAListenerDelegate(); + registerDeviceManagerDebugCounters(); } @Override @@ -889,8 +890,6 @@ IFlowReconcileListener, IInfoProvider { logger.debug("Could not instantiate REST API"); } - registerDeviceManagerDebugCounters(); - try { this.syncService.registerStore(DEVICE_SYNC_STORE_NAME, Scope.LOCAL); this.storeClient = this.syncService @@ -902,146 +901,146 @@ IFlowReconcileListener, IInfoProvider { } } - private void registerDeviceManagerDebugCounters() { + private void registerDeviceManagerDebugCounters() throws FloodlightModuleException { if (debugCounters == null) { logger.error("Debug Counter Service not found."); debugCounters = new NullDebugCounter(); } try { - cntIncoming = debugCounters.registerCounter(MODULE_NAME, "incoming", + cntIncoming = debugCounters.registerCounter(PACKAGE, "incoming", "All incoming packets seen by this module", CounterType.ALWAYS_COUNT); - cntReconcileRequest = debugCounters.registerCounter(MODULE_NAME, + cntReconcileRequest = debugCounters.registerCounter(PACKAGE, "reconcile-request", "Number of flows that have been received for reconciliation by " + "this module", CounterType.ALWAYS_COUNT); - cntReconcileNoSource = debugCounters.registerCounter(MODULE_NAME, + cntReconcileNoSource = debugCounters.registerCounter(PACKAGE, "reconcile-no-source-device", "Number of flow reconcile events that failed because no source " + "device could be identified", - CounterType.ALWAYS_COUNT, WARN); // is this really a warning - cntReconcileNoDest = debugCounters.registerCounter(MODULE_NAME, + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); // is this really a IDebugCounterService.CTR_MDATA_WARNing + cntReconcileNoDest = debugCounters.registerCounter(PACKAGE, "reconcile-no-dest-device", "Number of flow reconcile events that failed because no " + "destination device could be identified", - CounterType.ALWAYS_COUNT, WARN); // is this really a warning - cntInvalidSource = debugCounters.registerCounter(MODULE_NAME, + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); // is this really a IDebugCounterService.CTR_MDATA_WARNing + cntInvalidSource = debugCounters.registerCounter(PACKAGE, "invalid-source", "Number of packetIns that were discarded because the source " + "MAC was invalid (broadcast, multicast, or zero)", - CounterType.ALWAYS_COUNT, WARN); - cntNoSource = debugCounters.registerCounter(MODULE_NAME, "no-source-device", + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); + cntNoSource = debugCounters.registerCounter(PACKAGE, "no-source-device", "Number of packetIns that were discarded because the " + "could not identify a source device. This can happen if a " + "packet is not allowed, appears on an illegal port, does not " + "have a valid address space, etc.", - CounterType.ALWAYS_COUNT, WARN); - cntInvalidDest = debugCounters.registerCounter(MODULE_NAME, + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); + cntInvalidDest = debugCounters.registerCounter(PACKAGE, "invalid-dest", "Number of packetIns that were discarded because the dest " + "MAC was invalid (zero)", - CounterType.ALWAYS_COUNT, WARN); - cntNoDest = debugCounters.registerCounter(MODULE_NAME, "no-dest-device", + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); + cntNoDest = debugCounters.registerCounter(PACKAGE, "no-dest-device", "Number of packetIns that did not have an associated " + "destination device. E.g., because the destination MAC is " + "broadcast/multicast or is not yet known to the controller.", CounterType.ALWAYS_COUNT); - cntDhcpClientNameSnooped = debugCounters.registerCounter(MODULE_NAME, + cntDhcpClientNameSnooped = debugCounters.registerCounter(PACKAGE, "dhcp-client-name-snooped", "Number of times a DHCP client name was snooped from a " + "packetIn.", CounterType.ALWAYS_COUNT); cntDeviceOnInternalPortNotLearned = debugCounters.registerCounter( - MODULE_NAME, + PACKAGE, "device-on-internal-port-not-learned", "Number of times packetIn was received on an internal port and" + "no source device is known for the source MAC. The packetIn is " + "discarded.", - CounterType.ALWAYS_COUNT, WARN); - cntPacketNotAllowed = debugCounters.registerCounter(MODULE_NAME, + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); + cntPacketNotAllowed = debugCounters.registerCounter(PACKAGE, "packet-not-allowed", "Number of times a packetIn was not allowed due to spoofing " + "protection configuration.", - CounterType.ALWAYS_COUNT, WARN); // is this really a warning? - cntNewDevice = debugCounters.registerCounter(MODULE_NAME, "new-device", + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); // is this really a IDebugCounterService.CTR_MDATA_WARNing? + cntNewDevice = debugCounters.registerCounter(PACKAGE, "new-device", "Number of times a new device was learned", CounterType.ALWAYS_COUNT); cntPacketOnInternalPortForKnownDevice = debugCounters.registerCounter( - MODULE_NAME, + PACKAGE, "packet-on-internal-port-for-known-device", "Number of times a packetIn was received on an internal port " + "for a known device.", CounterType.ALWAYS_COUNT); - cntNewEntity = debugCounters.registerCounter(MODULE_NAME, "new-entity", + cntNewEntity = debugCounters.registerCounter(PACKAGE, "new-entity", "Number of times a new entity was learned for an existing device", CounterType.ALWAYS_COUNT); - cntDeviceChanged = debugCounters.registerCounter(MODULE_NAME, "device-changed", + cntDeviceChanged = debugCounters.registerCounter(PACKAGE, "device-changed", "Number of times device properties have changed", CounterType.ALWAYS_COUNT); - cntDeviceMoved = debugCounters.registerCounter(MODULE_NAME, "device-moved", + cntDeviceMoved = debugCounters.registerCounter(PACKAGE, "device-moved", "Number of times devices have moved", CounterType.ALWAYS_COUNT); - cntCleanupEntitiesRuns = debugCounters.registerCounter(MODULE_NAME, + cntCleanupEntitiesRuns = debugCounters.registerCounter(PACKAGE, "cleanup-entities-runs", "Number of times the entity cleanup task has been run", CounterType.ALWAYS_COUNT); - cntEntityRemovedTimeout = debugCounters.registerCounter(MODULE_NAME, + cntEntityRemovedTimeout = debugCounters.registerCounter(PACKAGE, "entity-removed-timeout", "Number of times entities have been removed due to timeout " + "(entity has been inactive for " + ENTITY_TIMEOUT/1000 + "s)", CounterType.ALWAYS_COUNT); - cntDeviceDeleted = debugCounters.registerCounter(MODULE_NAME, "device-deleted", + cntDeviceDeleted = debugCounters.registerCounter(PACKAGE, "device-deleted", "Number of devices that have been removed due to inactivity", CounterType.ALWAYS_COUNT); - cntDeviceReclassifyDelete = debugCounters.registerCounter(MODULE_NAME, + cntDeviceReclassifyDelete = debugCounters.registerCounter(PACKAGE, "device-reclassify-delete", "Number of devices that required reclassification and have been " + "temporarily delete for reclassification", CounterType.ALWAYS_COUNT); - cntDeviceStrored = debugCounters.registerCounter(MODULE_NAME, "device-stored", + cntDeviceStrored = debugCounters.registerCounter(PACKAGE, "device-stored", "Number of device entries written or updated to the sync store", CounterType.ALWAYS_COUNT); - cntDeviceStoreThrottled = debugCounters.registerCounter(MODULE_NAME, + cntDeviceStoreThrottled = debugCounters.registerCounter(PACKAGE, "device-store-throttled", "Number of times a device update to the sync store was " + "requested but not performed because the same device entities " + "have recently been updated already", CounterType.ALWAYS_COUNT); - cntDeviceRemovedFromStore = debugCounters.registerCounter(MODULE_NAME, + cntDeviceRemovedFromStore = debugCounters.registerCounter(PACKAGE, "device-removed-from-store", "Number of devices that were removed from the sync store " + "because the local controller removed the device due to " + "inactivity", CounterType.ALWAYS_COUNT); - cntSyncException = debugCounters.registerCounter(MODULE_NAME, "sync-exception", + cntSyncException = debugCounters.registerCounter(PACKAGE, "sync-exception", "Number of times an operation on the sync store resulted in " + "sync exception", - CounterType.ALWAYS_COUNT, WARN); // it this an error? - cntDevicesFromStore = debugCounters.registerCounter(MODULE_NAME, + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); // it this an error? + cntDevicesFromStore = debugCounters.registerCounter(PACKAGE, "devices-from-store", "Number of devices that were read from the sync store after " + "the local controller transitioned from SLAVE to MASTER", CounterType.ALWAYS_COUNT); - cntConsolidateStoreRuns = debugCounters.registerCounter(MODULE_NAME, + cntConsolidateStoreRuns = debugCounters.registerCounter(PACKAGE, "consolidate-store-runs", "Number of times the task to consolidate entries in the " + "store witch live known devices has been run", CounterType.ALWAYS_COUNT); - cntConsolidateStoreDevicesRemoved = debugCounters.registerCounter(MODULE_NAME, + cntConsolidateStoreDevicesRemoved = debugCounters.registerCounter(PACKAGE, "consolidate-store-devices-removed", "Number of times a device has been removed from the sync " + "store because no corresponding live device is known. " + "This indicates a remote controller still writing device " + "entries despite the local controller being MASTER or an " + "incosistent store update from the local controller.", - CounterType.ALWAYS_COUNT, WARN); - cntTransitionToMaster = debugCounters.registerCounter(MODULE_NAME, + CounterType.ALWAYS_COUNT, IDebugCounterService.CTR_MDATA_WARN); + cntTransitionToMaster = debugCounters.registerCounter(PACKAGE, "transition-to-master", "Number of times this controller has transitioned from SLAVE " + "to MASTER role. Will be 0 or 1.", CounterType.ALWAYS_COUNT); - } catch (Exception e) { - e.printStackTrace(); + } catch (CounterException e) { + throw new FloodlightModuleException(e.getMessage()); } } diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index 73e4f3a82..6fa6d00e5 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -59,6 +59,7 @@ import net.floodlightcontroller.core.module.IFloodlightService; import net.floodlightcontroller.core.util.SingletonTask; import net.floodlightcontroller.debugcounter.IDebugCounter; import net.floodlightcontroller.debugcounter.IDebugCounterService; +import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException; import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterType; import net.floodlightcontroller.debugcounter.NullDebugCounter; import net.floodlightcontroller.debugevent.IDebugEventService; @@ -265,7 +266,7 @@ public class LinkDiscoveryManager implements IOFMessageListener, private IHAListener haListener; /** - * Debug Counter + * Debug Counters */ private IDebugCounter ctrQuarantineDrops; private IDebugCounter ctrIgnoreSrcMacDrops; @@ -273,6 +274,8 @@ public class LinkDiscoveryManager implements IOFMessageListener, private IDebugCounter ctrLinkLocalDrops; private IDebugCounter ctrLldpEol; + private final String PACKAGE = LinkDiscoveryManager.class.getPackage().getName(); + //********************* // ILinkDiscoveryService @@ -1998,7 +2001,6 @@ public class LinkDiscoveryManager implements IOFMessageListener, this.haListener = new HAListenerDelegate(); registerLinkDiscoveryDebugCounters(); registerLinkDiscoveryDebugEvents(); - } @Override @@ -2024,7 +2026,7 @@ public class LinkDiscoveryManager implements IOFMessageListener, explanation = "An unknown error occured while sending LLDP " + "messages to switches.", recommendation = LogMessageDoc.CHECK_SWITCH) }) - public void startUp(FloodlightModuleContext context) { + public void startUp(FloodlightModuleContext context) throws FloodlightModuleException { // Initialize role to floodlight provider role. this.role = floodlightProvider.getRole(); @@ -2127,31 +2129,31 @@ public class LinkDiscoveryManager implements IOFMessageListener, // Link Discovery DebugCounters and DebugEvents // **************************************************** - private void registerLinkDiscoveryDebugCounters() { + private void registerLinkDiscoveryDebugCounters() throws FloodlightModuleException { if (debugCounters == null) { log.error("Debug Counter Service not found."); debugCounters = new NullDebugCounter(); } try { - ctrIncoming = debugCounters.registerCounter(getName(), "incoming", + ctrIncoming = debugCounters.registerCounter(PACKAGE, "incoming", "All incoming packets seen by this module", CounterType.ALWAYS_COUNT); - ctrLldpEol = debugCounters.registerCounter(getName(), "lldp-eol", + ctrLldpEol = debugCounters.registerCounter(PACKAGE, "lldp-eol", "End of Life for LLDP packets", CounterType.COUNT_ON_DEMAND); - ctrLinkLocalDrops = debugCounters.registerCounter(getName(), "linklocal-drops", + ctrLinkLocalDrops = debugCounters.registerCounter(PACKAGE, "linklocal-drops", "All link local packets dropped by this module", CounterType.COUNT_ON_DEMAND); - ctrIgnoreSrcMacDrops = debugCounters.registerCounter(getName(), "ignore-srcmac-drops", + ctrIgnoreSrcMacDrops = debugCounters.registerCounter(PACKAGE, "ignore-srcmac-drops", "All packets whose srcmac is configured to be dropped by this module", CounterType.COUNT_ON_DEMAND); - ctrQuarantineDrops = debugCounters.registerCounter(getName(), "quarantine-drops", + ctrQuarantineDrops = debugCounters.registerCounter(PACKAGE, "quarantine-drops", "All packets arriving on quarantined ports dropped by this module", CounterType.COUNT_ON_DEMAND); - } catch (Exception e) { - e.printStackTrace(); + } catch (CounterException e) { + throw new FloodlightModuleException(e.getMessage()); } } - private void registerLinkDiscoveryDebugEvents() { + private void registerLinkDiscoveryDebugEvents() throws FloodlightModuleException { if (debugEvents == null) { log.error("Debug Event Service not found."); debugEvents = new NullDebugEvent(); @@ -2163,7 +2165,7 @@ public class LinkDiscoveryManager implements IOFMessageListener, "Direct OpenFlow links discovered or timed-out", EventType.ALWAYS_LOG, DirectLinkEvent.class, 100); } catch (MaxEventsRegistered e) { - e.printStackTrace(); + throw new FloodlightModuleException("max events registered", e); } } diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java index 54c93b25c..c92e4b710 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java @@ -48,6 +48,7 @@ import net.floodlightcontroller.core.util.SingletonTask; import net.floodlightcontroller.counter.ICounterStoreService; import net.floodlightcontroller.debugcounter.IDebugCounter; import net.floodlightcontroller.debugcounter.IDebugCounterService; +import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException; import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterType; import net.floodlightcontroller.debugcounter.NullDebugCounter; import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryListener; @@ -160,7 +161,8 @@ public class TopologyManager implements /** * Debug Counters */ - protected static IDebugCounter ctrIncoming; + protected static final String PACKAGE = TopologyManager.class.getPackage().getName(); + protected IDebugCounter ctrIncoming; // Getter/Setter methods /** @@ -769,6 +771,7 @@ public class TopologyManager implements topologyAware = new ArrayList<ITopologyListener>(); ldUpdates = new LinkedBlockingQueue<LDUpdate>(); haListener = new HAListenerDelegate(); + registerTopologyDebugCounters(); } @Override @@ -788,20 +791,19 @@ public class TopologyManager implements floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this); floodlightProvider.addHAListener(this.haListener); addRestletRoutable(); - registerTopologyDebugCounters(); } - private void registerTopologyDebugCounters() { + private void registerTopologyDebugCounters() throws FloodlightModuleException { if (debugCounters == null) { log.error("Debug Counter Service not found."); debugCounters = new NullDebugCounter(); } try { - ctrIncoming = debugCounters.registerCounter(getName(), "incoming", + ctrIncoming = debugCounters.registerCounter(PACKAGE, "incoming", "All incoming packets seen by this module", CounterType.ALWAYS_COUNT); - } catch (Exception e) { - e.printStackTrace(); + } catch (CounterException e) { + throw new FloodlightModuleException(e.getMessage()); } } diff --git a/src/main/java/org/sdnplatform/sync/internal/SyncManager.java b/src/main/java/org/sdnplatform/sync/internal/SyncManager.java index 76b339397..727ccd519 100644 --- a/src/main/java/org/sdnplatform/sync/internal/SyncManager.java +++ b/src/main/java/org/sdnplatform/sync/internal/SyncManager.java @@ -60,6 +60,7 @@ import net.floodlightcontroller.core.module.IFloodlightService; import net.floodlightcontroller.core.util.SingletonTask; import net.floodlightcontroller.debugcounter.IDebugCounter; import net.floodlightcontroller.debugcounter.IDebugCounterService; +import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterException; import net.floodlightcontroller.debugcounter.IDebugCounterService.CounterType; import net.floodlightcontroller.storage.IStorageSourceService; import net.floodlightcontroller.threadpool.IThreadPoolService; @@ -507,42 +508,49 @@ public class SyncManager extends AbstractSyncManager { registerStore(s, Scope.GLOBAL); } } + registerDebugCounters(context); } - @Override - public void startUp(FloodlightModuleContext context) + private void registerDebugCounters(FloodlightModuleContext context) throws FloodlightModuleException { if (context != null) { try { counterHints = debugCounter.registerCounter(PACKAGE, " hints", - "Queued sync events processed", - CounterType.ALWAYS_COUNT); + "Queued sync events processed", + CounterType.ALWAYS_COUNT); counterSentValues = debugCounter.registerCounter(PACKAGE, "sent-values", - "Values synced to remote node", - CounterType.ALWAYS_COUNT); + "Values synced to remote node", + CounterType.ALWAYS_COUNT); counterReceivedValues = debugCounter.registerCounter(PACKAGE, "received-values", - "Values received from remote node", - CounterType.ALWAYS_COUNT); + "Values received from remote node", + CounterType.ALWAYS_COUNT); counterPuts = debugCounter.registerCounter(PACKAGE, "puts", - "Local puts to store", - CounterType.ALWAYS_COUNT); + "Local puts to store", + CounterType.ALWAYS_COUNT); counterGets = debugCounter.registerCounter(PACKAGE, "gets", - "Local gets from store", - CounterType.ALWAYS_COUNT); + "Local gets from store", + CounterType.ALWAYS_COUNT); counterIterators = debugCounter.registerCounter(PACKAGE, "iterators", - "Local iterators created over store", - CounterType.ALWAYS_COUNT); + "Local iterators created over store", + CounterType.ALWAYS_COUNT); counterErrorRemote = debugCounter.registerCounter(PACKAGE, "error-remote", - "Number of errors sent from remote clients", - CounterType.ALWAYS_COUNT); - counterErrorProcessing = debugCounter.registerCounter(PACKAGE, "error-processing", - "Number of errors processing messages from remote clients", - CounterType.ALWAYS_COUNT); - } catch (Exception e) { - e.printStackTrace(); + "Number of errors sent from remote clients", + CounterType.ALWAYS_COUNT); + counterErrorProcessing = debugCounter.registerCounter(PACKAGE, + "error-processing", + "Number of errors processing messages from remote clients", + CounterType.ALWAYS_COUNT); + } catch (CounterException e) { + throw new FloodlightModuleException(e.getMessage()); } } + } + + @Override + public void startUp(FloodlightModuleContext context) + throws FloodlightModuleException { + rpcService = new RPCService(this, debugCounter); cleanupTask = new SingletonTask(threadPool.getScheduledExecutor(), diff --git a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDeviceManager.java b/src/test/java/net/floodlightcontroller/devicemanager/test/MockDeviceManager.java index 9becbbb64..f15061ad0 100644 --- a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDeviceManager.java +++ b/src/test/java/net/floodlightcontroller/devicemanager/test/MockDeviceManager.java @@ -136,7 +136,7 @@ public class MockDeviceManager extends DeviceManagerImpl { } @Override - public void init(FloodlightModuleContext fmc) { + public void init(FloodlightModuleContext fmc) throws FloodlightModuleException { super.init(fmc); setSyncServiceIfNotSet(new MockSyncService()); } -- GitLab