Added javadocs for core

This commit is contained in:
Marcin Grzejszczak
2016-03-25 11:58:05 +01:00
parent 2f35d53859
commit 6532753691
5 changed files with 43 additions and 10 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.cloud.zookeeper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.curator.RetryPolicy;
import org.apache.curator.ensemble.EnsembleProvider;
import org.apache.curator.framework.CuratorFramework;
@@ -32,15 +33,18 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration Auto-configuration}
* that sets up Zookeeper discovery.
*
* @author Spencer Gibb
* @since 1.0.0
*/
@Configuration
@ConditionalOnProperty(value = "spring.cloud.zookeeper.enabled", matchIfMissing = true)
@EnableConfigurationProperties
public class ZookeeperAutoConfiguration {
private static final Log log = org.apache.commons.logging.LogFactory
.getLog(ZookeeperAutoConfiguration.class);
private static final Log log = LogFactory.getLog(ZookeeperAutoConfiguration.class);
@Autowired(required = false)
private EnsembleProvider ensembleProvider;
@@ -88,8 +92,8 @@ public class ZookeeperAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public ZookeeperHealthIndicator zookeeperHealthIndicator() {
return new ZookeeperHealthIndicator();
public ZookeeperHealthIndicator zookeeperHealthIndicator(CuratorFramework curator) {
return new ZookeeperHealthIndicator(curator);
}
}
}

View File

@@ -21,7 +21,11 @@ import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* A Zookeeper {@link org.springframework.boot.actuate.endpoint.Endpoint} that returns
* {@link ZookeeperData}.
*
* @author Spencer Gibb
* @since 1.0.0
*/
@ConfigurationProperties(prefix = "endpoints.zookeeper", ignoreUnknownFields = false)
public class ZookeeperEndpoint extends AbstractEndpoint<ZookeeperEndpoint.ZookeeperData> {

View File

@@ -18,16 +18,22 @@ package org.springframework.cloud.zookeeper;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
/**
* A {@link org.springframework.boot.actuate.health.HealthIndicator} that checks the
* status of the Zookeeper connection.
*
* @author Spencer Gibb
* @since 1.0.0
*/
public class ZookeeperHealthIndicator extends AbstractHealthIndicator {
@Autowired
CuratorFramework curator;
private final CuratorFramework curator;
public ZookeeperHealthIndicator(CuratorFramework curator) {
this.curator = curator;
}
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {

View File

@@ -22,33 +22,48 @@ import java.util.concurrent.TimeUnit;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Properties related to connecting to Zookeeper
*
* @author Spencer Gibb
* @since 1.0.0
*/
@ConfigurationProperties("spring.cloud.zookeeper")
public class ZookeeperProperties {
/**
* Connection string to the Zookeeper cluster
*/
@NotNull
private String connectString = "localhost:2181";
/**
* Is Zookeeper enabled
*/
private boolean enabled = true;
/**
* @param baseSleepTimeMs initial amount of time to wait between retries
* Initial amount of time to wait between retries
*/
private Integer baseSleepTimeMs = 50;
/**
* @param maxRetries max number of times to retry
* Max number of times to retry
*/
private Integer maxRetries = 10;
/**
* @param maxSleepMs max time in ms to sleep on each retry
* Max time in ms to sleep on each retry
*/
private Integer maxSleepMs = 500;
/**
* Wait time to block on connection to Zookeeper
*/
private Integer blockUntilConnectedWait = 10;
/**
* The unit of time related to blocking on connection to Zookeeper
*/
private TimeUnit blockUntilConnectedUnit = TimeUnit.SECONDS;
public String getConnectString() {

View File

@@ -15,6 +15,10 @@
<relativePath>..</relativePath>
</parent>
<properties>
<sonar.skip>true</sonar.skip>
</properties>
<build>
<plugins>
<plugin>