Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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.openstacktelemetry.api.config; |
| 17 | |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 18 | import org.onosproject.net.Annotations; |
| 19 | |
| 20 | import java.util.List; |
| 21 | import java.util.Map; |
| 22 | import java.util.Optional; |
| 23 | |
Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 24 | /** |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 25 | * An interface for telemetry config. |
Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 26 | */ |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 27 | public interface TelemetryConfig extends Annotations { |
Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 28 | |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 29 | /** |
| 30 | * Telemetry configuration type. |
| 31 | */ |
| 32 | enum ConfigType { |
| 33 | /** |
| 34 | * Indicates KAFKA telemetry config. |
| 35 | */ |
| 36 | KAFKA, |
Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 37 | |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 38 | /** |
| 39 | * Indicates GRPC telemetry config. |
| 40 | */ |
| 41 | GRPC, |
| 42 | |
| 43 | /** |
| 44 | * Indicates REST telemetry config. |
| 45 | */ |
| 46 | REST, |
| 47 | |
| 48 | /** |
| 49 | * Indicates InfluxDB telemetry config. |
| 50 | */ |
| 51 | INFLUXDB, |
| 52 | |
| 53 | /** |
| 54 | * Indicates prometheus telemetry config. |
| 55 | */ |
| 56 | PROMETHEUS, |
| 57 | |
| 58 | /** |
| 59 | * Indicates unknown telemetry config. |
| 60 | */ |
| 61 | UNKNOWN |
Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 62 | } |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 63 | |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame^] | 64 | enum Status { |
| 65 | /** |
| 66 | * Signifies that the service is in enable status. |
| 67 | */ |
| 68 | ENABLED, |
| 69 | |
| 70 | /** |
| 71 | * Signifies that the service is in disable status. |
| 72 | */ |
| 73 | DISABLED, |
| 74 | |
| 75 | /** |
| 76 | * Signifies that the service is in pending status. |
| 77 | */ |
| 78 | PENDING, |
| 79 | |
| 80 | /** |
| 81 | * Signifies that the service is in unknown status. |
| 82 | */ |
| 83 | UNKNOWN, |
| 84 | } |
| 85 | |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 86 | /** |
| 87 | * Returns the telemetry configuration name. |
| 88 | * |
| 89 | * @return configuration name |
| 90 | */ |
| 91 | String name(); |
| 92 | |
| 93 | /** |
| 94 | * Returns the telemetry configuration type. |
| 95 | * |
| 96 | * @return configuration type |
| 97 | */ |
| 98 | ConfigType type(); |
| 99 | |
| 100 | /** |
| 101 | * Returns all the parent configurations from which this configuration inherits |
| 102 | * properties. |
| 103 | * |
| 104 | * @return list of parent configurations |
| 105 | */ |
| 106 | List<TelemetryConfig> parents(); |
| 107 | |
| 108 | /** |
| 109 | * Returns the off-platform application manufacturer name. |
| 110 | * |
| 111 | * @return manufacturer name |
| 112 | */ |
| 113 | String manufacturer(); |
| 114 | |
| 115 | /** |
| 116 | * Returns the off-platform application software version. |
| 117 | * |
| 118 | * @return software version |
| 119 | */ |
| 120 | String swVersion(); |
| 121 | |
| 122 | /** |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame^] | 123 | * Returns the service status. |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 124 | * |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame^] | 125 | * @return service status |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 126 | */ |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame^] | 127 | Status status(); |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Returns the set of annotations as map of key/value properties. |
| 131 | * |
| 132 | * @return map of properties |
| 133 | */ |
| 134 | Map<String, String> properties(); |
| 135 | |
| 136 | /** |
| 137 | * Gets the value of the given property name. |
| 138 | * |
| 139 | * @param name property name |
| 140 | * @return the value of the property, |
| 141 | * or null if the property is not defined in this configuration nor |
| 142 | * in any of its ancestors |
| 143 | */ |
| 144 | String getProperty(String name); |
| 145 | |
| 146 | /** |
| 147 | * Get the value of the given property name. |
| 148 | * |
| 149 | * @param name property name |
| 150 | * @param defaultValue to use if the property is not defined in this configuration |
| 151 | * nor in any of its ancestors |
| 152 | * @return the value of the property, |
| 153 | * or null if the property is not defined in this configuration nor |
| 154 | * in any of its ancestors |
| 155 | */ |
| 156 | default String getProperty(String name, String defaultValue) { |
| 157 | return Optional.ofNullable(getProperty(name)).orElse(defaultValue); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Merges the specified config properties into this one, giving preference to |
| 162 | * the other config when dealing with conflicts. |
| 163 | * |
| 164 | * @param other other configuration |
| 165 | * @return merged configuration |
| 166 | */ |
| 167 | TelemetryConfig merge(TelemetryConfig other); |
Jian Li | 16f1f53 | 2018-12-27 17:45:09 +0900 | [diff] [blame] | 168 | |
| 169 | /** |
| 170 | * Obtains the cloned instance with updated properties. |
| 171 | * |
| 172 | * @param properties telemetry config properties |
| 173 | * @return a cloned instance |
| 174 | */ |
| 175 | TelemetryConfig updateProperties(Map<String, String> properties); |
| 176 | |
| 177 | /** |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame^] | 178 | * Obtains the cloned instance with updated status. |
Jian Li | 16f1f53 | 2018-12-27 17:45:09 +0900 | [diff] [blame] | 179 | * |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame^] | 180 | * @param status service status |
Jian Li | 16f1f53 | 2018-12-27 17:45:09 +0900 | [diff] [blame] | 181 | * @return a cloned instance |
| 182 | */ |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame^] | 183 | TelemetryConfig updateStatus(Status status); |
Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 184 | } |