9e8d5d2afa8e1e23329b5c8852db8b7dea43f8a5
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.plugins.context.locking.curator;
22
23 import org.onap.policy.apex.context.parameters.LockManagerParameters;
24 import org.onap.policy.apex.model.basicmodel.service.ParameterService;
25
26 /**
27  * Bean class for Curator locking parameters.
28  *
29  * @author Liam Fallon (liam.fallon@ericsson.com)
30  */
31 public class CuratorLockManagerParameters extends LockManagerParameters {
32     // @formatter:off
33     /** The default address used to connect to the Zookeeper server. */
34     public static final String DEFAULT_ZOOKEEPER_ADDRESS            = "localhost:2181";
35
36     /** The default sleep time to use when connecting to the Zookeeper server. */
37     public static final int DEFAULT_ZOOKEEPER_CONNECT_SLEEP_TIME = 1000;
38
39     /** The default number of times to retry failed connections to the Zookeeper server. */
40     public static final int DEFAULT_ZOOKEEPER_CONNECT_RETRIES = 3;
41
42     // Curator parameters
43     private String zookeeperAddress       = DEFAULT_ZOOKEEPER_ADDRESS;
44     private int zookeeperConnectSleepTime = DEFAULT_ZOOKEEPER_CONNECT_SLEEP_TIME;
45     private int zookeeperContextRetries   = DEFAULT_ZOOKEEPER_CONNECT_RETRIES;
46     // @formatter:on
47
48     /**
49      * The Constructor.
50      */
51     public CuratorLockManagerParameters() {
52         super(CuratorLockManagerParameters.class.getCanonicalName());
53         ParameterService.registerParameters(CuratorLockManagerParameters.class, this);
54     }
55
56     /**
57      * Gets the zookeeper address.
58      *
59      * @return the zookeeper address
60      */
61     public String getZookeeperAddress() {
62         return zookeeperAddress;
63     }
64
65     /**
66      * Sets the zookeeper address.
67      *
68      * @param zookeeperAddress the zookeeper address
69      */
70     public void setZookeeperAddress(final String zookeeperAddress) {
71         this.zookeeperAddress = zookeeperAddress;
72     }
73
74     /**
75      * Gets the zookeeper connect sleep time.
76      *
77      * @return the zookeeper connect sleep time
78      */
79     public int getZookeeperConnectSleepTime() {
80         return zookeeperConnectSleepTime;
81     }
82
83     /**
84      * Sets the zookeeper connect sleep time.
85      *
86      * @param zookeeperConnectSleepTime the zookeeper connect sleep time
87      */
88     public void setZookeeperConnectSleepTime(final int zookeeperConnectSleepTime) {
89         this.zookeeperConnectSleepTime = zookeeperConnectSleepTime;
90     }
91
92     /**
93      * Gets the zookeeper context retries.
94      *
95      * @return the zookeeper context retries
96      */
97     public int getZookeeperContextRetries() {
98         return zookeeperContextRetries;
99     }
100
101     /**
102      * Sets the zookeeper context retries.
103      *
104      * @param zookeeperContextRetries the zookeeper context retries
105      */
106     public void setZookeeperContextRetries(final int zookeeperContextRetries) {
107         this.zookeeperContextRetries = zookeeperContextRetries;
108     }
109
110     /*
111      * (non-Javadoc)
112      *
113      * @see org.onap.policy.apex.context.parameters.LockManagerParameters#toString()
114      */
115     @Override
116     public String toString() {
117         return "CuratorLockManagerParameters [zookeeperAddress=" + zookeeperAddress + ", zookeeperConnectSleepTime="
118                 + zookeeperConnectSleepTime + ", zookeeperContextRetries=" + zookeeperContextRetries + "]";
119     }
120 }