ac936d43668b3976e9d557a42286a1019dd2a9f9
[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
25 /**
26  * Bean class for Curator locking parameters.
27  *
28  * @author Liam Fallon (liam.fallon@ericsson.com)
29  */
30 public class CuratorLockManagerParameters extends LockManagerParameters {
31     // @formatter:off
32     /** The default address used to connect to the Zookeeper server. */
33     public static final String DEFAULT_ZOOKEEPER_ADDRESS            = "localhost:2181";
34
35     /** The default sleep time to use when connecting to the Zookeeper server. */
36     public static final int DEFAULT_ZOOKEEPER_CONNECT_SLEEP_TIME = 1000;
37
38     /** The default number of times to retry failed connections to the Zookeeper server. */
39     public static final int DEFAULT_ZOOKEEPER_CONNECT_RETRIES = 3;
40
41     // Curator parameters
42     private String zookeeperAddress       = DEFAULT_ZOOKEEPER_ADDRESS;
43     private int zookeeperConnectSleepTime = DEFAULT_ZOOKEEPER_CONNECT_SLEEP_TIME;
44     private int zookeeperContextRetries   = DEFAULT_ZOOKEEPER_CONNECT_RETRIES;
45     // @formatter:on
46
47     /**
48      * The Constructor.
49      */
50     public CuratorLockManagerParameters() {
51         super();
52     }
53
54     /**
55      * Gets the zookeeper address.
56      *
57      * @return the zookeeper address
58      */
59     public String getZookeeperAddress() {
60         return zookeeperAddress;
61     }
62
63     /**
64      * Sets the zookeeper address.
65      *
66      * @param zookeeperAddress the zookeeper address
67      */
68     public void setZookeeperAddress(final String zookeeperAddress) {
69         this.zookeeperAddress = zookeeperAddress;
70     }
71
72     /**
73      * Gets the zookeeper connect sleep time.
74      *
75      * @return the zookeeper connect sleep time
76      */
77     public int getZookeeperConnectSleepTime() {
78         return zookeeperConnectSleepTime;
79     }
80
81     /**
82      * Sets the zookeeper connect sleep time.
83      *
84      * @param zookeeperConnectSleepTime the zookeeper connect sleep time
85      */
86     public void setZookeeperConnectSleepTime(final int zookeeperConnectSleepTime) {
87         this.zookeeperConnectSleepTime = zookeeperConnectSleepTime;
88     }
89
90     /**
91      * Gets the zookeeper context retries.
92      *
93      * @return the zookeeper context retries
94      */
95     public int getZookeeperContextRetries() {
96         return zookeeperContextRetries;
97     }
98
99     /**
100      * Sets the zookeeper context retries.
101      *
102      * @param zookeeperContextRetries the zookeeper context retries
103      */
104     public void setZookeeperContextRetries(final int zookeeperContextRetries) {
105         this.zookeeperContextRetries = zookeeperContextRetries;
106     }
107
108     /*
109      * (non-Javadoc)
110      *
111      * @see org.onap.policy.apex.context.parameters.LockManagerParameters#toString()
112      */
113     @Override
114     public String toString() {
115         return "CuratorLockManagerParameters [zookeeperAddress=" + zookeeperAddress + ", zookeeperConnectSleepTime="
116                 + zookeeperConnectSleepTime + ", zookeeperContextRetries=" + zookeeperContextRetries + "]";
117     }
118 }