39972a7f17b1b443097689940fcd3bc7904a98f3
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2019 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.plugins.context.locking.curator;
23
24 import org.onap.policy.apex.context.parameters.LockManagerParameters;
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();
53     }
54
55     /**
56      * Gets the zookeeper address.
57      *
58      * @return the zookeeper address
59      */
60     public String getZookeeperAddress() {
61         return zookeeperAddress;
62     }
63
64     /**
65      * Sets the zookeeper address.
66      *
67      * @param zookeeperAddress the zookeeper address
68      */
69     public void setZookeeperAddress(final String zookeeperAddress) {
70         this.zookeeperAddress = zookeeperAddress;
71     }
72
73     /**
74      * Gets the zookeeper connect sleep time.
75      *
76      * @return the zookeeper connect sleep time
77      */
78     public int getZookeeperConnectSleepTime() {
79         return zookeeperConnectSleepTime;
80     }
81
82     /**
83      * Sets the zookeeper connect sleep time.
84      *
85      * @param zookeeperConnectSleepTime the zookeeper connect sleep time
86      */
87     public void setZookeeperConnectSleepTime(final int zookeeperConnectSleepTime) {
88         this.zookeeperConnectSleepTime = zookeeperConnectSleepTime;
89     }
90
91     /**
92      * Gets the zookeeper context retries.
93      *
94      * @return the zookeeper context retries
95      */
96     public int getZookeeperContextRetries() {
97         return zookeeperContextRetries;
98     }
99
100     /**
101      * Sets the zookeeper context retries.
102      *
103      * @param zookeeperContextRetries the zookeeper context retries
104      */
105     public void setZookeeperContextRetries(final int zookeeperContextRetries) {
106         this.zookeeperContextRetries = zookeeperContextRetries;
107     }
108
109     /*
110      * (non-Javadoc)
111      *
112      * @see org.onap.policy.apex.context.parameters.LockManagerParameters#toString()
113      */
114     @Override
115     public String toString() {
116         return "CuratorLockManagerParameters [zookeeperAddress=" + zookeeperAddress + ", zookeeperConnectSleepTime="
117                 + zookeeperConnectSleepTime + ", zookeeperContextRetries=" + zookeeperContextRetries + "]";
118     }
119 }