Drools support for kafka topics
[policy/drools-pdp.git] / feature-pooling-dmaap / src / main / java / org / onap / policy / drools / pooling / PoolingProperties.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.drools.pooling;
22
23 import java.util.Properties;
24 import lombok.Getter;
25 import lombok.Setter;
26 import org.onap.policy.common.utils.properties.BeanConfigurator;
27 import org.onap.policy.common.utils.properties.Property;
28 import org.onap.policy.common.utils.properties.SpecProperties;
29 import org.onap.policy.common.utils.properties.exception.PropertyException;
30
31 /**
32  * Properties used by the pooling feature, specific to a controller.
33  */
34 @Getter
35 @Setter
36 public class PoolingProperties {
37
38     /**
39      * The feature name, used to retrieve properties.
40      */
41     public static final String FEATURE_NAME = "feature-pooling-dmaap";
42
43     /**
44      * Feature properties all begin with this prefix.
45      */
46     public static final String PREFIX = "pooling.";
47
48     public static final String FEATURE_ENABLED = PREFIX + "enabled";
49     public static final String POOLING_TOPIC = PREFIX + "topic";
50     public static final String OFFLINE_LIMIT = PREFIX + "offline.queue.limit";
51     public static final String OFFLINE_AGE_MS = PREFIX + "offline.queue.age.milliseconds";
52     public static final String OFFLINE_PUB_WAIT_MS = PREFIX + "offline.publish.wait.milliseconds";
53     public static final String START_HEARTBEAT_MS = PREFIX + "start.heartbeat.milliseconds";
54     public static final String REACTIVATE_MS = PREFIX + "reactivate.milliseconds";
55     public static final String IDENTIFICATION_MS = PREFIX + "identification.milliseconds";
56     public static final String ACTIVE_HEARTBEAT_MS = PREFIX + "active.heartbeat.milliseconds";
57     public static final String INTER_HEARTBEAT_MS = PREFIX + "inter.heartbeat.milliseconds";
58
59     /**
60      * Type of item that the extractors will be extracting.
61      */
62     public static final String EXTRACTOR_TYPE = "requestId";
63
64     /**
65      * Prefix for extractor properties.
66      */
67     public static final String PROP_EXTRACTOR_PREFIX = "extractor." + EXTRACTOR_TYPE;
68
69     /**
70      * Properties from which this was constructed.
71      */
72     private Properties source;
73
74     /**
75      * Topic used for inter-host communication.
76      */
77     @Property(name = POOLING_TOPIC)
78     private String poolingTopic;
79
80     /**
81      * Maximum number of events to retain in the queue while waiting for
82      * buckets to be assigned.
83      */
84     @Property(name = OFFLINE_LIMIT, defaultValue = "1000")
85     private int offlineLimit;
86
87     /**
88      * Maximum age, in milliseconds, of events to be retained in the queue.
89      * Events older than this are discarded.
90      */
91     @Property(name = OFFLINE_AGE_MS, defaultValue = "60000")
92     private long offlineAgeMs;
93
94     /**
95      * Time, in milliseconds, to wait for an "Offline" message to be published
96      * to DMaaP.
97      */
98     @Property(name = OFFLINE_PUB_WAIT_MS, defaultValue = "3000")
99     private long offlinePubWaitMs;
100
101     /**
102      * Time, in milliseconds, to wait for this host's heart beat during the
103      * start-up state.
104      */
105     @Property(name = START_HEARTBEAT_MS, defaultValue = "100000")
106     private long startHeartbeatMs;
107
108     /**
109      * Time, in milliseconds, to wait before attempting to re-active this
110      * host when it has no bucket assignments.
111      */
112     @Property(name = REACTIVATE_MS, defaultValue = "50000")
113     private long reactivateMs;
114
115     /**
116      * Time, in milliseconds, to wait for all Identification messages to
117      * arrive during the query state.
118      */
119     @Property(name = IDENTIFICATION_MS, defaultValue = "50000")
120     private long identificationMs;
121
122     /**
123      * Time, in milliseconds, to wait for heart beats from this host, or its
124      * predecessor, during the active state.
125      */
126     @Property(name = ACTIVE_HEARTBEAT_MS, defaultValue = "50000")
127     private long activeHeartbeatMs;
128
129     /**
130      * Time, in milliseconds, to wait between heart beat generations during
131      * the active and start-up states.
132      */
133     @Property(name = INTER_HEARTBEAT_MS, defaultValue = "15000")
134     private long interHeartbeatMs;
135
136     /**
137      * Constructor.
138      *
139      * @param controllerName the name of the controller
140      * @param props set of properties used to configure this
141      * @throws PropertyException if an error occurs
142      *
143      */
144     public PoolingProperties(String controllerName, Properties props) throws PropertyException {
145         source = props;
146
147         new BeanConfigurator().configureFromProperties(this, new SpecProperties(PREFIX, controllerName, props));
148     }
149 }