Add ZooKeeper leadership related log.
- Raised mastership change log to info
- Log suppressed event at debug level.
Change-Id: If53b342e5de96eb447d3016f7fa674a7ed71a293
diff --git a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
index 35ce962..38ca110 100644
--- a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
+++ b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
@@ -160,7 +160,7 @@
}
class SwitchLeaderListener implements LeaderLatchListener {
- private String dpid;
+ private final String dpid;
public SwitchLeaderListener(String dpid) {
this.dpid = dpid;
@@ -168,7 +168,7 @@
@Override
public void isLeader() {
- log.debug("Became leader for {}", dpid);
+ log.info("Became leader for {}", dpid);
switchLeadershipEvents.add(
new SwitchLeaderEvent(HexString.toLong(dpid), true));
@@ -176,7 +176,7 @@
@Override
public void notLeader() {
- log.debug("Lost leadership for {}", dpid);
+ log.info("Lost leadership for {}", dpid);
switchLeadershipEvents.add(
new SwitchLeaderEvent(HexString.toLong(dpid), false));
@@ -236,12 +236,12 @@
@Override
public void isLeader() {
- log.debug("Cluster leadership aquired");
+ log.info("Cluster leadership aquired");
}
@Override
public void notLeader() {
- log.debug("Cluster leadership lost");
+ log.info("Cluster leadership lost");
}
}
@@ -474,6 +474,7 @@
return data;
}
+ @Override
public IdBlock allocateUniqueIdBlock(long range) {
try {
AtomicValue<Long> result = null;
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index 37e71c9..97f5812 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -24,6 +24,7 @@
import net.onrc.onos.core.registry.IControllerRegistryService.ControlChangeCallback;
import net.onrc.onos.core.registry.RegistryException;
import net.onrc.onos.core.topology.PortEvent.SwitchPort;
+import net.onrc.onos.core.util.Dpid;
import org.openflow.protocol.OFPhysicalPort;
import org.openflow.util.HexString;
@@ -131,16 +132,19 @@
@Override
public void linkDiscoveryUpdate(LDUpdate update) {
- if (!registryService.hasControl(update.getDst())) {
- // Don't process or send a link event if we're not master for the
- // destination switch
- return;
- }
LinkEvent linkEvent = new LinkEvent(update.getSrc(),
(long) update.getSrcPort(), update.getDst(),
(long) update.getDstPort());
+ if (!registryService.hasControl(update.getDst())) {
+ // Don't process or send a link event if we're not master for the
+ // destination switch
+ log.debug("Not the master for dst switch {}. Suppressed link event {}.",
+ update.getDst(), linkEvent);
+ return;
+ }
+
switch (update.getOperation()) {
case LINK_ADDED:
topologyDiscoveryInterface.putLinkDiscoveryEvent(linkEvent);
@@ -158,30 +162,41 @@
@Override
public void switchPortAdded(Long switchId, OFPhysicalPort port) {
+
+ PortEvent portEvent = new PortEvent(switchId, (long) port.getPortNumber());
if (registryService.hasControl(switchId)) {
- PortEvent portEvent = new PortEvent(switchId, (long) port.getPortNumber());
topologyDiscoveryInterface.putPortDiscoveryEvent(portEvent);
linkDiscovery.removeFromSuppressLLDPs(switchId, port.getPortNumber());
+ } else {
+ log.debug("Not the master for switch {}. Suppressed port add event {}.",
+ new Dpid(switchId), portEvent);
}
}
@Override
public void switchPortRemoved(Long switchId, OFPhysicalPort port) {
+
+ PortEvent portEvent = new PortEvent(switchId, (long) port.getPortNumber());
if (registryService.hasControl(switchId)) {
- PortEvent portEvent = new PortEvent(switchId, (long) port.getPortNumber());
topologyDiscoveryInterface.removePortDiscoveryEvent(portEvent);
+ } else {
+ log.debug("Not the master for switch {}. Suppressed port del event {}.",
+ new Dpid(switchId), portEvent);
}
}
@Override
public void addedSwitch(IOFSwitch sw) {
- // TODO Not very robust
- if (!registryService.hasControl(sw.getId())) {
- return;
- }
SwitchEvent switchEvent = new SwitchEvent(sw.getId());
+ // TODO Not very robust
+ if (!registryService.hasControl(sw.getId())) {
+ log.debug("Not the master for switch {}. Suppressed switch add event {}.",
+ new Dpid(sw.getId()), switchEvent);
+ return;
+ }
+
List<PortEvent> portEvents = new ArrayList<PortEvent>();
for (OFPhysicalPort port : sw.getPorts()) {
portEvents.add(new PortEvent(sw.getId(), (long) port.getPortNumber()));