mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Polish alibaba/spring-cloud-alibaba#1363 : Sync spring-cloud-alibaba-sentinel-datasource module
This commit is contained in:
parent
1d9c1975b2
commit
d11f2a0608
@ -17,6 +17,7 @@
|
||||
package com.alibaba.cloud.sentinel.datasource.config;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ConsulDataSourceFactoryBean;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@ -27,71 +28,70 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ConsulDataSourceProperties extends AbstractDataSourceProperties {
|
||||
|
||||
public ConsulDataSourceProperties(){
|
||||
super(ConsulDataSourceFactoryBean.class.getName());
|
||||
}
|
||||
public ConsulDataSourceProperties() {
|
||||
super(ConsulDataSourceFactoryBean.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* consul server host.
|
||||
*/
|
||||
private String host;
|
||||
/**
|
||||
* consul server host.
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* consul server port.
|
||||
*/
|
||||
private int port=8500;
|
||||
/**
|
||||
* consul server port.
|
||||
*/
|
||||
private int port = 8500;
|
||||
|
||||
/**
|
||||
* data key in Redis.
|
||||
*/
|
||||
private String ruleKey;
|
||||
/**
|
||||
* data key in Redis.
|
||||
*/
|
||||
private String ruleKey;
|
||||
|
||||
/**
|
||||
* Request of query will hang until timeout (in second) or get updated value.
|
||||
*/
|
||||
private int waitTimeoutInSecond = 1;
|
||||
/**
|
||||
* Request of query will hang until timeout (in second) or get updated value.
|
||||
*/
|
||||
private int waitTimeoutInSecond = 1;
|
||||
|
||||
@Override
|
||||
public void preCheck(String dataSourceName) {
|
||||
if(StringUtils.isEmpty(host)){
|
||||
throw new IllegalArgumentException(
|
||||
"ConsulDataSource server-host is empty");
|
||||
}
|
||||
if(StringUtils.isEmpty(ruleKey)){
|
||||
throw new IllegalArgumentException(
|
||||
"ConsulDataSource ruleKey can not be empty");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void preCheck(String dataSourceName) {
|
||||
if (StringUtils.isEmpty(host)) {
|
||||
throw new IllegalArgumentException("ConsulDataSource server-host is empty");
|
||||
}
|
||||
if (StringUtils.isEmpty(ruleKey)) {
|
||||
throw new IllegalArgumentException(
|
||||
"ConsulDataSource ruleKey can not be empty");
|
||||
}
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getRuleKey() {
|
||||
return ruleKey;
|
||||
}
|
||||
public String getRuleKey() {
|
||||
return ruleKey;
|
||||
}
|
||||
|
||||
public void setRuleKey(String ruleKey) {
|
||||
this.ruleKey = ruleKey;
|
||||
}
|
||||
public void setRuleKey(String ruleKey) {
|
||||
this.ruleKey = ruleKey;
|
||||
}
|
||||
|
||||
public int getWaitTimeoutInSecond() {
|
||||
return waitTimeoutInSecond;
|
||||
}
|
||||
public int getWaitTimeoutInSecond() {
|
||||
return waitTimeoutInSecond;
|
||||
}
|
||||
|
||||
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
|
||||
this.waitTimeoutInSecond = waitTimeoutInSecond;
|
||||
}
|
||||
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
|
||||
this.waitTimeoutInSecond = waitTimeoutInSecond;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package com.alibaba.cloud.sentinel.datasource.factorybean;
|
||||
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.consul.ConsulDataSource;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
/**
|
||||
@ -28,68 +29,63 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
*/
|
||||
public class ConsulDataSourceFactoryBean implements FactoryBean<ConsulDataSource> {
|
||||
|
||||
private String host;
|
||||
private String host;
|
||||
|
||||
private int port;
|
||||
private int port;
|
||||
|
||||
private String ruleKey;
|
||||
private String ruleKey;
|
||||
|
||||
private int waitTimeoutInSecond;
|
||||
private int waitTimeoutInSecond;
|
||||
|
||||
private Converter converter;
|
||||
private Converter converter;
|
||||
|
||||
@Override
|
||||
public ConsulDataSource getObject() throws Exception {
|
||||
return new ConsulDataSource(
|
||||
host,
|
||||
port,
|
||||
ruleKey,
|
||||
waitTimeoutInSecond,
|
||||
converter);
|
||||
}
|
||||
@Override
|
||||
public ConsulDataSource getObject() throws Exception {
|
||||
return new ConsulDataSource(host, port, ruleKey, waitTimeoutInSecond, converter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return ConsulDataSource.class;
|
||||
}
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return ConsulDataSource.class;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getRuleKey() {
|
||||
return ruleKey;
|
||||
}
|
||||
public String getRuleKey() {
|
||||
return ruleKey;
|
||||
}
|
||||
|
||||
public void setRuleKey(String ruleKey) {
|
||||
this.ruleKey = ruleKey;
|
||||
}
|
||||
public void setRuleKey(String ruleKey) {
|
||||
this.ruleKey = ruleKey;
|
||||
}
|
||||
|
||||
public int getWaitTimeoutInSecond() {
|
||||
return waitTimeoutInSecond;
|
||||
}
|
||||
public int getWaitTimeoutInSecond() {
|
||||
return waitTimeoutInSecond;
|
||||
}
|
||||
|
||||
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
|
||||
this.waitTimeoutInSecond = waitTimeoutInSecond;
|
||||
}
|
||||
public void setWaitTimeoutInSecond(int waitTimeoutInSecond) {
|
||||
this.waitTimeoutInSecond = waitTimeoutInSecond;
|
||||
}
|
||||
|
||||
public Converter getConverter() {
|
||||
return converter;
|
||||
}
|
||||
public Converter getConverter() {
|
||||
return converter;
|
||||
}
|
||||
|
||||
public void setConverter(Converter converter) {
|
||||
this.converter = converter;
|
||||
}
|
||||
public void setConverter(Converter converter) {
|
||||
this.converter = converter;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user