Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PubTools-tools
Project
Project
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
liuxingyu
PubTools-tools
Commits
3b89d155
Project 'lxy/Redisson-tools' was moved to 'lxy/pubtools'. Please update any links and bookmarks that may still have the old path.
Commit
3b89d155
authored
Aug 16, 2023
by
lihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add logging
parent
c914a370
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
pom.xml
task-executor-kit/pom.xml
+6
-0
pom.xml
task-executor-kit/task-executor-core/pom.xml
+7
-0
TaskExecutor.java
...ain/java/com/mushiny/task/executor/core/TaskExecutor.java
+12
-0
No files found.
task-executor-kit/pom.xml
View file @
3b89d155
...
@@ -25,6 +25,12 @@
...
@@ -25,6 +25,12 @@
<version>
4.13.2
</version>
<version>
4.13.2
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
1.7.27
</version>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
task-executor-kit/task-executor-core/pom.xml
View file @
3b89d155
...
@@ -21,5 +21,11 @@
...
@@ -21,5 +21,11 @@
<groupId>
junit
</groupId>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<artifactId>
junit
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<scope>
provided
</scope>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
task-executor-kit/task-executor-core/src/main/java/com/mushiny/task/executor/core/TaskExecutor.java
View file @
3b89d155
package
com
.
mushiny
.
task
.
executor
.
core
;
package
com
.
mushiny
.
task
.
executor
.
core
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
...
@@ -15,6 +18,9 @@ import java.util.function.Consumer;
...
@@ -15,6 +18,9 @@ import java.util.function.Consumer;
*/
*/
public
class
TaskExecutor
<
T
,
U
,
R
>
{
public
class
TaskExecutor
<
T
,
U
,
R
>
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
TaskExecutor
.
class
);
/**
/**
* 线程池
* 线程池
*/
*/
...
@@ -57,6 +63,9 @@ public class TaskExecutor<T, U, R> {
...
@@ -57,6 +63,9 @@ public class TaskExecutor<T, U, R> {
* 执行函数
* 执行函数
*/
*/
public
boolean
execute
()
{
public
boolean
execute
()
{
if
(
log
.
isInfoEnabled
())
{
log
.
info
(
"task start ======"
);
}
TaskDefinition
<
T
,
U
,
R
>
t
=
this
.
task
;
TaskDefinition
<
T
,
U
,
R
>
t
=
this
.
task
;
Collection
<
T
>
data
=
t
.
getData
();
Collection
<
T
>
data
=
t
.
getData
();
if
(
null
==
data
||
data
.
isEmpty
())
{
if
(
null
==
data
||
data
.
isEmpty
())
{
...
@@ -68,6 +77,9 @@ public class TaskExecutor<T, U, R> {
...
@@ -68,6 +77,9 @@ public class TaskExecutor<T, U, R> {
data
.
forEach
(
d
->
pool
.
execute
(()
->
{
data
.
forEach
(
d
->
pool
.
execute
(()
->
{
try
{
try
{
Object
apply
=
t
.
getHandler
().
apply
(
d
,
t
.
getContext
());
Object
apply
=
t
.
getHandler
().
apply
(
d
,
t
.
getContext
());
if
(
log
.
isInfoEnabled
())
{
log
.
info
(
"sub task finish ======"
);
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
if
(
Objects
.
nonNull
(
t
.
getExceptionHandler
()))
{
if
(
Objects
.
nonNull
(
t
.
getExceptionHandler
()))
{
t
.
getExceptionHandler
().
accept
(
d
);
t
.
getExceptionHandler
().
accept
(
d
);
...
...
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