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