Removes lombok
This commit is contained in:
35
README.adoc
35
README.adoc
@@ -44,7 +44,7 @@ See the https://consul.io/intro/index.html[intro] for more information.
|
||||
|
||||
== Building
|
||||
|
||||
:jdkversion: 1.7
|
||||
:jdkversion: 1.8
|
||||
|
||||
=== Basic Compile and Test
|
||||
|
||||
@@ -133,39 +133,6 @@ The generated eclipse projects can be imported by selecting `import existing pro
|
||||
from the `file` menu.
|
||||
|
||||
|
||||
==== Adding Project Lombok Agent
|
||||
|
||||
Spring Cloud uses http://projectlombok.org/features/index.html[Project Lombok]
|
||||
to generate getters and setters etc. Compiling from the command line this
|
||||
shouldn't cause any problems, but in an IDE you need to add an agent
|
||||
to the JVM. Full instructions can be found in the Lombok website. The
|
||||
sign that you need to do this is a lot of compiler errors to do with
|
||||
missing methods and fields, e.g.
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
The method getInitialStatus() is undefined for the type EurekaInstanceConfigBean EurekaDiscoveryClientConfiguration.java /spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka line 120 Java Problem
|
||||
The method getInitialStatus() is undefined for the type EurekaInstanceConfigBean EurekaDiscoveryClientConfiguration.java /spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka line 121 Java Problem
|
||||
The method setNonSecurePort(int) is undefined for the type EurekaInstanceConfigBean EurekaDiscoveryClientConfiguration.java /spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka line 112 Java Problem
|
||||
The type EurekaInstanceConfigBean.IdentifyingDataCenterInfo must implement the inherited abstract method DataCenterInfo.getName() EurekaInstanceConfigBean.java /spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka line 131 Java Problem
|
||||
The method getId() is undefined for the type ProxyRouteLocator.ProxyRouteSpec PreDecorationFilter.java /spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre line 60 Java Problem
|
||||
The method getLocation() is undefined for the type ProxyRouteLocator.ProxyRouteSpec PreDecorationFilter.java /spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre line 55 Java Problem
|
||||
----
|
||||
|
||||
==== Importing into Intellij
|
||||
Spring Cloud projects use annotation processing, particularly Lombok, which requires configuration
|
||||
or you will encounter compile problems. It also needs a specific version of maven and a profile
|
||||
enabled. Intellij 14.1+ requires some configuration to ensure these are setup properly.
|
||||
|
||||
1. Click Preferences, Plugins. *Ensure Lombok is installed*
|
||||
2. Click New, Project from Existing Sources, choose your spring-cloud project directory
|
||||
3. Choose Maven, and select Environment Settings. *Ensure you are using Maven 3.3.3*
|
||||
4. In the next screen, *Select the profile `spring`* click Next until Finish.
|
||||
5. Click Preferences, "Build, Execution, Deployment", Compiler, Annotation Processors. *Click Enable Annotation Processing*
|
||||
6. Click Build, Rebuild Project, and you are ready to go!
|
||||
|
||||
==== Importing into other IDEs
|
||||
Maven is well supported by most Java IDEs. Refer to you vendor documentation.
|
||||
|
||||
== Contributing
|
||||
|
||||
|
||||
@@ -35,9 +35,7 @@ See the https://consul.io/intro/index.html[intro] for more information.
|
||||
|
||||
== Building
|
||||
|
||||
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building.adoc[]
|
||||
|
||||
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building-lombok.adoc[]
|
||||
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building-jdk8.adoc[]
|
||||
|
||||
== Contributing
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<!-- Only needed at compile time -->
|
||||
<scope>provided</scope>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
|
||||
@@ -16,14 +16,31 @@
|
||||
|
||||
package org.springframework.cloud.consul.binder.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@ConfigurationProperties("spring.cloud.stream.consul.binder")
|
||||
@Data
|
||||
public class ConsulBinderProperties {
|
||||
private int eventTimeout = 5;
|
||||
|
||||
public ConsulBinderProperties() {
|
||||
}
|
||||
|
||||
public int getEventTimeout() {
|
||||
return this.eventTimeout;
|
||||
}
|
||||
|
||||
public void setEventTimeout(int eventTimeout) {
|
||||
this.eventTimeout = eventTimeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("eventTimeout", eventTimeout)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +85,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<!-- Only needed at compile time -->
|
||||
<scope>provided</scope>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -20,9 +20,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.QueryParams;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
@@ -30,7 +27,9 @@ import com.ecwid.consul.v1.agent.model.Service;
|
||||
import com.ecwid.consul.v1.catalog.model.CatalogService;
|
||||
import com.ecwid.consul.v1.catalog.model.Node;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -66,7 +65,6 @@ public class ConsulEndpoint {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ConsulData {
|
||||
Map<String, List<CatalogService>> catalogServices = new LinkedHashMap<>();
|
||||
|
||||
@@ -74,6 +72,40 @@ public class ConsulEndpoint {
|
||||
|
||||
List<Node> catalogNodes;
|
||||
|
||||
// List<KeyValue> keyValues;
|
||||
public ConsulData() {
|
||||
}
|
||||
|
||||
public Map<String, List<CatalogService>> getCatalogServices() {
|
||||
return this.catalogServices;
|
||||
}
|
||||
|
||||
public Map<String, Service> getAgentServices() {
|
||||
return this.agentServices;
|
||||
}
|
||||
|
||||
public List<Node> getCatalogNodes() {
|
||||
return this.catalogNodes;
|
||||
}
|
||||
|
||||
public void setCatalogServices(Map<String, List<CatalogService>> catalogServices) {
|
||||
this.catalogServices = catalogServices;
|
||||
}
|
||||
|
||||
public void setAgentServices(Map<String, Service> agentServices) {
|
||||
this.agentServices = agentServices;
|
||||
}
|
||||
|
||||
public void setCatalogNodes(List<Node> catalogNodes) {
|
||||
this.catalogNodes = catalogNodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("catalogServices", catalogServices)
|
||||
.append("agentServices", agentServices)
|
||||
.append("catalogNodes", catalogNodes)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
package org.springframework.cloud.consul;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@ConfigurationProperties("spring.cloud.consul.retry")
|
||||
@Data
|
||||
public class RetryProperties {
|
||||
|
||||
/** Initial retry interval in milliseconds. */
|
||||
@@ -38,4 +36,49 @@ public class RetryProperties {
|
||||
|
||||
/** Maximum number of attempts. */
|
||||
private int maxAttempts = 6;
|
||||
|
||||
public RetryProperties() {
|
||||
}
|
||||
|
||||
public long getInitialInterval() {
|
||||
return this.initialInterval;
|
||||
}
|
||||
|
||||
public double getMultiplier() {
|
||||
return this.multiplier;
|
||||
}
|
||||
|
||||
public long getMaxInterval() {
|
||||
return this.maxInterval;
|
||||
}
|
||||
|
||||
public int getMaxAttempts() {
|
||||
return this.maxAttempts;
|
||||
}
|
||||
|
||||
public void setInitialInterval(long initialInterval) {
|
||||
this.initialInterval = initialInterval;
|
||||
}
|
||||
|
||||
public void setMultiplier(double multiplier) {
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
public void setMaxInterval(long maxInterval) {
|
||||
this.maxInterval = maxInterval;
|
||||
}
|
||||
|
||||
public void setMaxAttempts(int maxAttempts) {
|
||||
this.maxAttempts = maxAttempts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("initialInterval", initialInterval)
|
||||
.append("multiplier", multiplier)
|
||||
.append("maxInterval", maxInterval)
|
||||
.append("maxAttempts", maxAttempts)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<!-- Only needed at compile time -->
|
||||
<scope>provided</scope>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -27,7 +27,8 @@ import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.QueryParams;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
@@ -39,8 +40,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@Slf4j
|
||||
public class ConsulCatalogWatch implements ApplicationEventPublisherAware, SmartLifecycle {
|
||||
private static final Log log = LogFactory.getLog(ConsulDiscoveryClient.class);
|
||||
|
||||
private final ConsulDiscoveryProperties properties;
|
||||
private final ConsulClient consul;
|
||||
@@ -123,8 +124,10 @@ public class ConsulCatalogWatch implements ApplicationEventPublisherAware, Smart
|
||||
catalogServicesIndex.set(BigInteger.valueOf(consulIndex));
|
||||
}
|
||||
|
||||
log.trace("Received services update from consul: {}, index: {}",
|
||||
response.getValue(), consulIndex);
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Received services update from consul: "+response.getValue()
|
||||
+", index: "+ consulIndex);
|
||||
}
|
||||
publisher.publishEvent(new HeartbeatEvent(this, consulIndex));
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -20,28 +20,29 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.QueryParams;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
import com.ecwid.consul.v1.health.model.HealthService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.QueryParams;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
import com.ecwid.consul.v1.health.model.HealthService;
|
||||
|
||||
import static org.springframework.cloud.consul.discovery.ConsulServerUtils.findHost;
|
||||
import static org.springframework.cloud.consul.discovery.ConsulServerUtils.getMetadata;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
* @author Joe Athman
|
||||
*/
|
||||
@CommonsLog
|
||||
public class ConsulDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ConsulDiscoveryClient.class);
|
||||
|
||||
@Deprecated
|
||||
public interface LocalResolver {
|
||||
String getInstanceId();
|
||||
|
||||
@@ -25,18 +25,19 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecwid.consul.v1.health.model.HealthService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
* @author Semenkov Alexey
|
||||
*/
|
||||
@CommonsLog
|
||||
public class ConsulServerUtils {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ConsulServerUtils.class);
|
||||
|
||||
public static String findHost(HealthService healthService) {
|
||||
HealthService.Service service = healthService.getService();
|
||||
HealthService.Node node = healthService.getNode();
|
||||
|
||||
@@ -21,15 +21,16 @@ import java.util.List;
|
||||
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import com.netflix.loadbalancer.ServerListFilter;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* ServerList implementaion that filters ConsulServers based on if all their Health Checks are PASSING.
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@CommonsLog
|
||||
public class HealthServiceServerListFilter implements ServerListFilter<Server> {
|
||||
private static final Log log = LogFactory.getLog(HealthServiceServerListFilter.class);
|
||||
|
||||
@Override
|
||||
public List<Server> getFilteredListOfServers(List<Server> servers) {
|
||||
List<Server> filtered = new ArrayList<>();
|
||||
@@ -43,7 +44,9 @@ public class HealthServiceServerListFilter implements ServerListFilter<Server> {
|
||||
}
|
||||
|
||||
} else {
|
||||
log.debug("Unable to determine aliveness of server type "+server.getClass()+", "+server);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unable to determine aliveness of server type " + server.getClass() + ", " + server);
|
||||
}
|
||||
filtered.add(server);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,25 +16,23 @@
|
||||
|
||||
package org.springframework.cloud.consul.discovery;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.validation.constraints.DecimalMax;
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.joda.time.Period;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ConfigurationProperties(prefix = "spring.cloud.consul.discovery.heartbeat")
|
||||
@Data
|
||||
@CommonsLog
|
||||
@Validated
|
||||
public class HeartbeatProperties {
|
||||
|
||||
private static final Log log = org.apache.commons.logging.LogFactory.getLog(HeartbeatProperties.class);
|
||||
// TODO: change enabled to default to true when I stop seeing messages like
|
||||
// [WARN] agent: Check 'service:testConsulApp:xtest:8080' missed TTL, is now critical
|
||||
boolean enabled = false;
|
||||
@@ -66,4 +64,46 @@ public class HeartbeatProperties {
|
||||
public String getTtl() {
|
||||
return ttlValue + ttlUnit;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public @Min(1) int getTtlValue() {
|
||||
return this.ttlValue;
|
||||
}
|
||||
|
||||
public @NotNull String getTtlUnit() {
|
||||
return this.ttlUnit;
|
||||
}
|
||||
|
||||
public @DecimalMin("0.1") @DecimalMax("0.9") double getIntervalRatio() {
|
||||
return this.intervalRatio;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setTtlValue(@Min(1) int ttlValue) {
|
||||
this.ttlValue = ttlValue;
|
||||
}
|
||||
|
||||
public void setTtlUnit(@NotNull String ttlUnit) {
|
||||
this.ttlUnit = ttlUnit;
|
||||
}
|
||||
|
||||
public void setIntervalRatio(@DecimalMin("0.1") @DecimalMax("0.9") double intervalRatio) {
|
||||
this.intervalRatio = intervalRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("enabled", enabled)
|
||||
.append("ttlValue", ttlValue)
|
||||
.append("ttlUnit", ttlUnit)
|
||||
.append("intervalRatio", intervalRatio)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,20 +21,20 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.agent.model.NewService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
|
||||
|
||||
/**
|
||||
* Created by nicu on 11.03.2015.
|
||||
* @author Stéphane LEROY
|
||||
*/
|
||||
@Slf4j
|
||||
public class TtlScheduler {
|
||||
private static final Log log = LogFactory.getLog(ConsulDiscoveryClient.class);
|
||||
|
||||
private final Map<String, ScheduledFuture> serviceHeartbeats = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -89,7 +89,9 @@ public class TtlScheduler {
|
||||
@Override
|
||||
public void run() {
|
||||
client.agentCheckPass(checkId);
|
||||
log.debug("Sending consul heartbeat for: " + checkId);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Sending consul heartbeat for: " + checkId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user