feat 添加Skywalking依赖
parent
2eb21c3906
commit
330110f419
|
@ -52,6 +52,19 @@
|
|||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- skywalking 整合 logback -->
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>apm-toolkit-logback-1.x</artifactId>
|
||||
<version>8.16.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>apm-toolkit-trace</artifactId>
|
||||
<version>8.16.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.muyu.source.client.config;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.connection.service.ConnectionPoolManagement;
|
||||
import com.muyu.source.client.pool.BasePool;
|
||||
import com.muyu.source.client.pool.MysqlPool;
|
||||
import com.muyu.source.client.pool.confilg.MysqlPoolConfig;
|
||||
import com.muyu.source.client.pool.dto.SysDataSource;
|
||||
import com.muyu.source.domain.Kvt;
|
||||
import com.muyu.source.remote.RemoteDataManagerService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
@ -9,6 +12,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -29,62 +38,62 @@ public class KvtClientRunner implements ApplicationRunner {
|
|||
public void run(ApplicationArguments args) {
|
||||
|
||||
|
||||
Result<List<Kvt>> list = remoteDataManagerService.selectKvt();
|
||||
List<Kvt> data = list.getData();
|
||||
Result<List<Kvt>> selectKvt = remoteDataManagerService.selectKvt();
|
||||
List<Kvt> data = selectKvt.getData();
|
||||
|
||||
if(data != null) {
|
||||
ConnectionPoolManagement.init(data);
|
||||
} else {
|
||||
log.warn("数据源为空");
|
||||
// if(data != null) {
|
||||
// ConnectionPoolManagement.init(data);
|
||||
// } else {
|
||||
// log.warn("数据源为空");
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
List<SysDataSource> aa = new ArrayList<>();
|
||||
HashMap<String, Connection> map = new HashMap<>();
|
||||
data.forEach(kvt -> {
|
||||
|
||||
MysqlPoolConfig build = MysqlPoolConfig.builder()
|
||||
.id(String.valueOf(kvt.getId()))
|
||||
.ip(kvt.getHost())
|
||||
.port(kvt.getPort())
|
||||
.databaseName(kvt.getDatabaseName())
|
||||
.param(kvt.getConnectionParam())
|
||||
.initTotal(Math.toIntExact(kvt.getInitNum()))
|
||||
.maxTotal(Math.toIntExact(kvt.getMaxNum()))
|
||||
.maxWaitTimes(kvt.getMaxWaitTime())
|
||||
.userName(kvt.getUsername())
|
||||
.password(kvt.getPassword())
|
||||
.driverName("com.mysql.cj.jdbc.Driver")
|
||||
.build();
|
||||
BasePool<Connection> mysqlPool = new MysqlPool(build);
|
||||
|
||||
log.info("初始化开始");
|
||||
|
||||
mysqlPool.init();
|
||||
int initNum = build.getInitTotal();
|
||||
for (int i = 0; i < initNum; i++) {
|
||||
Connection connection = mysqlPool.creatConnection();
|
||||
map.put(String.valueOf(i), connection);
|
||||
mysqlPool.returnConn(connection);
|
||||
}
|
||||
log.info("-------------------------");
|
||||
mysqlPool.close();
|
||||
log.info("map:{}",map);
|
||||
});
|
||||
Connection connection = map.get("1");
|
||||
Statement statement =null;
|
||||
try{
|
||||
statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery("SHOW Tables");
|
||||
while (resultSet.next()){
|
||||
String name = resultSet.getString(1);
|
||||
log.info("name:{}",name);
|
||||
}
|
||||
log.info("连接成功");
|
||||
}catch (SQLException e){
|
||||
log.error("sql错误");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// List<SysDataSource> list = new ArrayList<>();
|
||||
// HashMap<String, Object> hashMap = new HashMap<>();
|
||||
// data.forEach(kvt -> {
|
||||
//
|
||||
// MysqlPoolConfig build = MysqlPoolConfig.builder()
|
||||
// .id(String.valueOf(kvt.getId()))
|
||||
// .ip(kvt.getHost())
|
||||
// .port(kvt.getPort())
|
||||
// .databaseName(kvt.getDatabaseName())
|
||||
// .param(kvt.getConnectionParam())
|
||||
// .initTotal(Math.toIntExact(kvt.getInitNum()))
|
||||
// .maxTotal(Math.toIntExact(kvt.getMaxNum()))
|
||||
// .maxWaitTimes(kvt.getMaxWaitTime())
|
||||
// .userName(kvt.getUsername())
|
||||
// .password(kvt.getPassword())
|
||||
// .driverName("com.mysql.cj.jdbc.Driver")
|
||||
// .build();
|
||||
// BasePool<Connection> mysqlPool = new MysqlPool(build);
|
||||
//
|
||||
// log.info("初始化开始");
|
||||
//
|
||||
// mysqlPool.init();
|
||||
// int initNum = build.getInitTotal();
|
||||
// for (int i = 0; i < initNum; i++) {
|
||||
// Connection connection = mysqlPool.creatConnection();
|
||||
// map.put(String.valueOf(i), connection);
|
||||
// mysqlPool.returnConn(connection);
|
||||
// }
|
||||
// log.info("-------------------------");
|
||||
// mysqlPool.close();
|
||||
// log.info("map:{}",map);
|
||||
// });
|
||||
// Connection connection = map.get("1");
|
||||
// Statement statement =null;
|
||||
// try{
|
||||
// statement = connection.createStatement();
|
||||
// ResultSet resultSet = statement.executeQuery("SHOW Tables");
|
||||
// while (resultSet.next()){
|
||||
// String name = resultSet.getString(1);
|
||||
// log.info("name:{}",name);
|
||||
// }
|
||||
// log.info("连接成功");
|
||||
// }catch (SQLException e){
|
||||
// log.error("sql错误");
|
||||
// }
|
||||
|
||||
|
||||
// SysDataSource sysDataSource = new SysDataSource();
|
||||
|
@ -105,17 +114,17 @@ public class KvtClientRunner implements ApplicationRunner {
|
|||
// sysDataSource.setRemark("测试");
|
||||
// sysDataSource.setIsInit("Y");
|
||||
//
|
||||
// list.add(sysDataSource);
|
||||
// aa.add(sysDataSource);
|
||||
//
|
||||
// list.forEach(sysDataSoure -> {
|
||||
// MysqlPoolConfig build = MysqlPoolConfig.builder()
|
||||
// .id(sysDataSoure.getId())
|
||||
// .id(String.valueOf(sysDataSoure.getId()))
|
||||
// .ip(sysDataSoure.getHost())
|
||||
// .port(sysDataSoure.getPort())
|
||||
// .databaseName(sysDataSoure.getDatabaseName())
|
||||
// .param(sysDataSoure.getConnectionParam())
|
||||
// .initTotal(sysDataSoure.getInitNum())
|
||||
// .maxTotal(sysDataSoure.getMaxNum())
|
||||
// .initTotal(Math.toIntExact(sysDataSoure.getInitNum()))
|
||||
// .maxTotal(Math.toIntExact(sysDataSoure.getMaxNum()))
|
||||
// .maxWaitTimes(sysDataSoure.getMaxWaitTime())
|
||||
// .userName(sysDataSoure.getUsername())
|
||||
// .password(sysDataSoure.getPassword())
|
||||
|
@ -126,7 +135,7 @@ public class KvtClientRunner implements ApplicationRunner {
|
|||
// log.info("初始化开始");
|
||||
//
|
||||
// mysqlPool.init();
|
||||
// int initNum = sysDataSoure.getInitNum();
|
||||
// int initNum = Math.toIntExact(sysDataSoure.getInitNum());
|
||||
// for (int i = 0; i < initNum; i++) {
|
||||
// Connection connection = mysqlPool.creatConnection();
|
||||
// map.put(String.valueOf(i), connection);
|
||||
|
@ -136,16 +145,15 @@ public class KvtClientRunner implements ApplicationRunner {
|
|||
// mysqlPool.close();
|
||||
// log.info("map:{}",map);
|
||||
// });
|
||||
|
||||
//
|
||||
// Connection connection = map.get("1");
|
||||
// Statement statement =null;
|
||||
// try{
|
||||
// statement = connection.createStatement();
|
||||
// ResultSet resultSet = statement.executeQuery("select * from user");
|
||||
// ResultSet resultSet = statement.executeQuery("SELECT Table");
|
||||
// while (resultSet.next()){
|
||||
// int id = resultSet.getInt(1);
|
||||
// String name = resultSet.getString(2);
|
||||
// log.info("id:{},name:{}",id,name);
|
||||
// String name = resultSet.getString(1);
|
||||
// log.info("name:{}",name);
|
||||
// }
|
||||
// log.info("连接成功");
|
||||
// }catch (SQLException e){
|
||||
|
|
|
@ -2,12 +2,18 @@ package com.muyu.engine.client;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineVersion;
|
||||
import com.muyu.engine.remote.RuleEngineManangerService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
||||
import javax.tools.*;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -25,7 +31,80 @@ public class EngClientRunner implements ApplicationRunner {
|
|||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Result<List<RuleEngine>> listResult = ruleEngineManangerService.selectRuleEngine();
|
||||
System.out.println("sdsssssssssssssssssssssssss"+listResult.getData());
|
||||
|
||||
// Result<List<RuleEngineVersion>> result = ruleEngineManangerService.RuleEngineVersionList(new RuleEngineVersionQueryReq());
|
||||
// List<RuleEngineVersion> data = result.getData();
|
||||
// System.out.println("result = " + result);
|
||||
// data.forEach(ruleEngineVersion -> {
|
||||
// //如何判断指定目录下是否有.java文件
|
||||
// this.writeCodeAdd(ruleEngineVersion);
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
private String url ="D:\\work\\zglkh\\cloud-server\\muyu-modules\\muyu-rule-engine\\muyu-rule-engine-common\\src\\main\\java\\com\\muyu\\engine\\java\\";
|
||||
|
||||
public void writeCodeAdd(RuleEngineVersion ruleEngineVersion) {
|
||||
try {
|
||||
String originalVersionCode = ruleEngineVersion.getVersionCode();
|
||||
// 提取第一个字符并转换为大写
|
||||
String firstCharUpperCase = originalVersionCode.substring(0, 1).toUpperCase();
|
||||
// 截取从第二个字符到末尾的子串
|
||||
String restOfVersionCode = originalVersionCode.substring(1);
|
||||
// 将首字母大写和剩余部分拼接起来
|
||||
String newVersionCode = firstCharUpperCase + restOfVersionCode;
|
||||
|
||||
String className = newVersionCode;
|
||||
|
||||
//编译
|
||||
String path=url+className+".java";
|
||||
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(path));
|
||||
// 写入内容
|
||||
bufferedWriter.write(ruleEngineVersion.getCodeIng());
|
||||
// 关闭流
|
||||
bufferedWriter.close();
|
||||
//编译内容
|
||||
String content = ruleEngineVersion.getCodeIng();
|
||||
// 指定输出目录
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
// 获取编译器
|
||||
try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
|
||||
// 创建一个内存中的源文件
|
||||
JavaFileObject sourceFileObject = new JavaSourceFromString(className, content);
|
||||
|
||||
// 编译选项
|
||||
Iterable<String> options = Arrays.asList("-d", url);
|
||||
// 编译源代码
|
||||
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, options, null, Arrays.asList(sourceFileObject));
|
||||
boolean success = task.call();
|
||||
|
||||
if (success) {
|
||||
System.out.println("编译成功");
|
||||
} else {
|
||||
System.out.println("编译失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
//内存中的源文件
|
||||
static class JavaSourceFromString extends SimpleJavaFileObject {
|
||||
final String code;
|
||||
// 构造方法
|
||||
JavaSourceFromString(String name, String code) {
|
||||
// URI
|
||||
super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
|
||||
this.code = code;
|
||||
}
|
||||
// 返回源代码
|
||||
@Override
|
||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.muyu.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据模型 DataModel
|
||||
|
@ -9,6 +12,9 @@ import lombok.Data;
|
|||
* on 2024/5/8
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataModel {
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.muyu.scope.model;
|
||||
|
||||
import com.muyu.model.DataModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**数据处理模型
|
||||
* @Author: DongZeLiang
|
||||
|
@ -10,6 +13,9 @@ import lombok.Data;
|
|||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class DataProcessModel {
|
||||
|
||||
private DataModel dataModel;
|
||||
|
|
|
@ -32,4 +32,8 @@ import java.util.List;
|
|||
public interface RuleEngineManangerService {
|
||||
@PostMapping("/selectRuleEngine")
|
||||
public Result<List<RuleEngine>> selectRuleEngine();
|
||||
}
|
||||
//
|
||||
// @GetMapping("/RuleEngineVersionList")
|
||||
// public Result<List<RuleEngineVersion>> RuleEngineVersionList(RuleEngineVersionQueryReq ruleEngineVersionQueryReq) ;
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@ public class RuleEngineManangerServiceFactory implements FallbackFactory<RuleEng
|
|||
public Result<List<RuleEngine>> selectRuleEngine() {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Result<List<RuleEngineVersion>> RuleEngineVersionList(RuleEngineVersionQueryReq ruleEngineVersionQueryReq) {
|
||||
// return Result.error(cause.getMessage());
|
||||
// }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,8 +116,21 @@ private RuleEngineService ruleEngineService;
|
|||
log.info("编码保存成功");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result test(EngineVersionReq engineVersionReq) {
|
||||
if (engineVersionReq.getLevel().equals("data-field")){
|
||||
|
||||
}
|
||||
if (engineVersionReq.getLevel().equals("data-set")){
|
||||
|
||||
}
|
||||
if (engineVersionReq.getLevel().equals("recording")){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue