Jian Li | 6803ccd | 2018-06-08 09:26:09 +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.impl; |
| 17 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 18 | import com.fasterxml.jackson.databind.node.ArrayNode; |
| 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 20 | import com.google.common.collect.Maps; |
| 21 | import com.google.common.collect.Sets; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 22 | import org.apache.kafka.clients.producer.KafkaProducer; |
| 23 | import org.apache.kafka.clients.producer.Producer; |
| 24 | import org.apache.kafka.clients.producer.ProducerRecord; |
| 25 | import org.apache.kafka.clients.producer.RecordMetadata; |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 26 | import org.onosproject.codec.CodecContext; |
| 27 | import org.onosproject.codec.CodecService; |
| 28 | import org.onosproject.codec.JsonCodec; |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 29 | import org.onosproject.openstacktelemetry.api.FlowInfo; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 30 | import org.onosproject.openstacktelemetry.api.KafkaTelemetryAdminService; |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 31 | import org.onosproject.openstacktelemetry.api.LinkInfo; |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 32 | import org.onosproject.openstacktelemetry.api.OpenstackTelemetryService; |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 33 | import org.onosproject.openstacktelemetry.api.TelemetryCodec; |
| 34 | import org.onosproject.openstacktelemetry.api.TelemetryConfigService; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 35 | import org.onosproject.openstacktelemetry.api.config.KafkaTelemetryConfig; |
| 36 | import org.onosproject.openstacktelemetry.api.config.TelemetryConfig; |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 37 | import org.onosproject.rest.AbstractWebResource; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 38 | import org.osgi.service.component.annotations.Activate; |
| 39 | import org.osgi.service.component.annotations.Component; |
| 40 | import org.osgi.service.component.annotations.Deactivate; |
| 41 | import org.osgi.service.component.annotations.Reference; |
| 42 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 43 | import org.slf4j.Logger; |
| 44 | import org.slf4j.LoggerFactory; |
| 45 | |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 46 | import java.nio.ByteBuffer; |
| 47 | import java.util.Map; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 48 | import java.util.Properties; |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 49 | import java.util.Set; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 50 | import java.util.concurrent.Future; |
| 51 | |
Jian Li | b3b0168 | 2019-01-09 17:10:12 +0900 | [diff] [blame] | 52 | import static org.apache.kafka.clients.producer.ProducerConfig.ACKS_CONFIG; |
| 53 | import static org.apache.kafka.clients.producer.ProducerConfig.BATCH_SIZE_CONFIG; |
| 54 | import static org.apache.kafka.clients.producer.ProducerConfig.BOOTSTRAP_SERVERS_CONFIG; |
| 55 | import static org.apache.kafka.clients.producer.ProducerConfig.BUFFER_MEMORY_CONFIG; |
| 56 | import static org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG; |
| 57 | import static org.apache.kafka.clients.producer.ProducerConfig.LINGER_MS_CONFIG; |
| 58 | import static org.apache.kafka.clients.producer.ProducerConfig.METADATA_FETCH_TIMEOUT_CONFIG; |
| 59 | import static org.apache.kafka.clients.producer.ProducerConfig.RECONNECT_BACKOFF_MS_CONFIG; |
| 60 | import static org.apache.kafka.clients.producer.ProducerConfig.RETRIES_CONFIG; |
| 61 | import static org.apache.kafka.clients.producer.ProducerConfig.RETRY_BACKOFF_MS_CONFIG; |
| 62 | import static org.apache.kafka.clients.producer.ProducerConfig.TIMEOUT_CONFIG; |
| 63 | import static org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG; |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 64 | import static org.onosproject.openstacktelemetry.api.Constants.KAFKA_SCHEME; |
| 65 | import static org.onosproject.openstacktelemetry.api.config.TelemetryConfig.ConfigType.KAFKA; |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 66 | import static org.onosproject.openstacktelemetry.api.config.TelemetryConfig.Status.ENABLED; |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 67 | import static org.onosproject.openstacktelemetry.config.DefaultKafkaTelemetryConfig.fromTelemetryConfig; |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 68 | import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.flowsToLinks; |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 69 | import static org.onosproject.openstacktelemetry.util.OpenstackTelemetryUtil.testConnectivity; |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 70 | |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 71 | /** |
| 72 | * Kafka telemetry manager. |
| 73 | */ |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 74 | @Component(immediate = true, service = KafkaTelemetryAdminService.class) |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 75 | public class KafkaTelemetryManager extends AbstractWebResource |
| 76 | implements KafkaTelemetryAdminService { |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 77 | |
| 78 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 79 | |
Jian Li | b3b0168 | 2019-01-09 17:10:12 +0900 | [diff] [blame] | 80 | private static final int METADATA_FETCH_TIMEOUT_VAL = 300; |
| 81 | private static final int TIMEOUT_VAL = 300; |
| 82 | private static final int RETRY_BACKOFF_MS_VAL = 10000; |
| 83 | private static final int RECONNECT_BACKOFF_MS_VAL = 10000; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 84 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 85 | private static final String LINK_INFOS = "linkInfos"; |
| 86 | |
| 87 | private static final String BYTE_ARRAY_SERIALIZER = |
| 88 | "org.apache.kafka.common.serialization.ByteArraySerializer"; |
| 89 | private static final String STRING_SERIALIZER = |
| 90 | "org.apache.kafka.common.serialization.StringSerializer"; |
| 91 | |
| 92 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 93 | protected CodecService codecService; |
| 94 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 95 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 96 | protected OpenstackTelemetryService openstackTelemetryService; |
| 97 | |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 98 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 99 | protected TelemetryConfigService telemetryConfigService; |
| 100 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 101 | private Map<String, Producer<String, String>> stringProducers = Maps.newConcurrentMap(); |
| 102 | private Map<String, Producer<String, byte[]>> byteProducers = Maps.newConcurrentMap(); |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 103 | |
| 104 | @Activate |
| 105 | protected void activate() { |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 106 | |
| 107 | openstackTelemetryService.addTelemetryService(this); |
| 108 | |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 109 | log.info("Started"); |
| 110 | } |
| 111 | |
| 112 | @Deactivate |
| 113 | protected void deactivate() { |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 114 | stopAll(); |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 115 | |
| 116 | openstackTelemetryService.removeTelemetryService(this); |
| 117 | |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 118 | log.info("Stopped"); |
| 119 | } |
| 120 | |
| 121 | @Override |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 122 | public Set<Future<RecordMetadata>> publish(Set<FlowInfo> flowInfos) { |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 123 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 124 | boolean hasEmptyByteProducers = |
| 125 | byteProducers == null || byteProducers.isEmpty(); |
| 126 | boolean hasEmptyStringProducers = |
| 127 | stringProducers == null || stringProducers.isEmpty(); |
| 128 | |
| 129 | if (hasEmptyByteProducers && hasEmptyStringProducers) { |
Jian Li | a494768 | 2018-07-07 14:53:32 +0900 | [diff] [blame] | 130 | log.debug("Kafka telemetry service has not been enabled!"); |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 131 | return null; |
| 132 | } |
| 133 | |
Jian Li | 85573f4 | 2018-06-27 22:29:14 +0900 | [diff] [blame] | 134 | log.debug("Send telemetry record to kafka server..."); |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 135 | Set<Future<RecordMetadata>> futureSet = Sets.newHashSet(); |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 136 | |
| 137 | byteProducers.forEach((k, v) -> { |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 138 | TelemetryConfig config = telemetryConfigService.getConfig(k); |
Jian Li | 7fe7eaf | 2018-12-31 17:00:33 +0900 | [diff] [blame] | 139 | KafkaTelemetryConfig kafkaConfig = fromTelemetryConfig(config); |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 140 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 141 | if (kafkaConfig != null && |
| 142 | BYTE_ARRAY_SERIALIZER.equals(kafkaConfig.valueSerializer())) { |
| 143 | try { |
| 144 | Class codecClazz = Class.forName(kafkaConfig.codec()); |
| 145 | TelemetryCodec codec = (TelemetryCodec) codecClazz.newInstance(); |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 146 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 147 | ByteBuffer buffer = codec.encode(flowInfos); |
| 148 | ProducerRecord record = new ProducerRecord<>( |
| 149 | kafkaConfig.topic(), kafkaConfig.key(), buffer.array()); |
| 150 | futureSet.add(v.send(record)); |
| 151 | } catch (ClassNotFoundException | |
| 152 | IllegalAccessException | InstantiationException e) { |
| 153 | log.warn("Failed to send telemetry record due to {}", e); |
| 154 | } |
| 155 | } |
| 156 | }); |
| 157 | |
| 158 | stringProducers.forEach((k, v) -> { |
| 159 | TelemetryConfig config = telemetryConfigService.getConfig(k); |
| 160 | KafkaTelemetryConfig kafkaConfig = fromTelemetryConfig(config); |
| 161 | |
| 162 | if (kafkaConfig != null && |
| 163 | STRING_SERIALIZER.equals(kafkaConfig.valueSerializer())) { |
| 164 | |
| 165 | // TODO: this is a workaround to convert flowInfo to linkInfo |
| 166 | // need to find a better solution |
| 167 | |
| 168 | Set<LinkInfo> linkInfos = flowsToLinks(flowInfos); |
| 169 | |
| 170 | if (!linkInfos.isEmpty()) { |
| 171 | ProducerRecord record = new ProducerRecord<>( |
| 172 | kafkaConfig.topic(), kafkaConfig.key(), |
| 173 | encodeStrings(linkInfos, this, |
| 174 | kafkaConfig.codec()).toString()); |
| 175 | futureSet.add(v.send(record)); |
| 176 | } |
Jian Li | 69600e0 | 2018-12-24 13:21:18 +0900 | [diff] [blame] | 177 | } |
| 178 | }); |
| 179 | return futureSet; |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 180 | } |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 181 | |
| 182 | @Override |
| 183 | public boolean isRunning() { |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 184 | return !byteProducers.isEmpty(); |
Jian Li | d1ce10a | 2018-06-12 13:47:23 +0900 | [diff] [blame] | 185 | } |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 186 | |
| 187 | @Override |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 188 | public boolean start(String name) { |
| 189 | boolean success = false; |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 190 | TelemetryConfig config = telemetryConfigService.getConfig(name); |
| 191 | KafkaTelemetryConfig kafkaConfig = fromTelemetryConfig(config); |
| 192 | |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 193 | if (kafkaConfig != null && !config.name().equals(KAFKA_SCHEME) && |
| 194 | config.status() == ENABLED) { |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 195 | StringBuilder kafkaServerBuilder = new StringBuilder(); |
| 196 | kafkaServerBuilder.append(kafkaConfig.address()); |
| 197 | kafkaServerBuilder.append(":"); |
| 198 | kafkaServerBuilder.append(kafkaConfig.port()); |
| 199 | |
| 200 | // Configure Kafka server properties |
| 201 | Properties prop = new Properties(); |
Jian Li | b3b0168 | 2019-01-09 17:10:12 +0900 | [diff] [blame] | 202 | prop.put(BOOTSTRAP_SERVERS_CONFIG, kafkaServerBuilder.toString()); |
| 203 | prop.put(RETRIES_CONFIG, kafkaConfig.retries()); |
| 204 | prop.put(ACKS_CONFIG, kafkaConfig.requiredAcks()); |
| 205 | prop.put(BATCH_SIZE_CONFIG, kafkaConfig.batchSize()); |
| 206 | prop.put(LINGER_MS_CONFIG, kafkaConfig.lingerMs()); |
| 207 | prop.put(BUFFER_MEMORY_CONFIG, kafkaConfig.memoryBuffer()); |
| 208 | prop.put(KEY_SERIALIZER_CLASS_CONFIG, kafkaConfig.keySerializer()); |
| 209 | prop.put(VALUE_SERIALIZER_CLASS_CONFIG, kafkaConfig.valueSerializer()); |
| 210 | prop.put(METADATA_FETCH_TIMEOUT_CONFIG, METADATA_FETCH_TIMEOUT_VAL); |
| 211 | prop.put(TIMEOUT_CONFIG, TIMEOUT_VAL); |
| 212 | prop.put(RETRY_BACKOFF_MS_CONFIG, RETRY_BACKOFF_MS_VAL); |
| 213 | prop.put(RECONNECT_BACKOFF_MS_CONFIG, RECONNECT_BACKOFF_MS_VAL); |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 214 | |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 215 | if (testConnectivity(kafkaConfig.address(), kafkaConfig.port())) { |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 216 | if (kafkaConfig.valueSerializer().equals(BYTE_ARRAY_SERIALIZER)) { |
| 217 | byteProducers.put(name, new KafkaProducer<>(prop)); |
| 218 | } |
| 219 | |
| 220 | if (kafkaConfig.valueSerializer().equals(STRING_SERIALIZER)) { |
| 221 | stringProducers.put(name, new KafkaProducer<>(prop)); |
| 222 | } |
| 223 | |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 224 | success = true; |
| 225 | } else { |
| 226 | log.warn("Unable to connect to {}:{}, " + |
| 227 | "please check the connectivity manually", |
| 228 | kafkaConfig.address(), kafkaConfig.port()); |
| 229 | } |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 230 | } |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 231 | |
| 232 | return success; |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | @Override |
| 236 | public void stop(String name) { |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 237 | Producer<String, byte[]> byteProducer = byteProducers.get(name); |
| 238 | Producer<String, String> stringProducer = stringProducers.get(name); |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 239 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 240 | if (byteProducer != null) { |
| 241 | byteProducer.close(); |
| 242 | byteProducers.remove(name); |
| 243 | } |
| 244 | |
| 245 | if (stringProducer != null) { |
| 246 | stringProducer.close(); |
| 247 | stringProducers.remove(name); |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | |
| 251 | @Override |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 252 | public boolean restart(String name) { |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 253 | stop(name); |
Jian Li | 667c6eb | 2019-01-07 23:01:12 +0900 | [diff] [blame] | 254 | return start(name); |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | @Override |
| 258 | public void startAll() { |
| 259 | telemetryConfigService.getConfigsByType(KAFKA).forEach(c -> start(c.name())); |
| 260 | log.info("Kafka producer has Started"); |
| 261 | } |
| 262 | |
| 263 | @Override |
| 264 | public void stopAll() { |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 265 | if (!byteProducers.isEmpty()) { |
| 266 | byteProducers.values().forEach(Producer::close); |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 267 | } |
| 268 | |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 269 | byteProducers.clear(); |
| 270 | |
| 271 | if (!stringProducers.isEmpty()) { |
| 272 | stringProducers.values().forEach(Producer::close); |
| 273 | } |
| 274 | |
| 275 | stringProducers.clear(); |
Jian Li | a61e0b6 | 2018-12-28 19:10:10 +0900 | [diff] [blame] | 276 | |
| 277 | log.info("Kafka producer has Stopped"); |
| 278 | } |
| 279 | |
| 280 | @Override |
| 281 | public void restartAll() { |
| 282 | stopAll(); |
| 283 | startAll(); |
| 284 | } |
Jian Li | da8867f | 2019-01-31 01:17:36 +0900 | [diff] [blame^] | 285 | |
| 286 | private ObjectNode encodeStrings(Set<LinkInfo> infos, |
| 287 | CodecContext context, String codecName) { |
| 288 | ObjectNode root = context.mapper().createObjectNode(); |
| 289 | ArrayNode array = context.mapper().createArrayNode(); |
| 290 | try { |
| 291 | Class codecClazz = Class.forName(codecName); |
| 292 | JsonCodec codec = codecService.getCodec(codecClazz); |
| 293 | |
| 294 | infos.forEach(l -> array.add(codec.encode(l, context))); |
| 295 | } catch (ClassNotFoundException e) { |
| 296 | log.warn("Failed to send telemetry record due to {}", e); |
| 297 | } |
| 298 | |
| 299 | root.set(LINK_INFOS, array); |
| 300 | return root; |
| 301 | } |
Jian Li | 6803ccd | 2018-06-08 09:26:09 +0900 | [diff] [blame] | 302 | } |