Commit e2583f53 by Spencer Gibb

upgrade Ribbon to version 2.0.0.

From 2.0.RC13 fixes gh-216
parent df7abd1b
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<eureka.version>1.1.147</eureka.version> <eureka.version>1.1.147</eureka.version>
<feign.version>7.3.0</feign.version> <feign.version>7.3.0</feign.version>
<hystrix.version>1.4.0</hystrix.version> <hystrix.version>1.4.0</hystrix.version>
<ribbon.version>2.0-RC13</ribbon.version> <ribbon.version>2.0.0</ribbon.version>
<zuul.version>1.0.28</zuul.version> <zuul.version>1.0.28</zuul.version>
<netflix.rxjava.version>0.20.7</netflix.rxjava.version> <netflix.rxjava.version>0.20.7</netflix.rxjava.version>
<java.version>1.7</java.version> <java.version>1.7</java.version>
...@@ -239,6 +239,11 @@ ...@@ -239,6 +239,11 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.netflix.ribbon</groupId>
<artifactId>ribbon-loadbalancer</artifactId>
<version>${ribbon.version}</version>
</dependency>
<dependency>
<groupId>com.netflix.rxjava</groupId> <groupId>com.netflix.rxjava</groupId>
<artifactId>rxjava-core</artifactId> <artifactId>rxjava-core</artifactId>
<version>${netflix.rxjava.version}</version> <version>${netflix.rxjava.version}</version>
......
...@@ -54,6 +54,11 @@ ...@@ -54,6 +54,11 @@
<artifactId>eureka-core</artifactId> <artifactId>eureka-core</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>com.netflix.ribbon</groupId>
<artifactId>ribbon-loadbalancer</artifactId>
<optional>true</optional>
</dependency>
<!-- Eureka core deps that are now optional --> <!-- Eureka core deps that are now optional -->
<dependency> <dependency>
<groupId>com.thoughtworks.xstream</groupId> <groupId>com.thoughtworks.xstream</groupId>
......
...@@ -21,8 +21,6 @@ import java.net.URI; ...@@ -21,8 +21,6 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.List; import java.util.List;
import javax.ws.rs.core.MultivaluedMap;
import com.netflix.client.http.HttpRequest; import com.netflix.client.http.HttpRequest;
import com.netflix.client.http.HttpRequest.Builder; import com.netflix.client.http.HttpRequest.Builder;
import com.netflix.client.http.HttpRequest.Verb; import com.netflix.client.http.HttpRequest.Verb;
...@@ -37,6 +35,7 @@ import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy; ...@@ -37,6 +35,7 @@ import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
import com.netflix.niws.client.http.RestClient; import com.netflix.niws.client.http.RestClient;
import com.netflix.zuul.constants.ZuulConstants; import com.netflix.zuul.constants.ZuulConstants;
import com.netflix.zuul.context.RequestContext; import com.netflix.zuul.context.RequestContext;
import org.springframework.util.MultiValueMap;
/** /**
* Hystrix wrapper around Eureka Ribbon command * Hystrix wrapper around Eureka Ribbon command
...@@ -45,6 +44,7 @@ import com.netflix.zuul.context.RequestContext; ...@@ -45,6 +44,7 @@ import com.netflix.zuul.context.RequestContext;
* https://github.com/Netflix/zuul/blob/master/zuul-netflix/src/main/java/com/ * https://github.com/Netflix/zuul/blob/master/zuul-netflix/src/main/java/com/
* netflix/zuul/dependency/ribbon/hystrix/RibbonCommand.java * netflix/zuul/dependency/ribbon/hystrix/RibbonCommand.java
*/ */
@SuppressWarnings("deprecation")
public class RibbonCommand extends HystrixCommand<HttpResponse> { public class RibbonCommand extends HystrixCommand<HttpResponse> {
private RestClient restClient; private RestClient restClient;
...@@ -55,24 +55,24 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> { ...@@ -55,24 +55,24 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
private Boolean retryable; private Boolean retryable;
private MultivaluedMap<String, String> headers; private MultiValueMap<String, String> headers;
private MultivaluedMap<String, String> params; private MultiValueMap<String, String> params;
private InputStream requestEntity; private InputStream requestEntity;
public RibbonCommand(RestClient restClient, Verb verb, String uri, public RibbonCommand(RestClient restClient, Verb verb, String uri,
Boolean retryable, Boolean retryable,
MultivaluedMap<String, String> headers, MultiValueMap<String, String> headers,
MultivaluedMap<String, String> params, InputStream requestEntity) MultiValueMap<String, String> params, InputStream requestEntity)
throws URISyntaxException { throws URISyntaxException {
this("default", restClient, verb, uri, retryable , headers, params, requestEntity); this("default", restClient, verb, uri, retryable , headers, params, requestEntity);
} }
public RibbonCommand(String commandKey, RestClient restClient, Verb verb, String uri, public RibbonCommand(String commandKey, RestClient restClient, Verb verb, String uri,
Boolean retryable, Boolean retryable,
MultivaluedMap<String, String> headers, MultiValueMap<String, String> headers,
MultivaluedMap<String, String> params, InputStream requestEntity) MultiValueMap<String, String> params, InputStream requestEntity)
throws URISyntaxException { throws URISyntaxException {
super(getSetter(commandKey)); super(getSetter(commandKey));
this.restClient = restClient; this.restClient = restClient;
......
...@@ -20,13 +20,11 @@ import java.io.IOException; ...@@ -20,13 +20,11 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.MultivaluedMap;
import lombok.extern.apachecommons.CommonsLog; import lombok.extern.apachecommons.CommonsLog;
...@@ -43,7 +41,6 @@ import com.netflix.niws.client.http.RestClient; ...@@ -43,7 +41,6 @@ import com.netflix.niws.client.http.RestClient;
import com.netflix.zuul.ZuulFilter; import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext; import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException; import com.netflix.zuul.exception.ZuulException;
import com.sun.jersey.core.util.MultivaluedMapImpl;
@CommonsLog @CommonsLog
public class RibbonRoutingFilter extends ZuulFilter { public class RibbonRoutingFilter extends ZuulFilter {
...@@ -125,7 +122,7 @@ public class RibbonRoutingFilter extends ZuulFilter { ...@@ -125,7 +122,7 @@ public class RibbonRoutingFilter extends ZuulFilter {
Map<String, Object> info = this.helper.debug(verb.verb(), uri, headers, params, Map<String, Object> info = this.helper.debug(verb.verb(), uri, headers, params,
requestEntity); requestEntity);
RibbonCommand command = new RibbonCommand(service, restClient, verb, uri, retryable, RibbonCommand command = new RibbonCommand(service, restClient, verb, uri, retryable,
convertHeaders(headers), convertHeaders(params), requestEntity); headers, params, requestEntity);
try { try {
HttpResponse response = command.execute(); HttpResponse response = command.execute();
this.helper.appendDebug(info, response.getStatus(), this.helper.appendDebug(info, response.getStatus(),
...@@ -150,18 +147,9 @@ public class RibbonRoutingFilter extends ZuulFilter { ...@@ -150,18 +147,9 @@ public class RibbonRoutingFilter extends ZuulFilter {
private MultiValueMap<String, String> revertHeaders( private MultiValueMap<String, String> revertHeaders(
Map<String, Collection<String>> headers) { Map<String, Collection<String>> headers) {
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
for (Entry<String, Collection<String>> entry : headers.entrySet()) { for (Entry<String, Collection<String>> entry : headers.entrySet()) {
map.put(entry.getKey(), new ArrayList<String>(entry.getValue())); map.put(entry.getKey(), new ArrayList<>(entry.getValue()));
}
return map;
}
private MultivaluedMap<String, String> convertHeaders(
MultiValueMap<String, String> headers) {
MultivaluedMap<String, String> map = new MultivaluedMapImpl();
for (Entry<String, List<String>> entry : headers.entrySet()) {
map.put(entry.getKey(), entry.getValue());
} }
return map; return map;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment