tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net; |
| 2 | |
| 3 | /** |
| 4 | * Representation of a network edge location where an end-station host is |
| 5 | * connected. |
| 6 | */ |
tom | bb58c20 | 2014-09-07 22:51:50 -0700 | [diff] [blame] | 7 | public class HostLocation extends ConnectPoint { |
| 8 | |
tom | a56d5fe | 2014-09-17 11:05:47 -0700 | [diff] [blame] | 9 | // Note that time is explicitly excluded from the notion of equality. |
tom | bb58c20 | 2014-09-07 22:51:50 -0700 | [diff] [blame] | 10 | private final long time; |
| 11 | |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 12 | /** |
| 13 | * Creates a new host location using the supplied device & port. |
| 14 | * |
| 15 | * @param deviceId device identity |
| 16 | * @param portNumber device port number |
| 17 | * @param time time when detected, in millis since start of epoch |
| 18 | */ |
tom | bb58c20 | 2014-09-07 22:51:50 -0700 | [diff] [blame] | 19 | public HostLocation(DeviceId deviceId, PortNumber portNumber, long time) { |
| 20 | super(deviceId, portNumber); |
| 21 | this.time = time; |
| 22 | } |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
tom | 297dfc0 | 2014-10-08 10:42:56 -0700 | [diff] [blame] | 25 | * Creates a new host location derived from the supplied connection point. |
| 26 | * |
| 27 | * @param connectPoint connection point |
| 28 | * @param time time when detected, in millis since start of epoch |
| 29 | */ |
| 30 | public HostLocation(ConnectPoint connectPoint, long time) { |
| 31 | super(connectPoint.deviceId(), connectPoint.port()); |
| 32 | this.time = time; |
| 33 | } |
| 34 | |
| 35 | /** |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 36 | * Returns the time when the location was established, given in |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 37 | * milliseconds since start of epoch. |
| 38 | * |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 39 | * @return time in milliseconds since start of epoch |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 40 | */ |
tom | bb58c20 | 2014-09-07 22:51:50 -0700 | [diff] [blame] | 41 | public long time() { |
| 42 | return time; |
| 43 | } |
| 44 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 45 | } |