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