mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
ha
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package com.alibaba.druid.pool.ha;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.alibaba.druid.logging.Log;
|
||||
@@ -140,27 +137,6 @@ public class HADataSource extends MultiDataSource implements HADataSourceMBean,
|
||||
this.setSlave(tmp);
|
||||
}
|
||||
|
||||
public synchronized void setDataSources(List<DruidDataSource> dataSources) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public MultiConnectionHolder getConnectionInternal(MultiDataSourceConnection connection, String sql) throws SQLException {
|
||||
DataSourceHolder dataSource = null;
|
||||
if (master.isEnable()) {
|
||||
dataSource = master;
|
||||
}
|
||||
|
||||
if (dataSource == null && slave.isEnable()) {
|
||||
dataSource = slave;
|
||||
}
|
||||
|
||||
if (dataSource == null) {
|
||||
throw new SQLException("get HAConnection error");
|
||||
}
|
||||
|
||||
return dataSource.getConnection();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
super.close();
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.alibaba.druid.pool.ha.config;
|
||||
|
||||
public class DruidDataSourceConfig {
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
private int initialSize;
|
||||
protected int maxActive;
|
||||
private int minIdle;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getInitialSize() {
|
||||
return initialSize;
|
||||
}
|
||||
|
||||
public void setInitialSize(int initialSize) {
|
||||
this.initialSize = initialSize;
|
||||
}
|
||||
|
||||
public int getMaxActive() {
|
||||
return maxActive;
|
||||
}
|
||||
|
||||
public void setMaxActive(int maxActive) {
|
||||
this.maxActive = maxActive;
|
||||
}
|
||||
|
||||
public int getMinIdle() {
|
||||
return minIdle;
|
||||
}
|
||||
|
||||
public void setMinIdle(int minIdle) {
|
||||
this.minIdle = minIdle;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.alibaba.druid.pool.ha.config;
|
||||
|
||||
public class HADataSourceConfig {
|
||||
|
||||
private DruidDataSourceConfig master;
|
||||
private DruidDataSourceConfig slave;
|
||||
|
||||
public DruidDataSourceConfig getMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public void setMaster(DruidDataSourceConfig master) {
|
||||
this.master = master;
|
||||
}
|
||||
|
||||
public DruidDataSourceConfig getSlave() {
|
||||
return slave;
|
||||
}
|
||||
|
||||
public void setSlave(DruidDataSourceConfig slave) {
|
||||
this.slave = slave;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.alibaba.druid.pool.ha.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MultiDataSourceConfig {
|
||||
|
||||
private String name;
|
||||
|
||||
private List<DruidDataSourceConfig> dataSources = new ArrayList<DruidDataSourceConfig>();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<DruidDataSourceConfig> getDataSources() {
|
||||
return dataSources;
|
||||
}
|
||||
|
||||
public void setDataSources(List<DruidDataSourceConfig> dataSources) {
|
||||
this.dataSources = dataSources;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user