Madan Jampani
Committed by Brian O'Connor

Logging improvements.

Change-Id: I79b9ff16a0000e4bd72022f02baef5c779ea1b48
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
15 */ 15 */
16 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
17 17
18 +import java.util.Comparator;
19 +import java.util.Map;
20 +
18 import org.apache.karaf.shell.commands.Command; 21 import org.apache.karaf.shell.commands.Command;
19 import org.onosproject.cli.AbstractShellCommand; 22 import org.onosproject.cli.AbstractShellCommand;
20 import org.onosproject.cluster.Leadership; 23 import org.onosproject.cluster.Leadership;
21 import org.onosproject.cluster.LeadershipService; 24 import org.onosproject.cluster.LeadershipService;
22 25
23 -import java.util.Comparator;
24 -import java.util.Map;
25 -
26 /** 26 /**
27 * Prints the leader for every topic. 27 * Prints the leader for every topic.
28 */ 28 */
...@@ -30,13 +30,15 @@ import java.util.Map; ...@@ -30,13 +30,15 @@ import java.util.Map;
30 description = "Finds the leader for particular topic.") 30 description = "Finds the leader for particular topic.")
31 public class LeaderCommand extends AbstractShellCommand { 31 public class LeaderCommand extends AbstractShellCommand {
32 32
33 - private static final String FMT = "%-20s: %15s %15s"; 33 + private static final String FMT = "%-20s | %-15s | %-6s |";
34 34
35 @Override 35 @Override
36 protected void execute() { 36 protected void execute() {
37 LeadershipService leaderService = get(LeadershipService.class); 37 LeadershipService leaderService = get(LeadershipService.class);
38 Map<String, Leadership> leaderBoard = leaderService.getLeaderBoard(); 38 Map<String, Leadership> leaderBoard = leaderService.getLeaderBoard();
39 + print("-------------------------------------------------");
39 print(FMT, "Topic", "Leader", "Epoch"); 40 print(FMT, "Topic", "Leader", "Epoch");
41 + print("-------------------------------------------------");
40 42
41 Comparator<Leadership> leadershipComparator = 43 Comparator<Leadership> leadershipComparator =
42 (e1, e2) -> { 44 (e1, e2) -> {
...@@ -56,6 +58,7 @@ public class LeaderCommand extends AbstractShellCommand { ...@@ -56,6 +58,7 @@ public class LeaderCommand extends AbstractShellCommand {
56 .stream() 58 .stream()
57 .sorted(leadershipComparator) 59 .sorted(leadershipComparator)
58 .forEach(l -> print(FMT, l.topic(), l.leader(), l.epoch())); 60 .forEach(l -> print(FMT, l.topic(), l.leader(), l.epoch()));
61 + print("-------------------------------------------------");
59 } 62 }
60 63
61 } 64 }
......
1 +package org.onosproject.store.cluster.impl;
2 +
3 +import java.util.Set;
4 +
5 +import org.onosproject.cluster.DefaultControllerNode;
6 +
7 +import com.google.common.collect.ImmutableSet;
8 +
9 +/**
10 + * Cluster definition.
11 + */
12 +public class ClusterDefinition {
13 +
14 + private Set<DefaultControllerNode> nodes;
15 + private String ipPrefix;
16 +
17 + /**
18 + * Creates a new cluster definition.
19 + * @param nodes cluster nodes.
20 + * @param ipPrefix ip prefix common to all cluster nodes.
21 + * @return cluster definition
22 + */
23 + public static ClusterDefinition from(Set<DefaultControllerNode> nodes, String ipPrefix) {
24 + ClusterDefinition definition = new ClusterDefinition();
25 + definition.ipPrefix = ipPrefix;
26 + definition.nodes = ImmutableSet.copyOf(nodes);
27 + return definition;
28 + }
29 +
30 + /**
31 + * Returns set of cluster nodes.
32 + * @return cluster nodes.
33 + */
34 + public Set<DefaultControllerNode> nodes() {
35 + return ImmutableSet.copyOf(nodes);
36 + }
37 +
38 + /**
39 + * Returns ipPrefix in dotted decimal notion.
40 + * @return ip prefix.
41 + */
42 + public String ipPrefix() {
43 + return ipPrefix;
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -21,6 +21,8 @@ import com.fasterxml.jackson.databind.JsonNode; ...@@ -21,6 +21,8 @@ import com.fasterxml.jackson.databind.JsonNode;
21 import com.fasterxml.jackson.databind.ObjectMapper; 21 import com.fasterxml.jackson.databind.ObjectMapper;
22 import com.fasterxml.jackson.databind.node.ArrayNode; 22 import com.fasterxml.jackson.databind.node.ArrayNode;
23 import com.fasterxml.jackson.databind.node.ObjectNode; 23 import com.fasterxml.jackson.databind.node.ObjectNode;
24 +import com.fasterxml.jackson.databind.node.TextNode;
25 +
24 import org.onosproject.cluster.DefaultControllerNode; 26 import org.onosproject.cluster.DefaultControllerNode;
25 import org.onosproject.cluster.NodeId; 27 import org.onosproject.cluster.NodeId;
26 import org.onlab.packet.IpAddress; 28 import org.onlab.packet.IpAddress;
...@@ -53,7 +55,7 @@ public class ClusterDefinitionStore { ...@@ -53,7 +55,7 @@ public class ClusterDefinitionStore {
53 * 55 *
54 * @return set of controller nodes 56 * @return set of controller nodes
55 */ 57 */
56 - public Set<DefaultControllerNode> read() throws IOException { 58 + public ClusterDefinition read() throws IOException {
57 Set<DefaultControllerNode> nodes = new HashSet<>(); 59 Set<DefaultControllerNode> nodes = new HashSet<>();
58 ObjectMapper mapper = new ObjectMapper(); 60 ObjectMapper mapper = new ObjectMapper();
59 ObjectNode clusterNodeDef = (ObjectNode) mapper.readTree(file); 61 ObjectNode clusterNodeDef = (ObjectNode) mapper.readTree(file);
...@@ -64,20 +66,23 @@ public class ClusterDefinitionStore { ...@@ -64,20 +66,23 @@ public class ClusterDefinitionStore {
64 IpAddress.valueOf(nodeDef.get("ip").asText()), 66 IpAddress.valueOf(nodeDef.get("ip").asText()),
65 nodeDef.get("tcpPort").asInt(9876))); 67 nodeDef.get("tcpPort").asInt(9876)));
66 } 68 }
67 - return nodes; 69 + String ipPrefix = clusterNodeDef.get("ipPrefix").asText();
70 +
71 + return ClusterDefinition.from(nodes, ipPrefix);
68 } 72 }
69 73
70 /* 74 /*
71 - * Writes the given set of the controller nodes. 75 + * Writes the given cluster definition.
72 * 76 *
73 - * @param nodes set of controller nodes 77 + * @param cluster definition
74 */ 78 */
75 - public void write(Set<DefaultControllerNode> nodes) throws IOException { 79 + public void write(ClusterDefinition definition) throws IOException {
76 ObjectMapper mapper = new ObjectMapper(); 80 ObjectMapper mapper = new ObjectMapper();
77 ObjectNode clusterNodeDef = mapper.createObjectNode(); 81 ObjectNode clusterNodeDef = mapper.createObjectNode();
82 + clusterNodeDef.set("ipPrefix", new TextNode(definition.ipPrefix()));
78 ArrayNode nodeDefs = mapper.createArrayNode(); 83 ArrayNode nodeDefs = mapper.createArrayNode();
79 clusterNodeDef.set("nodes", nodeDefs); 84 clusterNodeDef.set("nodes", nodeDefs);
80 - for (DefaultControllerNode node : nodes) { 85 + for (DefaultControllerNode node : definition.nodes()) {
81 ObjectNode nodeDef = mapper.createObjectNode(); 86 ObjectNode nodeDef = mapper.createObjectNode();
82 nodeDef.put("id", node.id().toString()) 87 nodeDef.put("id", node.id().toString())
83 .put("ip", node.ip().toString()) 88 .put("ip", node.ip().toString())
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.store.cluster.impl; 16 package org.onosproject.store.cluster.impl;
2 17
3 import static org.onlab.util.Tools.groupedThreads; 18 import static org.onlab.util.Tools.groupedThreads;
...@@ -45,6 +60,7 @@ import org.slf4j.Logger; ...@@ -45,6 +60,7 @@ import org.slf4j.Logger;
45 60
46 import com.google.common.collect.ImmutableSet; 61 import com.google.common.collect.ImmutableSet;
47 import com.google.common.collect.Maps; 62 import com.google.common.collect.Maps;
63 +import com.hazelcast.util.AddressUtil;
48 64
49 import static com.google.common.base.Preconditions.checkNotNull; 65 import static com.google.common.base.Preconditions.checkNotNull;
50 import static com.google.common.base.Preconditions.checkArgument; 66 import static com.google.common.base.Preconditions.checkArgument;
...@@ -60,7 +76,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -60,7 +76,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
60 private final Logger log = getLogger(getClass()); 76 private final Logger log = getLogger(getClass());
61 77
62 protected final AbstractListenerRegistry<ClusterEvent, ClusterEventListener> 78 protected final AbstractListenerRegistry<ClusterEvent, ClusterEventListener>
63 - listenerRegistry = new AbstractListenerRegistry<>(); 79 + listenerRegistry = new AbstractListenerRegistry<>();
64 80
65 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 81 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
66 protected EventDeliveryService eventDispatcher; 82 protected EventDeliveryService eventDispatcher;
...@@ -73,7 +89,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -73,7 +89,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
73 private static final String CONFIG_DIR = "../config"; 89 private static final String CONFIG_DIR = "../config";
74 private static final String CLUSTER_DEFINITION_FILE = "cluster.json"; 90 private static final String CLUSTER_DEFINITION_FILE = "cluster.json";
75 91
76 - private ClusterDefinitionStore clusterDefinition; 92 + private ClusterDefinition clusterDefinition;
77 93
78 private Set<ControllerNode> seedNodes; 94 private Set<ControllerNode> seedNodes;
79 private final Map<NodeId, ControllerNode> allNodes = Maps.newConcurrentMap(); 95 private final Map<NodeId, ControllerNode> allNodes = Maps.newConcurrentMap();
...@@ -108,9 +124,10 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -108,9 +124,10 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
108 public void activate() { 124 public void activate() {
109 125
110 File clusterDefinitionFile = new File(CONFIG_DIR, CLUSTER_DEFINITION_FILE); 126 File clusterDefinitionFile = new File(CONFIG_DIR, CLUSTER_DEFINITION_FILE);
111 - clusterDefinition = new ClusterDefinitionStore(clusterDefinitionFile.getPath()); 127 +
112 try { 128 try {
113 - seedNodes = ImmutableSet.copyOf(clusterDefinition.read()); 129 + clusterDefinition = new ClusterDefinitionStore(clusterDefinitionFile.getPath()).read();
130 + seedNodes = ImmutableSet.copyOf(clusterDefinition.nodes());
114 } catch (IOException e) { 131 } catch (IOException e) {
115 log.warn("Failed to read cluster definition.", e); 132 log.warn("Failed to read cluster definition.", e);
116 } 133 }
...@@ -128,7 +145,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -128,7 +145,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
128 messagingService.activate(); 145 messagingService.activate();
129 } catch (InterruptedException e) { 146 } catch (InterruptedException e) {
130 Thread.currentThread().interrupt(); 147 Thread.currentThread().interrupt();
131 - log.warn("Failed to cleanly initialize membership and" 148 + throw new IllegalStateException("Failed to cleanly initialize membership and"
132 + " failure detector communication channel.", e); 149 + " failure detector communication channel.", e);
133 } 150 }
134 messagingService.registerHandler( 151 messagingService.registerHandler(
...@@ -156,8 +173,8 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -156,8 +173,8 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
156 log.trace("Failed to cleanly shutdown cluster membership messaging", e); 173 log.trace("Failed to cleanly shutdown cluster membership messaging", e);
157 } 174 }
158 175
159 - heartBeatSender.shutdown(); 176 + heartBeatSender.shutdownNow();
160 - heartBeatMessageHandler.shutdown(); 177 + heartBeatMessageHandler.shutdownNow();
161 eventDispatcher.removeSink(ClusterEvent.class); 178 eventDispatcher.removeSink(ClusterEvent.class);
162 179
163 log.info("Stopped"); 180 log.info("Stopped");
...@@ -287,7 +304,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -287,7 +304,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
287 } 304 }
288 } 305 }
289 306
290 - private class HeartbeatMessage { 307 + private static class HeartbeatMessage {
291 private ControllerNode source; 308 private ControllerNode source;
292 private Set<ControllerNode> knownPeers; 309 private Set<ControllerNode> knownPeers;
293 310
...@@ -306,13 +323,16 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -306,13 +323,16 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
306 } 323 }
307 324
308 private IpAddress findLocalIp() throws SocketException { 325 private IpAddress findLocalIp() throws SocketException {
309 - NetworkInterface ni = NetworkInterface.getByName("eth0"); 326 + Enumeration<NetworkInterface> interfaces =
310 - Enumeration<InetAddress> inetAddresses = ni.getInetAddresses(); 327 + NetworkInterface.getNetworkInterfaces();
311 - 328 + while (interfaces.hasMoreElements()) {
312 - while (inetAddresses.hasMoreElements()) { 329 + NetworkInterface iface = interfaces.nextElement();
313 - InetAddress ia = inetAddresses.nextElement(); 330 + Enumeration<InetAddress> inetAddresses = iface.getInetAddresses();
314 - if (!ia.isLinkLocalAddress()) { 331 + while (inetAddresses.hasMoreElements()) {
315 - return IpAddress.valueOf(ia); 332 + IpAddress ip = IpAddress.valueOf(inetAddresses.nextElement());
333 + if (AddressUtil.matchInterface(ip.toString(), clusterDefinition.ipPrefix())) {
334 + return ip;
335 + }
316 } 336 }
317 } 337 }
318 throw new IllegalStateException("Unable to determine local ip"); 338 throw new IllegalStateException("Unable to determine local ip");
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.store.cluster.impl; 16 package org.onosproject.store.cluster.impl;
2 17
3 import static com.google.common.base.Preconditions.checkArgument; 18 import static com.google.common.base.Preconditions.checkArgument;
...@@ -21,6 +36,7 @@ public class PhiAccrualFailureDetector { ...@@ -21,6 +36,7 @@ public class PhiAccrualFailureDetector {
21 // TODO: make these configurable. 36 // TODO: make these configurable.
22 private static final int WINDOW_SIZE = 250; 37 private static final int WINDOW_SIZE = 250;
23 private static final int MIN_SAMPLES = 25; 38 private static final int MIN_SAMPLES = 25;
39 + private static final double PHI_FACTOR = 1.0 / Math.log(10.0);
24 40
25 // If a node does not have any heartbeats, this is the phi 41 // If a node does not have any heartbeats, this is the phi
26 // value to report. Indicates the node is inactive (from the 42 // value to report. Indicates the node is inactive (from the
...@@ -59,11 +75,11 @@ public class PhiAccrualFailureDetector { ...@@ -59,11 +75,11 @@ public class PhiAccrualFailureDetector {
59 * @param nodeId node id 75 * @param nodeId node id
60 * @return phi value 76 * @return phi value
61 */ 77 */
62 - public Double phi(NodeId nodeId) { 78 + public double phi(NodeId nodeId) {
79 + checkNotNull(nodeId, "NodeId must not be null");
63 if (!states.containsKey(nodeId)) { 80 if (!states.containsKey(nodeId)) {
64 return BOOTSTRAP_PHI_VALUE; 81 return BOOTSTRAP_PHI_VALUE;
65 } 82 }
66 - checkNotNull(nodeId, "NodeId must not be null");
67 History nodeState = states.get(nodeId); 83 History nodeState = states.get(nodeId);
68 synchronized (nodeState) { 84 synchronized (nodeState) {
69 long latestHeartbeat = nodeState.latestHeartbeatTime(); 85 long latestHeartbeat = nodeState.latestHeartbeatTime();
...@@ -79,7 +95,7 @@ public class PhiAccrualFailureDetector { ...@@ -79,7 +95,7 @@ public class PhiAccrualFailureDetector {
79 long size = samples.getN(); 95 long size = samples.getN();
80 long t = tNow - tLast; 96 long t = tNow - tLast;
81 return (size > 0) 97 return (size > 0)
82 - ? (1.0 / Math.log(10.0)) * t / samples.getMean() 98 + ? PHI_FACTOR * t / samples.getMean()
83 : BOOTSTRAP_PHI_VALUE; 99 : BOOTSTRAP_PHI_VALUE;
84 } 100 }
85 101
......
...@@ -150,7 +150,7 @@ public class ClusterCommunicationManager ...@@ -150,7 +150,7 @@ public class ClusterCommunicationManager
150 messagingService.sendAsync(nodeEp, subject.value(), payload); 150 messagingService.sendAsync(nodeEp, subject.value(), payload);
151 return true; 151 return true;
152 } catch (IOException e) { 152 } catch (IOException e) {
153 - log.trace("Failed to send cluster message to nodeId: " + toNodeId, e); 153 + log.debug("Failed to send cluster message to nodeId: " + toNodeId, e);
154 throw e; 154 throw e;
155 } 155 }
156 } 156 }
...@@ -179,6 +179,7 @@ public class ClusterCommunicationManager ...@@ -179,6 +179,7 @@ public class ClusterCommunicationManager
179 } 179 }
180 180
181 @Override 181 @Override
182 + @Deprecated
182 public void addSubscriber(MessageSubject subject, 183 public void addSubscriber(MessageSubject subject,
183 ClusterMessageHandler subscriber) { 184 ClusterMessageHandler subscriber) {
184 messagingService.registerHandler(subject.value(), new InternalClusterMessageHandler(subscriber)); 185 messagingService.registerHandler(subject.value(), new InternalClusterMessageHandler(subscriber));
...@@ -210,13 +211,13 @@ public class ClusterCommunicationManager ...@@ -210,13 +211,13 @@ public class ClusterCommunicationManager
210 try { 211 try {
211 clusterMessage = SERIALIZER.decode(message.payload()); 212 clusterMessage = SERIALIZER.decode(message.payload());
212 } catch (Exception e) { 213 } catch (Exception e) {
213 - log.error("Failed decoding ClusterMessage {}", message, e); 214 + log.error("Failed decoding {}", message, e);
214 throw e; 215 throw e;
215 } 216 }
216 try { 217 try {
217 handler.handle(new InternalClusterMessage(clusterMessage, message)); 218 handler.handle(new InternalClusterMessage(clusterMessage, message));
218 } catch (Exception e) { 219 } catch (Exception e) {
219 - log.error("Exception caught handling {}", clusterMessage, e); 220 + log.trace("Failed handling {}", clusterMessage, e);
220 throw e; 221 throw e;
221 } 222 }
222 } 223 }
......
...@@ -87,7 +87,7 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -87,7 +87,7 @@ public class DistributedLeadershipManager implements LeadershipService {
87 87
88 private static final int DELAY_BETWEEN_LEADER_LOCK_ATTEMPTS_SEC = 2; 88 private static final int DELAY_BETWEEN_LEADER_LOCK_ATTEMPTS_SEC = 2;
89 private static final int DEADLOCK_DETECTION_INTERVAL_SEC = 2; 89 private static final int DEADLOCK_DETECTION_INTERVAL_SEC = 2;
90 - private static final int LEADERSHIP_STATUS_UPDATE_INTERVAL = 2; 90 + private static final int LEADERSHIP_STATUS_UPDATE_INTERVAL_SEC = 2;
91 91
92 private static final KryoSerializer SERIALIZER = new KryoSerializer() { 92 private static final KryoSerializer SERIALIZER = new KryoSerializer() {
93 @Override 93 @Override
...@@ -134,7 +134,7 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -134,7 +134,7 @@ public class DistributedLeadershipManager implements LeadershipService {
134 deadLockDetectionExecutor.scheduleWithFixedDelay( 134 deadLockDetectionExecutor.scheduleWithFixedDelay(
135 this::purgeStaleLocks, 0, DEADLOCK_DETECTION_INTERVAL_SEC, TimeUnit.SECONDS); 135 this::purgeStaleLocks, 0, DEADLOCK_DETECTION_INTERVAL_SEC, TimeUnit.SECONDS);
136 leadershipStatusBroadcaster.scheduleWithFixedDelay( 136 leadershipStatusBroadcaster.scheduleWithFixedDelay(
137 - this::sendLeadershipStatus, 0, LEADERSHIP_STATUS_UPDATE_INTERVAL, TimeUnit.SECONDS); 137 + this::sendLeadershipStatus, 0, LEADERSHIP_STATUS_UPDATE_INTERVAL_SEC, TimeUnit.SECONDS);
138 138
139 listenerRegistry = new AbstractListenerRegistry<>(); 139 listenerRegistry = new AbstractListenerRegistry<>();
140 eventDispatcher.addSink(LeadershipEvent.class, listenerRegistry); 140 eventDispatcher.addSink(LeadershipEvent.class, listenerRegistry);
...@@ -190,7 +190,7 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -190,7 +190,7 @@ public class DistributedLeadershipManager implements LeadershipService {
190 190
191 @Override 191 @Override
192 public void runForLeadership(String path) { 192 public void runForLeadership(String path) {
193 - log.info("Running for leadership for topic: {}", path); 193 + log.trace("Running for leadership for topic: {}", path);
194 activeTopics.add(path); 194 activeTopics.add(path);
195 tryLeaderLock(path); 195 tryLeaderLock(path);
196 } 196 }
...@@ -200,11 +200,11 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -200,11 +200,11 @@ public class DistributedLeadershipManager implements LeadershipService {
200 activeTopics.remove(path); 200 activeTopics.remove(path);
201 try { 201 try {
202 if (lockMap.remove(path, localNodeId)) { 202 if (lockMap.remove(path, localNodeId)) {
203 - log.info("Sucessfully gave up leadership for {}", path); 203 + log.info("Gave up leadership for {}", path);
204 } 204 }
205 // else we are not the current owner. 205 // else we are not the current owner.
206 } catch (Exception e) { 206 } catch (Exception e) {
207 - log.warn("Failed to verify (and clear) any lock this node might be holding for {}", path, e); 207 + log.debug("Failed to verify (and clear) any lock this node might be holding for {}", path, e);
208 } 208 }
209 } 209 }
210 210
...@@ -244,7 +244,7 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -244,7 +244,7 @@ public class DistributedLeadershipManager implements LeadershipService {
244 } 244 }
245 } 245 }
246 } catch (Exception e) { 246 } catch (Exception e) {
247 - log.warn("Attempt to acquire leadership lock for topic {} failed", path, e); 247 + log.debug("Attempt to acquire leadership lock for topic {} failed", path, e);
248 retry(path); 248 retry(path);
249 } 249 }
250 } 250 }
...@@ -300,7 +300,7 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -300,7 +300,7 @@ public class DistributedLeadershipManager implements LeadershipService {
300 LeadershipEvent leadershipEvent = 300 LeadershipEvent leadershipEvent =
301 SERIALIZER.decode(message.payload()); 301 SERIALIZER.decode(message.payload());
302 302
303 - log.trace("Leadership Event: time = {} type = {} event = {}", 303 + log.debug("Leadership Event: time = {} type = {} event = {}",
304 leadershipEvent.time(), leadershipEvent.type(), 304 leadershipEvent.time(), leadershipEvent.type(),
305 leadershipEvent); 305 leadershipEvent);
306 306
...@@ -350,7 +350,7 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -350,7 +350,7 @@ public class DistributedLeadershipManager implements LeadershipService {
350 log.info("Lock for {} is held by {} which is currently inactive", path, nodeId); 350 log.info("Lock for {} is held by {} which is currently inactive", path, nodeId);
351 try { 351 try {
352 if (lockMap.remove(path, epoch)) { 352 if (lockMap.remove(path, epoch)) {
353 - log.info("Successfully purged stale lock held by {} for {}", nodeId, path); 353 + log.info("Purged stale lock held by {} for {}", nodeId, path);
354 notifyRemovedLeader(path, nodeId, epoch); 354 notifyRemovedLeader(path, nodeId, epoch);
355 } 355 }
356 } catch (Exception e) { 356 } catch (Exception e) {
...@@ -361,7 +361,7 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -361,7 +361,7 @@ public class DistributedLeadershipManager implements LeadershipService {
361 log.info("Lock for {} is held by {} when it not running for leadership.", path, nodeId); 361 log.info("Lock for {} is held by {} when it not running for leadership.", path, nodeId);
362 try { 362 try {
363 if (lockMap.remove(path, epoch)) { 363 if (lockMap.remove(path, epoch)) {
364 - log.info("Successfully purged stale lock held by {} for {}", nodeId, path); 364 + log.info("Purged stale lock held by {} for {}", nodeId, path);
365 notifyRemovedLeader(path, nodeId, epoch); 365 notifyRemovedLeader(path, nodeId, epoch);
366 } 366 }
367 } catch (Exception e) { 367 } catch (Exception e) {
...@@ -370,20 +370,24 @@ public class DistributedLeadershipManager implements LeadershipService { ...@@ -370,20 +370,24 @@ public class DistributedLeadershipManager implements LeadershipService {
370 } 370 }
371 }); 371 });
372 } catch (Exception e) { 372 } catch (Exception e) {
373 - log.warn("Failed cleaning up stale locks", e); 373 + log.debug("Failed cleaning up stale locks", e);
374 } 374 }
375 } 375 }
376 376
377 private void sendLeadershipStatus() { 377 private void sendLeadershipStatus() {
378 - leaderBoard.forEach((path, leadership) -> { 378 + try {
379 - if (leadership.leader().equals(localNodeId)) { 379 + leaderBoard.forEach((path, leadership) -> {
380 - LeadershipEvent event = new LeadershipEvent(LeadershipEvent.Type.LEADER_ELECTED, leadership); 380 + if (leadership.leader().equals(localNodeId)) {
381 - clusterCommunicator.broadcast( 381 + LeadershipEvent event = new LeadershipEvent(LeadershipEvent.Type.LEADER_ELECTED, leadership);
382 - new ClusterMessage( 382 + clusterCommunicator.broadcast(
383 - clusterService.getLocalNode().id(), 383 + new ClusterMessage(
384 - LEADERSHIP_EVENT_MESSAGE_SUBJECT, 384 + clusterService.getLocalNode().id(),
385 - SERIALIZER.encode(event))); 385 + LEADERSHIP_EVENT_MESSAGE_SUBJECT,
386 - } 386 + SERIALIZER.encode(event)));
387 - }); 387 + }
388 + });
389 + } catch (Exception e) {
390 + log.debug("Failed to send leadership updates", e);
391 + }
388 } 392 }
389 -}
...\ No newline at end of file ...\ No newline at end of file
393 +}
......
...@@ -10,7 +10,8 @@ remote=$ONOS_USER@${1:-$OCI} ...@@ -10,7 +10,8 @@ remote=$ONOS_USER@${1:-$OCI}
10 10
11 # Generate a cluster.json from the ON* environment variables 11 # Generate a cluster.json from the ON* environment variables
12 CDEF_FILE=/tmp/${remote}.cluster.json 12 CDEF_FILE=/tmp/${remote}.cluster.json
13 -echo "{ \"nodes\":[" > $CDEF_FILE 13 +echo "{ \"ipPrefix\": \"$ONOS_NIC\"," > $CDEF_FILE
14 +echo " \"nodes\":[" >> $CDEF_FILE
14 for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do 15 for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do
15 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE 16 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE
16 done 17 done
......