feat: 数据源高级参数设置
This commit is contained in:
parent
ede4ebded2
commit
d7f363e97b
@ -14,4 +14,12 @@ public class JdbcDTO {
|
||||
private String dataBase;
|
||||
private String schema;
|
||||
private String dataSourceType = "jdbc";
|
||||
|
||||
private int initialPoolSize = 5;
|
||||
private int minPoolSize = 5;
|
||||
private int maxPoolSize = 50;
|
||||
private int maxIdleTime = 30;
|
||||
private int acquireIncrement = 5;
|
||||
private int idleConnectionTestPeriod = 5;
|
||||
private int connectTimeout = 5;
|
||||
}
|
||||
|
||||
@ -373,12 +373,12 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
private void addToPool(DatasourceRequest datasourceRequest) throws PropertyVetoException {
|
||||
ComboPooledDataSource dataSource;
|
||||
dataSource = new ComboPooledDataSource();
|
||||
setCredential(datasourceRequest, dataSource);
|
||||
dataSource.setMaxIdleTime(30); // 最大空闲时间
|
||||
dataSource.setAcquireIncrement(5);// 增长数
|
||||
dataSource.setInitialPoolSize(initPoolSize);// 初始连接数
|
||||
dataSource.setMinPoolSize(initPoolSize); // 最小连接数
|
||||
dataSource.setMaxPoolSize(maxConnections); // 最大连接数
|
||||
JdbcDTO jdbcDTO = setCredential(datasourceRequest, dataSource);
|
||||
dataSource.setMaxIdleTime(jdbcDTO.getMaxIdleTime()); // 最大空闲时间
|
||||
dataSource.setAcquireIncrement(jdbcDTO.getAcquireIncrement());// 增长数
|
||||
dataSource.setInitialPoolSize(jdbcDTO.getInitialPoolSize());// 初始连接数
|
||||
dataSource.setMinPoolSize(jdbcDTO.getMinPoolSize()); // 最小连接数
|
||||
dataSource.setMaxPoolSize(jdbcDTO.getMaxPoolSize()); // 最大连接数
|
||||
dataSource.setAcquireRetryAttempts(30);// 获取连接重试次数
|
||||
dataSource.setIdleConnectionTestPeriod(60); // 每60s检查数据库空闲连接
|
||||
dataSource.setMaxStatements(0); // c3p0全局的PreparedStatements缓存的大小
|
||||
@ -449,8 +449,9 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
}
|
||||
|
||||
|
||||
private void setCredential(DatasourceRequest datasourceRequest, ComboPooledDataSource dataSource) throws PropertyVetoException {
|
||||
private JdbcDTO setCredential(DatasourceRequest datasourceRequest, ComboPooledDataSource dataSource) throws PropertyVetoException {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
|
||||
JdbcDTO jdbcDTO = new JdbcDTO();
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
MysqlConfigration mysqlConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfigration.class);
|
||||
@ -458,6 +459,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
dataSource.setDriverClass(mysqlConfigration.getDriver());
|
||||
dataSource.setPassword(mysqlConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(mysqlConfigration.getJdbc());
|
||||
jdbcDTO = mysqlConfigration;
|
||||
break;
|
||||
case doris:
|
||||
MysqlConfigration dorisConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfigration.class);
|
||||
@ -465,6 +467,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
dataSource.setDriverClass(dorisConfigration.getDriver());
|
||||
dataSource.setPassword(dorisConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(dorisConfigration.getJdbc());
|
||||
jdbcDTO = dorisConfigration;
|
||||
break;
|
||||
case sqlServer:
|
||||
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfigration.class);
|
||||
@ -472,6 +475,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
dataSource.setDriverClass(sqlServerConfigration.getDriver());
|
||||
dataSource.setPassword(sqlServerConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(sqlServerConfigration.getJdbc());
|
||||
jdbcDTO = sqlServerConfigration;
|
||||
break;
|
||||
case oracle:
|
||||
OracleConfigration oracleConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), OracleConfigration.class);
|
||||
@ -479,6 +483,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
dataSource.setDriverClass(oracleConfigration.getDriver());
|
||||
dataSource.setPassword(oracleConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(oracleConfigration.getJdbc());
|
||||
jdbcDTO = oracleConfigration;
|
||||
break;
|
||||
case pg:
|
||||
PgConfigration pgConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfigration.class);
|
||||
@ -486,10 +491,12 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
dataSource.setDriverClass(pgConfigration.getDriver());
|
||||
dataSource.setPassword(pgConfigration.getPassword());
|
||||
dataSource.setJdbcUrl(pgConfigration.getJdbc());
|
||||
jdbcDTO = pgConfigration;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return jdbcDTO;
|
||||
}
|
||||
|
||||
private String getDatabase(DatasourceRequest datasourceRequest) {
|
||||
|
||||
@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.xml.crypto.Data;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -77,7 +78,11 @@ public class DatasourceService {
|
||||
|
||||
public List<DatasourceDTO> getDatasourceList(DatasourceUnionRequest request) throws Exception {
|
||||
request.setSort("update_time desc");
|
||||
return extDataSourceMapper.queryUnion(request);
|
||||
List<DatasourceDTO> datasourceDTOS = extDataSourceMapper.queryUnion(request);
|
||||
datasourceDTOS.forEach(datasourceDTO -> {
|
||||
datasourceDTO.getType();
|
||||
});
|
||||
return datasourceDTOS;
|
||||
}
|
||||
|
||||
public List<DatasourceDTO> gridQuery(BaseGridRequest request) {
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
package io.dataease.dto.dataset;
|
||||
|
||||
import io.dataease.datasource.dto.TableFiled;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ExcelFileData {
|
||||
|
||||
@ -1044,7 +1044,21 @@ export default {
|
||||
get_schema: 'Get Schema',
|
||||
schema: 'Database Schema',
|
||||
please_choose_schema: 'Please select Schema',
|
||||
in_valid: 'Invalid datasource'
|
||||
in_valid: 'Invalid datasource',
|
||||
initial_pool_size: 'Initial connections',
|
||||
min_pool_size: 'Minimum of connections',
|
||||
max_pool_size: 'Maximum connection',
|
||||
max_idle_time: 'Maximum idle (seconds)',
|
||||
acquire_increment: 'Growth number',
|
||||
connect_timeout: 'Connection timeout (seconds)',
|
||||
please_input_initial_pool_size: 'Please enter the number of initial connections',
|
||||
please_input_min_pool_size: 'Please enter the minimum number of connections',
|
||||
please_input_max_pool_size: 'Please enter the maximum number of connections',
|
||||
please_input_max_idle_time: 'Please enter the maximum idle (seconds)',
|
||||
please_input_acquire_increment: 'Please enter the growth number',
|
||||
please_input_connect_timeout: 'Please enter the connection timeout (seconds)',
|
||||
no_less_then_0: 'Parameters in advanced settings cannot be less than zero',
|
||||
priority: 'Advanced setting'
|
||||
},
|
||||
pblink: {
|
||||
key_pwd: 'Please enter the password to open the link',
|
||||
|
||||
@ -1044,7 +1044,21 @@ export default {
|
||||
get_schema: '獲取 Schema',
|
||||
schema: '數據庫 Schema',
|
||||
please_choose_schema: '請選擇數據庫 Schema',
|
||||
in_valid: '無效數據源'
|
||||
in_valid: '無效數據源',
|
||||
initial_pool_size: '初始連結數',
|
||||
min_pool_size: '最小連結數',
|
||||
max_pool_size: '最大連結數',
|
||||
max_idle_time: '最大空閒(秒)',
|
||||
acquire_increment: '增長數',
|
||||
connect_timeout: '連接超時(秒)',
|
||||
please_input_initial_pool_size: '請輸入初始連結數',
|
||||
please_input_min_pool_size: '請輸入最小連結數',
|
||||
please_input_max_pool_size: '請輸入最大連結數',
|
||||
please_input_max_idle_time: '請輸入最大空閒(秒)',
|
||||
please_input_acquire_increment: '請輸入增長數',
|
||||
please_input_connect_timeout: '請輸入連接超時(秒)',
|
||||
no_less_then_0: '高級設置中的參數不能小於零',
|
||||
priority: '高級設置'
|
||||
},
|
||||
pblink: {
|
||||
key_pwd: '請輸入密碼打開鏈接',
|
||||
|
||||
@ -1046,7 +1046,21 @@ export default {
|
||||
schema: '数据库 Schema',
|
||||
please_choose_schema: '请选择数据库 Schema',
|
||||
edit_datasource_msg: '修改数据源信息,可能会导致改数据源下的数据集不可用,确认修改?',
|
||||
in_valid: '无效数据源'
|
||||
in_valid: '无效数据源',
|
||||
initial_pool_size: '初始连接数',
|
||||
min_pool_size: '最小连接数',
|
||||
max_pool_size: '最大连接数',
|
||||
max_idle_time: '最大空闲(秒)',
|
||||
acquire_increment: '增长数',
|
||||
connect_timeout: '连接超时(秒)',
|
||||
please_input_initial_pool_size: '请输入初始连接数',
|
||||
please_input_min_pool_size: '请输入最小连接数',
|
||||
please_input_max_pool_size: '请输入最大连接数',
|
||||
please_input_max_idle_time: '请输入最大空闲(秒)',
|
||||
please_input_acquire_increment: '请输入增长数',
|
||||
please_input_connect_timeout: '请输入连接超时(秒)',
|
||||
no_less_then_0: '高级设置中的参数不能小于零',
|
||||
priority: '高级设置'
|
||||
},
|
||||
pblink: {
|
||||
key_pwd: '请输入密码打开链接',
|
||||
|
||||
@ -215,35 +215,35 @@
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.markdown>p,
|
||||
.markdown>blockquote,
|
||||
.markdown>.highlight,
|
||||
.markdown>ol,
|
||||
.markdown>ul {
|
||||
.markdown >p,
|
||||
.markdown >blockquote,
|
||||
.markdown >.highlight,
|
||||
.markdown >ol,
|
||||
.markdown >ul {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.markdown ul>li {
|
||||
.markdown ul >li {
|
||||
list-style: circle;
|
||||
}
|
||||
|
||||
.markdown>ul li,
|
||||
.markdown blockquote ul>li {
|
||||
.markdown >ul li,
|
||||
.markdown blockquote ul >li {
|
||||
margin-left: 20px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.markdown>ul li p,
|
||||
.markdown>ol li p {
|
||||
.markdown >ul li p,
|
||||
.markdown >ol li p {
|
||||
margin: 0.6em 0;
|
||||
}
|
||||
|
||||
.markdown ol>li {
|
||||
.markdown ol >li {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
.markdown>ol li,
|
||||
.markdown blockquote ol>li {
|
||||
.markdown >ol li,
|
||||
.markdown blockquote ol >li {
|
||||
margin-left: 20px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
@ -260,7 +260,7 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.markdown>table {
|
||||
.markdown >table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0px;
|
||||
empty-cells: show;
|
||||
@ -269,14 +269,14 @@
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.markdown>table th {
|
||||
.markdown >table th {
|
||||
white-space: nowrap;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.markdown>table th,
|
||||
.markdown>table td {
|
||||
.markdown >table th,
|
||||
.markdown >table td {
|
||||
border: 1px solid #e9e9e9;
|
||||
padding: 8px 16px;
|
||||
text-align: left;
|
||||
|
||||
@ -11,8 +11,7 @@
|
||||
<el-input v-model="form.name" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.description')" prop="desc">
|
||||
|
||||
<el-input v-model="form.desc" autocomplete="off" type="textarea" />
|
||||
<el-input v-model="form.desc" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('datasource.type')" prop="type">
|
||||
<el-select v-model="form.type" :placeholder="$t('datasource.please_choose_type')" class="select-width" :disabled="formType=='modify' || (formType==='add' && params && !!params.type)" @change="changeType()">
|
||||
@ -62,7 +61,30 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-collapse >
|
||||
<el-collapse-item :title="$t('datasource.priority')" name="1">
|
||||
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.initial_pool_size')" prop="configuration.initialPoolSize">
|
||||
<el-input v-model="form.configuration.initialPoolSize" autocomplete="off" type="number" min="0" size="small" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.min_pool_size')" prop="configuration.minPoolSize">
|
||||
<el-input v-model="form.configuration.minPoolSize" autocomplete="off" type="number" min="0"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.max_pool_size')" prop="configuration.maxPoolSize">
|
||||
<el-input v-model="form.configuration.maxPoolSize" autocomplete="off" type="number" min="0"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.max_idle_time')" prop="configuration.maxIdleTime">
|
||||
<el-input v-model="form.configuration.maxIdleTime" autocomplete="off" type="number" min="0"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.acquire_increment')" prop="configuration.acquireIncrement">
|
||||
<el-input v-model="form.configuration.acquireIncrement" autocomplete="off" type="number" min="0"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.connect_timeout')" prop="configuration.connectTimeout">
|
||||
<el-input v-model="form.configuration.connectTimeout" autocomplete="off" type="number" min="0"/>
|
||||
</el-form-item>
|
||||
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</el-form>
|
||||
<div v-if="canEdit" slot="footer" class="dialog-footer">
|
||||
<el-button v-if="formType==='add'?true: hasDataPermission('manage',params.privileges)" @click="validaDatasource">{{ $t('commons.validate') }}</el-button>
|
||||
@ -92,7 +114,15 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: { configuration: {}},
|
||||
form: { configuration: {
|
||||
initialPoolSize: 5,
|
||||
minPoolSize: 5,
|
||||
maxPoolSize: 50,
|
||||
maxIdleTime: 30,
|
||||
acquireIncrement: 5,
|
||||
idleConnectionTestPeriod: 5,
|
||||
connectTimeout: 5
|
||||
}},
|
||||
rule: {
|
||||
name: [{ required: true, message: this.$t('datasource.input_name'), trigger: 'blur' },
|
||||
{ min: 2, max: 25, message: this.$t('datasource.input_limit_2_25', [2, 25]), trigger: 'blur' }],
|
||||
@ -103,7 +133,13 @@ export default {
|
||||
'configuration.username': [{ required: true, message: this.$t('datasource.please_input_user_name'), trigger: 'blur' }],
|
||||
'configuration.password': [{ required: true, message: this.$t('datasource.please_input_password'), trigger: 'change' }],
|
||||
'configuration.host': [{ required: true, message: this.$t('datasource.please_input_host'), trigger: 'change' }],
|
||||
'configuration.port': [{ required: true, message: this.$t('datasource.please_input_port'), trigger: 'change' }]
|
||||
'configuration.port': [{ required: true, message: this.$t('datasource.please_input_port'), trigger: 'change' }],
|
||||
'configuration.initialPoolSize': [{ required: true, message: this.$t('datasource.please_input_initial_pool_size'), trigger: 'change' }],
|
||||
'configuration.minPoolSize': [{ required: true, message: this.$t('datasource.please_input_min_pool_size'), trigger: 'change' }],
|
||||
'configuration.maxPoolSize': [{ required: true, message: this.$t('datasource.please_input_max_pool_size'), trigger: 'change' }],
|
||||
'configuration.maxIdleTime': [{ required: true, message: this.$t('datasource.please_input_max_idle_time'), trigger: 'change' }],
|
||||
'configuration.acquireIncrement': [{ required: true, message: this.$t('datasource.please_input_acquire_increment'), trigger: 'change' }],
|
||||
'configuration.connectTimeout': [{ required: true, message: this.$t('datasource.please_input_connect_timeout'), trigger: 'change' }]
|
||||
},
|
||||
allTypes: [{ name: 'mysql', label: 'MySQL', type: 'jdbc' },
|
||||
{ name: 'oracle', label: 'Oracle', type: 'jdbc' },
|
||||
@ -131,9 +167,16 @@ export default {
|
||||
methods: {
|
||||
setType() {
|
||||
this.form.type = this.params.type
|
||||
this.form.configuration = {}
|
||||
this.form.configuration = {
|
||||
initialPoolSize: 5,
|
||||
minPoolSize: 5,
|
||||
maxPoolSize: 50,
|
||||
maxIdleTime: 30,
|
||||
acquireIncrement: 5,
|
||||
idleConnectionTestPeriod: 5,
|
||||
connectTimeout: 5
|
||||
}
|
||||
this.changeType()
|
||||
console.log(this.form)
|
||||
},
|
||||
changeEdit() {
|
||||
this.canEdit = true
|
||||
@ -148,16 +191,42 @@ export default {
|
||||
this.form = Object.assign({}, row)
|
||||
this.originConfiguration = this.form.configuration
|
||||
this.form.configuration = JSON.parse(this.form.configuration)
|
||||
if(!this.form.configuration.initialPoolSize){
|
||||
this.form.configuration.initialPoolSize = 5
|
||||
}
|
||||
if(!this.form.configuration.minPoolSize){
|
||||
this.form.configuration.minPoolSize = 5
|
||||
}
|
||||
if(!this.form.configuration.maxPoolSize){
|
||||
this.form.configuration.maxPoolSize = 50
|
||||
}
|
||||
if(!this.form.configuration.maxIdleTime){
|
||||
this.form.configuration.maxIdleTime = 30
|
||||
}
|
||||
if(!this.form.configuration.acquireIncrement){
|
||||
this.form.configuration.acquireIncrement = 5
|
||||
}
|
||||
if(!this.form.configuration.idleConnectionTestPeriod){
|
||||
this.form.configuration.idleConnectionTestPeriod = 5
|
||||
}
|
||||
if(!this.form.configuration.connectTimeout){
|
||||
this.form.configuration.connectTimeout = 5
|
||||
}
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.$refs.dsForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
if (!this.form.configuration.schema && this.form.type === 'oracle') {
|
||||
if (!this.form.configuration.schema && (this.form.type === 'oracle' || this.form.type === 'sqlServer')) {
|
||||
this.$message.error(this.$t('datasource.please_choose_schema'))
|
||||
return
|
||||
}
|
||||
if(this.form.configuration.initialPoolSize < 0 || this.form.configuration.minPoolSize < 0 || this.form.configuration.maxPoolSize < 0 || this.form.configuration.maxIdleTime < 0
|
||||
|| this.form.configuration.acquireIncrement < 0 || this.form.configuration.idleConnectionTestPeriod < 0 || this.form.configuration.connectTimeout < 0){
|
||||
this.$message.error(this.$t('datasource.no_less_then_0'))
|
||||
return
|
||||
}
|
||||
this.$refs.dsForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addDs : editDs
|
||||
@ -244,4 +313,11 @@ export default {
|
||||
transform: scale(0.85);
|
||||
}
|
||||
}
|
||||
|
||||
.el-input {
|
||||
width: 300px;
|
||||
}
|
||||
.el-select {
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user