Commit 02cc880a authored by wenmo's avatar wenmo

优化pom和日志以及升级springboot

parent a5052c91
......@@ -66,7 +66,7 @@
</exclusion>
</exclusions>
</dependency>
<!--<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<exclusions>
......@@ -75,18 +75,6 @@
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
......@@ -133,11 +121,11 @@
<groupId>com.dlink</groupId>
<artifactId>dlink-gateway</artifactId>
</dependency>
<!--<dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-metadata-mysql</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>-->
<version>0.5.0</version>
</dependency>
<!--<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-yarn_2.11</artifactId>
......
......@@ -13,6 +13,8 @@ import com.dlink.job.JobConfig;
import com.dlink.job.JobManager;
import com.dlink.job.JobResult;
import com.dlink.mapper.TaskMapper;
import com.dlink.metadata.driver.Driver;
import com.dlink.metadata.result.JdbcSelectResult;
import com.dlink.model.*;
import com.dlink.service.*;
import com.dlink.utils.CustomStringJavaCompiler;
......@@ -20,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
......@@ -43,7 +46,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Autowired
private JarService jarService;
@Autowired
private StudioService studioService;
private DataBaseService dataBaseService;
@Value("${spring.datasource.driver-class-name}")
private String driver;
......@@ -63,7 +66,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Task task = this.getTaskInfoById(id);
Asserts.checkNull(task, Tips.TASK_NOT_EXIST);
if(Dialect.isSql(task.getDialect())){
return studioService.executeCommonSql(SqlDTO.build(task.getStatement(),
return executeCommonSql(SqlDTO.build(task.getStatement(),
task.getDatabaseId(),null));
}
JobConfig config = buildJobConfig(task);
......@@ -75,6 +78,38 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
}
}
private JobResult executeCommonSql(SqlDTO sqlDTO) {
JobResult result = new JobResult();
result.setStatement(sqlDTO.getStatement());
result.setStartTime(LocalDateTime.now());
if(Asserts.isNull(sqlDTO.getDatabaseId())){
result.setSuccess(false);
result.setError("请指定数据源");
result.setEndTime(LocalDateTime.now());
return result;
}else{
DataBase dataBase = dataBaseService.getById(sqlDTO.getDatabaseId());
if(Asserts.isNull(dataBase)){
result.setSuccess(false);
result.setError("数据源不存在");
result.setEndTime(LocalDateTime.now());
return result;
}
Driver driver = Driver.build(dataBase.getDriverConfig()).connect();
JdbcSelectResult selectResult = driver.executeSql(sqlDTO.getStatement(),sqlDTO.getMaxRowNum());
driver.close();
result.setResult(selectResult);
if(selectResult.isSuccess()){
result.setSuccess(true);
}else{
result.setSuccess(false);
result.setError(selectResult.getError());
}
result.setEndTime(LocalDateTime.now());
return result;
}
}
private boolean isJarTask(Task task){
return (GatewayType.YARN_APPLICATION.equalsValue(task.getType())||GatewayType.KUBERNETES_APPLICATION.equalsValue(task.getType()))&&Asserts.isNotNull(task.getJarId());
}
......
......@@ -16,6 +16,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- `provided` for product environment ,`compile` for dev environment -->
<scope.runtime>provided</scope.runtime>
</properties>
<dependencies>
......@@ -70,5 +72,10 @@
<artifactId>dlink-gateway</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-hadoop</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -31,14 +31,14 @@
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot-dependencies.version>2.3.8.RELEASE</spring-boot-dependencies.version>
<spring-boot-dependencies.version>2.6.3</spring-boot-dependencies.version>
<hutool.version>5.1.4</hutool.version>
<druid-starter>1.2.8</druid-starter>
<mybatis-plus-boot-starter.version>3.4.0</mybatis-plus-boot-starter.version>
<lombok.version>1.18.16</lombok.version>
<jackjson.version>2.11.4</jackjson.version>
<guava.version>21.0</guava.version>
<log4j.version>2.17.1</log4j.version>
<!-- <log4j.version>2.17.1</log4j.version>-->
<mysql-connector-java.version>8.0.22</mysql-connector-java.version>
<ojdbc8.version>12.2.0.1</ojdbc8.version>
<clickhouse.version>0.2.6</clickhouse.version>
......@@ -102,7 +102,7 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
......@@ -111,12 +111,12 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
</dependency>-->
<!--<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.30</version>
</dependency>
</dependency>-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment