forked from github/dataease
Merge pull request #9367 from dataease/pr@dev-v2@fixds
fix: 将有效的数据源重新放到连接池
This commit is contained in:
commit
970720eeab
@ -981,6 +981,23 @@ public class CalciteProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDsPoolAfterCheckStatus(DatasourceDTO datasourceDTO) throws DEException {
|
||||
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
|
||||
BeanUtils.copyBean(datasourceSchemaDTO, datasourceDTO);
|
||||
datasourceSchemaDTO.setSchemaAlias(String.format(SQLConstants.SCHEMA, datasourceSchemaDTO.getId()));
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO));
|
||||
try {
|
||||
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
|
||||
SchemaPlus rootSchema = calciteConnection.getRootSchema();
|
||||
if (rootSchema.getSubSchema(datasourceSchemaDTO.getSchemaAlias()) == null) {
|
||||
buildSchema(datasourceRequest, calciteConnection);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(CoreDatasource datasource) throws DEException {
|
||||
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
|
||||
BeanUtils.copyBean(datasourceSchemaDTO, datasource);
|
||||
|
@ -655,9 +655,7 @@ public class DatasourceServer implements DatasourceApi {
|
||||
BeanUtils.copyBean(datasourceDTO, coreDatasource);
|
||||
try {
|
||||
checkDatasourceStatus(coreDatasource);
|
||||
if(StringUtils.isNotEmpty(lastStatus) && StringUtils.isNotEmpty(coreDatasource.getStatus()) && lastStatus.equalsIgnoreCase("Error") && coreDatasource.getStatus().equalsIgnoreCase("Success")){
|
||||
calciteProvider.update(datasourceDTO);
|
||||
}
|
||||
calciteProvider.updateDsPoolAfterCheckStatus(datasourceDTO);
|
||||
} catch (Exception e) {
|
||||
coreDatasource.setStatus("Error");
|
||||
DEException.throwException(e.getMessage());
|
||||
|
Loading…
Reference in New Issue
Block a user