001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.model.cloud;
018
019import javax.xml.bind.annotation.XmlAccessType;
020import javax.xml.bind.annotation.XmlAccessorType;
021import javax.xml.bind.annotation.XmlAttribute;
022import javax.xml.bind.annotation.XmlRootElement;
023
024import org.apache.camel.spi.Metadata;
025
026@Metadata(label = "routing,cloud,service-discovery")
027@XmlRootElement(name = "zookeeperServiceDiscovery")
028@XmlAccessorType(XmlAccessType.FIELD)
029public class ZooKeeperServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration {
030    @XmlAttribute(required = true)
031    private String nodes;
032    @XmlAttribute
033    private String namespace;
034    @XmlAttribute
035    private String reconnectBaseSleepTime;
036    @XmlAttribute
037    private String reconnectMaxSleepTime;
038    @XmlAttribute
039    private Integer reconnectMaxRetries;
040    @XmlAttribute
041    private String sessionTimeout;
042    @XmlAttribute
043    private String connectionTimeout;
044    @XmlAttribute(required = true)
045    private String basePath;
046
047    public ZooKeeperServiceCallServiceDiscoveryConfiguration() {
048        this(null);
049    }
050
051    public ZooKeeperServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) {
052        super(parent, "zookeeper-service-discovery");
053    }
054
055    // *************************************************************************
056    // Getter/Setter
057    // *************************************************************************
058
059    public String getNodes() {
060        return nodes;
061    }
062
063    /**
064     * A comma separate list of servers to connect to in the form host:port
065     */
066    public void setNodes(String nodes) {
067        this.nodes = nodes;
068    }
069
070    public String getNamespace() {
071        return namespace;
072    }
073
074    /**
075     * As ZooKeeper is a shared space, users of a given cluster should stay
076     * within a pre-defined namespace. If a namespace is set here, all paths
077     * will get pre-pended with the namespace
078     */
079    public void setNamespace(String namespace) {
080        this.namespace = namespace;
081    }
082
083    public String getReconnectBaseSleepTime() {
084        return reconnectBaseSleepTime;
085    }
086
087    /**
088     * Initial amount of time to wait between retries.
089     */
090    public void setReconnectBaseSleepTime(String reconnectBaseSleepTime) {
091        this.reconnectBaseSleepTime = reconnectBaseSleepTime;
092    }
093
094    public String getReconnectMaxSleepTime() {
095        return reconnectMaxSleepTime;
096    }
097
098    /**
099     * Max time in ms to sleep on each retry
100     */
101    public void setReconnectMaxSleepTime(String reconnectMaxSleepTime) {
102        this.reconnectMaxSleepTime = reconnectMaxSleepTime;
103    }
104
105    public Integer getReconnectMaxRetries() {
106        return reconnectMaxRetries;
107    }
108
109    /**
110     * Max number of times to retry
111     */
112    public void setReconnectMaxRetries(Integer reconnectMaxRetries) {
113        this.reconnectMaxRetries = reconnectMaxRetries;
114    }
115
116    public String getSessionTimeout() {
117        return sessionTimeout;
118    }
119
120    /**
121     * Session timeout.
122     */
123    public void setSessionTimeout(String sessionTimeout) {
124        this.sessionTimeout = sessionTimeout;
125    }
126
127    public String getConnectionTimeout() {
128        return connectionTimeout;
129    }
130
131    /**
132     * Connection timeout.
133     */
134    public void setConnectionTimeout(String connectionTimeout) {
135        this.connectionTimeout = connectionTimeout;
136    }
137
138    public String getBasePath() {
139        return basePath;
140    }
141
142    /**
143     * Set the base path to store in ZK
144     */
145    public void setBasePath(String basePath) {
146        this.basePath = basePath;
147    }
148
149    // *************************************************************************
150    // Fluent API
151    // *************************************************************************
152
153    public ZooKeeperServiceCallServiceDiscoveryConfiguration nodes(String nodes) {
154        setNodes(nodes);
155        return this;
156    }
157
158    public ZooKeeperServiceCallServiceDiscoveryConfiguration namespace(String namespace) {
159        setNamespace(namespace);
160        return this;
161    }
162
163    public ZooKeeperServiceCallServiceDiscoveryConfiguration reconnectBaseSleepTime(String reconnectBaseSleepTime) {
164        setReconnectBaseSleepTime(reconnectBaseSleepTime);
165        return this;
166    }
167
168    public ZooKeeperServiceCallServiceDiscoveryConfiguration reconnectMaxSleepTime(String reconnectMaxSleepTime) {
169        setReconnectMaxSleepTime(reconnectMaxSleepTime);
170        return this;
171    }
172
173    public ZooKeeperServiceCallServiceDiscoveryConfiguration reconnectMaxRetries(int reconnectMaxRetries) {
174        setReconnectMaxRetries(reconnectMaxRetries);
175        return this;
176    }
177
178    public ZooKeeperServiceCallServiceDiscoveryConfiguration sessionTimeout(String sessionTimeout) {
179        setSessionTimeout(sessionTimeout);
180        return this;
181    }
182
183    public ZooKeeperServiceCallServiceDiscoveryConfiguration connectionTimeout(String connectionTimeout) {
184        setConnectionTimeout(connectionTimeout);
185        return this;
186    }
187
188    public ZooKeeperServiceCallServiceDiscoveryConfiguration basePath(String basePath) {
189        setBasePath(basePath);
190        return this;
191    }
192}