Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
16cb2560
authored
Dec 04, 2015
by
xueli.xue
Browse files
Options
_('Browse Files')
Download
Plain Diff
init
parents
a94fabad
6b951c58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java
xxl-job-admin/src/main/java/com/xxl/quartz/ReturnT.java
xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java
View file @
16cb2560
package
com
.
xxl
.
controller
;
import
java.text.MessageFormat
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang.StringUtils
;
import
org.quartz.CronExpression
;
...
...
@@ -136,4 +138,60 @@ public class IndexController {
return
"job/help"
;
}
private
int
simpleParam
=
0
;
private
ThreadLocal
<
Integer
>
tlParam
;
@RequestMapping
(
"/beat"
)
@ResponseBody
public
String
beat
()
{
if
(
tlParam
==
null
)
{
tlParam
=
new
ThreadLocal
<
Integer
>();
}
if
(
tlParam
.
get
()
==
null
)
{
tlParam
.
set
(
5000
);
}
simpleParam
++;
tlParam
.
set
(
tlParam
.
get
()
+
1
);
long
start
=
System
.
currentTimeMillis
();
try
{
TimeUnit
.
SECONDS
.
sleep
(
1
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
long
end
=
System
.
currentTimeMillis
();
return
MessageFormat
.
format
(
"cost:{0}, hashCode:{1}, simpleParam:{2}, tlParam:{3}"
,
(
end
-
start
),
this
.
hashCode
(),
simpleParam
,
tlParam
.
get
());
}
public
static
void
main
(
String
[]
args
)
{
Runnable
runa
=
new
Runnable
()
{
private
int
simInt
=
0
;
private
ThreadLocal
<
Integer
>
tlParam
=
new
ThreadLocal
<
Integer
>();
@Override
public
void
run
()
{
while
(
true
)
{
try
{
TimeUnit
.
SECONDS
.
sleep
(
1
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
if
(
tlParam
.
get
()
==
null
)
{
tlParam
.
set
(
0
);
}
simInt
++;
tlParam
.
set
(
tlParam
.
get
()+
1
);
System
.
out
.
println
(
Thread
.
currentThread
().
hashCode
()
+
":simInt:"
+
simInt
);
System
.
out
.
println
(
Thread
.
currentThread
().
hashCode
()
+
":tlParam:"
+
tlParam
.
get
());
}
}
};
Thread
t1
=
new
Thread
(
runa
);
Thread
t2
=
new
Thread
(
runa
);
t1
.
start
();
t2
.
start
();
}
}
xxl-job-admin/src/main/java/com/xxl/quartz/ReturnT.java
0 → 100644
View file @
16cb2560
package
com
.
xxl
.
quartz
;
/**
* common return
* @author xuxueli 2015-12-4 16:32:31
* @param <T>
*/
public
class
ReturnT
<
T
>
{
public
static
final
ReturnT
<
String
>
SUCCESS
=
new
ReturnT
<
String
>(
null
);
public
static
final
ReturnT
<
String
>
FAIL
=
new
ReturnT
<
String
>(
500
,
null
);
private
int
code
;
private
String
msg
;
private
T
content
;
public
ReturnT
(
int
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
ReturnT
(
T
content
)
{
this
.
code
=
200
;
this
.
content
=
content
;
}
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
T
getContent
()
{
return
content
;
}
public
void
setContent
(
T
content
)
{
this
.
content
=
content
;
}
@Override
public
String
toString
()
{
return
"ReturnT [code="
+
code
+
", msg="
+
msg
+
", content="
+
content
+
"]"
;
}
}
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