Jonathan Hart | 472062d | 2014-04-03 10:56:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.topology; |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 3 | import java.nio.ByteBuffer; |
| 4 | import java.nio.charset.StandardCharsets; |
weibit | cef0986 | 2014-07-11 17:05:16 -0700 | [diff] [blame] | 5 | import java.util.Objects; |
| 6 | |
Pavlin Radoslavov | d7b792e | 2014-08-01 02:47:47 -0700 | [diff] [blame] | 7 | import net.onrc.onos.core.util.Dpid; |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 8 | import net.onrc.onos.core.util.OnosInstanceId; |
| 9 | |
| 10 | import static com.google.common.base.Preconditions.checkNotNull; |
weibit | cef0986 | 2014-07-11 17:05:16 -0700 | [diff] [blame] | 11 | |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 12 | /** |
| 13 | * Self-contained Topology event Object |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 14 | * <p/> |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 15 | * TODO: For now the topology event contains one of the following events: |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 16 | * Switch Mastership, Switch, Port, Link, Host. In the future it will contain |
Pavlin Radoslavov | 695f895 | 2014-07-23 16:57:01 -0700 | [diff] [blame] | 17 | * multiple events in a single transaction. |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 18 | * TODO: This class should become immutable after its internals and usage |
| 19 | * are finalized. |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 20 | */ |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 21 | public final class TopologyEvent { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 22 | private final MastershipEvent mastershipEvent; // Set for Mastership event |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 23 | private final SwitchEvent switchEvent; // Set for Switch event |
| 24 | private final PortEvent portEvent; // Set for Port event |
| 25 | private final LinkEvent linkEvent; // Set for Link event |
| 26 | private final HostEvent hostEvent; // Set for Host event |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 27 | private final OnosInstanceId onosInstanceId; // The ONOS Instance ID |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 28 | |
| 29 | /** |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 30 | * Default constructor for serializer. |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 31 | */ |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 32 | @Deprecated |
| 33 | protected TopologyEvent() { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 34 | mastershipEvent = null; |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 35 | switchEvent = null; |
| 36 | portEvent = null; |
| 37 | linkEvent = null; |
| 38 | hostEvent = null; |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 39 | onosInstanceId = null; |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | /** |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 43 | * Constructor for creating an empty (NO-OP) Topology Event. |
| 44 | * |
| 45 | * @param onosInstanceId the ONOS Instance ID that originates the event. |
| 46 | */ |
| 47 | protected TopologyEvent(OnosInstanceId onosInstanceId) { |
| 48 | mastershipEvent = null; |
| 49 | switchEvent = null; |
| 50 | portEvent = null; |
| 51 | linkEvent = null; |
| 52 | hostEvent = null; |
| 53 | this.onosInstanceId = checkNotNull(onosInstanceId); |
| 54 | } |
| 55 | |
| 56 | /** |
Pavlin Radoslavov | 695f895 | 2014-07-23 16:57:01 -0700 | [diff] [blame] | 57 | * Constructor for given Switch Mastership event. |
| 58 | * |
| 59 | * @param mastershipEvent the Switch Mastership event to use. |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 60 | * @param onosInstanceId the ONOS Instance ID that originates the event. |
Pavlin Radoslavov | 695f895 | 2014-07-23 16:57:01 -0700 | [diff] [blame] | 61 | */ |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 62 | TopologyEvent(MastershipEvent mastershipEvent, |
| 63 | OnosInstanceId onosInstanceId) { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 64 | this.mastershipEvent = checkNotNull(mastershipEvent); |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 65 | this.switchEvent = null; |
| 66 | this.portEvent = null; |
| 67 | this.linkEvent = null; |
| 68 | this.hostEvent = null; |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 69 | this.onosInstanceId = checkNotNull(onosInstanceId); |
| 70 | } |
| 71 | |
| 72 | /** |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 73 | * Constructor for given Switch event. |
| 74 | * |
| 75 | * @param switchEvent the Switch event to use. |
| 76 | * @param onosInstanceId the ONOS Instance ID that originates the event. |
| 77 | */ |
| 78 | TopologyEvent(SwitchEvent switchEvent, OnosInstanceId onosInstanceId) { |
| 79 | this.mastershipEvent = null; |
| 80 | this.switchEvent = checkNotNull(switchEvent); |
| 81 | this.portEvent = null; |
| 82 | this.linkEvent = null; |
| 83 | this.hostEvent = null; |
| 84 | this.onosInstanceId = checkNotNull(onosInstanceId); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Constructor for given Port event. |
| 89 | * |
| 90 | * @param portEvent the Port event to use. |
| 91 | * @param onosInstanceId the ONOS Instance ID that originates the event. |
| 92 | */ |
| 93 | TopologyEvent(PortEvent portEvent, OnosInstanceId onosInstanceId) { |
| 94 | this.mastershipEvent = null; |
| 95 | this.switchEvent = null; |
| 96 | this.portEvent = checkNotNull(portEvent); |
| 97 | this.linkEvent = null; |
| 98 | this.hostEvent = null; |
| 99 | this.onosInstanceId = checkNotNull(onosInstanceId); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Constructor for given Link event. |
| 104 | * |
| 105 | * @param linkEvent the Link event to use. |
| 106 | * @param onosInstanceId the ONOS Instance ID that originates the event. |
| 107 | */ |
| 108 | TopologyEvent(LinkEvent linkEvent, OnosInstanceId onosInstanceId) { |
| 109 | this.mastershipEvent = null; |
| 110 | this.switchEvent = null; |
| 111 | this.portEvent = null; |
| 112 | this.linkEvent = checkNotNull(linkEvent); |
| 113 | this.hostEvent = null; |
| 114 | this.onosInstanceId = checkNotNull(onosInstanceId); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Constructor for given Host event. |
| 119 | * |
| 120 | * @param hostEvent the Host event to use. |
| 121 | * @param onosInstanceId the ONOS Instance ID that originates the event. |
| 122 | */ |
| 123 | TopologyEvent(HostEvent hostEvent, OnosInstanceId onosInstanceId) { |
| 124 | this.mastershipEvent = null; |
| 125 | this.switchEvent = null; |
| 126 | this.portEvent = null; |
| 127 | this.linkEvent = null; |
| 128 | this.hostEvent = checkNotNull(hostEvent); |
| 129 | this.onosInstanceId = checkNotNull(onosInstanceId); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Gets the Mastership event. |
| 134 | * |
| 135 | * @return the Mastership event. |
| 136 | */ |
| 137 | public MastershipEvent getMastershipEvent() { |
| 138 | return mastershipEvent; |
| 139 | } |
| 140 | |
| 141 | /** |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 142 | * Gets the Switch event. |
| 143 | * |
| 144 | * @return the Switch event. |
| 145 | */ |
| 146 | public SwitchEvent getSwitchEvent() { |
| 147 | return switchEvent; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Gets the Port event. |
| 152 | * |
| 153 | * @return the Port event. |
| 154 | */ |
| 155 | public PortEvent getPortEvent() { |
| 156 | return portEvent; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Gets the Link event. |
| 161 | * |
| 162 | * @return the Link event. |
| 163 | */ |
| 164 | public LinkEvent getLinkEvent() { |
| 165 | return linkEvent; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Gets the Host event. |
| 170 | * |
| 171 | * @return the Host event. |
| 172 | */ |
| 173 | public HostEvent getHostEvent() { |
| 174 | return hostEvent; |
| 175 | } |
| 176 | |
| 177 | /** |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 178 | * Gets the ONOS Instance ID. |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 179 | * |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 180 | * @return the ONOS Instance ID. |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 181 | */ |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 182 | public OnosInstanceId getOnosInstanceId() { |
| 183 | return onosInstanceId; |
Pavlin Radoslavov | 695f895 | 2014-07-23 16:57:01 -0700 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | /** |
Pavlin Radoslavov | d7b792e | 2014-08-01 02:47:47 -0700 | [diff] [blame] | 187 | * Gets the event origin DPID. |
| 188 | * |
| 189 | * @return the event origin DPID. |
| 190 | */ |
| 191 | public Dpid getOriginDpid() { |
| 192 | if (mastershipEvent != null) { |
| 193 | return mastershipEvent.getOriginDpid(); |
| 194 | } |
| 195 | if (switchEvent != null) { |
| 196 | return switchEvent.getOriginDpid(); |
| 197 | } |
| 198 | if (portEvent != null) { |
| 199 | return portEvent.getOriginDpid(); |
| 200 | } |
| 201 | if (linkEvent != null) { |
| 202 | return linkEvent.getOriginDpid(); |
| 203 | } |
| 204 | if (hostEvent != null) { |
| 205 | return hostEvent.getOriginDpid(); |
| 206 | } |
| 207 | return null; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Tests whether the event origin DPID equals the specified DPID. |
| 212 | * |
| 213 | * @param dpid the DPID to compare against. |
| 214 | * @return true if the event origin Dpid equals the specified DPID. |
| 215 | */ |
| 216 | public boolean equalsOriginDpid(Dpid dpid) { |
| 217 | return dpid.equals(getOriginDpid()); |
| 218 | } |
| 219 | |
| 220 | /** |
Pavlin Radoslavov | ae7e848 | 2014-08-11 16:58:19 -0700 | [diff] [blame] | 221 | * Returns the config state of the topology element. |
| 222 | * |
| 223 | * @return the config state of the topology element. |
| 224 | */ |
| 225 | public ConfigState getConfigState() { |
| 226 | if (mastershipEvent != null) { |
| 227 | return mastershipEvent.getConfigState(); |
| 228 | } |
| 229 | if (switchEvent != null) { |
| 230 | return switchEvent.getConfigState(); |
| 231 | } |
| 232 | if (portEvent != null) { |
| 233 | return portEvent.getConfigState(); |
| 234 | } |
| 235 | if (linkEvent != null) { |
| 236 | return linkEvent.getConfigState(); |
| 237 | } |
| 238 | if (hostEvent != null) { |
| 239 | return hostEvent.getConfigState(); |
| 240 | } |
| 241 | return ConfigState.NOT_CONFIGURED; // Default: not configured |
| 242 | } |
| 243 | |
| 244 | /** |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 245 | * Checks if all events contained are equal. |
Yuta HIGUCHI | ccab05d | 2014-07-26 22:42:28 -0700 | [diff] [blame] | 246 | * |
| 247 | * @param obj TopologyEvent to compare against |
weibit | cef0986 | 2014-07-11 17:05:16 -0700 | [diff] [blame] | 248 | */ |
| 249 | @Override |
| 250 | public boolean equals(Object obj) { |
| 251 | if (this == obj) { |
| 252 | return true; |
| 253 | } |
| 254 | |
| 255 | if (obj == null) { |
| 256 | return false; |
| 257 | } |
| 258 | |
| 259 | if (getClass() != obj.getClass()) { |
| 260 | return false; |
| 261 | } |
| 262 | |
| 263 | TopologyEvent other = (TopologyEvent) obj; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 264 | return Objects.equals(mastershipEvent, other.mastershipEvent) && |
| 265 | Objects.equals(switchEvent, other.switchEvent) && |
| 266 | Objects.equals(portEvent, other.portEvent) && |
| 267 | Objects.equals(linkEvent, other.linkEvent) && |
| 268 | Objects.equals(hostEvent, other.hostEvent) && |
| 269 | Objects.equals(onosInstanceId, other.onosInstanceId); |
weibit | cef0986 | 2014-07-11 17:05:16 -0700 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | @Override |
| 273 | public int hashCode() { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 274 | return Objects.hash(mastershipEvent, switchEvent, portEvent, |
| 275 | linkEvent, hostEvent, onosInstanceId); |
weibit | cef0986 | 2014-07-11 17:05:16 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | /** |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 279 | * Gets the string representation of the event. |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 280 | * |
| 281 | * @return the string representation of the event. |
| 282 | */ |
| 283 | @Override |
| 284 | public String toString() { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 285 | String eventStr = null; |
| 286 | |
| 287 | // |
| 288 | // Get the Event string |
| 289 | // |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 290 | stringLabel: { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 291 | if (mastershipEvent != null) { |
| 292 | eventStr = mastershipEvent.toString(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 293 | break stringLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 294 | } |
| 295 | if (switchEvent != null) { |
| 296 | eventStr = switchEvent.toString(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 297 | break stringLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 298 | } |
| 299 | if (portEvent != null) { |
| 300 | eventStr = portEvent.toString(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 301 | break stringLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 302 | } |
| 303 | if (linkEvent != null) { |
| 304 | eventStr = linkEvent.toString(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 305 | break stringLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 306 | } |
| 307 | if (hostEvent != null) { |
| 308 | eventStr = hostEvent.toString(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 309 | break stringLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 310 | } |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 311 | // Test whether this is NO-OP event |
| 312 | if (onosInstanceId != null) { |
| 313 | eventStr = "NO-OP"; |
| 314 | break stringLabel; |
| 315 | } |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 316 | // No event found |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 317 | return "[Unknown TopologyEvent]"; |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 318 | } |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 319 | |
| 320 | return "[TopologyEvent " + eventStr + " from " + |
| 321 | onosInstanceId.toString() + "]"; |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | /** |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 325 | * Gets the Topology event ID as a byte array. |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 326 | * |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 327 | * @return the Topology event ID as a byte array. |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 328 | */ |
| 329 | public byte[] getID() { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 330 | return getIDasByteBuffer().array(); |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Gets the Topology event ID as a ByteBuffer. |
| 335 | * |
| 336 | * @return the Topology event ID as a ByteBuffer. |
| 337 | */ |
| 338 | public ByteBuffer getIDasByteBuffer() { |
| 339 | ByteBuffer eventId = null; |
| 340 | |
| 341 | // |
| 342 | // Get the Event ID |
| 343 | // |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 344 | idLabel: { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 345 | if (mastershipEvent != null) { |
| 346 | eventId = mastershipEvent.getIDasByteBuffer(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 347 | break idLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 348 | } |
| 349 | if (switchEvent != null) { |
| 350 | eventId = switchEvent.getIDasByteBuffer(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 351 | break idLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 352 | } |
| 353 | if (portEvent != null) { |
| 354 | eventId = portEvent.getIDasByteBuffer(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 355 | break idLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 356 | } |
| 357 | if (linkEvent != null) { |
| 358 | eventId = linkEvent.getIDasByteBuffer(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 359 | break idLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 360 | } |
| 361 | if (hostEvent != null) { |
| 362 | eventId = hostEvent.getIDasByteBuffer(); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 363 | break idLabel; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 364 | } |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 365 | // Test whether this is NO-OP event |
| 366 | if (onosInstanceId != null) { |
| 367 | String id = "NO-OP"; |
| 368 | eventId = ByteBuffer.wrap(id.getBytes(StandardCharsets.UTF_8)); |
| 369 | break idLabel; |
| 370 | } |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 371 | // No event found |
| 372 | throw new IllegalStateException("Invalid TopologyEvent ID"); |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 373 | } |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 374 | |
| 375 | // |
| 376 | // Prepare the ONOS Instance ID. The '@' separator is needed to avoid |
| 377 | // potential key collisions. |
| 378 | // |
Pavlin Radoslavov | 845ffdd | 2014-08-06 18:01:26 -0700 | [diff] [blame] | 379 | byte[] onosId = |
| 380 | ("@" + onosInstanceId.toString()).getBytes(StandardCharsets.UTF_8); |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 381 | |
| 382 | // Concatenate the IDs |
| 383 | ByteBuffer buf = |
| 384 | ByteBuffer.allocate(eventId.capacity() + onosId.length); |
| 385 | buf.put(eventId); |
| 386 | buf.put(onosId); |
| 387 | buf.flip(); |
| 388 | return buf; |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 389 | } |
Pavlin Radoslavov | 45ec04b | 2014-02-14 23:29:33 -0800 | [diff] [blame] | 390 | } |