Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xxl-job-admin-client
Overview
Overview
Details
Activity
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
黄营
xxl-job-admin-client
Commits
eae6585f
Commit
eae6585f
authored
Jun 30, 2024
by
ys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
7fd38335
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
XxlJobAdminClient.java
src/main/java/com/tbyf/util/XxlJobAdminClient.java
+46
-0
XxlJobAdminClientTest.java
src/test/java/com/tbyf/util/XxlJobAdminClientTest.java
+6
-0
No files found.
src/main/java/com/tbyf/util/XxlJobAdminClient.java
View file @
eae6585f
...
...
@@ -107,6 +107,7 @@ public class XxlJobAdminClient {
}
}
/**
* 立即执行一次任务
*/
...
...
@@ -121,6 +122,51 @@ public class XxlJobAdminClient {
}
}
public
void
start
(
int
jobId
)
{
FormBody
formBody
=
new
FormBody
.
Builder
()
.
add
(
"id"
,
String
.
valueOf
(
jobId
))
.
build
();
try
{
postForm
(
"jobinfo/start"
,
formBody
,
null
);
}
catch
(
Exception
e
)
{
}
}
public
void
stop
(
int
jobId
)
{
FormBody
formBody
=
new
FormBody
.
Builder
()
.
add
(
"id"
,
String
.
valueOf
(
jobId
))
.
build
();
try
{
postForm
(
"jobinfo/stop"
,
formBody
,
null
);
}
catch
(
Exception
e
)
{
}
}
public
Integer
getExecutorIdByName
(
String
name
)
{
FormBody
formBody
=
new
FormBody
.
Builder
()
.
add
(
"appname"
,
name
)
.
add
(
"start"
,
"0"
)
.
add
(
"length"
,
"10"
)
.
build
();
try
{
return
(
Integer
)
postForm
(
"jobgroup/pageList"
,
formBody
,
(
response
,
list
)
->
{
ResponseBody
responseBody
=
response
.
body
();
if
(
responseBody
!=
null
)
{
PageResult
result
=
objectMapper
.
readValue
(
responseBody
.
string
(),
PageResult
.
class
);
List
<
Object
>
data
=
result
.
getData
();
if
(
data
==
null
||
data
.
isEmpty
())
{
list
.
add
(
null
);
return
;
}
Integer
id
=
(
Integer
)
((
Map
<
String
,
Object
>)
data
.
get
(
0
)).
get
(
"id"
);
list
.
add
(
id
);
}
}).
get
(
0
);
}
catch
(
Exception
e
)
{
return
null
;
}
}
public
List
<
TriggerLog
>
getTriggerLogs
(
int
jobId
,
String
from
,
String
to
,
int
offset
,
int
limit
)
{
return
doGetTriggerLogs
(
jobId
,
-
1
,
from
,
to
,
offset
,
limit
);
}
...
...
src/test/java/com/tbyf/util/XxlJobAdminClientTest.java
View file @
eae6585f
...
...
@@ -38,4 +38,9 @@ class XxlJobAdminClientTest {
2
);
triggerLogs
.
forEach
(
log
->
System
.
out
.
println
(
log
.
getTriggerId
()
+
": "
+
log
.
getTriggerMsg
()));
}
@Test
void
getExecutorIdByName
()
{
System
.
out
.
println
(
adminClient
.
getExecutorIdByName
(
"sample-executor"
));
}
}
\ 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