Merge "Add api-resource-locks feature"
[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      * Feature properties all begin with this prefix.
34      */
35     public static final String PREFIX = "pooling.";
36
37     /*
38      * These properties REQUIRE a controller name, thus they use the "{$}" form.
39      */
40     public static final String POOLING_TOPIC = PREFIX + "{$}.topic";
41
42     /*
43      * These properties allow the controller name to be left out, thus they use
44      * the "{prefix?suffix}" form.
45      */
46     public static final String FEATURE_ENABLED = PREFIX + "{?.}enabled";
47     public static final String OFFLINE_LIMIT = PREFIX + "{?.}offline.queue.limit";
48     public static final String OFFLINE_AGE_MS = PREFIX + "{?.}offline.queue.age.milliseconds";
49     public static final String START_HEARTBEAT_MS = PREFIX + "{?.}start.heartbeat.milliseconds";
50     public static final String REACTIVATE_MS = PREFIX + "{?.}reactivate.milliseconds";
51     public static final String IDENTIFICATION_MS = PREFIX + "{?.}identification.milliseconds";
52     public static final String ACTIVE_HEARTBEAT_MS = PREFIX + "{?.}active.heartbeat.milliseconds";
53     public static final String INTER_HEARTBEAT_MS = PREFIX + "{?.}inter.heartbeat.milliseconds";
54
55     /**
56      * Properties from which this was constructed.
57      */
58     private Properties source;
59
60     /**
61      * Topic used for inter-host communication.
62      */
63     @Property(name = POOLING_TOPIC)
64     private String poolingTopic;
65
66     /**
67      * Maximum number of events to retain in the queue while waiting for
68      * buckets to be assigned.
69      */
70     @Property(name = OFFLINE_LIMIT, defaultValue = "1000")
71     private int offlineLimit;
72
73     /**
74      * Maximum age, in milliseconds, of events to be retained in the queue.
75      * Events older than this are discarded.
76      */
77     @Property(name = OFFLINE_AGE_MS, defaultValue = "60000")
78     private long offlineAgeMs;
79
80     /**
81      * Time, in milliseconds, to wait for this host's heart beat during the
82      * start-up state.
83      */
84     @Property(name = START_HEARTBEAT_MS, defaultValue = "50000")
85     private long startHeartbeatMs;
86
87     /**
88      * Time, in milliseconds, to wait before attempting to re-active this
89      * host when it has no bucket assignments.
90      */
91     @Property(name = REACTIVATE_MS, defaultValue = "50000")
92     private long reactivateMs;
93
94     /**
95      * Time, in milliseconds, to wait for all Identification messages to
96      * arrive during the query state.
97      */
98     @Property(name = IDENTIFICATION_MS, defaultValue = "50000")
99     private long identificationMs;
100
101     /**
102      * Time, in milliseconds, to wait for heart beats from this host, or its
103      * predecessor, during the active state.
104      */
105     @Property(name = ACTIVE_HEARTBEAT_MS, defaultValue = "50000")
106     private long activeHeartbeatMs;
107
108     /**
109      * Time, in milliseconds, to wait between heart beat generations during
110      * the active state.
111      */
112     @Property(name = INTER_HEARTBEAT_MS, defaultValue = "15000")
113     private long interHeartbeatMs;
114
115     /**
116      * @param controllerName the name of the controller
117      * @param props set of properties used to configure this
118      * @throws PropertyException if an error occurs
119      * 
120      */
121     public PoolingProperties(String controllerName, Properties props) throws PropertyException {
122         super(controllerName, props);
123
124         source = props;
125     }
126
127     public Properties getSource() {
128         return source;
129     }
130
131     public String getPoolingTopic() {
132         return poolingTopic;
133     }
134
135     public int getOfflineLimit() {
136         return offlineLimit;
137     }
138
139     public long getOfflineAgeMs() {
140         return offlineAgeMs;
141     }
142
143     public long getStartHeartbeatMs() {
144         return startHeartbeatMs;
145     }
146
147     public long getReactivateMs() {
148         return reactivateMs;
149     }
150
151     public long getIdentificationMs() {
152         return identificationMs;
153     }
154
155     public long getActiveHeartbeatMs() {
156         return activeHeartbeatMs;
157     }
158
159     public long getInterHeartbeatMs() {
160         return interHeartbeatMs;
161     }
162 }