Yuta HIGUCHI

Throwing IOException to match Service definition

Change-Id: Id6455fb8277822d3e5cfc87db76174044cbab69d
...@@ -92,7 +92,7 @@ public class ClusterCommunicationManager ...@@ -92,7 +92,7 @@ public class ClusterCommunicationManager
92 } 92 }
93 93
94 @Override 94 @Override
95 - public boolean broadcast(ClusterMessage message) { 95 + public boolean broadcast(ClusterMessage message) throws IOException {
96 boolean ok = true; 96 boolean ok = true;
97 for (ControllerNode node : clusterService.getNodes()) { 97 for (ControllerNode node : clusterService.getNodes()) {
98 if (!node.equals(localNode)) { 98 if (!node.equals(localNode)) {
...@@ -103,7 +103,7 @@ public class ClusterCommunicationManager ...@@ -103,7 +103,7 @@ public class ClusterCommunicationManager
103 } 103 }
104 104
105 @Override 105 @Override
106 - public boolean multicast(ClusterMessage message, Set<NodeId> nodes) { 106 + public boolean multicast(ClusterMessage message, Set<NodeId> nodes) throws IOException {
107 boolean ok = true; 107 boolean ok = true;
108 for (NodeId nodeId : nodes) { 108 for (NodeId nodeId : nodes) {
109 if (!nodeId.equals(localNode.id())) { 109 if (!nodeId.equals(localNode.id())) {
...@@ -114,7 +114,7 @@ public class ClusterCommunicationManager ...@@ -114,7 +114,7 @@ public class ClusterCommunicationManager
114 } 114 }
115 115
116 @Override 116 @Override
117 - public boolean unicast(ClusterMessage message, NodeId toNodeId) { 117 + public boolean unicast(ClusterMessage message, NodeId toNodeId) throws IOException {
118 ControllerNode node = clusterService.getNode(toNodeId); 118 ControllerNode node = clusterService.getNode(toNodeId);
119 checkArgument(node != null, "Unknown nodeId: %s", toNodeId); 119 checkArgument(node != null, "Unknown nodeId: %s", toNodeId);
120 Endpoint nodeEp = new Endpoint(node.ip().toString(), node.tcpPort()); 120 Endpoint nodeEp = new Endpoint(node.ip().toString(), node.tcpPort());
...@@ -124,9 +124,8 @@ public class ClusterCommunicationManager ...@@ -124,9 +124,8 @@ public class ClusterCommunicationManager
124 return true; 124 return true;
125 } catch (IOException e) { 125 } catch (IOException e) {
126 log.error("Failed to send cluster message to nodeId: " + toNodeId, e); 126 log.error("Failed to send cluster message to nodeId: " + toNodeId, e);
127 + throw e;
127 } 128 }
128 -
129 - return false;
130 } 129 }
131 130
132 @Override 131 @Override
...@@ -151,10 +150,10 @@ public class ClusterCommunicationManager ...@@ -151,10 +150,10 @@ public class ClusterCommunicationManager
151 150
152 @Override 151 @Override
153 public void removeNode(ControllerNode node) { 152 public void removeNode(ControllerNode node) {
154 - broadcast(new ClusterMessage( 153 +// broadcast(new ClusterMessage(
155 - localNode.id(), 154 +// localNode.id(),
156 - new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"), 155 +// new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"),
157 - SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.LEAVING_MEMBER, node)))); 156 +// SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.LEAVING_MEMBER, node))));
158 //members.remove(node.id()); 157 //members.remove(node.id());
159 } 158 }
160 159
...@@ -163,10 +162,14 @@ public class ClusterCommunicationManager ...@@ -163,10 +162,14 @@ public class ClusterCommunicationManager
163 162
164 @Override 163 @Override
165 public void run() { 164 public void run() {
166 - broadcast(new ClusterMessage( 165 + try {
167 - localNode.id(), 166 + broadcast(new ClusterMessage(
168 - new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"), 167 + localNode.id(),
169 - SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.HEART_BEAT, localNode)))); 168 + new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"),
169 + SERIALIZER.encode(new ClusterMembershipEvent(ClusterMembershipEventType.HEART_BEAT, localNode))));
170 + } catch (IOException e) {
171 + log.warn("I/O error while broadcasting heart beats.", e);
172 + }
170 } 173 }
171 } 174 }
172 175
......