Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
jz-dmp-service
Commits
8a7d0cf1
Commit
8a7d0cf1
authored
Dec 25, 2020
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试连通性
parent
da86cb93
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
177 additions
and
119 deletions
+177
-119
JsonResult.java
src/main/java/com/jz/common/constant/JsonResult.java
+85
-79
DataSourceController.java
...ules/controller/DataIntegration/DataSourceController.java
+12
-0
DmpSyncingDatasourceReq.java
...troller/DataIntegration/bean/DmpSyncingDatasourceReq.java
+0
-39
DmpSyncingDatasourceDao.java
.../java/com/jz/dmp/modules/dao/DmpSyncingDatasourceDao.java
+2
-0
DmpSyncingDatasourceService.java
...m/jz/dmp/modules/service/DmpSyncingDatasourceService.java
+2
-0
DmpSyncingDatasourceServiceImpl.java
...modules/service/impl/DmpSyncingDatasourceServiceImpl.java
+66
-1
DmpSyncingDatasourceDao.xml
src/main/resources/mapper/dmp/DmpSyncingDatasourceDao.xml
+10
-0
No files found.
src/main/java/com/jz/common/constant/JsonResult.java
View file @
8a7d0cf1
...
@@ -60,6 +60,12 @@ public class JsonResult<T> {
...
@@ -60,6 +60,12 @@ public class JsonResult<T> {
}
}
public
JsonResult
(
com
.
jz
.
dmp
.
agent
.
ResultCode
code
,
String
message
)
{
public
JsonResult
(
com
.
jz
.
dmp
.
agent
.
ResultCode
code
,
String
message
)
{
this
.
setCode
(
code
);
this
.
setMessage
(
message
);
}
public
void
setCode
(
com
.
jz
.
dmp
.
agent
.
ResultCode
code
)
{
this
.
code
=
code
.
val
();
}
}
public
String
getCode
()
{
public
String
getCode
()
{
...
...
src/main/java/com/jz/dmp/modules/controller/DataIntegration/DataSourceController.java
View file @
8a7d0cf1
...
@@ -110,4 +110,16 @@ public class DataSourceController {
...
@@ -110,4 +110,16 @@ public class DataSourceController {
JsonResult
result
=
dmpSyncingDatasourceService
.
addDatasourceInfo
(
saveBody
);
JsonResult
result
=
dmpSyncingDatasourceService
.
addDatasourceInfo
(
saveBody
);
return
result
;
return
result
;
}
}
/**
* 测试连通性
*
* @return
*/
@ApiOperation
(
value
=
"测试连通性"
,
notes
=
"测试连通性"
)
@PostMapping
(
value
=
"/testConnection"
)
public
JsonResult
testConnection
(
@RequestBody
@Validated
DmpSyncingDatasourceReq
saveBody
,
HttpServletRequest
httpRequest
)
throws
Exception
{
JsonResult
result
=
dmpSyncingDatasourceService
.
testConnection
(
saveBody
);
return
result
;
}
}
}
src/main/java/com/jz/dmp/modules/controller/DataIntegration/bean/DmpSyncingDatasourceReq.java
View file @
8a7d0cf1
...
@@ -105,21 +105,6 @@ public class DmpSyncingDatasourceReq implements Serializable {
...
@@ -105,21 +105,6 @@ public class DmpSyncingDatasourceReq implements Serializable {
*/
*/
@ApiModelProperty
(
value
=
"表空间"
)
@ApiModelProperty
(
value
=
"表空间"
)
private
String
tableSchema
;
private
String
tableSchema
;
/**
* 数据状态
*/
@ApiModelProperty
(
value
=
"数据状态"
)
private
String
dataStatus
;
/**
* 创建用户ID
*/
@ApiModelProperty
(
value
=
"创建用户ID"
)
private
String
createUserId
;
/**
* 数据创建时间
*/
@ApiModelProperty
(
value
=
"数据创建时间"
)
private
String
createTime
;
/**
/**
* 项目ID
* 项目ID
...
@@ -269,30 +254,6 @@ public class DmpSyncingDatasourceReq implements Serializable {
...
@@ -269,30 +254,6 @@ public class DmpSyncingDatasourceReq implements Serializable {
this
.
tableSchema
=
tableSchema
;
this
.
tableSchema
=
tableSchema
;
}
}
public
String
getDataStatus
()
{
return
dataStatus
;
}
public
void
setDataStatus
(
String
dataStatus
)
{
this
.
dataStatus
=
dataStatus
;
}
public
String
getCreateUserId
()
{
return
createUserId
;
}
public
void
setCreateUserId
(
String
createUserId
)
{
this
.
createUserId
=
createUserId
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getProjectId
()
{
public
String
getProjectId
()
{
return
projectId
;
return
projectId
;
}
}
...
...
src/main/java/com/jz/dmp/modules/dao/DmpSyncingDatasourceDao.java
View file @
8a7d0cf1
...
@@ -4,6 +4,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
...
@@ -4,6 +4,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DmpSyncingDatasourceReq
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DmpSyncingDatasourceReq
;
import
com.jz.dmp.modules.model.DmpSyncingDatasource
;
import
com.jz.dmp.modules.model.DmpSyncingDatasource
;
import
com.jz.dmp.modules.model.DmpSyncingDatasourceType
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
...
@@ -98,4 +99,5 @@ public interface DmpSyncingDatasourceDao {
...
@@ -98,4 +99,5 @@ public interface DmpSyncingDatasourceDao {
int
countDatasourceByName
(
@Param
(
"datasourceName"
)
String
datasourceName
,
@Param
(
"projectId"
)
String
projectId
);
int
countDatasourceByName
(
@Param
(
"datasourceName"
)
String
datasourceName
,
@Param
(
"projectId"
)
String
projectId
);
DmpSyncingDatasourceType
queryDatasourceTypeById
(
@Param
(
"datasourceTypeId"
)
String
datasourceTypeId
);
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/DmpSyncingDatasourceService.java
View file @
8a7d0cf1
...
@@ -69,4 +69,6 @@ public interface DmpSyncingDatasourceService {
...
@@ -69,4 +69,6 @@ public interface DmpSyncingDatasourceService {
JsonResult
queryGroupDatasourceType
()
throws
Exception
;
JsonResult
queryGroupDatasourceType
()
throws
Exception
;
JsonResult
addDatasourceInfo
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
;
JsonResult
addDatasourceInfo
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
;
JsonResult
testConnection
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
;
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/impl/DmpSyncingDatasourceServiceImpl.java
View file @
8a7d0cf1
...
@@ -4,14 +4,21 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,14 +4,21 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.jz.agent.service.DmpDsAgentService
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.common.utils.JsonMapper
;
import
com.jz.dmp.agent.DmpAgentResult
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DmpSyncingDatasourceReq
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.DmpSyncingDatasourceReq
;
import
com.jz.dmp.modules.dao.DmpProjectDao
;
import
com.jz.dmp.modules.dao.DmpSyncingDatasourceDao
;
import
com.jz.dmp.modules.dao.DmpSyncingDatasourceDao
;
import
com.jz.dmp.modules.model.DmpAgentDatasourceInfo
;
import
com.jz.dmp.modules.model.DmpProjectSystemInfo
;
import
com.jz.dmp.modules.model.DmpSyncingDatasource
;
import
com.jz.dmp.modules.model.DmpSyncingDatasource
;
import
com.jz.dmp.modules.model.DmpSyncingDatasourceType
;
import
com.jz.dmp.modules.service.DmpSyncingDatasourceService
;
import
com.jz.dmp.modules.service.DmpSyncingDatasourceService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -40,6 +47,12 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
...
@@ -40,6 +47,12 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
@Autowired
@Autowired
private
DmpSyncingDatasourceDao
dmpSyncingDatasourceDao
;
private
DmpSyncingDatasourceDao
dmpSyncingDatasourceDao
;
@Autowired
private
DmpProjectDao
dmpProjectDao
;
@Autowired
private
DmpDsAgentService
dmpDsAgentServiceImp
;
/**
/**
* 通过ID查询单条数据
* 通过ID查询单条数据
*
*
...
@@ -183,10 +196,62 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
...
@@ -183,10 +196,62 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
BeanUtils
.
copyProperties
(
saveBody
,
dsd
);
BeanUtils
.
copyProperties
(
saveBody
,
dsd
);
dsd
.
setCreateTime
(
new
Date
());
dsd
.
setCreateTime
(
new
Date
());
dsd
.
setDatasourceType
(
Integer
.
valueOf
(
saveBody
.
getDatasourceType
()));
dsd
.
setDatasourceType
(
Integer
.
valueOf
(
saveBody
.
getDatasourceType
()));
//数据源类型ID
dsd
.
setProjectId
(
Integer
.
valueOf
(
saveBody
.
getProjectId
()));
dsd
.
setProjectId
(
Integer
.
valueOf
(
saveBody
.
getProjectId
()));
dsd
.
setDataStatus
(
"1"
);
dsd
.
setDataStatus
(
"1"
);
dmpSyncingDatasourceDao
.
insert
(
dsd
);
dmpSyncingDatasourceDao
.
insert
(
dsd
);
return
new
JsonResult
(
dsd
);
return
new
JsonResult
(
dsd
);
}
}
/**
* 测试连通性
*
* @return
*/
@Override
public
JsonResult
testConnection
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
{
DmpAgentDatasourceInfo
ds
=
this
.
dsInfoDTO
(
saveBody
);
//查询数据源 对应的 数据库信息
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
testConnect
(
ds
);
//连接测试
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
return
new
JsonResult
(
rst
.
getCode
(),
rst
.
getMessage
());
}
else
{
rst
.
setResult
(
JsonMapper
.
fromJsonString
(
rst
.
getMessage
(),
Boolean
.
class
));
return
new
JsonResult
(
ResultCode
.
SUCCESS
,
rst
);
}
}
private
DmpAgentDatasourceInfo
dsInfoDTO
(
DmpSyncingDatasourceReq
body
)
{
//数据源类型ID去查询
DmpSyncingDatasourceType
type
=
dmpSyncingDatasourceDao
.
queryDatasourceTypeById
(
body
.
getDatasourceType
());
DmpAgentDatasourceInfo
ds
=
new
DmpAgentDatasourceInfo
();
ds
.
setDatasourceType
(
type
.
getDatasourceType
());
ds
.
setDatasourceName
(
body
.
getDatasourceName
());
ds
.
setDbName
(
body
.
getDbName
());
ds
.
setJdbcUrl
(
body
.
getJdbcUrl
());
ds
.
setUserName
(
body
.
getUserName
());
ds
.
setPassword
(
body
.
getPassword
());
ds
.
setDriverClassName
(
type
.
getDriverClassName
());
ds
.
setHost
(
body
.
getHost
());
ds
.
setPort
(
body
.
getPort
());
ds
.
setDelimiter
(
body
.
getDelimiter
());
ds
.
setProtocol
(
body
.
getProtocol
());
ds
.
setProjectId
(
body
.
getProjectId
()
+
""
);
ds
.
setAccessId
(
body
.
getAccessId
());
ds
.
setAccessKey
(
body
.
getAccessKey
());
ds
.
setIsHaveHeader
(
body
.
getIsHaveHeader
());
ds
.
setEndpoint
(
body
.
getEndpoint
());
ds
.
setDefaultFs
(
body
.
getDefaultFs
());
DmpProjectSystemInfo
info
=
dmpProjectDao
.
queryProjectSystemInfo
(
Long
.
valueOf
(
body
.
getProjectId
()));
ds
.
setKerberosIsenable
(
info
.
getKerberosIsenable
());
ds
.
setKerberosJaasConf
(
info
.
getKerberosJaasConf
());
ds
.
setKerberosKrb5Conf
(
info
.
getKerberosKrb5Conf
());
ds
.
setKerberosFqdn
(
info
.
getKerberosFqdn
());
ds
.
setHdfsDefaultConf
(
""
);
// info.getHdfsDefaultConf());
ds
.
setHdfsConfPath
(
""
);
// info.getHdfsConfPath());
ds
.
setHdfsAuthPath
(
body
.
getAccessKey
());
ds
.
setHdfsUserName
(
info
.
getHdfsUserName
());
ds
.
setHdfsSyncingPath
(
info
.
getHdfsSyncingPath
());
return
ds
;
}
}
}
\ No newline at end of file
src/main/resources/mapper/dmp/DmpSyncingDatasourceDao.xml
View file @
8a7d0cf1
...
@@ -313,4 +313,14 @@
...
@@ -313,4 +313,14 @@
and ds.project_id = #{projectId}
and ds.project_id = #{projectId}
</select>
</select>
<select
id=
"queryDatasourceTypeById"
parameterType=
"map"
resultType=
"dmpSyncingDatasourceType"
>
select
datasource as datasourceName,
id ,
datasource_type as datasourceType,
driver_class_name as driverClassName
from dmp_syncing_datasource_type
where id=#{datasourceTypeId}
</select>
</mapper>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment