summaryrefslogtreecommitdiffstats
path: root/dcae-analytics/dcae-analytics-web/src/main/java/org
diff options
context:
space:
mode:
authorKai <lukai@chinamobile.com>2020-02-20 21:14:48 +0800
committerKai <lukai@chinamobile.com>2020-02-20 21:15:35 +0800
commit40ffc89f78576dc2f7da221c7f1ce7ba5e8f4112 (patch)
treed577c4085e3087da940f1301e5ae7072f83ee95a /dcae-analytics/dcae-analytics-web/src/main/java/org
parentf2b60295e7e93926ed875cccf5ef581d7d7a1314 (diff)
optimize CBS query for tcagen2
Issue-ID: DCAEGEN2-2079 Signed-off-by: Kai Lu <lukai@chinamobile.com> Change-Id: Ic59be266ea0606dd888208688facb329eaccd198
Diffstat (limited to 'dcae-analytics/dcae-analytics-web/src/main/java/org')
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/SystemConfig.java84
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java28
2 files changed, 7 insertions, 105 deletions
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/SystemConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/SystemConfig.java
deleted file mode 100644
index 946c2f2..0000000
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/SystemConfig.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START======================================================================
- * Copyright (C) 2019-2020 China Mobile. All rights reserved.
- * ===============================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END========================================================================
- */
-
-package org.onap.dcae.analytics.web.config;
-
-import java.util.Optional;
-
-import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
-import org.onap.dcae.analytics.web.exception.EnvironmentLoaderException;
-
-/**
- *
- * get consul config and cbs config.
- *
- * @author Kai Lu
- */
-public class SystemConfig {
-
- /**
- *
- * private constructor.
- *
- */
- private SystemConfig() {
- }
-
- /**
- * getConsulHost.
- *
- * @return consulHost consulHost
- *
- */
- public static String getConsulHost() throws EnvironmentLoaderException {
- return Optional.ofNullable(ConfigBindingServiceConstants.CONSUL_HOST_ENV_VARIABLE_VALUE)
- .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined"));
- }
-
- /**
- * getConsultPort.
- *
- * @return consulPort consulPort
- *
- */
- public static Integer getConsultPort() {
- return ConfigBindingServiceConstants.DEFAULT_CONSUL_PORT_ENV_VARIABLE_VALUE;
- }
-
- /**
- * getConfigBindingService.
- *
- * @return configBindingService configBindingService
- *
- */
- public static String getConfigBindingService() throws EnvironmentLoaderException {
- return Optional.ofNullable(ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE) //
- .orElseThrow(() -> new EnvironmentLoaderException(
- "$CONFIG_BINDING_SERVICE environment has not been defined"));
- }
-
- /**
- * getService.
- *
- * @return service service
- *
- */
- public static String getService() throws EnvironmentLoaderException {
- return Optional.ofNullable(ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE).orElseThrow(
- () -> new EnvironmentLoaderException("$HOSTNAME have not been defined as system environment"));
- }
-
-}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java
index 5fa82d6..d643de2 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java
@@ -30,14 +30,11 @@ import java.util.stream.Collectors;
import org.onap.dcae.analytics.model.AnalyticsProfile;
import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
import org.onap.dcae.analytics.model.util.function.JsonStringToMapFunction;
-import org.onap.dcae.analytics.web.config.SystemConfig;
-import org.onap.dcae.analytics.web.exception.EnvironmentLoaderException;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClient;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest;
-import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
-import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableEnvProperties;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -177,21 +174,10 @@ public class ConfigBindingServiceEnvironmentPostProcessor implements Environment
* @return environment properties.
*
*/
- public Mono<EnvProperties> readEnvironmentVariables() {
+ public Mono<CbsClientConfiguration> readEnvironmentVariables() {
logger.trace("Loading configuration from system environment variables");
- EnvProperties envProperties;
- try {
- envProperties = ImmutableEnvProperties.builder() //
- .consulHost(SystemConfig.getConsulHost()) //
- .consulPort(SystemConfig.getConsultPort()) //
- .cbsName(SystemConfig.getConfigBindingService()) //
- .appName(SystemConfig.getService()) //
- .build();
- } catch (EnvironmentLoaderException e) {
- return Mono.error(e);
- }
- logger.trace("Evaluated environment system variables {}", envProperties);
- return Mono.just(envProperties);
+ CbsClientConfiguration cbsClientConfiguration = CbsClientConfiguration.fromEnvironment();
+ return Mono.just(cbsClientConfiguration);
}
/**
@@ -220,12 +206,12 @@ public class ConfigBindingServiceEnvironmentPostProcessor implements Environment
/**
* create CbsClient.
*
- * @param env environment properties
+ * @param cbsClientConfiguration cbs configuration
* @return cbsclient
*
*/
- public Mono<CbsClient> createCbsClient(EnvProperties env) {
- return CbsClientFactory.createCbsClient(env);
+ public Mono<CbsClient> createCbsClient(CbsClientConfiguration cbsClientConfiguration) {
+ return CbsClientFactory.createCbsClient(cbsClientConfiguration);
}
/**