Merge "Add setXxx methods for @Property annotation"
[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 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 org.onap.policy.common.utils.properties.SpecPropertyConfiguration;
25 import org.onap.policy.common.utils.properties.exception.PropertyException;
26
27 /**
28  * Properties used by the pooling feature, specific to a controller.
29  */
30 public class PoolingProperties extends SpecPropertyConfiguration {
31
32     /**
33      * The feature name, used to retrieve properties.
34      */
35     public static final String FEATURE_NAME = "feature-pooling-dmaap";
36
37     /**
38      * Feature properties all begin with this prefix.
39      */
40     public static final String PREFIX = "pooling.";
41     
42     /*
43      * These properties are not used by a SpecPropertyConfiguration, thus
44      * they do not use any of the "{xxx}" forms.
45      */
46     public static final String FEATURE_ENABLED = PREFIX + "enabled";
47
48     /*
49      * These properties REQUIRE a controller name, thus they use the "{$}" form.
50      */
51     public static final String POOLING_TOPIC = PREFIX + "{$}.topic";
52
53     /*
54      * These properties allow the controller name to be left out, thus they use
55      * the "{prefix?suffix}" form.
56      */
57     public static final String OFFLINE_LIMIT = PREFIX + "{?.}offline.queue.limit";
58     public static final String OFFLINE_AGE_MS = PREFIX + "{?.}offline.queue.age.milliseconds";
59     public static final String OFFLINE_PUB_WAIT_MS = PREFIX + "{?.}offline.publish.wait.milliseconds";
60     public static final String START_HEARTBEAT_MS = PREFIX + "{?.}start.heartbeat.milliseconds";
61     public static final String REACTIVATE_MS = PREFIX + "{?.}reactivate.milliseconds";
62     public static final String IDENTIFICATION_MS = PREFIX + "{?.}identification.milliseconds";
63     public static final String ACTIVE_HEARTBEAT_MS = PREFIX + "{?.}active.heartbeat.milliseconds";
64     public static final String INTER_HEARTBEAT_MS = PREFIX + "{?.}inter.heartbeat.milliseconds";
65
66     /**
67      * Type of item that the extractors will be extracting.
68      */
69     public static final String EXTRACTOR_TYPE = "requestId";
70
71     /**
72      * Prefix for extractor properties.
73      */
74     public static final String PROP_EXTRACTOR_PREFIX = "extractor." + EXTRACTOR_TYPE;
75
76     /**
77      * Properties from which this was constructed.
78      */
79     private Properties source;
80
81     /**
82      * Topic used for inter-host communication.
83      */
84     @Property(name = POOLING_TOPIC)
85     private String poolingTopic;
86
87     /**
88      * Maximum number of events to retain in the queue while waiting for
89      * buckets to be assigned.
90      */
91     @Property(name = OFFLINE_LIMIT, defaultValue = "1000")
92     private int offlineLimit;
93
94     /**
95      * Maximum age, in milliseconds, of events to be retained in the queue.
96      * Events older than this are discarded.
97      */
98     @Property(name = OFFLINE_AGE_MS, defaultValue = "60000")
99     private long offlineAgeMs;
100
101     /**
102      * Time, in milliseconds, to wait for an "Offline" message to be published
103      * to DMaaP.
104      */
105     @Property(name = OFFLINE_PUB_WAIT_MS, defaultValue = "3000")
106     private long offlinePubWaitMs;
107
108     /**
109      * Time, in milliseconds, to wait for this host's heart beat during the
110      * start-up state.
111      */
112     @Property(name = START_HEARTBEAT_MS, defaultValue = "100000")
113     private long startHeartbeatMs;
114
115     /**
116      * Time, in milliseconds, to wait before attempting to re-active this
117      * host when it has no bucket assignments.
118      */
119     @Property(name = REACTIVATE_MS, defaultValue = "50000")
120     private long reactivateMs;
121
122     /**
123      * Time, in milliseconds, to wait for all Identification messages to
124      * arrive during the query state.
125      */
126     @Property(name = IDENTIFICATION_MS, defaultValue = "50000")
127     private long identificationMs;
128
129     /**
130      * Time, in milliseconds, to wait for heart beats from this host, or its
131      * predecessor, during the active state.
132      */
133     @Property(name = ACTIVE_HEARTBEAT_MS, defaultValue = "50000")
134     private long activeHeartbeatMs;
135
136     /**
137      * Time, in milliseconds, to wait between heart beat generations during
138      * the active and start-up states.
139      */
140     @Property(name = INTER_HEARTBEAT_MS, defaultValue = "15000")
141     private long interHeartbeatMs;
142
143     /**
144      * @param controllerName the name of the controller
145      * @param props set of properties used to configure this
146      * @throws PropertyException if an error occurs
147      * 
148      */
149     public PoolingProperties(String controllerName, Properties props) throws PropertyException {
150         super(controllerName, props);
151
152         source = props;
153     }
154
155     public Properties getSource() {
156         return source;
157     }
158
159     public String getPoolingTopic() {
160         return poolingTopic;
161     }
162
163     public int getOfflineLimit() {
164         return offlineLimit;
165     }
166
167     public long getOfflineAgeMs() {
168         return offlineAgeMs;
169     }
170
171     public long getOfflinePubWaitMs() {
172         return offlinePubWaitMs;
173     }
174
175     public long getStartHeartbeatMs() {
176         return startHeartbeatMs;
177     }
178
179     public long getReactivateMs() {
180         return reactivateMs;
181     }
182
183     public long getIdentificationMs() {
184         return identificationMs;
185     }
186
187     public long getActiveHeartbeatMs() {
188         return activeHeartbeatMs;
189     }
190
191     public long getInterHeartbeatMs() {
192         return interHeartbeatMs;
193     }
194
195     public void setPoolingTopic(String poolingTopic) {
196         this.poolingTopic = poolingTopic;
197     }
198
199     public void setOfflineLimit(int offlineLimit) {
200         this.offlineLimit = offlineLimit;
201     }
202
203     public void setOfflineAgeMs(long offlineAgeMs) {
204         this.offlineAgeMs = offlineAgeMs;
205     }
206
207     public void setOfflinePubWaitMs(long offlinePubWaitMs) {
208         this.offlinePubWaitMs = offlinePubWaitMs;
209     }
210
211     public void setStartHeartbeatMs(long startHeartbeatMs) {
212         this.startHeartbeatMs = startHeartbeatMs;
213     }
214
215     public void setReactivateMs(long reactivateMs) {
216         this.reactivateMs = reactivateMs;
217     }
218
219     public void setIdentificationMs(long identificationMs) {
220         this.identificationMs = identificationMs;
221     }
222
223     public void setActiveHeartbeatMs(long activeHeartbeatMs) {
224         this.activeHeartbeatMs = activeHeartbeatMs;
225     }
226
227     public void setInterHeartbeatMs(long interHeartbeatMs) {
228         this.interHeartbeatMs = interHeartbeatMs;
229     }
230 }