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
048    public ZooKeeperServiceCallServiceDiscoveryConfiguration() {
049        this(null);
050    }
051
052    public ZooKeeperServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) {
053        super(parent, "zookeeper-service-discovery");
054    }
055
056    // *************************************************************************
057    // Getter/Setter
058    // *************************************************************************
059
060    public String getNodes() {
061        return nodes;
062    }
063
064    /**
065     * A comma separate list of servers to connect to in the form host:port
066     */
067    public void setNodes(String nodes) {
068        this.nodes = nodes;
069    }
070
071    public String getNamespace() {
072        return namespace;
073    }
074
075    /**
076     * As ZooKeeper is a shared space, users of a given cluster should stay within
077     * a pre-defined namespace. If a namespace is set here, all paths will get pre-pended
078     * with the namespace
079     */
080    public void setNamespace(String namespace) {
081        this.namespace = namespace;
082    }
083
084    public String getReconnectBaseSleepTime() {
085        return reconnectBaseSleepTime;
086    }
087
088    /**
089     * Initial amount of time to wait between retries.
090     */
091    public void setReconnectBaseSleepTime(String reconnectBaseSleepTime) {
092        this.reconnectBaseSleepTime = reconnectBaseSleepTime;
093    }
094
095    public String getReconnectMaxSleepTime() {
096        return reconnectMaxSleepTime;
097    }
098
099    /**
100     * Max time in ms to sleep on each retry
101     */
102    public void setReconnectMaxSleepTime(String reconnectMaxSleepTime) {
103        this.reconnectMaxSleepTime = reconnectMaxSleepTime;
104    }
105
106    public Integer getReconnectMaxRetries() {
107        return reconnectMaxRetries;
108    }
109
110    /**
111     * Max number of times to retry
112     */
113    public void setReconnectMaxRetries(Integer reconnectMaxRetries) {
114        this.reconnectMaxRetries = reconnectMaxRetries;
115    }
116
117    public String getSessionTimeout() {
118        return sessionTimeout;
119    }
120
121    /**
122     * Session timeout.
123     */
124    public void setSessionTimeout(String sessionTimeout) {
125        this.sessionTimeout = sessionTimeout;
126    }
127
128    public String getConnectionTimeout() {
129        return connectionTimeout;
130    }
131
132    /**
133     * Connection timeout.
134     */
135    public void setConnectionTimeout(String connectionTimeout) {
136        this.connectionTimeout = connectionTimeout;
137    }
138
139    public String getBasePath() {
140        return basePath;
141    }
142
143    /**
144     * Set the base path to store in ZK
145     */
146    public void setBasePath(String basePath) {
147        this.basePath = basePath;
148    }
149
150    // *************************************************************************
151    // Fluent API
152    // *************************************************************************
153
154    public ZooKeeperServiceCallServiceDiscoveryConfiguration nodes(String nodes) {
155        setNodes(nodes);
156        return this;
157    }
158
159    public ZooKeeperServiceCallServiceDiscoveryConfiguration namespace(String namespace) {
160        setNamespace(namespace);
161        return this;
162    }
163
164    public ZooKeeperServiceCallServiceDiscoveryConfiguration reconnectBaseSleepTime(String reconnectBaseSleepTime) {
165        setReconnectBaseSleepTime(reconnectBaseSleepTime);
166        return this;
167    }
168
169    public ZooKeeperServiceCallServiceDiscoveryConfiguration reconnectMaxSleepTime(String reconnectMaxSleepTime) {
170        setReconnectMaxSleepTime(reconnectMaxSleepTime);
171        return this;
172    }
173
174    public ZooKeeperServiceCallServiceDiscoveryConfiguration reconnectMaxRetries(int reconnectMaxRetries) {
175        setReconnectMaxRetries(reconnectMaxRetries);
176        return this;
177    }
178
179    public ZooKeeperServiceCallServiceDiscoveryConfiguration sessionTimeout(String sessionTimeout) {
180        setSessionTimeout(sessionTimeout);
181        return this;
182    }
183
184    public ZooKeeperServiceCallServiceDiscoveryConfiguration connectionTimeout(String connectionTimeout) {
185        setConnectionTimeout(connectionTimeout);
186        return this;
187    }
188
189    public ZooKeeperServiceCallServiceDiscoveryConfiguration basePath(String basePath) {
190        setBasePath(basePath);
191        return this;
192    }
193}