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 | |
| 64 | /** |
| 65 | * Returns the telemetry configuration name. |
| 66 | * |
| 67 | * @return configuration name |
| 68 | */ |
| 69 | String name(); |
| 70 | |
| 71 | /** |
| 72 | * Returns the telemetry configuration type. |
| 73 | * |
| 74 | * @return configuration type |
| 75 | */ |
| 76 | ConfigType type(); |
| 77 | |
| 78 | /** |
| 79 | * Returns all the parent configurations from which this configuration inherits |
| 80 | * properties. |
| 81 | * |
| 82 | * @return list of parent configurations |
| 83 | */ |
| 84 | List<TelemetryConfig> parents(); |
| 85 | |
| 86 | /** |
| 87 | * Returns the off-platform application manufacturer name. |
| 88 | * |
| 89 | * @return manufacturer name |
| 90 | */ |
| 91 | String manufacturer(); |
| 92 | |
| 93 | /** |
| 94 | * Returns the off-platform application software version. |
| 95 | * |
| 96 | * @return software version |
| 97 | */ |
| 98 | String swVersion(); |
| 99 | |
| 100 | /** |
| 101 | * Returns the service enable flag. |
| 102 | * |
| 103 | * @return enable flag |
| 104 | */ |
| 105 | boolean enabled(); |
| 106 | |
| 107 | /** |
| 108 | * Returns the set of annotations as map of key/value properties. |
| 109 | * |
| 110 | * @return map of properties |
| 111 | */ |
| 112 | Map<String, String> properties(); |
| 113 | |
| 114 | /** |
| 115 | * Gets the value of the given property name. |
| 116 | * |
| 117 | * @param name property name |
| 118 | * @return the value of the property, |
| 119 | * or null if the property is not defined in this configuration nor |
| 120 | * in any of its ancestors |
| 121 | */ |
| 122 | String getProperty(String name); |
| 123 | |
| 124 | /** |
| 125 | * Get the value of the given property name. |
| 126 | * |
| 127 | * @param name property name |
| 128 | * @param defaultValue to use if the property is not defined in this configuration |
| 129 | * nor in any of its ancestors |
| 130 | * @return the value of the property, |
| 131 | * or null if the property is not defined in this configuration nor |
| 132 | * in any of its ancestors |
| 133 | */ |
| 134 | default String getProperty(String name, String defaultValue) { |
| 135 | return Optional.ofNullable(getProperty(name)).orElse(defaultValue); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Merges the specified config properties into this one, giving preference to |
| 140 | * the other config when dealing with conflicts. |
| 141 | * |
| 142 | * @param other other configuration |
| 143 | * @return merged configuration |
| 144 | */ |
| 145 | TelemetryConfig merge(TelemetryConfig other); |
Jian Li | 52c1122 | 2018-06-07 11:39:17 +0900 | [diff] [blame] | 146 | } |