2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.policy.drools.pooling;
24 import java.util.Properties;
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;
33 * Properties used by the pooling feature, specific to a controller.
37 public class PoolingProperties {
40 * The feature name, used to retrieve properties.
42 public static final String FEATURE_NAME = "feature-pooling-messages";
45 * Feature properties all begin with this prefix.
47 public static final String PREFIX = "pooling.";
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";
61 * Type of item that the extractors will be extracting.
63 public static final String EXTRACTOR_TYPE = "requestId";
66 * Prefix for extractor properties.
68 public static final String PROP_EXTRACTOR_PREFIX = "extractor." + EXTRACTOR_TYPE;
71 * Properties from which this was constructed.
73 private Properties source;
76 * Topic used for inter-host communication.
78 @Property(name = POOLING_TOPIC)
79 private String poolingTopic;
82 * Maximum number of events to retain in the queue while waiting for
83 * buckets to be assigned.
85 @Property(name = OFFLINE_LIMIT, defaultValue = "1000")
86 private int offlineLimit;
89 * Maximum age, in milliseconds, of events to be retained in the queue.
90 * Events older than this are discarded.
92 @Property(name = OFFLINE_AGE_MS, defaultValue = "60000")
93 private long offlineAgeMs;
96 * Time, in milliseconds, to wait for an "Offline" message to be published
99 @Property(name = OFFLINE_PUB_WAIT_MS, defaultValue = "3000")
100 private long offlinePubWaitMs;
103 * Time, in milliseconds, to wait for this host's heart beat during the
106 @Property(name = START_HEARTBEAT_MS, defaultValue = "100000")
107 private long startHeartbeatMs;
110 * Time, in milliseconds, to wait before attempting to reactivate this
111 * host when it has no bucket assignments.
113 @Property(name = REACTIVATE_MS, defaultValue = "50000")
114 private long reactivateMs;
117 * Time, in milliseconds, to wait for all Identification messages to
118 * arrive during the query state.
120 @Property(name = IDENTIFICATION_MS, defaultValue = "50000")
121 private long identificationMs;
124 * Time, in milliseconds, to wait for heart beats from this host, or its
125 * predecessor, during the active state.
127 @Property(name = ACTIVE_HEARTBEAT_MS, defaultValue = "50000")
128 private long activeHeartbeatMs;
131 * Time, in milliseconds, to wait between heart beat generations during
132 * the active and start-up states.
134 @Property(name = INTER_HEARTBEAT_MS, defaultValue = "15000")
135 private long interHeartbeatMs;
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
145 public PoolingProperties(String controllerName, Properties props) throws PropertyException {
148 new BeanConfigurator().configureFromProperties(this, new SpecProperties(PREFIX, controllerName, props));