Refactored code in an attempt to break dependency cycles
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterManagementMessageSubjects.java b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterManagementMessageSubjects.java
index 74c22f1..aa0dc83 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterManagementMessageSubjects.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterManagementMessageSubjects.java
@@ -6,5 +6,5 @@
     // avoid instantiation
     private ClusterManagementMessageSubjects() {}
 
-    public static final MessageSubject CLUSTER_MEMBERSHIP_EVENT = new MessageSubject("CLUSTER_MEMBERSHIP_EVENT");
+    public static final MessageSubject CLUSTER_MEMBERSHIP_EVENT = new MessageSubject("cluster-membership-event");
 }
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterNodesDelegate.java b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterNodesDelegate.java
index b82a835..2ad2666 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterNodesDelegate.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterNodesDelegate.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.store.cluster.impl;
 
-import org.onlab.onos.cluster.DefaultControllerNode;
+import org.onlab.onos.cluster.ControllerNode;
 import org.onlab.onos.cluster.NodeId;
 import org.onlab.packet.IpPrefix;
 
@@ -18,7 +18,7 @@
      * @param tcpPort node TCP listen port
      * @return the controller node
      */
-    DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort);
+    ControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort);
 
     /**
      * Notifies about cluster node going offline.
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
index 5e64a39..9433130 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
@@ -1,9 +1,5 @@
 package org.onlab.onos.store.cluster.impl;
 
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
 import com.google.common.collect.ImmutableSet;
 
 import org.apache.felix.scr.annotations.Activate;
@@ -18,8 +14,16 @@
 import org.onlab.onos.cluster.NodeId;
 import org.onlab.onos.store.AbstractStore;
 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService;
-import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager;
+import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
+import org.onlab.onos.store.cluster.messaging.ClusterMessage;
+import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
+import org.onlab.onos.store.cluster.messaging.MessageSubject;
+import org.onlab.onos.store.cluster.messaging.impl.ClusterMessageSerializer;
+import org.onlab.onos.store.cluster.messaging.impl.MessageSubjectSerializer;
+import org.onlab.onos.store.serializers.KryoPoolUtil;
+import org.onlab.onos.store.serializers.KryoSerializer;
 import org.onlab.packet.IpPrefix;
+import org.onlab.util.KryoPool;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,7 +31,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
 
 import static org.onlab.onos.cluster.ControllerNode.State;
 import static org.onlab.packet.IpPrefix.valueOf;
@@ -43,17 +46,33 @@
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private DefaultControllerNode localNode;
-    private final Map<NodeId, DefaultControllerNode> nodes = new ConcurrentHashMap<>();
+    private ControllerNode localNode;
+    private final Map<NodeId, ControllerNode> nodes = new ConcurrentHashMap<>();
     private final Map<NodeId, State> states = new ConcurrentHashMap<>();
-    private final Cache<NodeId, ControllerNode> livenessCache = CacheBuilder.newBuilder()
-            .maximumSize(1000)
-            .expireAfterWrite(ClusterCommunicationManager.HEART_BEAT_INTERVAL_MILLIS * 3, TimeUnit.MILLISECONDS)
-            .removalListener(new LivenessCacheRemovalListener()).build();
+
+    private static final KryoSerializer SERIALIZER = new KryoSerializer() {
+        @Override
+        protected void setupKryoPool() {
+            serializerPool = KryoPool.newBuilder()
+                    .register(KryoPoolUtil.API)
+                    .register(ClusterMessage.class, new ClusterMessageSerializer())
+                    .register(ClusterMembershipEvent.class)
+                    .register(byte[].class)
+                    .register(MessageSubject.class, new MessageSubjectSerializer())
+                    .build()
+                    .populate(1);
+        }
+    };
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     private ClusterCommunicationAdminService clusterCommunicationAdminService;
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private ClusterCommunicationService clusterCommunicator;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private ClusterMonitorService clusterMonitor;
+
     private final ClusterNodesDelegate nodesDelegate = new InnerNodesDelegate();
 
     @Activate
@@ -61,10 +80,15 @@
         loadClusterDefinition();
         establishSelfIdentity();
 
-        // Start-up the comm service and prime it with the loaded nodes.
-        clusterCommunicationAdminService.initialize(localNode, nodesDelegate);
-        for (DefaultControllerNode node : nodes.values()) {
-            clusterCommunicationAdminService.addNode(node);
+        clusterCommunicator.addSubscriber(
+                ClusterManagementMessageSubjects.CLUSTER_MEMBERSHIP_EVENT,
+                new ClusterMembershipEventListener());
+
+        // Start-up the monitor service and prime it with the loaded nodes.
+        clusterMonitor.initialize(localNode, nodesDelegate);
+
+        for (ControllerNode node : nodes.values()) {
+            clusterMonitor.addNode(node);
         }
         log.info("Started");
     }
@@ -130,22 +154,78 @@
     @Override
     public ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort) {
         DefaultControllerNode node = new DefaultControllerNode(nodeId, ip, tcpPort);
-        nodes.put(nodeId, node);
-        clusterCommunicationAdminService.addNode(node);
+        addNodeInternal(node);
+
+        try {
+            clusterCommunicator.broadcast(
+                    new ClusterMessage(
+                            localNode.id(),
+                            ClusterManagementMessageSubjects.CLUSTER_MEMBERSHIP_EVENT,
+                            SERIALIZER.encode(
+                                    new ClusterMembershipEvent(
+                                            ClusterMembershipEventType.NEW_MEMBER,
+                                            node))));
+        } catch (IOException e) {
+            // TODO: In a setup where cluster membership is not static (i.e. not everything has the same picture)
+            // we'll need a more consistent/dependable way to replicate membership events.
+            log.error("Failed to notify peers of a new cluster member", e);
+        }
+
         return node;
     }
 
+    private void addNodeInternal(ControllerNode node) {
+        nodes.put(node.id(), node);
+    }
+
     @Override
     public void removeNode(NodeId nodeId) {
+        ControllerNode node = removeNodeInternal(nodeId);
+
+        if (node != null) {
+            try {
+                clusterCommunicator.broadcast(
+                        new ClusterMessage(
+                                localNode.id(),
+                                ClusterManagementMessageSubjects.CLUSTER_MEMBERSHIP_EVENT,
+                                SERIALIZER.encode(
+                                        new ClusterMembershipEvent(
+                                                ClusterMembershipEventType.LEAVING_MEMBER,
+                                                node))));
+            } catch (IOException e) {
+                // TODO: In a setup where cluster membership is not static (i.e. not everything has the same picture)
+                // we'll need a more consistent/dependable way to replicate membership events.
+                log.error("Failed to notify peers of a existing cluster member leaving.", e);
+            }
+        }
+
+    }
+
+    private ControllerNode removeNodeInternal(NodeId nodeId) {
         if (nodeId.equals(localNode.id())) {
             nodes.clear();
             nodes.put(localNode.id(), localNode);
+            return localNode;
 
-        } else {
-            // Remove the other node.
-            DefaultControllerNode node = nodes.remove(nodeId);
-            if (node != null) {
-                clusterCommunicationAdminService.removeNode(node);
+        }
+        // Remove the other node.
+        ControllerNode node = nodes.remove(nodeId);
+        return node;
+    }
+
+    private class ClusterMembershipEventListener implements ClusterMessageHandler {
+        @Override
+        public void handle(ClusterMessage message) {
+
+            log.info("Received cluster membership event from peer: {}", message.sender());
+            ClusterMembershipEvent event = (ClusterMembershipEvent) SERIALIZER.decode(message.payload());
+            if (event.type() == ClusterMembershipEventType.NEW_MEMBER) {
+                log.info("Node {} is added", event.node().id());
+                addNodeInternal(event.node());
+            }
+            if (event.type() == ClusterMembershipEventType.LEAVING_MEMBER) {
+                log.info("Node {} is removed ", event.node().id());
+                removeNodeInternal(event.node().id());
             }
         }
     }
@@ -153,13 +233,12 @@
     // Entity to handle back calls from the connection manager.
     private class InnerNodesDelegate implements ClusterNodesDelegate {
         @Override
-        public DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) {
-            DefaultControllerNode node = nodes.get(nodeId);
+        public ControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) {
+            ControllerNode node = nodes.get(nodeId);
             if (node == null) {
                 node = (DefaultControllerNode) addNode(nodeId, ip, tcpPort);
             }
             states.put(nodeId, State.ACTIVE);
-            livenessCache.put(nodeId, node);
             return node;
         }
 
@@ -173,14 +252,4 @@
             removeNode(nodeId);
         }
     }
-
-    private class LivenessCacheRemovalListener implements RemovalListener<NodeId, ControllerNode> {
-
-        @Override
-        public void onRemoval(RemovalNotification<NodeId, ControllerNode> entry) {
-            NodeId nodeId = entry.getKey();
-            log.warn("Failed to receive heartbeats from controller: " + nodeId);
-            nodesDelegate.nodeVanished(nodeId);
-        }
-    }
 }
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
index c72fae8..0e6b1b8 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
@@ -4,8 +4,6 @@
 
 import java.io.IOException;
 import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -16,10 +14,6 @@
 import org.onlab.onos.cluster.ClusterService;
 import org.onlab.onos.cluster.ControllerNode;
 import org.onlab.onos.cluster.NodeId;
-import org.onlab.onos.store.cluster.impl.ClusterMembershipEvent;
-import org.onlab.onos.store.cluster.impl.ClusterMembershipEventType;
-import org.onlab.onos.store.cluster.impl.ClusterNodesDelegate;
-import org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService;
 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
@@ -38,7 +32,7 @@
 @Component(immediate = true)
 @Service
 public class ClusterCommunicationManager
-        implements ClusterCommunicationService, ClusterCommunicationAdminService {
+        implements ClusterCommunicationService {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -47,10 +41,6 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     private ClusterService clusterService;
 
-    private ClusterNodesDelegate nodesDelegate;
-    private final Timer timer = new Timer("onos-controller-heatbeats");
-    public static final long HEART_BEAT_INTERVAL_MILLIS = 1000L;
-
     // TODO: This probably should not be a OSGi service.
     private MessagingService messagingService;
 
@@ -60,7 +50,6 @@
             serializerPool = KryoPool.newBuilder()
                     .register(KryoPoolUtil.API)
                     .register(ClusterMessage.class, new ClusterMessageSerializer())
-                    .register(ClusterMembershipEvent.class)
                     .register(byte[].class)
                     .register(MessageSubject.class, new MessageSubjectSerializer())
                     .build()
@@ -134,61 +123,6 @@
         messagingService.registerHandler(subject.value(), new InternalClusterMessageHandler(subscriber));
     }
 
-    @Override
-    public void initialize(ControllerNode localNode,
-            ClusterNodesDelegate delegate) {
-        this.localNode = localNode;
-        this.nodesDelegate = delegate;
-        this.addSubscriber(new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"), new ClusterMemebershipEventHandler());
-        timer.schedule(new KeepAlive(), 0, HEART_BEAT_INTERVAL_MILLIS);
-    }
-
-    @Override
-    public void addNode(ControllerNode node) {
-        //members.put(node.id(), node);
-    }
-
-    @Override
-    public void removeNode(ControllerNode node) {
-        broadcast(new ClusterMessage(
-                localNode.id(),
-                new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"),
-                SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.LEAVING_MEMBER, node))));
-        //members.remove(node.id());
-    }
-
-    // Sends a heart beat to all peers.
-    private class KeepAlive extends TimerTask {
-
-        @Override
-        public void run() {
-            broadcast(new ClusterMessage(
-                localNode.id(),
-                new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"),
-                SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.HEART_BEAT, localNode))));
-        }
-    }
-
-    private class ClusterMemebershipEventHandler implements ClusterMessageHandler {
-
-        @Override
-        public void handle(ClusterMessage message) {
-
-            ClusterMembershipEvent event = SERIALIZER.decode(message.payload());
-            ControllerNode node = event.node();
-            if (event.type() == ClusterMembershipEventType.HEART_BEAT) {
-                log.info("Node {} sent a hearbeat", node.id());
-                nodesDelegate.nodeDetected(node.id(), node.ip(), node.tcpPort());
-            } else if (event.type() == ClusterMembershipEventType.LEAVING_MEMBER) {
-                log.info("Node {} is leaving", node.id());
-                nodesDelegate.nodeRemoved(node.id());
-            } else if (event.type() == ClusterMembershipEventType.UNREACHABLE_MEMBER) {
-                log.info("Node {} is unreachable", node.id());
-                nodesDelegate.nodeVanished(node.id());
-            }
-        }
-    }
-
     private final class InternalClusterMessageHandler implements MessageHandler {
 
         private final ClusterMessageHandler handler;
@@ -208,4 +142,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyAdvertisement.java b/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyAdvertisement.java
index 132f27a..5ab3e6f 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyAdvertisement.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyAdvertisement.java
@@ -3,7 +3,7 @@
 import java.util.Map;
 
 import org.onlab.onos.cluster.NodeId;
-import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.net.device.Timestamp;
 
 import com.google.common.collect.ImmutableMap;
 
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyReply.java b/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyReply.java
index 46a2333..2a0ef60 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyReply.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyReply.java
@@ -4,7 +4,7 @@
 import java.util.Set;
 
 import org.onlab.onos.cluster.NodeId;
-import org.onlab.onos.store.VersionedValue;
+import org.onlab.onos.net.device.VersionedValue;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/DeviceMastershipBasedTimestamp.java b/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/DeviceMastershipBasedTimestamp.java
index 4bc41ab..30b3db6 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/DeviceMastershipBasedTimestamp.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/common/impl/DeviceMastershipBasedTimestamp.java
@@ -4,7 +4,7 @@
 
 import java.util.Objects;
 
-import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.net.device.Timestamp;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ComparisonChain;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyAdvertisement.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyAdvertisement.java
index c9f232a..6bb9f01 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyAdvertisement.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyAdvertisement.java
@@ -7,8 +7,8 @@
 import org.onlab.onos.cluster.NodeId;
 import org.onlab.onos.net.Device;
 import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.store.Timestamp;
-import org.onlab.onos.store.VersionedValue;
+import org.onlab.onos.net.device.Timestamp;
+import org.onlab.onos.net.device.VersionedValue;
 import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement;
 
 // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID)
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyReply.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyReply.java
index 34dc873..4bb9dda 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyReply.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyReply.java
@@ -9,8 +9,8 @@
 import org.onlab.onos.cluster.NodeId;
 import org.onlab.onos.net.Device;
 import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.store.Timestamp;
-import org.onlab.onos.store.VersionedValue;
+import org.onlab.onos.net.device.Timestamp;
+import org.onlab.onos.net.device.VersionedValue;
 import org.onlab.onos.store.common.impl.AntiEntropyReply;
 
 import com.google.common.collect.ImmutableMap;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceClockManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceClockManager.java
index 6f4fb96..a8d023c 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceClockManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceClockManager.java
@@ -11,10 +11,10 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.device.DeviceClockProviderService;
+import org.onlab.onos.net.device.DeviceClockService;
 import org.onlab.onos.net.device.DeviceMastershipTerm;
-import org.onlab.onos.store.ClockProviderService;
-import org.onlab.onos.store.ClockService;
-import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.net.device.Timestamp;
 import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp;
 import org.slf4j.Logger;
 
@@ -23,7 +23,7 @@
  */
 @Component(immediate = true)
 @Service
-public class DeviceClockManager implements ClockService, ClockProviderService {
+public class DeviceClockManager implements DeviceClockService, DeviceClockProviderService {
 
     private final Logger log = getLogger(getClass());
 
@@ -51,7 +51,7 @@
     }
 
     @Override
-    public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
+    public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
         deviceMastershipTerms.put(deviceId, term);
     }
 }
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
index 06c70a0..ebcbb0c 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
@@ -26,16 +26,16 @@
 import org.onlab.onos.net.SparseAnnotations;
 import org.onlab.onos.net.device.DefaultDeviceDescription;
 import org.onlab.onos.net.device.DefaultPortDescription;
+import org.onlab.onos.net.device.DeviceClockService;
 import org.onlab.onos.net.device.DeviceDescription;
 import org.onlab.onos.net.device.DeviceEvent;
 import org.onlab.onos.net.device.DeviceStore;
 import org.onlab.onos.net.device.DeviceStoreDelegate;
 import org.onlab.onos.net.device.PortDescription;
+import org.onlab.onos.net.device.Timestamp;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.onos.net.provider.ProviderId;
 import org.onlab.onos.store.AbstractStore;
-import org.onlab.onos.store.ClockService;
-import org.onlab.onos.store.Timestamp;
-import org.onlab.onos.store.Timestamped;
 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
@@ -105,7 +105,7 @@
     private final Set<DeviceId> availableDevices = Sets.newConcurrentHashSet();
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected ClockService clockService;
+    protected DeviceClockService clockService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected ClusterCommunicationService clusterCommunicator;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEvent.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEvent.java
index 1deb5d5..55da310 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEvent.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEvent.java
@@ -2,8 +2,8 @@
 
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.device.DeviceDescription;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.Timestamped;
 
 /**
  * Information published by GossipDeviceStore to notify peers of a device
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java
index 63ddda3..f17a602 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java
@@ -2,8 +2,8 @@
 
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.device.DeviceDescription;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.Timestamped;
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.Serializer;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEvent.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEvent.java
index d8942d6..806a9fb 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEvent.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEvent.java
@@ -1,7 +1,7 @@
 package org.onlab.onos.store.device.impl;
 
 import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.net.device.Timestamp;
 
 /**
  * Information published by GossipDeviceStore to notify peers of a device
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEventSerializer.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEventSerializer.java
index 7059636..e014cac 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEventSerializer.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEventSerializer.java
@@ -1,7 +1,7 @@
 package org.onlab.onos.store.device.impl;
 
 import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.net.device.Timestamp;
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.Serializer;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceRemovedEvent.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceRemovedEvent.java
index 6c8b905..5800583 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceRemovedEvent.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceRemovedEvent.java
@@ -1,7 +1,7 @@
 package org.onlab.onos.store.device.impl;
 
 import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.net.device.Timestamp;
 
 /**
  * Information published by GossipDeviceStore to notify peers of a device
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEvent.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEvent.java
index ad4e380..b9acb2c 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEvent.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEvent.java
@@ -4,8 +4,8 @@
 
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.device.PortDescription;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.Timestamped;
 
 /**
  * Information published by GossipDeviceStore to notify peers of a port
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java
index ede88f1..a2737b4 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java
@@ -4,8 +4,8 @@
 
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.device.PortDescription;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.Timestamped;
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.Serializer;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEvent.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEvent.java
index 00f9a9f..07424eb 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEvent.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEvent.java
@@ -2,8 +2,8 @@
 
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.device.PortDescription;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.Timestamped;
 
 /**
  * Information published by GossipDeviceStore to notify peers of a port
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEventSerializer.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEventSerializer.java
index 82fbb89..434787c 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEventSerializer.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEventSerializer.java
@@ -2,8 +2,8 @@
 
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.device.PortDescription;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.Timestamped;
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.Serializer;
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/OnosDistributedLinkStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/OnosDistributedLinkStore.java
index d00d76b..17fbe10 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/OnosDistributedLinkStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/OnosDistributedLinkStore.java
@@ -23,15 +23,15 @@
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.Link;
 import org.onlab.onos.net.LinkKey;
+import org.onlab.onos.net.device.DeviceClockService;
+import org.onlab.onos.net.device.Timestamp;
+import org.onlab.onos.net.device.VersionedValue;
 import org.onlab.onos.net.link.LinkDescription;
 import org.onlab.onos.net.link.LinkEvent;
 import org.onlab.onos.net.link.LinkStore;
 import org.onlab.onos.net.link.LinkStoreDelegate;
 import org.onlab.onos.net.provider.ProviderId;
 import org.onlab.onos.store.AbstractStore;
-import org.onlab.onos.store.ClockService;
-import org.onlab.onos.store.Timestamp;
-import org.onlab.onos.store.VersionedValue;
 import org.slf4j.Logger;
 
 import com.google.common.collect.HashMultimap;
@@ -71,7 +71,7 @@
     private final Multimap<DeviceId, VersionedValue<Link>> dstLinks = HashMultimap.create();
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected ClockService clockService;
+    protected DeviceClockService clockService;
 
     @Activate
     public void activate() {
diff --git a/core/store/dist/src/test/java/org/onlab/onos/store/cluster/impl/ClusterCommunicationManagerTest.java b/core/store/dist/src/test/java/org/onlab/onos/store/cluster/impl/ClusterCommunicationManagerTest.java
index e63fcaa..c78f78a 100644
--- a/core/store/dist/src/test/java/org/onlab/onos/store/cluster/impl/ClusterCommunicationManagerTest.java
+++ b/core/store/dist/src/test/java/org/onlab/onos/store/cluster/impl/ClusterCommunicationManagerTest.java
@@ -2,8 +2,6 @@
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
 import org.onlab.onos.cluster.DefaultControllerNode;
 import org.onlab.onos.cluster.NodeId;
 import org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager;
@@ -11,12 +9,6 @@
 import org.onlab.netty.NettyMessagingService;
 import org.onlab.packet.IpPrefix;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
 /**
  * Tests of the cluster communication manager.
  */
@@ -33,9 +25,6 @@
     private ClusterCommunicationManager ccm1;
     private ClusterCommunicationManager ccm2;
 
-    private TestDelegate cnd1 = new TestDelegate();
-    private TestDelegate cnd2 = new TestDelegate();
-
     private DefaultControllerNode node1 = new DefaultControllerNode(N1, IP, P1);
     private DefaultControllerNode node2 = new DefaultControllerNode(N2, IP, P2);
 
@@ -48,15 +37,10 @@
         messagingService.activate();
 
         ccm1 = new ClusterCommunicationManager();
-//        ccm1.serializationService = messageSerializer;
         ccm1.activate();
 
         ccm2 = new ClusterCommunicationManager();
-//        ccm2.serializationService = messageSerializer;
         ccm2.activate();
-
-        ccm1.initialize(node1, cnd1);
-        ccm2.initialize(node2, cnd2);
     }
 
     @After
@@ -64,70 +48,4 @@
         ccm1.deactivate();
         ccm2.deactivate();
     }
-
-    @Ignore("FIXME: failing randomly?")
-    @Test
-    public void connect() throws Exception {
-        cnd1.latch = new CountDownLatch(1);
-        cnd2.latch = new CountDownLatch(1);
-
-        ccm1.addNode(node2);
-        validateDelegateEvent(cnd1, Op.DETECTED, node2.id());
-        validateDelegateEvent(cnd2, Op.DETECTED, node1.id());
-    }
-
-    @Test
-    @Ignore
-    public void disconnect() throws Exception {
-        cnd1.latch = new CountDownLatch(1);
-        cnd2.latch = new CountDownLatch(1);
-
-        ccm1.addNode(node2);
-        validateDelegateEvent(cnd1, Op.DETECTED, node2.id());
-        validateDelegateEvent(cnd2, Op.DETECTED, node1.id());
-
-        cnd1.latch = new CountDownLatch(1);
-        cnd2.latch = new CountDownLatch(1);
-        ccm1.deactivate();
-//
-//        validateDelegateEvent(cnd2, Op.VANISHED, node1.id());
-    }
-
-    private void validateDelegateEvent(TestDelegate delegate, Op op, NodeId nodeId)
-            throws InterruptedException {
-        assertTrue("did not connect in time", delegate.latch.await(2500, TimeUnit.MILLISECONDS));
-        assertEquals("incorrect event", op, delegate.op);
-        assertEquals("incorrect event node", nodeId, delegate.nodeId);
-    }
-
-    enum Op { DETECTED, VANISHED, REMOVED };
-
-    private class TestDelegate implements ClusterNodesDelegate {
-
-        Op op;
-        CountDownLatch latch;
-        NodeId nodeId;
-
-        @Override
-        public DefaultControllerNode nodeDetected(NodeId nodeId, IpPrefix ip, int tcpPort) {
-            latch(nodeId, Op.DETECTED);
-            return new DefaultControllerNode(nodeId, ip, tcpPort);
-        }
-
-        @Override
-        public void nodeVanished(NodeId nodeId) {
-            latch(nodeId, Op.VANISHED);
-        }
-
-        @Override
-        public void nodeRemoved(NodeId nodeId) {
-            latch(nodeId, Op.REMOVED);
-        }
-
-        private void latch(NodeId nodeId, Op op) {
-            this.op = op;
-            this.nodeId = nodeId;
-            latch.countDown();
-        }
-    }
-}
+}
\ No newline at end of file
diff --git a/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampTest.java b/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampTest.java
index 2c8ff35..154c2f6 100644
--- a/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampTest.java
+++ b/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampTest.java
@@ -5,7 +5,7 @@
 import java.nio.ByteBuffer;
 
 import org.junit.Test;
-import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.net.device.Timestamp;
 import org.onlab.util.KryoPool;
 
 import com.google.common.testing.EqualsTester;
diff --git a/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/TimestampedTest.java b/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/TimestampedTest.java
index 2a0faa8..9b6c3e6 100644
--- a/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/TimestampedTest.java
+++ b/core/store/dist/src/test/java/org/onlab/onos/store/common/impl/TimestampedTest.java
@@ -5,8 +5,8 @@
 import java.nio.ByteBuffer;
 
 import org.junit.Test;
-import org.onlab.onos.store.Timestamp;
-import org.onlab.onos.store.Timestamped;
+import org.onlab.onos.net.device.Timestamp;
+import org.onlab.onos.net.device.Timestamped;
 import org.onlab.util.KryoPool;
 
 import com.google.common.testing.EqualsTester;
diff --git a/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java b/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
index d1060cc..a683f91 100644
--- a/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
+++ b/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
@@ -35,6 +35,7 @@
 import org.onlab.onos.net.SparseAnnotations;
 import org.onlab.onos.net.device.DefaultDeviceDescription;
 import org.onlab.onos.net.device.DefaultPortDescription;
+import org.onlab.onos.net.device.DeviceClockService;
 import org.onlab.onos.net.device.DeviceDescription;
 import org.onlab.onos.net.device.DeviceEvent;
 import org.onlab.onos.net.device.DeviceStore;
@@ -42,7 +43,6 @@
 import org.onlab.onos.net.device.DeviceMastershipTerm;
 import org.onlab.onos.net.device.PortDescription;
 import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.ClockService;
 import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
@@ -96,7 +96,7 @@
     private DeviceStore deviceStore;
 
     private DeviceClockManager deviceClockManager;
-    private ClockService clockService;
+    private DeviceClockService clockService;
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
@@ -113,8 +113,8 @@
         deviceClockManager.activate();
         clockService = deviceClockManager;
 
-        deviceClockManager.setMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1));
-        deviceClockManager.setMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2));
+        deviceClockManager.setDeviceMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1));
+        deviceClockManager.setDeviceMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2));
 
         ClusterCommunicationService clusterCommunicator = new TestClusterCommunicationService();
         ClusterService clusterService = new TestClusterService();
@@ -556,7 +556,7 @@
     private static final class TestGossipDeviceStore extends GossipDeviceStore {
 
         public TestGossipDeviceStore(
-                ClockService clockService,
+                DeviceClockService clockService,
                 ClusterService clusterService,
                 ClusterCommunicationService clusterCommunicator) {
             this.clockService = clockService;
diff --git a/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStore.java b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStore.java
index cdcf84b..f9f0381 100644
--- a/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStore.java
+++ b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStore.java
@@ -14,8 +14,8 @@
 import org.onlab.onos.cluster.ClusterService;
 import org.onlab.onos.cluster.NodeId;
 import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.net.MastershipRole;
 import org.onlab.onos.net.device.DeviceMastershipEvent;
+import org.onlab.onos.net.device.DeviceMastershipRole;
 import org.onlab.onos.net.device.DeviceMastershipStore;
 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
 import org.onlab.onos.net.device.DeviceMastershipTerm;
@@ -76,7 +76,7 @@
     }
 
     @Override
-    public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
+    public DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
         byte[] did = serialize(deviceId);
         byte[] nid = serialize(nodeId);
 
@@ -84,17 +84,17 @@
         if (current == null) {
             if (standbys.containsEntry(did, nid)) {
                 //was previously standby, or set to standby from master
-                return MastershipRole.STANDBY;
+                return DeviceMastershipRole.STANDBY;
             } else {
-                return MastershipRole.NONE;
+                return DeviceMastershipRole.NONE;
             }
         } else {
             if (current.equals(nodeId)) {
                 //*should* be in unusable, not always
-                return MastershipRole.MASTER;
+                return DeviceMastershipRole.MASTER;
             } else {
                 //may be in backups or unusable from earlier retirement
-                return MastershipRole.STANDBY;
+                return DeviceMastershipRole.STANDBY;
             }
         }
     }
@@ -107,7 +107,7 @@
         ILock lock = theInstance.getLock(LOCK);
         lock.lock();
         try {
-            MastershipRole role = getRole(nodeId, deviceId);
+            DeviceMastershipRole role = getRole(nodeId, deviceId);
             switch (role) {
                 case MASTER:
                     //reinforce mastership
@@ -157,7 +157,7 @@
     }
 
     @Override
-    public MastershipRole requestRole(DeviceId deviceId) {
+    public DeviceMastershipRole requestRole(DeviceId deviceId) {
         NodeId local = clusterService.getLocalNode().id();
         byte [] did = serialize(deviceId);
         byte [] lnid = serialize(local);
@@ -165,7 +165,7 @@
         ILock lock = theInstance.getLock(LOCK);
         lock.lock();
         try {
-            MastershipRole role = getRole(local, deviceId);
+            DeviceMastershipRole role = getRole(local, deviceId);
             switch (role) {
                 case MASTER:
                     evict(lnid, did);
@@ -179,7 +179,7 @@
                     masters.put(did, lnid);
                     evict(lnid, did);
                     updateTerm(did);
-                    role = MastershipRole.MASTER;
+                    role = DeviceMastershipRole.MASTER;
                     break;
                 default:
                     log.warn("unknown Mastership Role {}", role);
@@ -210,7 +210,7 @@
         ILock lock = theInstance.getLock(LOCK);
         lock.lock();
         try {
-            MastershipRole role = getRole(nodeId, deviceId);
+            DeviceMastershipRole role = getRole(nodeId, deviceId);
             switch (role) {
                 case MASTER:
                     event = reelect(nodeId, deviceId);
@@ -239,7 +239,7 @@
         ILock lock = theInstance.getLock(LOCK);
         lock.lock();
         try {
-            MastershipRole role = getRole(nodeId, deviceId);
+            DeviceMastershipRole role = getRole(nodeId, deviceId);
             switch (role) {
                 case MASTER:
                     event = reelect(nodeId, deviceId);
diff --git a/core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStoreTest.java b/core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStoreTest.java
index d993250..d1b9407 100644
--- a/core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStoreTest.java
+++ b/core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStoreTest.java
@@ -3,7 +3,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.onlab.onos.net.MastershipRole.*;
+import static org.onlab.onos.net.device.DeviceMastershipRole.*;
 
 import java.util.Map;
 import java.util.Set;
diff --git a/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockProviderService.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockProviderService.java
index 729b01e..018fca6 100644
--- a/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockProviderService.java
+++ b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockProviderService.java
@@ -3,18 +3,18 @@
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.device.DeviceClockProviderService;
 import org.onlab.onos.net.device.DeviceMastershipTerm;
-import org.onlab.onos.store.ClockProviderService;
 
 // FIXME: Code clone in onos-core-trivial, onos-core-hz-net
 /**
- * Dummy implementation of {@link ClockProviderService}.
+ * Dummy implementation of {@link DeviceClockProviderService}.
  */
 @Component(immediate = true)
 @Service
-public class NoOpClockProviderService implements ClockProviderService {
+public class NoOpClockProviderService implements DeviceClockProviderService {
 
     @Override
-    public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
+    public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
     }
 }
diff --git a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
index 5676cb6..c32c04a 100644
--- a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
+++ b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
@@ -18,11 +18,11 @@
 import org.onlab.onos.net.Element;
 import org.onlab.onos.net.Link;
 import org.onlab.onos.net.LinkKey;
-import org.onlab.onos.net.MastershipRole;
 import org.onlab.onos.net.Port;
 import org.onlab.onos.net.PortNumber;
 import org.onlab.onos.net.device.DefaultDeviceDescription;
 import org.onlab.onos.net.device.DefaultPortDescription;
+import org.onlab.onos.net.device.DeviceMastershipRole;
 import org.onlab.onos.net.device.DeviceMastershipTerm;
 import org.onlab.onos.net.provider.ProviderId;
 import org.onlab.packet.IpAddress;
@@ -59,7 +59,7 @@
                     DefaultControllerNode.class,
                     DefaultDevice.class,
                     DefaultDeviceDescription.class,
-                    MastershipRole.class,
+                    DeviceMastershipRole.class,
                     Port.class,
                     DefaultPortDescription.class,
                     Element.class,
@@ -75,7 +75,7 @@
             .register(ConnectPoint.class, new ConnectPointSerializer())
             .register(DefaultLink.class, new DefaultLinkSerializer())
             .register(DeviceMastershipTerm.class, new MastershipTermSerializer())
-            .register(MastershipRole.class, new MastershipRoleSerializer())
+            .register(DeviceMastershipRole.class, new MastershipRoleSerializer())
 
             .build();
 
diff --git a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/MastershipRoleSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/MastershipRoleSerializer.java
index dab5aa8..f94441e 100644
--- a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/MastershipRoleSerializer.java
+++ b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/MastershipRoleSerializer.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.store.serializers;
 
-import org.onlab.onos.net.MastershipRole;
+import org.onlab.onos.net.device.DeviceMastershipRole;
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.Serializer;
@@ -8,12 +8,12 @@
 import com.esotericsoftware.kryo.io.Output;
 
 /**
- * Kryo Serializer for {@link org.onlab.onos.net.MastershipRole}.
+ * Kryo Serializer for {@link org.onlab.onos.net.device.DeviceMastershipRole}.
  */
-public class MastershipRoleSerializer extends Serializer<MastershipRole> {
+public class MastershipRoleSerializer extends Serializer<DeviceMastershipRole> {
 
     /**
-     * Creates {@link MastershipRole} serializer instance.
+     * Creates {@link DeviceMastershipRole} serializer instance.
      */
     public MastershipRoleSerializer() {
         // non-null, immutable
@@ -21,13 +21,13 @@
     }
 
     @Override
-    public MastershipRole read(Kryo kryo, Input input, Class<MastershipRole> type) {
+    public DeviceMastershipRole read(Kryo kryo, Input input, Class<DeviceMastershipRole> type) {
         final String role = kryo.readObject(input, String.class);
-        return MastershipRole.valueOf(role);
+        return DeviceMastershipRole.valueOf(role);
     }
 
     @Override
-    public void write(Kryo kryo, Output output, MastershipRole object) {
+    public void write(Kryo kryo, Output output, DeviceMastershipRole object) {
         kryo.writeObject(output, object.toString());
     }
 
diff --git a/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java b/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
index ab9e012..6d5b31d 100644
--- a/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
+++ b/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
@@ -21,9 +21,9 @@
 import org.onlab.onos.net.DeviceId;
 import org.onlab.onos.net.Link;
 import org.onlab.onos.net.LinkKey;
-import org.onlab.onos.net.MastershipRole;
 import org.onlab.onos.net.PortNumber;
 import org.onlab.onos.net.SparseAnnotations;
+import org.onlab.onos.net.device.DeviceMastershipRole;
 import org.onlab.onos.net.device.DeviceMastershipTerm;
 import org.onlab.onos.net.provider.ProviderId;
 import org.onlab.packet.IpAddress;
@@ -115,7 +115,7 @@
         testSerialized(PIDA);
         testSerialized(new NodeId("bar"));
         testSerialized(DeviceMastershipTerm.of(new NodeId("foo"), 2));
-        for (MastershipRole role : MastershipRole.values()) {
+        for (DeviceMastershipRole role : DeviceMastershipRole.values()) {
             testSerialized(role);
         }
     }
diff --git a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/NoOpClockProviderService.java b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/NoOpClockProviderService.java
index 5f3c2ef..afef76d 100644
--- a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/NoOpClockProviderService.java
+++ b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/NoOpClockProviderService.java
@@ -3,18 +3,18 @@
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.device.DeviceClockProviderService;
 import org.onlab.onos.net.device.DeviceMastershipTerm;
-import org.onlab.onos.store.ClockProviderService;
 
 //FIXME: Code clone in onos-core-trivial, onos-core-hz-net
 /**
- * Dummy implementation of {@link ClockProviderService}.
+ * Dummy implementation of {@link DeviceClockProviderService}.
  */
 @Component(immediate = true)
 @Service
-public class NoOpClockProviderService implements ClockProviderService {
+public class NoOpClockProviderService implements DeviceClockProviderService {
 
     @Override
-    public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
+    public void setDeviceMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
     }
 }
diff --git a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStore.java b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStore.java
index 7f88edb..38ca2ee 100644
--- a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStore.java
+++ b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStore.java
@@ -17,8 +17,8 @@
 import org.onlab.onos.cluster.DefaultControllerNode;
 import org.onlab.onos.cluster.NodeId;
 import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.net.MastershipRole;
 import org.onlab.onos.net.device.DeviceMastershipEvent;
+import org.onlab.onos.net.device.DeviceMastershipRole;
 import org.onlab.onos.net.device.DeviceMastershipStore;
 import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
 import org.onlab.onos.net.device.DeviceMastershipTerm;
@@ -64,7 +64,7 @@
 
     @Override
     public DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
-        MastershipRole role = getRole(nodeId, deviceId);
+        DeviceMastershipRole role = getRole(nodeId, deviceId);
 
         synchronized (this) {
             switch (role) {
@@ -106,10 +106,10 @@
     }
 
     @Override
-    public MastershipRole requestRole(DeviceId deviceId) {
+    public DeviceMastershipRole requestRole(DeviceId deviceId) {
         //query+possible reelection
         NodeId node = instance.id();
-        MastershipRole role = getRole(node, deviceId);
+        DeviceMastershipRole role = getRole(node, deviceId);
 
         switch (role) {
             case MASTER:
@@ -121,7 +121,7 @@
                     if (rel == null) {
                         masterMap.put(deviceId, node);
                         termMap.put(deviceId, new AtomicInteger());
-                        role = MastershipRole.MASTER;
+                        role = DeviceMastershipRole.MASTER;
                     }
                     backups.add(node);
                 }
@@ -132,7 +132,7 @@
                     masterMap.put(deviceId, node);
                     termMap.put(deviceId, new AtomicInteger());
                     backups.add(node);
-                    role = MastershipRole.MASTER;
+                    role = DeviceMastershipRole.MASTER;
                 }
                 break;
             default:
@@ -142,22 +142,22 @@
     }
 
     @Override
-    public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
+    public DeviceMastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
         //just query
         NodeId current = masterMap.get(deviceId);
-        MastershipRole role;
+        DeviceMastershipRole role;
 
         if (current == null) {
             if (backups.contains(nodeId)) {
-                role = MastershipRole.STANDBY;
+                role = DeviceMastershipRole.STANDBY;
             } else {
-                role = MastershipRole.NONE;
+                role = DeviceMastershipRole.NONE;
             }
         } else {
             if (current.equals(nodeId)) {
-                role = MastershipRole.MASTER;
+                role = DeviceMastershipRole.MASTER;
             } else {
-                role = MastershipRole.STANDBY;
+                role = DeviceMastershipRole.STANDBY;
             }
         }
         return role;
@@ -175,7 +175,7 @@
 
     @Override
     public DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
-        MastershipRole role = getRole(nodeId, deviceId);
+        DeviceMastershipRole role = getRole(nodeId, deviceId);
         synchronized (this) {
             switch (role) {
                 case MASTER:
diff --git a/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStoreTest.java b/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStoreTest.java
index d3430ca..a1cc132 100644
--- a/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStoreTest.java
+++ b/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStoreTest.java
@@ -15,8 +15,8 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.onlab.onos.net.MastershipRole.*;
 import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*;
+import static org.onlab.onos.net.device.DeviceMastershipRole.*;
 
 /**
  * Test for the simple MastershipStore implementation.