Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net; |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Collection of keys for annotation. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 20 | * <p> |
| 21 | * Number of the annotation keys have been deprecated as the use of annotations |
| 22 | * is being phased out and instead network configuration subsystem is being |
| 23 | * phased-in for majority of model meta-data. |
| 24 | * </p> |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 25 | */ |
| 26 | public final class AnnotationKeys { |
| 27 | |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 28 | |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 29 | // Prohibit instantiation |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 30 | private AnnotationKeys() { |
| 31 | } |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 32 | |
| 33 | /** |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 34 | * Annotation key for instance name. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 35 | * |
| 36 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 37 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 38 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 39 | public static final String NAME = "name"; |
| 40 | |
| 41 | /** |
| 42 | * Annotation key for instance type (e.g. host type). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 43 | * |
| 44 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 45 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 46 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 47 | public static final String TYPE = "type"; |
| 48 | |
| 49 | /** |
| 50 | * Annotation key for latitude (e.g. latitude of device). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 51 | * |
| 52 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 53 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 54 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 55 | public static final String LATITUDE = "latitude"; |
| 56 | |
| 57 | /** |
| 58 | * Annotation key for longitute (e.g. longitude of device). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 59 | * |
| 60 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 61 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 62 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 63 | public static final String LONGITUDE = "longitude"; |
| 64 | |
| 65 | /** |
| 66 | * Annotation key for southbound protocol. |
| 67 | */ |
| 68 | public static final String PROTOCOL = "protocol"; |
| 69 | |
| 70 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 71 | * Annotation key for the device driver name. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 72 | * |
| 73 | * @deprecated since Cardinal |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 74 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 75 | @Deprecated |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 76 | public static final String DRIVER = "driver"; |
| 77 | |
| 78 | /** |
Thomas Vachuska | 57126fe | 2014-11-11 17:13:24 -0800 | [diff] [blame] | 79 | * Annotation key for durable links. |
| 80 | */ |
| 81 | public static final String DURABLE = "durable"; |
| 82 | |
| 83 | /** |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 84 | * Annotation key for latency. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 85 | * |
| 86 | * @deprecated since Cardinal |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 87 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 88 | @Deprecated |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 89 | public static final String LATENCY = "latency"; |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 90 | |
| 91 | /** |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 92 | * Annotation key for bandwidth. |
Sho SHIMIZU | 0ce220a | 2015-01-23 15:54:47 -0800 | [diff] [blame] | 93 | * The value for this key is interpreted as Mbps. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 94 | * |
| 95 | * @deprecated since Cardinal |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 96 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 97 | @Deprecated |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 98 | public static final String BANDWIDTH = "bandwidth"; |
| 99 | |
| 100 | /** |
| 101 | * Annotation key for the number of optical waves. |
| 102 | */ |
| 103 | public static final String OPTICAL_WAVES = "optical.waves"; |
| 104 | |
| 105 | /** |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 106 | * Annotation key for the port name. |
| 107 | */ |
| 108 | public static final String PORT_NAME = "portName"; |
| 109 | |
Simon Hunt | ab130524 | 2015-05-06 18:07:13 -0700 | [diff] [blame] | 110 | /** |
| 111 | * Annotation key for the router ID. |
| 112 | */ |
| 113 | public static final String ROUTER_ID = "routerId"; |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 114 | |
Marc De Leenheer | 723f553 | 2015-06-03 20:16:17 -0700 | [diff] [blame] | 115 | public static final String STATIC_LAMBDA = "staticLambda"; |
| 116 | |
| 117 | public static final String STATIC_PORT = "staticPort"; |
| 118 | |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 119 | /** |
Ayaka Koshibe | 0891129 | 2015-08-05 15:07:08 -0700 | [diff] [blame] | 120 | * Annotation key for device location. |
| 121 | */ |
| 122 | public static final String RACK_ADDRESS = "rackAddress"; |
| 123 | |
| 124 | /** |
| 125 | * Annotation key for device owner. |
| 126 | */ |
| 127 | public static final String OWNER = "owner"; |
| 128 | |
| 129 | /** |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 130 | * Annotation key for the channel id. |
| 131 | */ |
| 132 | public static final String CHANNEL_ID = "channelId"; |
| 133 | |
| 134 | /** |
| 135 | * Annotation key for the management address. |
| 136 | */ |
| 137 | public static final String MANAGEMENT_ADDRESS = "managementAddress"; |
| 138 | |
| 139 | /** |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 140 | * Returns the value annotated object for the specified annotation key. |
| 141 | * The annotated value is expected to be String that can be parsed as double. |
| 142 | * If parsing fails, the returned value will be 1.0. |
| 143 | * |
| 144 | * @param annotated annotated object whose annotated value is obtained |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 145 | * @param key key of annotation |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 146 | * @return double value of annotated object for the specified key |
| 147 | */ |
| 148 | public static double getAnnotatedValue(Annotated annotated, String key) { |
| 149 | double value; |
| 150 | try { |
| 151 | value = Double.parseDouble(annotated.annotations().value(key)); |
| 152 | } catch (NumberFormatException e) { |
| 153 | value = 1.0; |
| 154 | } |
| 155 | return value; |
| 156 | } |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 157 | } |