Merge pull request #9367 from dataease/pr@dev-v2@fixds

fix: 将有效的数据源重新放到连接池
This commit is contained in:
taojinlong 2024-04-26 15:44:29 +08:00 committed by GitHub
commit 970720eeab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View File

@ -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);

View File

@ -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());