feat(info-query): 增加简单table meta信息查询
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.lanyuanxiaoyao.service.configuration.entity.info;
|
||||
|
||||
/**
|
||||
* Flink job 信息聚合
|
||||
*
|
||||
* @author ZhangJiacheng
|
||||
* @date 2022-05-30
|
||||
*/
|
||||
public class SimpleTableMeta {
|
||||
private Long flinkJobId;
|
||||
private String flinkJobName;
|
||||
private String alias;
|
||||
private String schema;
|
||||
private String table;
|
||||
private String targetDb;
|
||||
private String targetTable;
|
||||
private String targetHdfs;
|
||||
|
||||
public SimpleTableMeta() {
|
||||
}
|
||||
|
||||
public SimpleTableMeta(Long flinkJobId, String flinkJobName, String alias, String schema, String table, String targetDb, String targetTable, String targetHdfs) {
|
||||
this.flinkJobId = flinkJobId;
|
||||
this.flinkJobName = flinkJobName;
|
||||
this.alias = alias;
|
||||
this.schema = schema;
|
||||
this.table = table;
|
||||
this.targetDb = targetDb;
|
||||
this.targetTable = targetTable;
|
||||
this.targetHdfs = targetHdfs;
|
||||
}
|
||||
|
||||
public Long getFlinkJobId() {
|
||||
return flinkJobId;
|
||||
}
|
||||
|
||||
public String getFlinkJobName() {
|
||||
return flinkJobName;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public String getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
public String getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public String getTargetDb() {
|
||||
return targetDb;
|
||||
}
|
||||
|
||||
public String getTargetTable() {
|
||||
return targetTable;
|
||||
}
|
||||
|
||||
public String getTargetHdfs() {
|
||||
return targetHdfs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SimpleTableMeta{" +
|
||||
"flinkJobId=" + flinkJobId +
|
||||
", flinkJobName='" + flinkJobName + '\'' +
|
||||
", alias='" + alias + '\'' +
|
||||
", schema='" + schema + '\'' +
|
||||
", table='" + table + '\'' +
|
||||
", targetDb='" + targetDb + '\'' +
|
||||
", targetTable='" + targetTable + '\'' +
|
||||
", targetHdfs='" + targetHdfs + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -135,4 +135,16 @@ public interface InfoService {
|
||||
|
||||
@Get("/info/all_hdfs")
|
||||
ImmutableList<String> allHdfs(@Query("key") String key);
|
||||
|
||||
@Get("/info/simple_table_metas")
|
||||
ImmutableList<SimpleTableMeta> simpleTableMetas();
|
||||
|
||||
@Get("/info/simple_table_metas")
|
||||
ImmutableList<SimpleTableMeta> simpleTableMetas(@Query("flink_job_id") Long flinkJobId);
|
||||
|
||||
@Get("/info/simple_table_metas")
|
||||
ImmutableList<SimpleTableMeta> simpleTableMetas(@Query("alias") String alias);
|
||||
|
||||
@Get("/info/simple_table_metas")
|
||||
ImmutableList<SimpleTableMeta> simpleTableMetas(@Query("flink_job_id") Long flinkJobId, @Query("alias") String alias);
|
||||
}
|
||||
|
||||
@@ -257,4 +257,12 @@ public class InfoController {
|
||||
.collect(TableInfoSearchCache::getHdfs)
|
||||
.distinct();
|
||||
}
|
||||
|
||||
@GetMapping("/simple_table_metas")
|
||||
public ImmutableList<SimpleTableMeta> simpleTableMetas(
|
||||
@RequestParam(value = "flink_job_id", required = false) Long flinkJobId,
|
||||
@RequestParam(value = "alias", required = false) String alias
|
||||
) {
|
||||
return infoService.simpleTableMetas(flinkJobId, alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -787,4 +787,41 @@ public class InfoService {
|
||||
(rs, row) -> new TableInfoSearchCache(rs.getLong(1), rs.getString(2), rs.getString(3))
|
||||
));
|
||||
}
|
||||
|
||||
@Cacheable(value = "simple-table-metas", sync = true, cacheManager = "long-cache")
|
||||
@Retryable(Throwable.class)
|
||||
public ImmutableList<SimpleTableMeta> simpleTableMetas(Long flinkJobId, String alias) {
|
||||
return Lists.immutable.ofAll(
|
||||
mysqlJdbcTemplate.query(
|
||||
SqlBuilder
|
||||
.select(
|
||||
TbAppFlinkJobConfig.ID_A,
|
||||
TbAppFlinkJobConfig.NAME_A,
|
||||
TbAppCollectTableInfo.ALIAS_A,
|
||||
TbAppCollectTableInfo.SRC_SCHEMA_A,
|
||||
TbAppCollectTableInfo.SRC_TABLE_A,
|
||||
TbAppCollectTableInfo.TGT_DB_A,
|
||||
TbAppCollectTableInfo.TGT_TABLE_A,
|
||||
TbAppCollectTableInfo.TGT_HDFS_PATH_A
|
||||
)
|
||||
.from(TbAppFlinkJobConfig._alias_, TbAppCollectTableInfo._alias_)
|
||||
.whereEq(TbAppFlinkJobConfig.ID_A, Column.as(TbAppCollectTableInfo.FLINK_JOB_ID_A))
|
||||
.andEq(TbAppFlinkJobConfig.STATUS_A, STATUS_Y)
|
||||
.andEq(TbAppCollectTableInfo.STATUS_A, STATUS_Y)
|
||||
.andEq(ObjectUtil.isNotNull(flinkJobId), TbAppFlinkJobConfig.ID_A, flinkJobId)
|
||||
.andEq(StrUtil.isNotBlank(alias), TbAppCollectTableInfo.ALIAS_A, alias)
|
||||
.build(),
|
||||
(rs, row) -> new SimpleTableMeta(
|
||||
rs.getLong(1),
|
||||
rs.getString(2),
|
||||
rs.getString(3),
|
||||
rs.getString(4),
|
||||
rs.getString(5),
|
||||
rs.getString(6),
|
||||
rs.getString(7),
|
||||
rs.getString(8)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user