summaryrefslogtreecommitdiffstats
path: root/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
blob: 4e8de0d0901fd8fbeb9cdb07a5557699db3a20a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
 * ============LICENSE_START=======================================================
 * ONAP
 * ================================================================================
 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.drools.pooling;

import java.util.Properties;
import org.onap.policy.common.utils.properties.SpecPropertyConfiguration;
import org.onap.policy.common.utils.properties.exception.PropertyException;

/**
 * Properties used by the pooling feature, specific to a controller.
 */
public class PoolingProperties extends SpecPropertyConfiguration {

    /**
     * The feature name, used to retrieve properties.
     */
    public static final String FEATURE_NAME = "feature-pooling-dmaap";

    /**
     * Feature properties all begin with this prefix.
     */
    public static final String PREFIX = "pooling.";

    /*
     * These properties REQUIRE a controller name, thus they use the "{$}" form.
     */
    public static final String POOLING_TOPIC = PREFIX + "{$}.topic";

    /*
     * These properties allow the controller name to be left out, thus they use
     * the "{prefix?suffix}" form.
     */
    public static final String FEATURE_ENABLED = PREFIX + "{?.}enabled";
    public static final String OFFLINE_LIMIT = PREFIX + "{?.}offline.queue.limit";
    public static final String OFFLINE_AGE_MS = PREFIX + "{?.}offline.queue.age.milliseconds";
    public static final String START_HEARTBEAT_MS = PREFIX + "{?.}start.heartbeat.milliseconds";
    public static final String REACTIVATE_MS = PREFIX + "{?.}reactivate.milliseconds";
    public static final String IDENTIFICATION_MS = PREFIX + "{?.}identification.milliseconds";
    public static final String ACTIVE_HEARTBEAT_MS = PREFIX + "{?.}active.heartbeat.milliseconds";
    public static final String INTER_HEARTBEAT_MS = PREFIX + "{?.}inter.heartbeat.milliseconds";
    public static final String OFFLINE_PUB_WAIT_MS = PREFIX + "{?.}offline.publish.wait.milliseconds";

    /**
     * Type of item that the extractors will be extracting.
     */
    public static final String EXTRACTOR_TYPE = "requestId";

    /**
     * Prefix for extractor properties.
     */
    public static final String PROP_EXTRACTOR_PREFIX = "extractor." + EXTRACTOR_TYPE;

    /**
     * Properties from which this was constructed.
     */
    private Properties source;

    /**
     * Topic used for inter-host communication.
     */
    @Property(name = POOLING_TOPIC)
    private String poolingTopic;

    /**
     * Maximum number of events to retain in the queue while waiting for
     * buckets to be assigned.
     */
    @Property(name = OFFLINE_LIMIT, defaultValue = "1000")
    private int offlineLimit;

    /**
     * Maximum age, in milliseconds, of events to be retained in the queue.
     * Events older than this are discarded.
     */
    @Property(name = OFFLINE_AGE_MS, defaultValue = "60000")
    private long offlineAgeMs;

    /**
     * Time, in milliseconds, to wait for this host's heart beat during the
     * start-up state.
     */
    @Property(name = START_HEARTBEAT_MS, defaultValue = "50000")
    private long startHeartbeatMs;

    /**
     * Time, in milliseconds, to wait before attempting to re-active this
     * host when it has no bucket assignments.
     */
    @Property(name = REACTIVATE_MS, defaultValue = "50000")
    private long reactivateMs;

    /**
     * Time, in milliseconds, to wait for all Identification messages to
     * arrive during the query state.
     */
    @Property(name = IDENTIFICATION_MS, defaultValue = "50000")
    private long identificationMs;

    /**
     * Time, in milliseconds, to wait for heart beats from this host, or its
     * predecessor, during the active state.
     */
    @Property(name = ACTIVE_HEARTBEAT_MS, defaultValue = "50000")
    private long activeHeartbeatMs;

    /**
     * Time, in milliseconds, to wait between heart beat generations during
     * the active state.
     */
    @Property(name = INTER_HEARTBEAT_MS, defaultValue = "15000")
    private long interHeartbeatMs;

    /**
     * Time, in milliseconds, to wait for an "Offline" message to be published
     * to DMaaP.
     */
    @Property(name = OFFLINE_PUB_WAIT_MS, defaultValue = "3000")
    private long offlinePubWaitMs;

    /**
     * @param controllerName the name of the controller
     * @param props set of properties used to configure this
     * @throws PropertyException if an error occurs
     * 
     */
    public PoolingProperties(String controllerName, Properties props) throws PropertyException {
        super(controllerName, props);

        source = props;
    }

    public Properties getSource() {
        return source;
    }

    public String getPoolingTopic() {
        return poolingTopic;
    }

    public int getOfflineLimit() {
        return offlineLimit;
    }

    public long getOfflineAgeMs() {
        return offlineAgeMs;
    }

    public long getStartHeartbeatMs() {
        return startHeartbeatMs;
    }

    public long getReactivateMs() {
        return reactivateMs;
    }

    public long getIdentificationMs() {
        return identificationMs;
    }

    public long getActiveHeartbeatMs() {
        return activeHeartbeatMs;
    }

    public long getInterHeartbeatMs() {
        return interHeartbeatMs;
    }

    public long getOfflinePubWaitMs() {
        return offlinePubWaitMs;
    }
}