2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.drools.pooling;
23 import java.util.Properties;
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;
32 * Properties used by the pooling feature, specific to a controller.
36 public class PoolingProperties {
39 * The feature name, used to retrieve properties.
41 public static final String FEATURE_NAME = "feature-pooling-dmaap";
44 * Feature properties all begin with this prefix.
46 public static final String PREFIX = "pooling.";
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";
60 * Type of item that the extractors will be extracting.
62 public static final String EXTRACTOR_TYPE = "requestId";
65 * Prefix for extractor properties.
67 public static final String PROP_EXTRACTOR_PREFIX = "extractor." + EXTRACTOR_TYPE;
70 * Properties from which this was constructed.
72 private Properties source;
75 * Topic used for inter-host communication.
77 @Property(name = POOLING_TOPIC)
78 private String poolingTopic;
81 * Maximum number of events to retain in the queue while waiting for
82 * buckets to be assigned.
84 @Property(name = OFFLINE_LIMIT, defaultValue = "1000")
85 private int offlineLimit;
88 * Maximum age, in milliseconds, of events to be retained in the queue.
89 * Events older than this are discarded.
91 @Property(name = OFFLINE_AGE_MS, defaultValue = "60000")
92 private long offlineAgeMs;
95 * Time, in milliseconds, to wait for an "Offline" message to be published
98 @Property(name = OFFLINE_PUB_WAIT_MS, defaultValue = "3000")
99 private long offlinePubWaitMs;
102 * Time, in milliseconds, to wait for this host's heart beat during the
105 @Property(name = START_HEARTBEAT_MS, defaultValue = "100000")
106 private long startHeartbeatMs;
109 * Time, in milliseconds, to wait before attempting to re-active this
110 * host when it has no bucket assignments.
112 @Property(name = REACTIVATE_MS, defaultValue = "50000")
113 private long reactivateMs;
116 * Time, in milliseconds, to wait for all Identification messages to
117 * arrive during the query state.
119 @Property(name = IDENTIFICATION_MS, defaultValue = "50000")
120 private long identificationMs;
123 * Time, in milliseconds, to wait for heart beats from this host, or its
124 * predecessor, during the active state.
126 @Property(name = ACTIVE_HEARTBEAT_MS, defaultValue = "50000")
127 private long activeHeartbeatMs;
130 * Time, in milliseconds, to wait between heart beat generations during
131 * the active and start-up states.
133 @Property(name = INTER_HEARTBEAT_MS, defaultValue = "15000")
134 private long interHeartbeatMs;
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
144 public PoolingProperties(String controllerName, Properties props) throws PropertyException {
147 new BeanConfigurator().configureFromProperties(this, new SpecProperties(PREFIX, controllerName, props));