1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Polish alibaba/spring-cloud-alibaba#1739 : Sync the Sentinel DataSource from master

This commit is contained in:
mercyblitz 2020-09-18 16:33:43 +08:00
parent bae6878c0d
commit 4003d3e15b
4 changed files with 61 additions and 2 deletions

View File

@ -47,9 +47,23 @@ public class DataSourcePropertiesConfiguration {
private RedisDataSourceProperties redis; private RedisDataSourceProperties redis;
private ConsulDataSourceProperties consul;
public DataSourcePropertiesConfiguration() { public DataSourcePropertiesConfiguration() {
} }
public DataSourcePropertiesConfiguration(ConsulDataSourceProperties consul) {
this.consul = consul;
}
public ConsulDataSourceProperties getConsul() {
return consul;
}
public void setConsul(ConsulDataSourceProperties consul) {
this.consul = consul;
}
public DataSourcePropertiesConfiguration(FileDataSourceProperties file) { public DataSourcePropertiesConfiguration(FileDataSourceProperties file) {
this.file = file; this.file = file;
} }

View File

@ -32,6 +32,10 @@ public class NacosDataSourceProperties extends AbstractDataSourceProperties {
private String serverAddr; private String serverAddr;
private String username;
private String password;
@NotEmpty @NotEmpty
private String groupId = "DEFAULT_GROUP"; private String groupId = "DEFAULT_GROUP";
@ -67,6 +71,22 @@ public class NacosDataSourceProperties extends AbstractDataSourceProperties {
this.serverAddr = serverAddr; this.serverAddr = serverAddr;
} }
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getGroupId() { public String getGroupId() {
return groupId; return groupId;
} }

View File

@ -24,7 +24,7 @@ import com.alibaba.cloud.sentinel.datasource.factorybean.RedisDataSourceFactoryB
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* Zookeeper Properties class Using by {@link DataSourcePropertiesConfiguration} and * Redis Properties class Using by {@link DataSourcePropertiesConfiguration} and
* {@link RedisDataSourceFactoryBean}. * {@link RedisDataSourceFactoryBean}.
* *
* @author <a href="mailto:wangiegie@gmail.com">lengleng</a> * @author <a href="mailto:wangiegie@gmail.com">lengleng</a>
@ -93,7 +93,7 @@ public class RedisDataSourceProperties extends AbstractDataSourceProperties {
"RedisDataSource channel can not be empty"); "RedisDataSource channel can not be empty");
} }
if (!StringUtils.isEmpty(masterId) && StringUtils.isEmpty(masterId)) { if (StringUtils.isEmpty(masterId)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"RedisDataSource sentinel modelmasterId can not be empty"); "RedisDataSource sentinel modelmasterId can not be empty");
} }

View File

@ -35,6 +35,10 @@ public class NacosDataSourceFactoryBean implements FactoryBean<NacosDataSource>
private String serverAddr; private String serverAddr;
private String username;
private String password;
private String groupId; private String groupId;
private String dataId; private String dataId;
@ -63,6 +67,12 @@ public class NacosDataSourceFactoryBean implements FactoryBean<NacosDataSource>
if (!StringUtils.isEmpty(this.namespace)) { if (!StringUtils.isEmpty(this.namespace)) {
properties.setProperty(PropertyKeyConst.NAMESPACE, this.namespace); properties.setProperty(PropertyKeyConst.NAMESPACE, this.namespace);
} }
if (!StringUtils.isEmpty(this.username)) {
properties.setProperty(PropertyKeyConst.USERNAME, this.username);
}
if (!StringUtils.isEmpty(this.password)) {
properties.setProperty(PropertyKeyConst.PASSWORD, this.password);
}
return new NacosDataSource(properties, groupId, dataId, converter); return new NacosDataSource(properties, groupId, dataId, converter);
} }
@ -79,6 +89,21 @@ public class NacosDataSourceFactoryBean implements FactoryBean<NacosDataSource>
this.serverAddr = serverAddr; this.serverAddr = serverAddr;
} }
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getGroupId() { public String getGroupId() {
return groupId; return groupId;
} }