增加redis测试 连接操作
parent
6669076034
commit
7ec90b2673
|
@ -18,13 +18,23 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- oracle 数据源连接-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle.database.jdbc</groupId>
|
||||||
|
<artifactId>ojdbc8</artifactId>
|
||||||
|
<version>19.3.0.0</version> <!-- 请使用适合你的Oracle数据库版本的驱动 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>redis.clients</groupId>
|
<groupId>redis.clients</groupId>
|
||||||
<artifactId>jedis</artifactId>
|
<artifactId>jedis</artifactId>
|
||||||
<version>2.9.0</version>
|
<version>2.9.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-core</artifactId>
|
<artifactId>cloud-common-core</artifactId>
|
||||||
|
|
|
@ -14,10 +14,11 @@ public class DataValueController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataValueService dataValueService;
|
private DataValueService dataValueService;
|
||||||
|
|
||||||
//获取字段值
|
|
||||||
|
//获取字段值 供任务调用
|
||||||
@PostMapping("/findTableValue")
|
@PostMapping("/findTableValue")
|
||||||
public Result findTableValue(@RequestParam("basicId") Long basicId,@RequestParam("sql") String sql) {
|
public Result findTableValue(@RequestParam("basicId") Long basicId,@RequestParam("sql") String sql) {
|
||||||
List<List<DataValue>> list= dataValueService.findTableValue(basicId,sql);
|
List<List<DataValue>> list= dataValueService.findTableValue(basicId,sql);
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +30,6 @@ public class DataValueController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,14 @@ public class SourceController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/connectionTest")
|
@PostMapping("/connectionTest")
|
||||||
public Result connectionTest(@RequestBody Source source) throws ServletException {
|
public Result connectionTest(@RequestBody Source source) throws ServletException {
|
||||||
return toAjax(sourceService.connectionTest(source));
|
if(source.getDatabaseType().equals("mysql")){
|
||||||
|
return toAjax(sourceService.connectionTest(source));
|
||||||
|
}
|
||||||
|
if(source.getDatabaseType().equals("redis")){
|
||||||
|
return toAjax(sourceService.connectionRedisTest(source));
|
||||||
|
}
|
||||||
|
return toAjax(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,6 @@ public interface AccreditMapper {
|
||||||
|
|
||||||
List<Integer> findDeptTableIds(@Param("deptId") Long deptId);
|
List<Integer> findDeptTableIds(@Param("deptId") Long deptId);
|
||||||
|
|
||||||
Accredit findAccreditBasic(@Param("tableId") Long tableId);
|
// Accredit findAccreditBasic(@Param("tableId") Long tableId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,8 @@ public interface SourceService extends IService<Source> {
|
||||||
int structure(Source source);
|
int structure(Source source);
|
||||||
|
|
||||||
int redis(Source source);
|
int redis(Source source);
|
||||||
|
|
||||||
|
int connectionRedisTest(Source source);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.cloud.etl.service.impl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.muyu.cloud.etl.mapper.SourceMapper;
|
import com.muyu.cloud.etl.mapper.SourceMapper;
|
||||||
import com.muyu.cloud.etl.service.SourceService;
|
import com.muyu.cloud.etl.service.SourceService;
|
||||||
import com.muyu.cloud.etl.service.StructureService;
|
import com.muyu.cloud.etl.service.StructureService;
|
||||||
|
@ -20,9 +21,8 @@ import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.JedisPoolConfig;
|
import redis.clients.jedis.JedisPoolConfig;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
@ -208,30 +208,67 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int redis(Source source) {
|
public int redis(Source source) {
|
||||||
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
||||||
jedisPoolConfig.setMaxTotal(100);
|
jedisPoolConfig.setMaxTotal(Math.toIntExact(source.getMaxLinkNum()));
|
||||||
jedisPoolConfig.setMaxIdle(100);
|
jedisPoolConfig.setMaxIdle(Math.toIntExact(source.getMaxLinkNum()));
|
||||||
jedisPoolConfig.setMaxWaitMillis(5);
|
jedisPoolConfig.setMaxWaitMillis(source.getMaxWaitTime());
|
||||||
|
|
||||||
JedisPool jedisPool = new JedisPool(jedisPoolConfig, "172.13.1.1", 6379, 3000, null);
|
JedisPool jedisPool = new JedisPool(jedisPoolConfig, source.getHost(), Integer.parseInt(source.getPort()), 3000, null);
|
||||||
Jedis jedis = jedisPool.getResource();
|
Jedis jedis = jedisPool.getResource();
|
||||||
|
|
||||||
|
HashMap<String, String> stringStringHashMap = new HashMap<>();
|
||||||
Set<String> keys = jedis.keys("*");
|
Set<String> keys = jedis.keys("*");
|
||||||
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
String value = jedis.get(key);
|
String value = jedis.get(key);
|
||||||
|
if (value != null) {
|
||||||
String[] split = value.split(",");
|
System.out.println(value);
|
||||||
for (String s : split) {
|
stringStringHashMap.put(key, value);
|
||||||
System.out.println(s);
|
// 反序列化逻辑
|
||||||
|
// Map<String, String> data = null;
|
||||||
|
// data.put(key,value);
|
||||||
|
// processData(key,data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int connectionRedisTest(Source source) {
|
||||||
|
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
||||||
|
jedisPoolConfig.setMaxTotal(Math.toIntExact(source.getMaxLinkNum()));
|
||||||
|
jedisPoolConfig.setMaxIdle(Math.toIntExact(source.getMaxLinkNum()));
|
||||||
|
jedisPoolConfig.setMaxWaitMillis(source.getMaxWaitTime());
|
||||||
|
JedisPool jedisPool = new JedisPool(jedisPoolConfig, source.getHost(), Integer.parseInt(source.getPort()), 3000, null);
|
||||||
|
Jedis jedis = jedisPool.getResource();
|
||||||
|
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
|
||||||
|
Set<String> keys = jedis.keys("*");
|
||||||
|
for (String key : keys) {
|
||||||
|
String s = jedis.get(key);
|
||||||
|
if(s!=null){
|
||||||
|
System.out.println(s);
|
||||||
|
objectObjectHashMap.put(key, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processData(String key, Map<String, String> data) {
|
||||||
|
// 处理数据的逻辑
|
||||||
|
System.out.println("Key: " + key + ", Data: " + data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void syncData(Connection conn, String databaseName, TableInfo table) throws SQLException {
|
public void syncData(Connection conn, String databaseName, TableInfo table) throws SQLException {
|
||||||
ExecutorService threadPool = Executors.newCachedThreadPool();
|
ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<result property="parentId" column="parent_id"/>
|
<result property="parentId" column="parent_id"/>
|
||||||
<result property="ancestors" column="ancestors"/>
|
<result property="ancestors" column="ancestors"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="AccreditUserRep" type="com.muyu.domain.rep.AccreditUserRep">
|
<resultMap id="AccreditUserRep" type="com.muyu.domain.rep.AccreditUserRep">
|
||||||
<result property="userId" column="user_id"/>
|
<result property="userId" column="user_id"/>
|
||||||
<result property="userName" column="user_name"/>
|
<result property="userName" column="user_name"/>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue