simple implementation of DistributedMastershipStore#unsetMaster

Change-Id: I955f394b975fb53d2ca93b7a8a34a7ad3d684767
diff --git a/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
index fafd450..bd7864a 100644
--- a/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
+++ b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
@@ -119,14 +119,24 @@
 
     @Override
     public MastershipTerm getTermFor(DeviceId deviceId) {
-        // FIXME: implement this
+        // FIXME: implement this properly
         return MastershipTerm.of(getMaster(deviceId), 1);
     }
 
     @Override
     public MastershipEvent unsetMaster(NodeId nodeId, DeviceId deviceId) {
-        // TODO Auto-generated method stub
-        return null;
+        boolean removed = rawMasters.remove(serialize(deviceId), serialize(nodeId));
+        masters.invalidate(deviceId);
+        if (!removed) {
+            return null;
+        }
+        Optional<NodeId> newMaster = masters.getUnchecked(deviceId);
+        if (newMaster.isPresent()) {
+            return new MastershipEvent(MASTER_CHANGED, deviceId, newMaster.get());
+        } else {
+            // FIXME: probably need to express NO_MASTER somehow.
+            return null;
+        }
     }
 
     private class RemoteMasterShipEventHandler extends RemoteCacheEventHandler<DeviceId, NodeId> {