Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.ui.impl; |
| 17 | |
| 18 | import com.fasterxml.jackson.databind.ObjectMapper; |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 19 | import com.fasterxml.jackson.databind.node.ArrayNode; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 21 | import org.eclipse.jetty.websocket.WebSocket; |
| 22 | import org.onlab.osgi.ServiceDirectory; |
Thomas Vachuska | fc52fec | 2015-05-18 19:13:56 -0700 | [diff] [blame] | 23 | import org.onlab.osgi.ServiceNotFoundException; |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 24 | import org.onosproject.cluster.ClusterService; |
| 25 | import org.onosproject.cluster.ControllerNode; |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 26 | import org.onosproject.ui.GlyphConstants; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 27 | import org.onosproject.ui.UiConnection; |
| 28 | import org.onosproject.ui.UiExtensionService; |
Simon Hunt | a0ddb02 | 2015-05-01 09:53:01 -0700 | [diff] [blame] | 29 | import org.onosproject.ui.UiMessageHandler; |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 30 | import org.onosproject.ui.UiMessageHandlerFactory; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 31 | import org.onosproject.ui.UiTopoLayoutService; |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 32 | import org.onosproject.ui.UiTopoOverlayFactory; |
Simon Hunt | 537bc76 | 2016-12-20 12:15:13 -0800 | [diff] [blame] | 33 | import org.onosproject.ui.impl.topo.Topo2Jsonifier; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 34 | import org.onosproject.ui.impl.topo.UiTopoSession; |
| 35 | import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel; |
| 36 | import org.onosproject.ui.model.topo.UiTopoLayout; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 37 | import org.slf4j.Logger; |
| 38 | import org.slf4j.LoggerFactory; |
| 39 | |
| 40 | import java.io.IOException; |
| 41 | import java.util.HashMap; |
| 42 | import java.util.Map; |
| 43 | |
| 44 | /** |
Simon Hunt | 7092cc4 | 2016-04-06 18:40:17 -0700 | [diff] [blame] | 45 | * Web socket capable of interacting with the Web UI. |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 46 | */ |
| 47 | public class UiWebSocket |
| 48 | implements UiConnection, WebSocket.OnTextMessage, WebSocket.OnControl { |
| 49 | |
| 50 | private static final Logger log = LoggerFactory.getLogger(UiWebSocket.class); |
| 51 | |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 52 | private static final String EVENT = "event"; |
| 53 | private static final String SID = "sid"; |
| 54 | private static final String PAYLOAD = "payload"; |
| 55 | private static final String UNKNOWN = "unknown"; |
| 56 | |
| 57 | private static final String ID = "id"; |
| 58 | private static final String IP = "ip"; |
| 59 | private static final String CLUSTER_NODES = "clusterNodes"; |
| 60 | private static final String USER = "user"; |
| 61 | private static final String BOOTSTRAP = "bootstrap"; |
| 62 | |
Simon Hunt | d7395c8 | 2016-10-20 17:54:01 -0700 | [diff] [blame] | 63 | private static final String TOPO = "topo"; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 64 | |
Thomas Vachuska | 1a989c1 | 2015-06-09 18:29:22 -0700 | [diff] [blame] | 65 | private static final long MAX_AGE_MS = 30_000; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 66 | |
| 67 | private static final byte PING = 0x9; |
| 68 | private static final byte PONG = 0xA; |
| 69 | private static final byte[] PING_DATA = new byte[]{(byte) 0xde, (byte) 0xad}; |
| 70 | |
Simon Hunt | 7092cc4 | 2016-04-06 18:40:17 -0700 | [diff] [blame] | 71 | private final ObjectMapper mapper = new ObjectMapper(); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 72 | private final ServiceDirectory directory; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 73 | private final UiTopoSession topoSession; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 74 | |
| 75 | private Connection connection; |
| 76 | private FrameConnection control; |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 77 | private String userName; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 78 | private String currentView; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 79 | |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 80 | private long lastActive = System.currentTimeMillis(); |
| 81 | |
Simon Hunt | a0ddb02 | 2015-05-01 09:53:01 -0700 | [diff] [blame] | 82 | private Map<String, UiMessageHandler> handlers; |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 83 | private TopoOverlayCache overlayCache; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 84 | |
| 85 | /** |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 86 | * Creates a new web-socket for serving data to the Web UI. |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 87 | * |
| 88 | * @param directory service directory |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 89 | * @param userName user name of the logged-in user |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 90 | */ |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 91 | public UiWebSocket(ServiceDirectory directory, String userName) { |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 92 | this.directory = directory; |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 93 | this.userName = userName; |
Simon Hunt | 537bc76 | 2016-12-20 12:15:13 -0800 | [diff] [blame] | 94 | |
| 95 | Topo2Jsonifier t2json = new Topo2Jsonifier(directory); |
| 96 | UiSharedTopologyModel sharedModel = directory.get(UiSharedTopologyModel.class); |
| 97 | UiTopoLayoutService layoutService = directory.get(UiTopoLayoutService.class); |
| 98 | this.topoSession = new UiTopoSession(this, t2json, sharedModel, layoutService); |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public String userName() { |
| 103 | return userName; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 106 | @Override |
| 107 | public UiTopoLayout currentLayout() { |
| 108 | return topoSession.currentLayout(); |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public void setCurrentLayout(UiTopoLayout topoLayout) { |
| 113 | topoSession.setCurrentLayout(topoLayout); |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public String currentView() { |
| 118 | return currentView; |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public void setCurrentView(String viewId) { |
| 123 | currentView = viewId; |
| 124 | topoSession.enableEvent(viewId.equals(TOPO)); |
| 125 | } |
| 126 | |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 127 | /** |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 128 | * Provides a reference to the topology session. |
| 129 | * |
| 130 | * @return topo session reference |
| 131 | */ |
| 132 | public UiTopoSession topoSession() { |
| 133 | return topoSession; |
| 134 | } |
| 135 | |
| 136 | /** |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 137 | * Issues a close on the connection. |
| 138 | */ |
| 139 | synchronized void close() { |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 140 | destroyHandlersAndOverlays(); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 141 | if (connection.isOpen()) { |
| 142 | connection.close(); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Indicates if this connection is idle. |
| 148 | * |
| 149 | * @return true if idle or closed |
| 150 | */ |
| 151 | synchronized boolean isIdle() { |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 152 | long quietFor = System.currentTimeMillis() - lastActive; |
| 153 | boolean idle = quietFor > MAX_AGE_MS; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 154 | if (idle || (connection != null && !connection.isOpen())) { |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 155 | log.debug("IDLE (or closed) websocket [{} ms]", quietFor); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 156 | return true; |
| 157 | } else if (connection != null) { |
| 158 | try { |
| 159 | control.sendControl(PING, PING_DATA, 0, PING_DATA.length); |
| 160 | } catch (IOException e) { |
| 161 | log.warn("Unable to send ping message due to: ", e); |
| 162 | } |
| 163 | } |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | @Override |
Satish K | 598c28d | 2015-11-24 17:20:40 +0530 | [diff] [blame] | 168 | public synchronized void onOpen(Connection connection) { |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 169 | this.connection = connection; |
| 170 | this.control = (FrameConnection) connection; |
Thomas Vachuska | fc52fec | 2015-05-18 19:13:56 -0700 | [diff] [blame] | 171 | try { |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 172 | topoSession.init(); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 173 | createHandlersAndOverlays(); |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 174 | sendBootstrapData(); |
| 175 | log.info("GUI client connected -- user <{}>", userName); |
Thomas Vachuska | fc52fec | 2015-05-18 19:13:56 -0700 | [diff] [blame] | 176 | |
| 177 | } catch (ServiceNotFoundException e) { |
Brian O'Connor | 75deea6 | 2015-06-24 16:09:17 -0400 | [diff] [blame] | 178 | log.warn("Unable to open GUI connection; services have been shut-down", e); |
Thomas Vachuska | fc52fec | 2015-05-18 19:13:56 -0700 | [diff] [blame] | 179 | this.connection.close(); |
| 180 | this.connection = null; |
| 181 | this.control = null; |
| 182 | } |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | @Override |
| 186 | public synchronized void onClose(int closeCode, String message) { |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 187 | topoSession.destroy(); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 188 | destroyHandlersAndOverlays(); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 189 | log.info("GUI client disconnected [close-code={}, message={}]", |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 190 | closeCode, message); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | @Override |
| 194 | public boolean onControl(byte controlCode, byte[] data, int offset, int length) { |
| 195 | lastActive = System.currentTimeMillis(); |
| 196 | return true; |
| 197 | } |
| 198 | |
| 199 | @Override |
| 200 | public void onMessage(String data) { |
| 201 | lastActive = System.currentTimeMillis(); |
| 202 | try { |
| 203 | ObjectNode message = (ObjectNode) mapper.reader().readTree(data); |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 204 | String type = message.path(EVENT).asText(UNKNOWN); |
Simon Hunt | a0ddb02 | 2015-05-01 09:53:01 -0700 | [diff] [blame] | 205 | UiMessageHandler handler = handlers.get(type); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 206 | if (handler != null) { |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 207 | log.debug("RX message: {}", message); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 208 | handler.process(message); |
| 209 | } else { |
| 210 | log.warn("No GUI message handler for type {}", type); |
| 211 | } |
| 212 | } catch (Exception e) { |
| 213 | log.warn("Unable to parse GUI message {} due to {}", data, e); |
| 214 | log.debug("Boom!!!", e); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | @Override |
Thomas Vachuska | 35fa3d4 | 2015-04-30 10:11:47 -0700 | [diff] [blame] | 219 | public synchronized void sendMessage(ObjectNode message) { |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 220 | try { |
| 221 | if (connection.isOpen()) { |
| 222 | connection.sendMessage(message.toString()); |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 223 | log.debug("TX message: {}", message); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 224 | } |
| 225 | } catch (IOException e) { |
| 226 | log.warn("Unable to send message {} to GUI due to {}", message, e); |
| 227 | log.debug("Boom!!!", e); |
| 228 | } |
| 229 | } |
| 230 | |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 231 | @Override |
Simon Hunt | c536818 | 2017-01-10 13:32:04 -0800 | [diff] [blame^] | 232 | public synchronized void sendMessage(String type, ObjectNode payload) { |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 233 | ObjectNode message = mapper.createObjectNode(); |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 234 | message.put(EVENT, type); |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 235 | message.set(PAYLOAD, payload != null ? payload : mapper.createObjectNode()); |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 236 | sendMessage(message); |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 239 | // Creates new message handlers. |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 240 | private synchronized void createHandlersAndOverlays() { |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 241 | log.debug("Creating handlers and overlays..."); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 242 | handlers = new HashMap<>(); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 243 | overlayCache = new TopoOverlayCache(); |
| 244 | |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 245 | UiExtensionService service = directory.get(UiExtensionService.class); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 246 | service.getExtensions().forEach(ext -> { |
| 247 | UiMessageHandlerFactory factory = ext.messageHandlerFactory(); |
| 248 | if (factory != null) { |
| 249 | factory.newHandlers().forEach(handler -> { |
Thomas Vachuska | c4178cc | 2015-12-10 11:43:32 -0800 | [diff] [blame] | 250 | try { |
| 251 | handler.init(this, directory); |
| 252 | handler.messageTypes().forEach(type -> handlers.put(type, handler)); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 253 | |
Thomas Vachuska | c4178cc | 2015-12-10 11:43:32 -0800 | [diff] [blame] | 254 | // need to inject the overlay cache into topology message handler |
Simon Hunt | 537bc76 | 2016-12-20 12:15:13 -0800 | [diff] [blame] | 255 | // TODO: code for Topo2ViewMessageHandler required here |
Thomas Vachuska | c4178cc | 2015-12-10 11:43:32 -0800 | [diff] [blame] | 256 | if (handler instanceof TopologyViewMessageHandler) { |
| 257 | ((TopologyViewMessageHandler) handler).setOverlayCache(overlayCache); |
| 258 | } |
| 259 | } catch (Exception e) { |
| 260 | log.warn("Unable to setup handler {} due to", handler, e); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 261 | } |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 262 | }); |
| 263 | } |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 264 | |
| 265 | UiTopoOverlayFactory overlayFactory = ext.topoOverlayFactory(); |
| 266 | if (overlayFactory != null) { |
| 267 | overlayFactory.newOverlays().forEach(overlayCache::add); |
| 268 | } |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 269 | }); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 270 | log.debug("#handlers = {}, #overlays = {}", handlers.size(), |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 271 | overlayCache.size()); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | // Destroys message handlers. |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 275 | private synchronized void destroyHandlersAndOverlays() { |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 276 | log.debug("Destroying handlers and overlays..."); |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 277 | handlers.forEach((type, handler) -> handler.destroy()); |
| 278 | handlers.clear(); |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 279 | |
| 280 | if (overlayCache != null) { |
| 281 | overlayCache.destroy(); |
| 282 | overlayCache = null; |
| 283 | } |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 284 | } |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 285 | |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 286 | // Sends initial information (username and cluster member information) |
| 287 | // to allow GUI to display logged-in user, and to be able to |
| 288 | // fail-over to an alternate cluster member if necessary. |
| 289 | private void sendBootstrapData() { |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 290 | ClusterService service = directory.get(ClusterService.class); |
| 291 | ArrayNode instances = mapper.createArrayNode(); |
| 292 | |
| 293 | for (ControllerNode node : service.getNodes()) { |
| 294 | ObjectNode instance = mapper.createObjectNode() |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 295 | .put(ID, node.id().toString()) |
| 296 | .put(IP, node.ip().toString()) |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 297 | .put(GlyphConstants.UI_ATTACHED, |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 298 | node.equals(service.getLocalNode())); |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 299 | instances.add(instance); |
| 300 | } |
| 301 | |
| 302 | ObjectNode payload = mapper.createObjectNode(); |
Simon Hunt | 7715e89 | 2016-04-12 19:55:32 -0700 | [diff] [blame] | 303 | payload.set(CLUSTER_NODES, instances); |
| 304 | payload.put(USER, userName); |
Simon Hunt | c536818 | 2017-01-10 13:32:04 -0800 | [diff] [blame^] | 305 | sendMessage(BOOTSTRAP, payload); |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 308 | } |
| 309 | |