Aggregate discovery support choosing registry center
This commit is contained in:
@@ -57,6 +57,7 @@ import we.fizz.input.ScriptHelper;
|
|||||||
import we.flume.clients.log4j2appender.LogService;
|
import we.flume.clients.log4j2appender.LogService;
|
||||||
import we.proxy.FizzWebClient;
|
import we.proxy.FizzWebClient;
|
||||||
import we.proxy.http.HttpInstanceService;
|
import we.proxy.http.HttpInstanceService;
|
||||||
|
import we.util.Consts;
|
||||||
import we.util.JacksonUtils;
|
import we.util.JacksonUtils;
|
||||||
import we.util.MapUtil;
|
import we.util.MapUtil;
|
||||||
import we.util.TypeUtils;
|
import we.util.TypeUtils;
|
||||||
@@ -89,7 +90,8 @@ public class RequestInput extends RPCInput implements IInput{
|
|||||||
private static final String CONTENT_TYPE_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
private static final String CONTENT_TYPE_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
||||||
|
|
||||||
private static final String CONTENT_TYPE = "content-type";
|
private static final String CONTENT_TYPE = "content-type";
|
||||||
|
|
||||||
|
private static final Integer SERVICE_TYPE_DISCOVERY = 1;
|
||||||
private static final Integer SERVICE_TYPE_HTTP = 2;
|
private static final Integer SERVICE_TYPE_HTTP = 2;
|
||||||
|
|
||||||
private String respContentType;
|
private String respContentType;
|
||||||
@@ -198,6 +200,7 @@ public class RequestInput extends RPCInput implements IInput{
|
|||||||
|
|
||||||
if (config.isNewVersion()) {
|
if (config.isNewVersion()) {
|
||||||
String host = config.getServiceName();
|
String host = config.getServiceName();
|
||||||
|
|
||||||
if (SERVICE_TYPE_HTTP.equals(config.getServiceType().intValue())) {
|
if (SERVICE_TYPE_HTTP.equals(config.getServiceType().intValue())) {
|
||||||
HttpInstanceService httpInstanceService = this.getCurrentApplicationContext()
|
HttpInstanceService httpInstanceService = this.getCurrentApplicationContext()
|
||||||
.getBean(HttpInstanceService.class);
|
.getBean(HttpInstanceService.class);
|
||||||
@@ -205,6 +208,11 @@ public class RequestInput extends RPCInput implements IInput{
|
|||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
host = instance;
|
host = instance;
|
||||||
}
|
}
|
||||||
|
} else if (SERVICE_TYPE_DISCOVERY.equals(config.getServiceType())) {
|
||||||
|
if (StringUtils.isNotBlank(config.getRegistryName())) {
|
||||||
|
// support choosing registry center
|
||||||
|
host = config.getRegistryName() + Consts.S.COMMA + host;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append(config.getProtocol()).append("://").append(host)
|
sb.append(config.getProtocol()).append("://").append(host)
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public class RequestInputConfig extends InputConfig {
|
|||||||
* retry interval in millisecond
|
* retry interval in millisecond
|
||||||
*/
|
*/
|
||||||
private long retryInterval;
|
private long retryInterval;
|
||||||
|
|
||||||
|
private String registryName;
|
||||||
|
|
||||||
public RequestInputConfig(Map configBody) {
|
public RequestInputConfig(Map configBody) {
|
||||||
super(configBody);
|
super(configBody);
|
||||||
@@ -61,6 +63,7 @@ public class RequestInputConfig extends InputConfig {
|
|||||||
serviceType = Integer.valueOf(configBody.get("serviceType").toString());
|
serviceType = Integer.valueOf(configBody.get("serviceType").toString());
|
||||||
protocol = ((String) configBody.get("protocol")).toLowerCase();
|
protocol = ((String) configBody.get("protocol")).toLowerCase();
|
||||||
serviceName = (String) configBody.get("serviceName");
|
serviceName = (String) configBody.get("serviceName");
|
||||||
|
registryName = (String)configBody.get("registryName");
|
||||||
path = (String) configBody.get("path");
|
path = (String) configBody.get("path");
|
||||||
} else {
|
} else {
|
||||||
String url = (String) configBody.get("url");
|
String url = (String) configBody.get("url");
|
||||||
@@ -211,4 +214,12 @@ public class RequestInputConfig extends InputConfig {
|
|||||||
public void setRetryInterval(long retryInterval) {
|
public void setRetryInterval(long retryInterval) {
|
||||||
this.retryInterval = retryInterval;
|
this.retryInterval = retryInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRegistryName() {
|
||||||
|
return registryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegistryName(String registryName) {
|
||||||
|
this.registryName = registryName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user