Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-cmdexectool
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-cmdexectool
Commits
0adfe38d
Commit
0adfe38d
authored
Mar 10, 2021
by
sml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码提交(文件生成根据execId)
parent
fbb66a81
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
10 deletions
+30
-10
ApiApplication.java
src/main/java/com/jz/dmp/cmdexectool/ApiApplication.java
+3
-2
SqlParameters.java
.../cmdexectool/scheduler/common/task/sql/SqlParameters.java
+3
-0
TaskExecutionContext.java
...xectool/scheduler/server/entity/TaskExecutionContext.java
+13
-0
WaterdropCommandExecutor.java
...cheduler/server/worker/task/WaterdropCommandExecutor.java
+2
-1
SqlTask.java
...cmdexectool/scheduler/server/worker/task/sql/SqlTask.java
+2
-2
ProcessService.java
...cmdexectool/scheduler/service/process/ProcessService.java
+5
-3
SQLCommandExecutorTest.java
...z/cmdexectool/test/task/shell/SQLCommandExecutorTest.java
+1
-1
ShellCommandExecutorTest.java
...cmdexectool/test/task/shell/ShellCommandExecutorTest.java
+1
-1
No files found.
src/main/java/com/jz/dmp/cmdexectool/ApiApplication.java
View file @
0adfe38d
...
@@ -31,11 +31,12 @@ public class ApiApplication implements HealthIndicator {
...
@@ -31,11 +31,12 @@ public class ApiApplication implements HealthIndicator {
}
}
String
jobId
=
args
[
1
];
String
jobId
=
args
[
1
];
boolean
isSingle
=
Boolean
.
parseBoolean
(
args
[
2
]);
boolean
isSingle
=
Boolean
.
parseBoolean
(
args
[
2
]);
String
execId
=
args
[
3
];
logger
.
info
(
"启动参数,taskId【{}】,jobId【{}】,isSingle【{}】
"
,
taskId
,
jobId
,
isSingle
);
logger
.
info
(
"启动参数,taskId【{}】,jobId【{}】,isSingle【{}】
, execId【{}】"
,
taskId
,
jobId
,
isSingle
,
execId
);
ProcessService
processService
=
ApplicationContextUtil
.
getBean
(
ProcessService
.
class
);
ProcessService
processService
=
ApplicationContextUtil
.
getBean
(
ProcessService
.
class
);
processService
.
taskStart
(
taskId
,
jobId
,
isSingle
);
processService
.
taskStart
(
taskId
,
jobId
,
isSingle
,
execId
);
long
cost
=
System
.
currentTimeMillis
()
-
start
;
long
cost
=
System
.
currentTimeMillis
()
-
start
;
logger
.
info
(
" started status: {}, cost: {}"
,
"SUCCESS!"
,
cost
);
logger
.
info
(
" started status: {}, cost: {}"
,
"SUCCESS!"
,
cost
);
...
...
src/main/java/com/jz/dmp/cmdexectool/scheduler/common/task/sql/SqlParameters.java
View file @
0adfe38d
...
@@ -356,9 +356,12 @@ public class SqlParameters extends AbstractParameters {
...
@@ -356,9 +356,12 @@ public class SqlParameters extends AbstractParameters {
JSONObject
hdfsObj
=
scriptObj
.
getJSONObject
(
"hdfs"
);
JSONObject
hdfsObj
=
scriptObj
.
getJSONObject
(
"hdfs"
);
String
hdfsDir
=
hdfsObj
.
getString
(
"hdfsDir"
);
String
hdfsDir
=
hdfsObj
.
getString
(
"hdfsDir"
);
hdfsDir
=
hdfsDir
+
"/"
+
System
.
currentTimeMillis
();
Map
<
String
,
String
>
hdfsModel
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
hdfsModel
=
new
HashMap
<
String
,
String
>();
hdfsModel
.
put
(
"source_table_name"
,
"t"
);
hdfsModel
.
put
(
"source_table_name"
,
"t"
);
hdfsModel
.
put
(
"path"
,
hdfsDir
);
hdfsModel
.
put
(
"path"
,
hdfsDir
);
hdfsModel
.
put
(
"save_mode"
,
"overwrite"
);
sink
=
FreeMarkerUtils
.
freemakerJson
(
CommConstant
.
WATERDROP_FTL_SINK_HDFS
,
hdfsModel
,
freeMarkerConfig
);
sink
=
FreeMarkerUtils
.
freemakerJson
(
CommConstant
.
WATERDROP_FTL_SINK_HDFS
,
hdfsModel
,
freeMarkerConfig
);
}
}
...
...
src/main/java/com/jz/dmp/cmdexectool/scheduler/server/entity/TaskExecutionContext.java
View file @
0adfe38d
...
@@ -230,6 +230,11 @@ public class TaskExecutionContext implements Serializable {
...
@@ -230,6 +230,11 @@ public class TaskExecutionContext implements Serializable {
private
AbstractParameters
parameters
;
private
AbstractParameters
parameters
;
/**
* azkaban 执行id
*/
private
String
execId
;
public
TaskExecutionContext
()
{}
public
TaskExecutionContext
()
{}
/**
/**
...
@@ -594,6 +599,14 @@ public class TaskExecutionContext implements Serializable {
...
@@ -594,6 +599,14 @@ public class TaskExecutionContext implements Serializable {
this
.
parameters
=
parameters
;
this
.
parameters
=
parameters
;
}
}
public
String
getExecId
()
{
return
execId
;
}
public
void
setExecId
(
String
execId
)
{
this
.
execId
=
execId
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"TaskExecutionContext{"
return
"TaskExecutionContext{"
...
...
src/main/java/com/jz/dmp/cmdexectool/scheduler/server/worker/task/WaterdropCommandExecutor.java
View file @
0adfe38d
...
@@ -60,9 +60,10 @@ public class WaterdropCommandExecutor extends AbstractCommandExecutor {
...
@@ -60,9 +60,10 @@ public class WaterdropCommandExecutor extends AbstractCommandExecutor {
@Override
@Override
protected
String
buildCommandFilePath
()
{
protected
String
buildCommandFilePath
()
{
// command file
// command file
return
String
.
format
(
"%s/%s.%s"
return
String
.
format
(
"%s/%s
_%s
.%s"
,
taskExecutionContext
.
getExecutePath
()
,
taskExecutionContext
.
getExecutePath
()
,
taskExecutionContext
.
getTaskAppId
()
,
taskExecutionContext
.
getTaskAppId
()
,
taskExecutionContext
.
getExecId
()
,
OSUtils
.
isWindows
()
?
"bat"
:
"command"
);
,
OSUtils
.
isWindows
()
?
"bat"
:
"command"
);
}
}
...
...
src/main/java/com/jz/dmp/cmdexectool/scheduler/server/worker/task/sql/SqlTask.java
View file @
0adfe38d
...
@@ -187,8 +187,8 @@ public class SqlTask extends AbstractTask {
...
@@ -187,8 +187,8 @@ public class SqlTask extends AbstractTask {
//String fileName = String.format("%s/%s_node.%s", taskExecutionContext.getExecutePath(),
//String fileName = String.format("%s/%s_node.%s", taskExecutionContext.getExecutePath(),
// taskExecutionContext.getTaskAppId(), OSUtils.isWindows() ? "bat" : "sh");
// taskExecutionContext.getTaskAppId(), OSUtils.isWindows() ? "bat" : "sh");
String
fileName
=
String
.
format
(
"%s/%s.%s"
,
taskExecutionContext
.
getExecutePath
(),
String
fileName
=
String
.
format
(
"%s/%s
_application_%s
.%s"
,
taskExecutionContext
.
getExecutePath
(),
"application"
,
"conf"
);
taskExecutionContext
.
getTaskAppId
(),
taskExecutionContext
.
getExecId
()
,
"conf"
);
Path
path
=
new
File
(
fileName
).
toPath
();
Path
path
=
new
File
(
fileName
).
toPath
();
...
...
src/main/java/com/jz/dmp/cmdexectool/scheduler/service/process/ProcessService.java
View file @
0adfe38d
...
@@ -80,9 +80,9 @@ public class ProcessService {
...
@@ -80,9 +80,9 @@ public class ProcessService {
* @Title: taskStart @Description: TODO(启动task) @param 参数 @return void
* @Title: taskStart @Description: TODO(启动task) @param 参数 @return void
* 返回类型 @throws
* 返回类型 @throws
*/
*/
public
void
taskStart
(
Integer
taskId
,
String
jobId
,
boolean
isSingle
)
{
public
void
taskStart
(
Integer
taskId
,
String
jobId
,
boolean
isSingle
,
String
execId
)
{
try
{
try
{
TaskExecutionContext
taskExecutionContext
=
findTaskExecutionContextById
(
taskId
,
jobId
,
isSingle
);
TaskExecutionContext
taskExecutionContext
=
findTaskExecutionContextById
(
taskId
,
jobId
,
isSingle
,
execId
);
AbstractTask
task
=
TaskManager
.
newTask
(
taskExecutionContext
);
AbstractTask
task
=
TaskManager
.
newTask
(
taskExecutionContext
);
// AbstractTask task = null;
// AbstractTask task = null;
...
@@ -118,7 +118,7 @@ public class ProcessService {
...
@@ -118,7 +118,7 @@ public class ProcessService {
* isSingle @param @return 参数 @return TaskExecutionContext
* isSingle @param @return 参数 @return TaskExecutionContext
* 返回类型 @throws
* 返回类型 @throws
*/
*/
public
TaskExecutionContext
findTaskExecutionContextById
(
Integer
taskId
,
String
jobId
,
boolean
isSingle
)
public
TaskExecutionContext
findTaskExecutionContextById
(
Integer
taskId
,
String
jobId
,
boolean
isSingle
,
String
execId
)
throws
Exception
{
throws
Exception
{
TaskExecutionContext
taskExecutionContext
=
new
TaskExecutionContext
();
TaskExecutionContext
taskExecutionContext
=
new
TaskExecutionContext
();
// 获取任务数据,并获取job json,并组装TaskInstance
// 获取任务数据,并获取job json,并组装TaskInstance
...
@@ -135,6 +135,8 @@ public class ProcessService {
...
@@ -135,6 +135,8 @@ public class ProcessService {
}
}
taskExecutionContext
=
dto2execcontext
(
dmpDevelopTaskDto
,
jobId
);
taskExecutionContext
=
dto2execcontext
(
dmpDevelopTaskDto
,
jobId
);
//设置azkaban执行ID
taskExecutionContext
.
setExecId
(
execId
);
return
taskExecutionContext
;
return
taskExecutionContext
;
}
}
...
...
src/test/java/com/jz/cmdexectool/test/task/shell/SQLCommandExecutorTest.java
View file @
0adfe38d
...
@@ -92,7 +92,7 @@ public class SQLCommandExecutorTest {
...
@@ -92,7 +92,7 @@ public class SQLCommandExecutorTest {
//@Test
//@Test
public
void
test
()
{
public
void
test
()
{
try
{
try
{
TaskExecutionContext
taskExecutionContext
=
processService
.
findTaskExecutionContextById
(
460
,
null
,
true
);
TaskExecutionContext
taskExecutionContext
=
processService
.
findTaskExecutionContextById
(
460
,
null
,
true
,
"2"
);
AbstractTask
task
=
TaskManager
.
newTask
(
taskExecutionContext
);
AbstractTask
task
=
TaskManager
.
newTask
(
taskExecutionContext
);
logger
.
info
(
"task info : {}"
,
task
);
logger
.
info
(
"task info : {}"
,
task
);
...
...
src/test/java/com/jz/cmdexectool/test/task/shell/ShellCommandExecutorTest.java
View file @
0adfe38d
...
@@ -74,7 +74,7 @@ public class ShellCommandExecutorTest {
...
@@ -74,7 +74,7 @@ public class ShellCommandExecutorTest {
//@Test
//@Test
public
void
test
()
{
public
void
test
()
{
try
{
try
{
TaskExecutionContext
taskExecutionContext
=
processService
.
findTaskExecutionContextById
(
473
,
null
,
true
);
TaskExecutionContext
taskExecutionContext
=
processService
.
findTaskExecutionContextById
(
473
,
null
,
true
,
"1"
);
AbstractTask
task
=
TaskManager
.
newTask
(
taskExecutionContext
);
AbstractTask
task
=
TaskManager
.
newTask
(
taskExecutionContext
);
//AbstractTask task = null;
//AbstractTask task = null;
...
...
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