diff --git a/src/main/java/net/floodlightcontroller/core/HAListenerTypeMarker.java b/src/main/java/net/floodlightcontroller/core/HAListenerTypeMarker.java
new file mode 100644
index 0000000000000000000000000000000000000000..d531994a93f0b9ea31ab20e99fd174492a0bac1b
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/core/HAListenerTypeMarker.java
@@ -0,0 +1,11 @@
+package net.floodlightcontroller.core;
+
+/**
+ * This is a dummy marker. IListener enforces call ordering by type. However,
+ * for IHAListeners we only have a single order. So we use this type as a
+ * placeholder to satisfy the generic requirement.
+ * @author gregor
+ *
+ */
+public enum HAListenerTypeMarker {
+}
diff --git a/src/main/java/net/floodlightcontroller/core/IHAListener.java b/src/main/java/net/floodlightcontroller/core/IHAListener.java
index d8f1e536b08cdf4f85b0bb9fcaecb8be7a8ce5a4..2ffe82fd586b1012f29c24d397eb6c212a5aa02e 100644
--- a/src/main/java/net/floodlightcontroller/core/IHAListener.java
+++ b/src/main/java/net/floodlightcontroller/core/IHAListener.java
@@ -18,15 +18,15 @@ package net.floodlightcontroller.core;
 
 import java.util.Map;
 
-import net.floodlightcontroller.core.IFloodlightProviderService.Role;
+public interface IHAListener extends IListener<HAListenerTypeMarker> {
 
-public interface IHAListener {
     /**
-     * Gets called when the controller changes role (i.e. Master -> Slave).
-     * Note that oldRole CAN be null.
-     * @param newRole The controller's new role
+     * This notification is fired if the controller's initial role was SLAVE
+     * and the controller is now transitioning to MASTER.
+     * Modules need to read their initial role in startUp from floodlight
+     * provider.
      */
-    public void roleChanged(Role newRole);
+    public void transitionToMaster();
 
     /**
      * Gets called when the IP addresses of the controller nodes in the
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 0ffe25b643b11318ef89767ab3c6ebf5f40248da..9ce62cf316c1c9e55c53ca8c7a49c7495737112b 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -42,10 +42,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
 import net.floodlightcontroller.core.FloodlightContext;
+import net.floodlightcontroller.core.HAListenerTypeMarker;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IHAListener;
 import net.floodlightcontroller.core.IInfoProvider;
@@ -62,7 +60,6 @@ import net.floodlightcontroller.core.annotations.LogMessageDoc;
 import net.floodlightcontroller.core.annotations.LogMessageDocs;
 import net.floodlightcontroller.core.module.FloodlightModuleException;
 import net.floodlightcontroller.core.util.ListenerDispatcher;
-import net.floodlightcontroller.core.util.SingletonTask;
 import net.floodlightcontroller.core.web.CoreWebRoutable;
 import net.floodlightcontroller.counter.ICounterStoreService;
 import net.floodlightcontroller.debugcounter.IDebugCounterService;
@@ -127,7 +124,7 @@ public class Controller implements IFloodlightProviderService,
     protected HashMap<String, String> controllerNodeIPsCache;
 
     protected Set<IOFSwitchListener> switchListeners;
-    protected Set<IHAListener> haListeners;
+    protected ListenerDispatcher<HAListenerTypeMarker,IHAListener> haListeners;
     protected Map<String, List<IInfoProvider>> providerMap;
     protected BlockingQueue<IUpdate> updates;
 
@@ -149,8 +146,6 @@ public class Controller implements IFloodlightProviderService,
     protected int workerThreads = 0;
 
 
-    private MessageDispatchGuard messageDispatchGuard;
-
     // This controller's current role that modules can use/query to decide
     // if they should operate in master or slave mode.
     // TODO: potentially we need to get rid of this field and modules must
@@ -186,8 +181,6 @@ public class Controller implements IFloodlightProviderService,
     protected static final boolean ALWAYS_DECODE_ETH = true;
 
 
-    private static long ROLE_FLAP_DAMPEN_TIME_MS = 2*1000; // 2 sec
-
     // Load monitor for overload protection
     protected final boolean overload_drop =
         Boolean.parseBoolean(System.getProperty("overload_drop", "false"));
@@ -195,95 +188,6 @@ public class Controller implements IFloodlightProviderService,
 
 
 
-    /**
-     * A utility class for guarding message dispatch to IOFMessage listeners
-     * especially during role transitions.
-     *
-     * The general goal we want to achieve is that IOFMessages are only
-     * dispatched to listeners if the listeners / modules have been notified
-     * to be in MASTER role. This guard helps ensure that no more messages
-     * are in the pipeline before notifying modules.
-     *
-     * The dispatch method must use acquireDispatchGuardAndCheck() and check
-     * its return value before calling the listeners. It also needs to
-     * releaseDispatchGuard() after the listeners have been called. Release
-     * should happen in a finally clause!
-     *
-     * @author gregor
-     *
-     */
-    private class MessageDispatchGuard {
-        /* We implement this using read/write lock. The dispatching method
-         * acquires the readlock, thus allowing multiple threads to
-         * dispatch at the same time. After acquiring the read-lock a user
-         * checks if dispatching is allowed. The lock is release after the
-         * dispatch is complete.
-         *
-         * When dispatching is enabled/disabled we acquire the write-lock, thus
-         * ensuring that no more messages are currently in the pipeline. Once
-         * we have the lock, the status can be changed.
-         */
-        private final ReentrantReadWriteLock lock;
-        private boolean dispatchEnabled;
-
-        /**
-         * @param dispatchAllowed if dispatching messages is allowed after
-         * instantiation
-         */
-        public MessageDispatchGuard(boolean dispatchAllowed) {
-            this.dispatchEnabled = dispatchAllowed;
-            lock = new ReentrantReadWriteLock();
-        }
-
-        /**
-         * message dispatching will be enabled. This method will block until
-         * nobody is holding the guard lock
-         */
-        public void enableDispatch() {
-            lock.writeLock().lock();
-            try {
-                this.dispatchEnabled = true;
-            } finally {
-                lock.writeLock().unlock();
-            }
-        }
-
-        /**
-         * message dispatch will be disabled. This method will block until
-         * nobody is holding the guard lock, i.e., until all messages are
-         * drained fromt the pipeline
-         */
-        public void disableDispatch() {
-            lock.writeLock().lock();
-            try {
-                this.dispatchEnabled = false;
-            } finally {
-                lock.writeLock().unlock();
-            }
-        }
-
-        /**
-         * Acquire the guard lock and return true if dispatching is enabled.
-         * Acquire the guard lock and return true if dispatching is enabled.
-         * Calls
-         * to this method should immediately be followed by a try-finally block
-         * and the finally block should call releaseDispatchGuard()
-         *
-         * @return true if dispatch is enabled
-         */
-        public boolean acquireDispatchGuardAndCheck() {
-            lock.readLock().lock();
-            return this.dispatchEnabled;
-        }
-
-        /**
-         * Release the guard lock.
-         */
-        public void releaseDispatchGuard() {
-            lock.readLock().unlock();
-        }
-    }
-
 
     /**
      * A utility class to manage the <i>controller roles</i>.
@@ -310,7 +214,6 @@ public class Controller implements IFloodlightProviderService,
      *
      */
     private class RoleManager {
-        private long lastRoleChangeTimeMillis;
         // This role represents the role that has been set by setRole. This
         // role might or might now have been notified to listeners just yet.
         // This is updated by setRole. doSetRole() will use this value as
@@ -324,33 +227,22 @@ public class Controller implements IFloodlightProviderService,
         private RoleInfo currentRoleInfo;
         private final Set<OFChannelHandler> connectedChannelHandlers;
 
-        /**
-         * This SingletonTask performs actually sends the role request
-         * to the channels.
-         */
-        private final SingletonTask changerTask;
-
-
         /**
          * @param role initial role
          * @param roleChangeDescription initial value of the change description
          * @throws NullPointerException if role or roleChangeDescription is null
+         * @throws IllegalArgumentException if role is EQUAL
          */
         public RoleManager(Role role, String roleChangeDescription) {
             if (role == null)
                 throw new NullPointerException("role must not be null");
+            if (role == Role.EQUAL)
+                throw new IllegalArgumentException("role must not be EQUAL");
             if (roleChangeDescription == null) {
                 throw new NullPointerException("roleChangeDescription must " +
                                                "not be null");
             }
 
-            this.changerTask =
-                    new SingletonTask(Controller.this.ses, new Runnable() {
-                        @Override
-                        public void run() {
-                            doSetRole();
-                        }
-                    });
             this.role = role;
             this.roleChangeDescription = roleChangeDescription;
             this.connectedChannelHandlers = new HashSet<OFChannelHandler>();
@@ -416,42 +308,30 @@ public class Controller implements IFloodlightProviderService,
                 throw new NullPointerException("roleChangeDescription must " +
                                                "not be null");
             }
-            long delay;
+            if (role == Role.EQUAL) {
+                log.debug("Received role request for EQUAL, setting to MASTER"
+                          + " instead");
+                role = Role.MASTER;
+            }
             if (role == this.role) {
                 log.debug("Received role request for {} but controller is "
                         + "already {}. Ingoring it.", role, this.role);
                 return;
             }
+            if (this.role == Role.MASTER && role == Role.SLAVE) {
+                log.info("Received role request to transition from MASTER "
+                          + " SLAVE (reason: {}). Terminating floodlight.",
+                          roleChangeDescription);
+                System.exit(0);
+            }
+            log.info("Received role request for {} (reason: {})."
+                     + " Initiating transition", role, roleChangeDescription);
+
             this.role = role;
             this.roleChangeDescription = roleChangeDescription;
 
-            long now = System.currentTimeMillis();
-            long timeSinceLastRoleChange = now - lastRoleChangeTimeMillis;
-            if (timeSinceLastRoleChange < ROLE_FLAP_DAMPEN_TIME_MS) {
-                // the last time the role was changed was less than
-                // ROLE_FLAP_DAMPEN_TIME_MS in the past. We delay the
-                // next notification to switches by ROLE_FLAP_DAMPEN_TIME_MS
-                delay = ROLE_FLAP_DAMPEN_TIME_MS;
-                if (log.isDebugEnabled()) {
-                    log.debug("Last role change was {} ms ago, delaying role" +
-                            " delaying role change to {}",
-                            lastRoleChangeTimeMillis, role);
-                }
-            } else {
-                // last role change was longer than ROLE_FLAP_DAMPEN_TIME_MS
-                // ago. Notify switches immediately.
-                delay = 0;
-            }
-            lastRoleChangeTimeMillis = now;
-            changerTask.reschedule(delay, TimeUnit.MILLISECONDS);
-        }
-
-        /**
-         * The internal method that actually sends the notification to
-         * the switches and that enqueues the role update to HAListeners.
-         * Also updates the RoleInfo we return to REST callers.
-         */
-        private synchronized void doSetRole() {
+            // TODO: we currently notify switches synchronously from the REST
+            // API handler. We could (should?) do this asynchronously.
             currentRoleInfo = new RoleInfo(this.role,
                                            this.roleChangeDescription,
                                            new Date());
@@ -791,11 +671,17 @@ public class Controller implements IFloodlightProviderService,
     }
 
     /**
-     * Update message indicating controller's role has changed
+     * Update message indicating controller's role has changed.
+     * RoleManager, which enqueues these updates gurantees that we will
+     * only have a single transition from SLAVE to MASTER.
      */
     private class HARoleUpdate implements IUpdate {
         private Role newRole;
         public HARoleUpdate(Role newRole) {
+            if (newRole != Role.MASTER)
+                throw new IllegalArgumentException("Only legal role change is"
+                                                   + "to MASTER. Got to "
+                                                   + newRole);
             this.newRole = newRole;
         }
         @Override
@@ -804,17 +690,18 @@ public class Controller implements IFloodlightProviderService,
                 log.debug("Dispatching HA Role update newRole = {}",
                           newRole);
             }
+            /*
             if (newRole == Role.SLAVE) {
                 messageDispatchGuard.disableDispatch();
                 Controller.this.notifiedRole = newRole;
             }
+            */
             if (haListeners != null) {
-                for (IHAListener listener : haListeners) {
-                        listener.roleChanged(newRole);
+                for (IHAListener listener : haListeners.getOrderedListeners()) {
+                    listener.transitionToMaster();
                 }
             }
             if (newRole != Role.SLAVE) {
-                messageDispatchGuard.enableDispatch();
                 Controller.this.notifiedRole = newRole;
             }
         }
@@ -846,7 +733,7 @@ public class Controller implements IFloodlightProviderService,
                         );
             }
             if (haListeners != null) {
-                for (IHAListener listener: haListeners) {
+                for (IHAListener listener: haListeners.getOrderedListeners()) {
                     listener.controllerNodeIPsChanged(curControllerNodeIPs,
                             addedControllerNodeIPs, removedControllerNodeIPs);
                 }
@@ -968,37 +855,16 @@ public class Controller implements IFloodlightProviderService,
 
 
     /**
+     *
      * Handle and dispatch a message to IOFMessageListeners.
      *
-     * Handle and dispatch a message to IOFMessageListeners. Dispatching
-     * of messages if protected by messageDispatchGuard. We only dispatch
-     * messages to listeners if the controller's role is MASTER.
+     * We only dispatch messages to listeners if the controller's role is MASTER.
      *
      * @param sw The switch sending the message
      * @param m The message the switch sent
      * @param flContext The floodlight context to use for this message. If
      * null, a new context will be allocated.
      * @throws IOException
-     */
-    protected void handleMessage(IOFSwitch sw, OFMessage m,
-                                 FloodlightContext flContext)
-            throws IOException {
-        boolean dispatchAllowed;
-
-        dispatchAllowed = messageDispatchGuard.acquireDispatchGuardAndCheck();
-        try {
-            if (dispatchAllowed)
-                handleMessageUnprotected(sw, m, flContext);
-        } finally {
-            messageDispatchGuard.releaseDispatchGuard();
-        }
-    }
-
-    /**
-     * Internal backend for message dispatch. Does the actual works.
-     * see handleMessage() for parameters
-     *
-     * Caller needs to hold messageDispatchGuard!
      *
      * FIXME: this method and the ChannelHandler disagree on which messages
      * should be dispatched and which shouldn't
@@ -1015,11 +881,17 @@ public class Controller implements IFloodlightProviderService,
                 explanation="The switch sent a message not handled by " +
                         "the controller")
     })
-    protected void handleMessageUnprotected(IOFSwitch sw, OFMessage m,
+    protected void handleMessage(IOFSwitch sw, OFMessage m,
                                  FloodlightContext bContext)
             throws IOException {
         Ethernet eth = null;
 
+        if (this.notifiedRole == Role.SLAVE) {
+            // We are SLAVE. Do not dispatch messages to listeners.
+            return;
+        }
+
+
         switch (m.getType()) {
             case PACKET_IN:
                 OFPacketIn pi = (OFPacketIn)m;
@@ -1371,6 +1243,8 @@ public class Controller implements IFloodlightProviderService,
                 log.error("Invalid current role value: {}", roleString);
             }
         }
+        if (role == Role.EQUAL)
+            role = Role.MASTER;
 
         log.info("Controller role set to {}", role);
 
@@ -1484,7 +1358,8 @@ public class Controller implements IFloodlightProviderService,
                                       ListenerDispatcher<OFType,
                                                          IOFMessageListener>>();
         this.switchListeners = new CopyOnWriteArraySet<IOFSwitchListener>();
-        this.haListeners = new CopyOnWriteArraySet<IHAListener>();
+        this.haListeners =
+                new ListenerDispatcher<HAListenerTypeMarker, IHAListener>();
         this.driverRegistry = new NaiiveSwitchDriverRegistry();
         this.controllerNodeIPsCache = new HashMap<String, String>();
         this.updates = new LinkedBlockingQueue<IUpdate>();
@@ -1492,12 +1367,6 @@ public class Controller implements IFloodlightProviderService,
         this.providerMap = new HashMap<String, List<IInfoProvider>>();
         setConfigParams(configParams);
         Role initialRole = getInitialRole(configParams);
-        // FIXME: we should initialize RoleManager here but we need to wait
-        // until we have the scheduled executor service. GRR.
-        //this.roleManager = new RoleManager(initialRole,
-        //                                   INITIAL_ROLE_CHANGE_DESCRIPTION);
-        this.messageDispatchGuard =
-                new MessageDispatchGuard(initialRole != Role.SLAVE);
         this.notifiedRole = initialRole;
         initVendorMessages();
 
@@ -1587,12 +1456,12 @@ public class Controller implements IFloodlightProviderService,
 
     @Override
     public void addHAListener(IHAListener listener) {
-        this.haListeners.add(listener);
+        this.haListeners.addListener(null,listener);
     }
 
     @Override
     public void removeHAListener(IHAListener listener) {
-        this.haListeners.remove(listener);
+        this.haListeners.removeListener(listener);
     }
 
 
diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
index 27e15b37fffd0485009879daa99d26c40c330217..1a3a1447fb4955e54a3e8ebd6dc6c4fc7d430c21 100755
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
@@ -22,7 +22,6 @@ import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.ConcurrentModificationException;
 import java.util.Date;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -40,13 +39,13 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 import net.floodlightcontroller.core.FloodlightContext;
+import net.floodlightcontroller.core.HAListenerTypeMarker;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IHAListener;
 import net.floodlightcontroller.core.IInfoProvider;
 import net.floodlightcontroller.core.IOFMessageListener;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.IFloodlightProviderService.Role;
-import net.floodlightcontroller.core.SwitchSyncRepresentation;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.module.FloodlightModuleException;
 import net.floodlightcontroller.core.module.IFloodlightModule;
@@ -92,7 +91,6 @@ import org.openflow.protocol.OFPort;
 import org.openflow.protocol.OFType;
 import org.sdnplatform.sync.IClosableIterator;
 import org.sdnplatform.sync.IStoreClient;
-import org.sdnplatform.sync.IStoreListener;
 import org.sdnplatform.sync.ISyncService;
 import org.sdnplatform.sync.ISyncService.Scope;
 import org.sdnplatform.sync.Versioned;
@@ -110,7 +108,7 @@ import org.slf4j.LoggerFactory;
 public class DeviceManagerImpl implements
 IDeviceService, IOFMessageListener, ITopologyListener,
 IFloodlightModule, IEntityClassListener,
-IFlowReconcileListener, IInfoProvider, IHAListener {
+IFlowReconcileListener, IInfoProvider {
     protected static Logger logger =
             LoggerFactory.getLogger(DeviceManagerImpl.class);
 
@@ -370,6 +368,11 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
      */
     public SingletonTask entityCleanupTask;
 
+    /**
+     * Listens for HA notifications
+     */
+    protected HAListenerDelegate haListenerDelegate;
+
 
     // *********************
     // IDeviceManagerService
@@ -759,6 +762,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
         this.syncService = fmc.getServiceImpl(ISyncService.class);
         this.deviceSyncManager = new DeviceSyncManager();
         this.syncStoreIntervalNs = DEFAULT_SYNC_STORE_INTERVAL_NS;
+        this.haListenerDelegate = new HAListenerDelegate();
     }
 
     @Override
@@ -773,7 +777,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
         apComparator = new AttachmentPointComparator();
 
         floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
-        floodlightProvider.addHAListener(this);
+        floodlightProvider.addHAListener(this.haListenerDelegate);
         if (topology != null)
             topology.addListener(this);
         flowReconcileMgr.addFlowReconcileListener(this);
@@ -825,27 +829,41 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
     // IHAListener
     // ***************
 
-    @Override
-    public void roleChanged(Role newRole) {
-        switch(newRole) {
-            case SLAVE:
-                logger.debug("Resetting device state because of role change");
-                // FIXME
-                //startUp(null);
-                break;
-            default:
-                break;
+    protected class HAListenerDelegate implements IHAListener {
+        @Override
+        public void transitionToMaster() {
+            DeviceManagerImpl.this.deviceSyncManager.goToMaster();
         }
-    }
 
-    @Override
-    public void controllerNodeIPsChanged(
-                                         Map<String, String> curControllerNodeIPs,
-                                         Map<String, String> addedControllerNodeIPs,
-                                         Map<String, String> removedControllerNodeIPs) {
-        // no-op
+        @Override
+        public void controllerNodeIPsChanged(
+                Map<String, String> curControllerNodeIPs,
+                Map<String, String> addedControllerNodeIPs,
+                Map<String, String> removedControllerNodeIPs) {
+            // no-op
+        }
+
+        @Override
+        public String getName() {
+            return this.getClass().getName();
+        }
+
+        @Override
+        public boolean isCallbackOrderingPrereq(HAListenerTypeMarker type,
+                                                String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
+
+        @Override
+        public boolean isCallbackOrderingPostreq(HAListenerTypeMarker type,
+                                                 String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
     }
 
+
     // ****************
     // Internal methods
     // ****************
@@ -2138,10 +2156,6 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
         deviceSyncManager.consolidateStore();
     }
 
-    void goToMaster() {
-        deviceSyncManager.goToMaster();
-    }
-
     /**
      * For testing. Sets the syncService. Only call after init but before
      * startUp. Used by MockDeviceManager
@@ -2151,4 +2165,12 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
         if (this.syncService == null)
             this.syncService = syncService;
     }
+
+    /**
+     * For testing.
+     * @return
+     */
+    IHAListener getHAListener() {
+        return this.haListenerDelegate;
+    }
 }
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index 7cf8b9d63d48dcd622bee9aba6e3a8b5ae4d8db9..dd56627218844a4aa2da09d6665620431ad95088 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -42,6 +42,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import net.floodlightcontroller.core.FloodlightContext;
+import net.floodlightcontroller.core.HAListenerTypeMarker;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IFloodlightProviderService.Role;
 import net.floodlightcontroller.core.IHAListener;
@@ -120,7 +121,7 @@ import org.slf4j.LoggerFactory;
 @LogMessageCategory("Network Topology")
 public class LinkDiscoveryManager implements IOFMessageListener,
     IOFSwitchListener, IStorageSourceListener, ILinkDiscoveryService,
-    IFloodlightModule, IInfoProvider, IHAListener {
+    IFloodlightModule, IInfoProvider {
     protected static final Logger log = LoggerFactory.getLogger(LinkDiscoveryManager.class);
 
     // Names of table/fields for links in the storage API
@@ -261,6 +262,8 @@ public class LinkDiscoveryManager implements IOFMessageListener,
     }
     protected Set<MACRange> ignoreMACSet;
 
+    private IHAListener haListener;
+
     //*********************
     // ILinkDiscoveryService
     //*********************
@@ -2213,6 +2216,7 @@ public class LinkDiscoveryManager implements IOFMessageListener,
         this.evHistTopologyCluster = new EventHistory<EventHistoryTopologyCluster>(EVENT_HISTORY_SIZE);
         this.ignoreMACSet = Collections.newSetFromMap(
                                 new ConcurrentHashMap<MACRange,Boolean>());
+        this.haListener = new HAListenerDelegate();
     }
 
     @Override
@@ -2332,7 +2336,7 @@ public class LinkDiscoveryManager implements IOFMessageListener,
         floodlightProvider.addOFMessageListener(OFType.PORT_STATUS, this);
         // Register for switch updates
         floodlightProvider.addOFSwitchListener(this);
-        floodlightProvider.addHAListener(this);
+        floodlightProvider.addHAListener(this.haListener);
         floodlightProvider.addInfoProvider("summary", this);
         if (restApi != null)
                             restApi.addRestletRoutable(new LinkDiscoveryWebRoutable());
@@ -2453,42 +2457,45 @@ public class LinkDiscoveryManager implements IOFMessageListener,
     // IHAListener
     //***************
 
-    @Override
-    public void roleChanged(Role newRole) {
-        switch (newRole) {
-            case MASTER:
-                if (log.isTraceEnabled()) {
-                    log.trace("Sending LLDPs "
-                              + "to HA change from SLAVE->MASTER");
-                }
-                this.role = Role.MASTER;
-                clearAllLinks();
-                readTopologyConfigFromStorage();
-                log.debug("Role Change to Master: Rescheduling discovery task.");
-                discoveryTask.reschedule(1, TimeUnit.MICROSECONDS);
-                break;
-            case SLAVE:
-                if (log.isTraceEnabled()) {
-                    log.trace("Clearing links due to "
-                              + "HA change to SLAVE");
-                }
-                this.role = Role.SLAVE;
-                switchLinks.clear();
-                links.clear();
-                portLinks.clear();
-                portBroadcastDomainLinks.clear();
-                discoverOnAllPorts();
-                break;
-            default:
-                break;
+    private class HAListenerDelegate implements IHAListener {
+        @Override
+        public void  transitionToMaster() {
+            if (log.isTraceEnabled()) {
+                log.trace("Sending LLDPs "
+                        + "to HA change from SLAVE->MASTER");
+            }
+            LinkDiscoveryManager.this.role = Role.MASTER;
+            clearAllLinks();
+            readTopologyConfigFromStorage();
+            log.debug("Role Change to Master: Rescheduling discovery task.");
+            discoveryTask.reschedule(1, TimeUnit.MICROSECONDS);
         }
-    }
 
-    @Override
-    public void controllerNodeIPsChanged(Map<String, String> curControllerNodeIPs,
-                                         Map<String, String> addedControllerNodeIPs,
-                                         Map<String, String> removedControllerNodeIPs) {
-        // ignore
+        @Override
+        public void controllerNodeIPsChanged(Map<String, String> curControllerNodeIPs,
+                                             Map<String, String> addedControllerNodeIPs,
+                                             Map<String, String> removedControllerNodeIPs) {
+            // ignore
+        }
+
+        @Override
+        public String getName() {
+            return getClass().getName();
+        }
+
+        @Override
+        public boolean isCallbackOrderingPrereq(HAListenerTypeMarker type,
+                                                String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
+
+        @Override
+        public boolean isCallbackOrderingPostreq(HAListenerTypeMarker type,
+                                                 String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
     }
 
 }
diff --git a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java
index ea7f120a4fbfa3340d123f1f67faef1f9a35da1b..106716dc748f0b7fa7d9cf27d9b976c5e636ef37 100644
--- a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java
+++ b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java
@@ -30,8 +30,8 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import net.floodlightcontroller.core.FloodlightContext;
+import net.floodlightcontroller.core.HAListenerTypeMarker;
 import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IFloodlightProviderService.Role;
 import net.floodlightcontroller.core.IHAListener;
 import net.floodlightcontroller.core.IOFMessageListener;
 import net.floodlightcontroller.core.IOFSwitch;
@@ -68,7 +68,7 @@ import org.slf4j.LoggerFactory;
  */
 public class StaticFlowEntryPusher
     implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
-        IStorageSourceListener, IOFMessageListener, IHAListener {
+        IStorageSourceListener, IOFMessageListener {
     protected static Logger log = LoggerFactory.getLogger(StaticFlowEntryPusher.class);
     public static final String StaticFlowName = "staticflowentry";
 
@@ -110,6 +110,8 @@ public class StaticFlowEntryPusher
     protected IStorageSourceService storageSource;
     protected IRestApiService restApi;
 
+    private IHAListener haListener;
+
     // Map<DPID, Map<Name, FlowMod>>; FlowMod can be null to indicate non-active
     protected Map<String, Map<String, OFFlowMod>> entriesFromStorage;
     // Entry Name -> DPID of Switch it's on
@@ -653,13 +655,14 @@ public class StaticFlowEntryPusher
             context.getServiceImpl(IStorageSourceService.class);
         restApi =
             context.getServiceImpl(IRestApiService.class);
+        haListener = new HAListenerDelegate();
     }
 
     @Override
     public void startUp(FloodlightModuleContext context) {
         floodlightProvider.addOFMessageListener(OFType.FLOW_REMOVED, this);
         floodlightProvider.addOFSwitchListener(this);
-        floodlightProvider.addHAListener(this);
+        floodlightProvider.addHAListener(this.haListener);
 
         // assumes no switches connected at startup()
         storageSource.createTable(TABLE_NAME, null);
@@ -804,31 +807,40 @@ public class StaticFlowEntryPusher
 
     // IHAListener
 
-    @Override
-    public void roleChanged(Role newRole) {
-        switch(newRole) {
-            case MASTER:
-                log.debug("Re-reading static flows from storage due " +
-                        "to HA change from SLAVE->MASTER");
-                entriesFromStorage = readEntriesFromStorage();
-                entry2dpid = computeEntry2DpidMap(entriesFromStorage);
-                break;
-            case SLAVE:
-                log.debug("Clearing in-memory flows due to " +
-                        "HA change to SLAVE");
-                entry2dpid.clear();
-                entriesFromStorage.clear();
-                break;
-            default:
-            	break;
+    private class HAListenerDelegate implements IHAListener {
+        @Override
+        public void transitionToMaster() {
+            log.debug("Re-reading static flows from storage due " +
+                    "to HA change from SLAVE->MASTER");
+            entriesFromStorage = readEntriesFromStorage();
+            entry2dpid = computeEntry2DpidMap(entriesFromStorage);
         }
-    }
 
-    @Override
-    public void controllerNodeIPsChanged(
-            Map<String, String> curControllerNodeIPs,
-            Map<String, String> addedControllerNodeIPs,
-            Map<String, String> removedControllerNodeIPs) {
-        // ignore
+        @Override
+        public void controllerNodeIPsChanged(
+                Map<String, String> curControllerNodeIPs,
+                Map<String, String> addedControllerNodeIPs,
+                Map<String, String> removedControllerNodeIPs) {
+            // ignore
+        }
+
+        @Override
+        public String getName() {
+            return getClass().getName();
+        }
+
+        @Override
+        public boolean isCallbackOrderingPrereq(HAListenerTypeMarker type,
+                                                String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
+
+        @Override
+        public boolean isCallbackOrderingPostreq(HAListenerTypeMarker type,
+                                                 String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
     }
 }
diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
index ea6e34407d283c665a673951aef5ff07716945de..9941e23c743592123ba9ea67c8ff93821f73df0a 100644
--- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
+++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
@@ -31,6 +31,7 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 import net.floodlightcontroller.core.FloodlightContext;
+import net.floodlightcontroller.core.HAListenerTypeMarker;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IFloodlightProviderService.Role;
 import net.floodlightcontroller.core.IHAListener;
@@ -78,7 +79,7 @@ import org.slf4j.LoggerFactory;
 public class TopologyManager implements
         IFloodlightModule, ITopologyService,
         IRoutingService, ILinkDiscoveryListener,
-        IOFMessageListener, IHAListener {
+        IOFMessageListener {
 
     protected static Logger log = LoggerFactory.getLogger(TopologyManager.class);
 
@@ -151,6 +152,8 @@ public class TopologyManager implements
 
     protected int TOPOLOGY_COMPUTE_INTERVAL_MS = 500;
 
+    private IHAListener haListener;
+
    //  Getter/Setter methods
     /**
      * Get the time interval for the period topology updates, if any.
@@ -668,34 +671,42 @@ public class TopologyManager implements
     // IHAListener
     // ***************
 
-    @Override
-    public void roleChanged(Role newRole) {
-        switch(newRole) {
-            case MASTER:
-                role = Role.MASTER;
-                log.debug("Re-computing topology due " +
-                        "to HA change from SLAVE->MASTER");
-                newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
-                                           TimeUnit.MILLISECONDS);
-                break;
-            case SLAVE:
-                log.debug("Clearing topology due to " +
-                        "HA change to SLAVE");
-                role = Role.SLAVE;
-                ldUpdates.clear();
-                clearCurrentTopology();
-                break;
-            default:
-            	break;
+    private class HAListenerDelegate implements IHAListener {
+        @Override
+        public void transitionToMaster() {
+            role = Role.MASTER;
+            log.debug("Re-computing topology due " +
+                    "to HA change from SLAVE->MASTER");
+            newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
+                                       TimeUnit.MILLISECONDS);
         }
-    }
 
-    @Override
-    public void controllerNodeIPsChanged(
-                          Map<String, String> curControllerNodeIPs,
-                          Map<String, String> addedControllerNodeIPs,
-                          Map<String, String> removedControllerNodeIPs) {
-        // no-op
+        @Override
+        public void controllerNodeIPsChanged(
+                                             Map<String, String> curControllerNodeIPs,
+                                             Map<String, String> addedControllerNodeIPs,
+                                             Map<String, String> removedControllerNodeIPs) {
+            // no-op
+        }
+
+        @Override
+        public String getName() {
+            return getClass().getName();
+        }
+
+        @Override
+        public boolean isCallbackOrderingPrereq(HAListenerTypeMarker type,
+                                                String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
+
+        @Override
+        public boolean isCallbackOrderingPostreq(HAListenerTypeMarker type,
+                                                 String name) {
+            // TODO Auto-generated method stub
+            return false;
+        }
     }
 
     // *****************
@@ -755,6 +766,7 @@ public class TopologyManager implements
         topologyAware = new ArrayList<ITopologyListener>();
         ldUpdates = new LinkedBlockingQueue<LDUpdate>();
         appliedUpdates = new ArrayList<LDUpdate>();
+        haListener = new HAListenerDelegate();
     }
 
     @Override
@@ -772,7 +784,7 @@ public class TopologyManager implements
 
         linkDiscovery.addListener(this);
         floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
-        floodlightProvider.addHAListener(this);
+        floodlightProvider.addHAListener(this.haListener);
         addRestletRoutable();
         registerTopologyDebugCounters();
     }
diff --git a/src/main/java/org/sdnplatform/sync/IStoreClient.java b/src/main/java/org/sdnplatform/sync/IStoreClient.java
index e9f20f924622dd27b7b2f2f8dede270ab2c907c1..23e8920b6f6c994a45ca506ba5f50ba2e6c2b586 100644
--- a/src/main/java/org/sdnplatform/sync/IStoreClient.java
+++ b/src/main/java/org/sdnplatform/sync/IStoreClient.java
@@ -19,7 +19,6 @@ package org.sdnplatform.sync;
 import java.util.Iterator;
 import java.util.Map.Entry;
 
-import org.omg.CORBA.UserException;
 import org.sdnplatform.sync.error.ObsoleteVersionException;
 import org.sdnplatform.sync.error.SyncException;
 
diff --git a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
index a3fe5b4f77c952531108dd2408ad4d5013ba6fbb..56e56c0c1336bbe54dd9eb1e89127ecba62462c2 100644
--- a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
+++ b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
@@ -29,3 +29,4 @@ net.floodlightcontroller.firewall.Firewall
 net.floodlightcontroller.loadbalancer.LoadBalancer
 org.sdnplatform.sync.internal.SyncManager
 org.sdnplatform.sync.internal.SyncTorture
+org.sdnplatform.sync.test.MockSyncService
diff --git a/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java b/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
index 5dc2bf0e551f853fc9de42d24e4d9697e2e777b8..868855f44add6fb5b73e0c4b032930834aae827b 100644
--- a/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
+++ b/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 
+import org.sdnplatform.sync.test.MockSyncService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,164 +36,167 @@ import net.floodlightcontroller.storage.memory.MemoryStorageSource;
 import net.floodlightcontroller.topology.TopologyManager;
 
 public class FloodlightTestModuleLoader extends FloodlightModuleLoader {
-	protected static Logger log = LoggerFactory.getLogger(FloodlightTestModuleLoader.class);
-	
-	// List of default modules to use unless specified otherwise
-	public static final Class<? extends IFloodlightModule> DEFAULT_STORAGE_SOURCE =
-			MemoryStorageSource.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_FLOODLIGHT_PRPOVIDER =
-			MockFloodlightProvider.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_TOPOLOGY_PROVIDER =
-			TopologyManager.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_DEVICE_SERVICE =
-			MockDeviceManager.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_COUNTER_STORE =
-			NullCounterStore.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_THREADPOOL =
-			MockThreadPoolService.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_ENTITY_CLASSIFIER =
-			DefaultEntityClassifier.class;
-	public static final Class<? extends IFloodlightModule> DEFAULT_PERFMON =
-			NullPktInProcessingTime.class;
-	
-	protected static final Collection<Class<? extends IFloodlightModule>> DEFAULT_MODULE_LIST;
-	
-	static {
-		DEFAULT_MODULE_LIST = new ArrayList<Class<? extends IFloodlightModule>>();
-		DEFAULT_MODULE_LIST.add(DEFAULT_DEVICE_SERVICE);
-		DEFAULT_MODULE_LIST.add(DEFAULT_FLOODLIGHT_PRPOVIDER);
-		DEFAULT_MODULE_LIST.add(DEFAULT_STORAGE_SOURCE);
-		DEFAULT_MODULE_LIST.add(DEFAULT_TOPOLOGY_PROVIDER);
-		DEFAULT_MODULE_LIST.add(DEFAULT_COUNTER_STORE);
-		DEFAULT_MODULE_LIST.add(DEFAULT_THREADPOOL);
-		DEFAULT_MODULE_LIST.add(DEFAULT_ENTITY_CLASSIFIER);
-		DEFAULT_MODULE_LIST.add(DEFAULT_PERFMON);
-	}
-	
-	protected IFloodlightModuleContext fmc;
-	
-	/**
-	 * Adds default modules to the list of modules to load. This is done
-	 * in order to avoid the module loader throwing errors about duplicate
-	 * modules and neither one is specified by the user.
-	 * @param userModules The list of user specified modules to add to.
-	 */
-	protected void addDefaultModules(Collection<Class<? extends IFloodlightModule>> userModules) {
-		Collection<Class<? extends IFloodlightModule>> defaultModules =
-				new ArrayList<Class<? extends IFloodlightModule>>(DEFAULT_MODULE_LIST.size());
-		defaultModules.addAll(DEFAULT_MODULE_LIST);
-		
-		Iterator<Class<? extends IFloodlightModule>> modIter = userModules.iterator();
-		while (modIter.hasNext()) {
-			Class<? extends IFloodlightModule> userMod = modIter.next();
-			Iterator<Class<? extends IFloodlightModule>> dmIter = defaultModules.iterator();
-			while (dmIter.hasNext()) {
-				Class<? extends IFloodlightModule> dmMod = dmIter.next();
-				Collection<Class<? extends IFloodlightService>> userModServs;
-				Collection<Class<? extends IFloodlightService>> dmModServs;
-				try {
-					dmModServs = dmMod.newInstance().getModuleServices();
-					userModServs = userMod.newInstance().getModuleServices();
-				} catch (InstantiationException e) {
-					log.error(e.getMessage());
-					break;
-				} catch (IllegalAccessException e) {
-					log.error(e.getMessage());
-					break;
-				}
-				
-				// If either of these are null continue as they have no services
-				if (dmModServs == null || userModServs == null) continue;
-				
-				// If the user supplied modules has a service
-				// that is in the default module list we remove
-				// the default module from the list.
-				boolean shouldBreak = false;
-				Iterator<Class<? extends IFloodlightService>> userModServsIter 
-					= userModServs.iterator();
-				while (userModServsIter.hasNext()) {
-					Class<? extends IFloodlightService> userModServIntf = userModServsIter.next();
-					Iterator<Class<? extends IFloodlightService>> dmModsServsIter 
-						= dmModServs.iterator();
-					while (dmModsServsIter.hasNext()) {
-						Class<? extends IFloodlightService> dmModServIntf 
-							= dmModsServsIter.next();
-						
-						if (dmModServIntf.getCanonicalName().equals(
-								userModServIntf.getCanonicalName())) {
-							logger.debug("Removing default module {} because it was " +
-									"overriden by an explicitly specified module",
-									dmModServIntf.getCanonicalName());
-							dmIter.remove();
-							shouldBreak = true;
-							break;
-						}
-					}
-					if (shouldBreak) break;
-				}
-				if (shouldBreak) break;
-			}
-		}
-		
-		// Append the remaining default modules to the user specified ones.
-		// This avoids the module loader throwing duplicate module errors.
-		userModules.addAll(defaultModules);
-		log.debug("Using module set " + userModules.toString());
-	}
-	
-	/**
-	 * Sets up all modules and their dependencies.
-	 * @param modules The list of modules that the user wants to load.
-	 * @param mockedServices The list of services that will be mocked. Any
-	 * module that provides this service will not be loaded.
-	 */
-	public void setupModules(Collection<Class<? extends IFloodlightModule>> modules,
-			Collection<IFloodlightService> mockedServices) {
-		addDefaultModules(modules);
-		Collection<String> modulesAsString = new ArrayList<String>();
-		for (Class<? extends IFloodlightModule> m : modules) {
-			modulesAsString.add(m.getCanonicalName());
-		}
-		
-		try {
-			fmc = loadModulesFromList(modulesAsString, null, mockedServices);
-		} catch (FloodlightModuleException e) {
-			log.error(e.getMessage());
-		}
-	}
-	
-	/**
-	 * Gets the inited/started instance of a module from the context.
-	 * @param ifl The name if the module to get, i.e. "LearningSwitch.class".
-	 * @return The inited/started instance of the module.
-	 */
-	public IFloodlightModule getModuleByName(Class<? extends IFloodlightModule> ifl) {
-		Collection<IFloodlightModule> modules = fmc.getAllModules();
-		for (IFloodlightModule m : modules) {
-			if (ifl.getCanonicalName().equals(m.getClass().getCanonicalName())) {
-				return m;
-			}
-		}
-		return null;
-	}
-	
-	/**
-	 * Gets an inited/started instance of a service from the context.
-	 * @param ifs The name of the service to get, i.e. "ITopologyService.class".
-	 * @return The inited/started instance of the service from teh context.
-	 */
-	public IFloodlightService getModuleByService(Class<? extends IFloodlightService> ifs) {
-		Collection<IFloodlightModule> modules = fmc.getAllModules();
-		for (IFloodlightModule m : modules) {
-			Collection<Class<? extends IFloodlightService>> mServs = m.getModuleServices();
-			if (mServs == null) continue;
-			for (Class<? extends IFloodlightService> mServClass : mServs) {
-				if (mServClass.getCanonicalName().equals(ifs.getCanonicalName())) {
-					assert(m instanceof IFloodlightService);
-					return (IFloodlightService)m;
-				}
-			}
-		}
-		return null;
-	}
+    protected static Logger log = LoggerFactory.getLogger(FloodlightTestModuleLoader.class);
+
+    // List of default modules to use unless specified otherwise
+    public static final Class<? extends IFloodlightModule> DEFAULT_STORAGE_SOURCE =
+            MemoryStorageSource.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_FLOODLIGHT_PRPOVIDER =
+            MockFloodlightProvider.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_TOPOLOGY_PROVIDER =
+            TopologyManager.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_DEVICE_SERVICE =
+            MockDeviceManager.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_COUNTER_STORE =
+            NullCounterStore.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_THREADPOOL =
+            MockThreadPoolService.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_ENTITY_CLASSIFIER =
+            DefaultEntityClassifier.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_PERFMON =
+            NullPktInProcessingTime.class;
+    public static final Class<? extends IFloodlightModule> DEFAULT_SYNC_SERVICE =
+            MockSyncService.class;
+
+    protected static final Collection<Class<? extends IFloodlightModule>> DEFAULT_MODULE_LIST;
+
+    static {
+        DEFAULT_MODULE_LIST = new ArrayList<Class<? extends IFloodlightModule>>();
+        DEFAULT_MODULE_LIST.add(DEFAULT_DEVICE_SERVICE);
+        DEFAULT_MODULE_LIST.add(DEFAULT_FLOODLIGHT_PRPOVIDER);
+        DEFAULT_MODULE_LIST.add(DEFAULT_STORAGE_SOURCE);
+        DEFAULT_MODULE_LIST.add(DEFAULT_TOPOLOGY_PROVIDER);
+        DEFAULT_MODULE_LIST.add(DEFAULT_COUNTER_STORE);
+        DEFAULT_MODULE_LIST.add(DEFAULT_THREADPOOL);
+        DEFAULT_MODULE_LIST.add(DEFAULT_ENTITY_CLASSIFIER);
+        DEFAULT_MODULE_LIST.add(DEFAULT_PERFMON);
+        DEFAULT_MODULE_LIST.add(DEFAULT_SYNC_SERVICE);
+    }
+
+    protected IFloodlightModuleContext fmc;
+
+    /**
+     * Adds default modules to the list of modules to load. This is done
+     * in order to avoid the module loader throwing errors about duplicate
+     * modules and neither one is specified by the user.
+     * @param userModules The list of user specified modules to add to.
+     */
+    protected void addDefaultModules(Collection<Class<? extends IFloodlightModule>> userModules) {
+        Collection<Class<? extends IFloodlightModule>> defaultModules =
+                new ArrayList<Class<? extends IFloodlightModule>>(DEFAULT_MODULE_LIST.size());
+        defaultModules.addAll(DEFAULT_MODULE_LIST);
+
+        Iterator<Class<? extends IFloodlightModule>> modIter = userModules.iterator();
+        while (modIter.hasNext()) {
+            Class<? extends IFloodlightModule> userMod = modIter.next();
+            Iterator<Class<? extends IFloodlightModule>> dmIter = defaultModules.iterator();
+            while (dmIter.hasNext()) {
+                Class<? extends IFloodlightModule> dmMod = dmIter.next();
+                Collection<Class<? extends IFloodlightService>> userModServs;
+                Collection<Class<? extends IFloodlightService>> dmModServs;
+                try {
+                    dmModServs = dmMod.newInstance().getModuleServices();
+                    userModServs = userMod.newInstance().getModuleServices();
+                } catch (InstantiationException e) {
+                    log.error(e.getMessage());
+                    break;
+                } catch (IllegalAccessException e) {
+                    log.error(e.getMessage());
+                    break;
+                }
+
+                // If either of these are null continue as they have no services
+                if (dmModServs == null || userModServs == null) continue;
+
+                // If the user supplied modules has a service
+                // that is in the default module list we remove
+                // the default module from the list.
+                boolean shouldBreak = false;
+                Iterator<Class<? extends IFloodlightService>> userModServsIter
+                    = userModServs.iterator();
+                while (userModServsIter.hasNext()) {
+                    Class<? extends IFloodlightService> userModServIntf = userModServsIter.next();
+                    Iterator<Class<? extends IFloodlightService>> dmModsServsIter
+                        = dmModServs.iterator();
+                    while (dmModsServsIter.hasNext()) {
+                        Class<? extends IFloodlightService> dmModServIntf
+                            = dmModsServsIter.next();
+
+                        if (dmModServIntf.getCanonicalName().equals(
+                                userModServIntf.getCanonicalName())) {
+                            logger.debug("Removing default module {} because it was " +
+                                    "overriden by an explicitly specified module",
+                                    dmModServIntf.getCanonicalName());
+                            dmIter.remove();
+                            shouldBreak = true;
+                            break;
+                        }
+                    }
+                    if (shouldBreak) break;
+                }
+                if (shouldBreak) break;
+            }
+        }
+
+        // Append the remaining default modules to the user specified ones.
+        // This avoids the module loader throwing duplicate module errors.
+        userModules.addAll(defaultModules);
+        log.debug("Using module set " + userModules.toString());
+    }
+
+    /**
+     * Sets up all modules and their dependencies.
+     * @param modules The list of modules that the user wants to load.
+     * @param mockedServices The list of services that will be mocked. Any
+     * module that provides this service will not be loaded.
+     */
+    public void setupModules(Collection<Class<? extends IFloodlightModule>> modules,
+            Collection<IFloodlightService> mockedServices) {
+        addDefaultModules(modules);
+        Collection<String> modulesAsString = new ArrayList<String>();
+        for (Class<? extends IFloodlightModule> m : modules) {
+            modulesAsString.add(m.getCanonicalName());
+        }
+
+        try {
+            fmc = loadModulesFromList(modulesAsString, null, mockedServices);
+        } catch (FloodlightModuleException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    /**
+     * Gets the inited/started instance of a module from the context.
+     * @param ifl The name if the module to get, i.e. "LearningSwitch.class".
+     * @return The inited/started instance of the module.
+     */
+    public IFloodlightModule getModuleByName(Class<? extends IFloodlightModule> ifl) {
+        Collection<IFloodlightModule> modules = fmc.getAllModules();
+        for (IFloodlightModule m : modules) {
+            if (ifl.getCanonicalName().equals(m.getClass().getCanonicalName())) {
+                return m;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Gets an inited/started instance of a service from the context.
+     * @param ifs The name of the service to get, i.e. "ITopologyService.class".
+     * @return The inited/started instance of the service from teh context.
+     */
+    public IFloodlightService getModuleByService(Class<? extends IFloodlightService> ifs) {
+        Collection<IFloodlightModule> modules = fmc.getAllModules();
+        for (IFloodlightModule m : modules) {
+            Collection<Class<? extends IFloodlightService>> mServs = m.getModuleServices();
+            if (mServs == null) continue;
+            for (Class<? extends IFloodlightService> mServClass : mServs) {
+                if (mServClass.getCanonicalName().equals(ifs.getCanonicalName())) {
+                    assert(m instanceof IFloodlightService);
+                    return (IFloodlightService)m;
+                }
+            }
+        }
+        return null;
+    }
 }
diff --git a/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java b/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java
index 5ae3eb8138983e15151ce72c20ab87e870fd3f19..d503b2e77fc9323d8a72590b0aff8a8ac26aa150 100644
--- a/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java
+++ b/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java
@@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import net.floodlightcontroller.core.FloodlightContext;
+import net.floodlightcontroller.core.HAListenerTypeMarker;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IHAListener;
 import net.floodlightcontroller.core.IInfoProvider;
@@ -66,7 +67,7 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     protected static Logger log = LoggerFactory.getLogger(MockFloodlightProvider.class);
     protected ConcurrentMap<OFType, ListenerDispatcher<OFType,IOFMessageListener>> listeners;
     protected List<IOFSwitchListener> switchListeners;
-    protected List<IHAListener> haListeners;
+    protected ListenerDispatcher<HAListenerTypeMarker, IHAListener> haListeners;
     protected Map<Long, IOFSwitch> switches;
     protected BasicFactory factory;
 
@@ -78,7 +79,8 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
                                    IOFMessageListener>>();
         switches = new ConcurrentHashMap<Long, IOFSwitch>();
         switchListeners = new CopyOnWriteArrayList<IOFSwitchListener>();
-        haListeners = new CopyOnWriteArrayList<IHAListener>();
+        haListeners =
+                new ListenerDispatcher<HAListenerTypeMarker, IHAListener>();
         factory = BasicFactory.getInstance();
     }
 
@@ -295,12 +297,12 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
 
     @Override
     public void addHAListener(IHAListener listener) {
-        haListeners.add(listener);
+        haListeners.addListener(null,listener);
     }
 
     @Override
     public void removeHAListener(IHAListener listener) {
-        haListeners.remove(listener);
+        haListeners.removeListener(listener);
     }
 
     @Override
@@ -318,9 +320,9 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
      * @param oldRole
      * @param newRole
      */
-    public void dispatchRoleChanged(Role newRole) {
-        for (IHAListener rl : haListeners) {
-            rl.roleChanged(newRole);
+    public void transitionToMaster() {
+        for (IHAListener rl : haListeners.getOrderedListeners()) {
+            rl.transitionToMaster();
         }
     }
 
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
index 702366ef0fcd9d9c372f3ba180509e99f0c3a20b..317a6bd7eaae6b903c1c693addc48449779d9510 100644
--- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
+++ b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
@@ -2486,7 +2486,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
                 storeClient.get("FooBar");
         storeClient.put("FooBar", versionedDsr);
 
-        deviceManager.goToMaster();
+        deviceManager.getHAListener().transitionToMaster();
 
         // Query for the Device1. Make sure we have the two IPs we stored.
         IDevice d = getSingleDeviceFromDeviceManager(1L);
diff --git a/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java b/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java
index a2f358a7501155c610280ea1885d61408be51dba..d8da84ff89bea099c40af6792b7c0ad632a99514 100644
--- a/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java
+++ b/src/test/java/net/floodlightcontroller/learningswitch/LearningSwitchTest.java
@@ -1,7 +1,7 @@
 /**
-*    Copyright 2011, Big Switch Networks, Inc. 
+*    Copyright 2011, 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
@@ -25,7 +25,6 @@ import static org.easymock.EasyMock.verify;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-
 import net.floodlightcontroller.core.IOFMessageListener;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.module.FloodlightTestModuleLoader;
@@ -65,19 +64,21 @@ public class LearningSwitchTest extends FloodlightTestCase {
     protected IPacket testPacketReply;
     protected byte[] testPacketReplySerialized;
     private LearningSwitch learningSwitch;
-    
+
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
         FloodlightTestModuleLoader fml = new FloodlightTestModuleLoader();
-        Collection<Class<? extends IFloodlightModule>> mods 
+        Collection<Class<? extends IFloodlightModule>> mods
         	= new ArrayList<Class<? extends IFloodlightModule>>();
         mods.add(LearningSwitch.class);
+
         fml.setupModules(mods, null);
         learningSwitch = (LearningSwitch) fml.getModuleByName(LearningSwitch.class);
-        mockFloodlightProvider = 
+        mockFloodlightProvider =
                 (MockFloodlightProvider) fml.getModuleByName(MockFloodlightProvider.class);
-       
+
         // Build our test packet
         this.testPacket = new Ethernet()
             .setDestinationMACAddress("00:11:22:33:44:55")
@@ -161,14 +162,14 @@ public class LearningSwitchTest extends FloodlightTestCase {
         // Make sure it's the right listener
         listener.receive(mockSwitch, this.packetIn, parseAndAnnotate(this.packetIn));
 
-        // Verify the replay matched our expectations      
+        // Verify the replay matched our expectations
         short result = learningSwitch.getFromPortMap(mockSwitch, Ethernet.toLong(Ethernet.toMACAddress("00:44:33:22:11:00")), (short) 42).shortValue();
         verify(mockSwitch);
 
         // Verify the MAC table inside the switch
         assertEquals(1, result);
     }
-    
+
     @Test
     public void testFlowMod() throws Exception {
         // tweak the test packet in since we need a bufferId
@@ -211,7 +212,7 @@ public class LearningSwitchTest extends FloodlightTestCase {
         ofAcOut.setPort((short)2);
         ofAcOut.setLength((short) 8);
         ofAcOut.setType(OFActionType.OUTPUT);
-        
+
         OFPacketOut packetOut = new OFPacketOut();
         packetOut.setActions(Arrays.asList(new OFAction[] {ofAcOut}))
         .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
@@ -220,11 +221,11 @@ public class LearningSwitchTest extends FloodlightTestCase {
         .setPacketData(null)
         .setLength((short) (OFPacketOut.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));
         packetOut.setActionFactory(mockFloodlightProvider.getOFMessageFactory());
-        
+
         // Mock up our expected behavior
         IOFSwitch mockSwitch = createMock(IOFSwitch.class);
         expect(mockSwitch.getId()).andReturn(1L).anyTimes();
-        expect(mockSwitch.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).andReturn((Integer) (OFMatch.OFPFW_IN_PORT | OFMatch.OFPFW_NW_PROTO
+        expect(mockSwitch.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).andReturn((OFMatch.OFPFW_IN_PORT | OFMatch.OFPFW_NW_PROTO
                 | OFMatch.OFPFW_TP_SRC | OFMatch.OFPFW_TP_DST | OFMatch.OFPFW_NW_SRC_ALL
                 | OFMatch.OFPFW_NW_DST_ALL | OFMatch.OFPFW_NW_TOS));
         expect(mockSwitch.getBuffers()).andReturn(100).anyTimes();
@@ -238,12 +239,12 @@ public class LearningSwitchTest extends FloodlightTestCase {
         // Populate the MAC table
         learningSwitch.addToPortMap(mockSwitch,
                 Ethernet.toLong(Ethernet.toMACAddress("00:11:22:33:44:55")), (short) 42, (short) 2);
-        
+
         // Get the listener and trigger the packet in
         IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
                 OFType.PACKET_IN).get(0);
         listener.receive(mockSwitch, this.packetIn, parseAndAnnotate(this.packetIn));
-        
+
         // Verify the replay matched our expectations
         short result = learningSwitch.getFromPortMap(mockSwitch, Ethernet.toLong(Ethernet.toMACAddress("00:44:33:22:11:00")), (short) 42).shortValue();
         verify(mockSwitch);
diff --git a/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java b/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
index f3274fd5b955f5ac4e09084f9b3e16b030e995ff..b824602f9eabd639538d7834f16d8e9b9392cea2 100644
--- a/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
+++ b/src/test/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
@@ -34,7 +34,6 @@ import java.util.Set;
 
 import net.floodlightcontroller.core.FloodlightContext;
 import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IFloodlightProviderService.Role;
 import net.floodlightcontroller.core.IListener.Command;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
@@ -444,6 +443,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
         assertTrue(linkDiscovery.portLinks.get(dstNpt).contains(lt));
         assertTrue(linkDiscovery.links.containsKey(lt));
 
+        /* FIXME: what's the right thing to do here:
         // check that it clears from memory
         getMockFloodlightProvider().dispatchRoleChanged(Role.SLAVE);
         assertTrue(linkDiscovery.switchLinks.isEmpty());
@@ -452,6 +452,7 @@ public class LinkDiscoveryManagerTest extends FloodlightTestCase {
         assertTrue(ldm.isSendLLDPsCalled);
         assertTrue(ldm.isClearLinksCalled);
         ldm.reset();
+        */
     }
 
     @Test
diff --git a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
index 5bec9d0d8f52aec63484476b9de97f229946d47e..a1e33539ebcb2b7099740fd62d1116fd7364b782 100644
--- a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
+++ b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
@@ -39,12 +39,12 @@ import org.openflow.util.HexString;
 
 
 import net.floodlightcontroller.core.FloodlightContext;
-import net.floodlightcontroller.core.IFloodlightProviderService.Role;
+import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.module.FloodlightModuleException;
 import net.floodlightcontroller.core.test.MockFloodlightProvider;
 import net.floodlightcontroller.test.FloodlightTestCase;
+import net.floodlightcontroller.restserver.IRestApiService;
 import net.floodlightcontroller.restserver.RestApiServer;
 import net.floodlightcontroller.staticflowentry.StaticFlowEntryPusher;
 import net.floodlightcontroller.storage.IStorageSourceService;
@@ -114,6 +114,13 @@ public class StaticFlowTests extends FloodlightTestCase {
 
     static Map<String,Object> TestRule3;
     static OFFlowMod FlowMod3;
+    private StaticFlowEntryPusher staticFlowEntryPusher;
+    private IOFSwitch mockSwitch;
+    private Capture<OFMessage> writeCapture;
+    private Capture<FloodlightContext> contextCapture;
+    private Capture<List<OFMessage>> writeCaptureList;
+    private long dpid;
+    private IStorageSourceService storage;
     static {
         FlowMod3 = new OFFlowMod();
         TestRule3 = new HashMap<String,Object>();
@@ -171,19 +178,14 @@ public class StaticFlowTests extends FloodlightTestCase {
     @Override
     public void setUp() throws Exception {
         super.setUp();
-    }
-
-    @Test
-    public void testStaticFlowPush() throws IOException {
-        StaticFlowEntryPusher staticFlowEntryPusher = new StaticFlowEntryPusher();
-        IStorageSourceService storage = createStorageWithFlowEntries();
-        long dpid = HexString.toLong(TestSwitch1DPID);
+        staticFlowEntryPusher = new StaticFlowEntryPusher();
+        storage = createStorageWithFlowEntries();
+        dpid = HexString.toLong(TestSwitch1DPID);
 
-        // Create a Switch and attach a switch
-        IOFSwitch mockSwitch = createNiceMock(IOFSwitch.class);
-        Capture<OFMessage> writeCapture = new Capture<OFMessage>(CaptureType.ALL);
-        Capture<FloodlightContext> contextCapture = new Capture<FloodlightContext>(CaptureType.ALL);
-        Capture<List<OFMessage>> writeCaptureList = new Capture<List<OFMessage>>(CaptureType.ALL);
+        mockSwitch = createNiceMock(IOFSwitch.class);
+        writeCapture = new Capture<OFMessage>(CaptureType.ALL);
+        contextCapture = new Capture<FloodlightContext>(CaptureType.ALL);
+        writeCaptureList = new Capture<List<OFMessage>>(CaptureType.ALL);
 
         //OFMessageSafeOutStream mockOutStream = createNiceMock(OFMessageSafeOutStream.class);
         mockSwitch.write(capture(writeCapture), capture(contextCapture));
@@ -193,24 +195,25 @@ public class StaticFlowTests extends FloodlightTestCase {
         mockSwitch.flush();
         expectLastCall().anyTimes();
 
-        staticFlowEntryPusher.setStorageSource(storage);
 
         FloodlightModuleContext fmc = new FloodlightModuleContext();
+        fmc.addService(IStorageSourceService.class, storage);
 
         MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
         Map<Long, IOFSwitch> switchMap = new HashMap<Long, IOFSwitch>();
         switchMap.put(dpid, mockSwitch);
         // NO ! expect(mockFloodlightProvider.getSwitches()).andReturn(switchMap).anyTimes();
         mockFloodlightProvider.setSwitches(switchMap);
-        staticFlowEntryPusher.setFloodlightProvider(mockFloodlightProvider);
+        fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
         RestApiServer restApi = new RestApiServer();
-        try {
-            restApi.init(fmc);
-        } catch (FloodlightModuleException e) {
-            e.printStackTrace();
-        }
-        staticFlowEntryPusher.restApi = restApi;
-        staticFlowEntryPusher.startUp(null);    // again, to hack unittest
+        fmc.addService(IRestApiService.class, restApi);
+        restApi.init(fmc);
+        staticFlowEntryPusher.init(fmc);
+        staticFlowEntryPusher.startUp(fmc);    // again, to hack unittest
+    }
+
+    @Test
+    public void testStaticFlowPush() throws Exception {
 
         // verify that flowpusher read all three entries from storage
         assertEquals(TotalTestRules, staticFlowEntryPusher.countEntries());
@@ -331,26 +334,13 @@ public class StaticFlowTests extends FloodlightTestCase {
 
     @Test
     public void testHARoleChanged() throws IOException {
-        StaticFlowEntryPusher staticFlowEntryPusher = new StaticFlowEntryPusher();
-        IStorageSourceService storage = createStorageWithFlowEntries();
-        MockFloodlightProvider mfp = getMockFloodlightProvider();
-        staticFlowEntryPusher.setFloodlightProvider(mfp);
-        staticFlowEntryPusher.setStorageSource(storage);
-        RestApiServer restApi = new RestApiServer();
-        try {
-            FloodlightModuleContext fmc = new FloodlightModuleContext();
-            restApi.init(fmc);
-        } catch (FloodlightModuleException e) {
-            e.printStackTrace();
-        }
-        staticFlowEntryPusher.restApi = restApi;
-        staticFlowEntryPusher.startUp(null);    // again, to hack unittest
 
         assert(staticFlowEntryPusher.entry2dpid.containsValue(TestSwitch1DPID));
         assert(staticFlowEntryPusher.entriesFromStorage.containsValue(FlowMod1));
         assert(staticFlowEntryPusher.entriesFromStorage.containsValue(FlowMod2));
         assert(staticFlowEntryPusher.entriesFromStorage.containsValue(FlowMod3));
 
+        /* FIXME: what's the right behavior here ??
         // Send a notification that we've changed to slave
         mfp.dispatchRoleChanged(Role.SLAVE);
         // Make sure we've removed all our entries
@@ -364,5 +354,6 @@ public class StaticFlowTests extends FloodlightTestCase {
         assert(staticFlowEntryPusher.entriesFromStorage.containsValue(FlowMod1));
         assert(staticFlowEntryPusher.entriesFromStorage.containsValue(FlowMod2));
         assert(staticFlowEntryPusher.entriesFromStorage.containsValue(FlowMod3));
+        */
     }
 }
diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
index abe069e3502d9d45bd4f2d5b6ae02a0b67791f41..b1027349cfc203a744a9cc18e828fe5d981064d1 100644
--- a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
+++ b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java
@@ -17,7 +17,6 @@
 package net.floodlightcontroller.topology;
 
 import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IFloodlightProviderService.Role;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
 import net.floodlightcontroller.linkdiscovery.ILinkDiscovery;
@@ -123,13 +122,4 @@ public class TopologyManagerTest extends FloodlightTestCase {
         assertTrue(tm.getTunnelPorts().size()==0);
     }
 
-    @Test
-    public void testHARoleChange() throws Exception {
-        testBasic2();
-        getMockFloodlightProvider().dispatchRoleChanged(Role.SLAVE);
-        assertTrue(tm.switchPorts.isEmpty());
-        assertTrue(tm.switchPortLinks.isEmpty());
-        assertTrue(tm.portBroadcastDomainLinks.isEmpty());
-        assertTrue(tm.tunnelPorts.isEmpty());
-    }
 }