提交 4c8e061e authored 作者: taojinlong's avatar taojinlong

feat: 定时检测数据源状态信息

上级 6b1abd07
......@@ -13,12 +13,14 @@ public class Datasource implements Serializable {
private String type;
private String createBy;
private Long createTime;
private Long updateTime;
private String createBy;
private String status;
private String configuration;
private static final long serialVersionUID = 1L;
......
......@@ -384,76 +384,6 @@ public class DatasourceExample {
return (Criteria) this;
}
public Criteria andCreateByIsNull() {
addCriterion("create_by is null");
return (Criteria) this;
}
public Criteria andCreateByIsNotNull() {
addCriterion("create_by is not null");
return (Criteria) this;
}
public Criteria andCreateByEqualTo(String value) {
addCriterion("create_by =", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotEqualTo(String value) {
addCriterion("create_by <>", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThan(String value) {
addCriterion("create_by >", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThanOrEqualTo(String value) {
addCriterion("create_by >=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThan(String value) {
addCriterion("create_by <", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThanOrEqualTo(String value) {
addCriterion("create_by <=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLike(String value) {
addCriterion("create_by like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotLike(String value) {
addCriterion("create_by not like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByIn(List<String> values) {
addCriterion("create_by in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotIn(List<String> values) {
addCriterion("create_by not in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByBetween(String value1, String value2) {
addCriterion("create_by between", value1, value2, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotBetween(String value1, String value2) {
addCriterion("create_by not between", value1, value2, "createBy");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
......@@ -573,6 +503,146 @@ public class DatasourceExample {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andCreateByIsNull() {
addCriterion("create_by is null");
return (Criteria) this;
}
public Criteria andCreateByIsNotNull() {
addCriterion("create_by is not null");
return (Criteria) this;
}
public Criteria andCreateByEqualTo(String value) {
addCriterion("create_by =", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotEqualTo(String value) {
addCriterion("create_by <>", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThan(String value) {
addCriterion("create_by >", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThanOrEqualTo(String value) {
addCriterion("create_by >=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThan(String value) {
addCriterion("create_by <", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThanOrEqualTo(String value) {
addCriterion("create_by <=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLike(String value) {
addCriterion("create_by like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotLike(String value) {
addCriterion("create_by not like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByIn(List<String> values) {
addCriterion("create_by in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotIn(List<String> values) {
addCriterion("create_by not in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByBetween(String value1, String value2) {
addCriterion("create_by between", value1, value2, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotBetween(String value1, String value2) {
addCriterion("create_by not between", value1, value2, "createBy");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
......
......@@ -6,9 +6,10 @@
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="desc" jdbcType="VARCHAR" property="desc" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="status" jdbcType="VARCHAR" property="status" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.Datasource">
<result column="configuration" jdbcType="LONGVARCHAR" property="configuration" />
......@@ -72,7 +73,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, `desc`, `type`, create_by, create_time, update_time
id, `name`, `desc`, `type`, create_time, update_time, create_by, `status`
</sql>
<sql id="Blob_Column_List">
configuration
......@@ -127,11 +128,13 @@
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.Datasource">
insert into datasource (id, `name`, `desc`,
`type`, create_by, create_time,
update_time, configuration)
`type`, create_time, update_time,
create_by, `status`, configuration
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{configuration,jdbcType=LONGVARCHAR})
#{type,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{createBy,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{configuration,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.Datasource">
insert into datasource
......@@ -148,15 +151,18 @@
<if test="type != null">
`type`,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="status != null">
`status`,
</if>
<if test="configuration != null">
configuration,
</if>
......@@ -174,15 +180,18 @@
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="configuration != null">
#{configuration,jdbcType=LONGVARCHAR},
</if>
......@@ -209,15 +218,18 @@
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.configuration != null">
configuration = #{record.configuration,jdbcType=LONGVARCHAR},
</if>
......@@ -232,9 +244,10 @@
`name` = #{record.name,jdbcType=VARCHAR},
`desc` = #{record.desc,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
configuration = #{record.configuration,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -246,9 +259,10 @@
`name` = #{record.name,jdbcType=VARCHAR},
`desc` = #{record.desc,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
update_time = #{record.updateTime,jdbcType=BIGINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -265,15 +279,18 @@
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="configuration != null">
configuration = #{configuration,jdbcType=LONGVARCHAR},
</if>
......@@ -285,9 +302,10 @@
set `name` = #{name,jdbcType=VARCHAR},
`desc` = #{desc,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_by = #{createBy,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
configuration = #{configuration,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
......@@ -296,9 +314,10 @@
set `name` = #{name,jdbcType=VARCHAR},
`desc` = #{desc,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}
update_time = #{updateTime,jdbcType=BIGINT},
create_by = #{createBy,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
......@@ -24,7 +24,7 @@
</select>
<select id="queryUnion" resultMap="BaseResultMapDTO">
select id , name , `desc` ,`type` , configuration ,create_time ,update_time,
select id , name , `desc` ,`type` , configuration ,create_time ,update_time, status,
get_auths(id,'link',#{userId}) as `privileges`
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'link') cids) t,datasource
<where>
......
......@@ -57,6 +57,7 @@ public class DatasourceService {
datasource.setCreateBy(String.valueOf(AuthUtils.getUser().getUsername()));
datasourceMapper.insertSelective(datasource);
handleConnectionPool(datasource, "add");
checkAndUpdateDatasourceStatus(datasource);
return datasource;
}
......@@ -111,6 +112,7 @@ public class DatasourceService {
datasource.setUpdateTime(System.currentTimeMillis());
datasourceMapper.updateByPrimaryKeySelective(datasource);
handleConnectionPool(datasource, "edit");
checkAndUpdateDatasourceStatus(datasource);
}
public void validate(Datasource datasource) throws Exception {
......@@ -200,4 +202,25 @@ public class DatasourceService {
DEException.throwException(Translator.get("i18n_ds_name_exists"));
}
}
public void updateDatasourceStatus(){
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
datasources.forEach(datasource -> {
checkAndUpdateDatasourceStatus(datasource);
});
}
private void checkAndUpdateDatasourceStatus(Datasource datasource){
try {
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(datasource);
datasourceProvider.checkStatus(datasourceRequest);
datasource.setStatus("Success");
datasourceMapper.updateByPrimaryKeySelective(datasource);
} catch (Exception e) {
datasource.setStatus("Error");
datasourceMapper.updateByPrimaryKeySelective(datasource);
}
}
}
......@@ -1542,7 +1542,6 @@ public class DataSetTableService {
@Resource
private UtilMapper utilMapper;
@QuartzScheduled(cron = "0 0/3 * * * ?")
public void updateDatasetTableStatus() {
List<QrtzSchedulerState> qrtzSchedulerStates = qrtzSchedulerStateMapper.selectByExample(null);
List<String> activeQrtzInstances = qrtzSchedulerStates.stream().filter(qrtzSchedulerState -> qrtzSchedulerState.getLastCheckinTime() + qrtzSchedulerState.getCheckinInterval() + 1000 > utilMapper.currentTimestamp()).map(QrtzSchedulerStateKey::getInstanceName).collect(Collectors.toList());
......
......@@ -64,7 +64,7 @@
<!--要生成的数据库表 -->
<table tableName="chart_view"/>
<table tableName="datasource"/>
<!-- <table tableName="sys_dict_item"/>-->
<!-- <table tableName="dataset_table_field"/>-->
<!-- <table tableName="v_chart">-->
......
......@@ -4,10 +4,6 @@
class="ms-aside-container"
:style="{'margin-left': !asideHidden ? 0 : '-' + width}"
>
<!--<div v-if="enableAsideHidden" class="hiddenBottom" @click="asideHidden = !asideHidden">-->
<!--<i v-if="!asideHidden" class="el-icon-arrow-left"/>-->
<!--<i v-if="asideHidden" class="el-icon-arrow-right"/>-->
<!--</div>-->
<slot />
<de-horizontal-drag-bar v-if="showDragBar" />
</el-aside>
......
......@@ -1043,7 +1043,8 @@ export default {
oracle_service_name: 'Service Name',
get_schema: 'Get Schema',
schema: 'Database Schema',
please_choose_schema: 'Please select Schema'
please_choose_schema: 'Please select Schema',
in_valid: 'Invalid datasource'
},
pblink: {
key_pwd: 'Please enter the password to open the link',
......
......@@ -1043,7 +1043,8 @@ export default {
oracle_service_name: '服務名',
get_schema: '獲取 Schema',
schema: '數據庫 Schema',
please_choose_schema: '請選擇數據庫 Schema'
please_choose_schema: '請選擇數據庫 Schema',
in_valid: '無效數據源'
},
pblink: {
key_pwd: '請輸入密碼打開鏈接',
......
......@@ -1045,7 +1045,8 @@ export default {
get_schema: '获取 Schema',
schema: '数据库 Schema',
please_choose_schema: '请选择数据库 Schema',
edit_datasource_msg: '修改数据源信息,可能会导致改数据源下的数据集不可用,确认修改?'
edit_datasource_msg: '修改数据源信息,可能会导致改数据源下的数据集不可用,确认修改?',
in_valid: '无效数据源'
},
pblink: {
key_pwd: '请输入密码打开链接',
......
......@@ -37,13 +37,22 @@
>
<span slot-scope="{ node, data }" class="custom-tree-node-list father">
<span style="display: flex;flex: 1;width: 0;">
<span v-if="data.type !== 'folder'">
<span v-if="data.type !== 'folder' && data.status !== 'Error'">
<svg-icon icon-class="datasource" class="ds-icon-scene" />
</span>
<span v-if="data.status === 'Error'">
<svg-icon icon-class="exclamationmark" class="ds-icon-scene" />
<el-tooltip v-if="data.status === 'Error'" style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" effect="dark" :content="$t('datasource.in_valid')" placement="right">
<el-button type="text" > {{ data.name }} </el-button>
</el-tooltip>
</span>
<span v-if="data.type === 'folder'">
<i class="el-icon-folder" />
</span>
<span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ data.name }}</span>
<span v-if=" data.status !== 'Error'" style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
{{ data.name }}
</span>
</span>
<span class="child">
<span v-if="data.type ==='folder'" @click.stop>
......@@ -67,24 +76,6 @@
@click="_handleDelete(data)"
/>
</span>
<!-- <el-dropdown trigger="click" size="small" @command="clickFileMore">
<span class="el-dropdown-link">
<el-button
icon="el-icon-more"
type="text"
size="small"
/>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-edit" :command="beforeClickFile('edit',data,node)">
{{ $t('panel.edit') }}
</el-dropdown-item>
<el-dropdown-item icon="el-icon-delete" :command="beforeClickFile('delete',data,node)">
{{ $t('panel.delete') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown> -->
</span>
</span>
</span>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论