add periodic fetch configuration
[dcaegen2/analytics/tca-gen2.git] / dcae-analytics / dcae-analytics-model / src / main / java / org / onap / dcae / analytics / model / configbindingservice / ConfigBindingServiceConstants.java
1 /*
2  * ================================================================================
3  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  *
18  */
19
20 package org.onap.dcae.analytics.model.configbindingservice;
21
22 import java.util.Map;
23 import java.util.Set;
24 import java.util.function.Predicate;
25 import java.util.stream.Collectors;
26 import java.util.stream.Stream;
27
28 import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.PubSubCommonDetails;
29
30 /**
31  * @author Rajiv Singla
32  */
33 public abstract class ConfigBindingServiceConstants {
34
35     // ================== CONFIG SERVICE CONSTANTS ============================== //
36     public static final String CONSUL_HOST_ENV_VARIABLE_KEY = "CONSUL_HOST";
37     public static final Integer DEFAULT_CONSUL_PORT_ENV_VARIABLE_VALUE = 8500;
38     public static final String CONSUL_HOST_ENV_VARIABLE_VALUE = System.getenv(CONSUL_HOST_ENV_VARIABLE_KEY);
39     public static final String CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY = "CONFIG_BINDING_SERVICE";
40     public static final String CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE =
41             System.getenv(CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY);
42     public static final String SERVICE_NAME_ENV_VARIABLE_KEY = "HOSTNAME";
43     public static final String SERVICE_NAME_ENV_VARIABLE_VALUE = System.getenv(SERVICE_NAME_ENV_VARIABLE_KEY);
44     public static final String CONSUL_QUERY_URL_STRING = String.format("http://%s:8500/v1/catalog/service/%s",
45             CONSUL_HOST_ENV_VARIABLE_VALUE, CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE);
46     public static final String CONFIG_SERVICE_QUERY_URL_STRING = "http://%s:%s/service_component/%s";
47
48
49     public static final String CONFIG_BINDING_SERVICE_PROPERTIES_KEY = "config-binding-service";
50
51     public static final Set<String> SPRING_RESERVED_PROPERTIES_KEY_PREFIXES =
52             Stream.of("spring", "endpoints", "server", "logging", "management").collect(Collectors.toSet());
53     public static final String CONFIG_SERVICE_MESSAGE_ROUTER_VALUE = "message_router";
54     // CONVERT JSON TO MAP
55     public static final String KEY_SEPARATOR = ".";
56     public static final String CONFIG = "config";
57     public static final int CONFIG_SERVICE_REFRESHPERIOD = 1;
58
59     // ============== CONFIG BINDING SERVICE UTILS ========================= //
60     /**
61      * Predicate which can be used to filter message router publisher or subscriber details
62      */
63     public static final Predicate<Map.Entry<String, ? extends PubSubCommonDetails>> MESSAGE_ROUTER_PREDICATE =
64             e -> e.getValue().getType() != null &&
65                     e.getValue().getType().equalsIgnoreCase(CONFIG_SERVICE_MESSAGE_ROUTER_VALUE);
66
67     private ConfigBindingServiceConstants() {
68         // private constructor
69     }
70 }