Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
粉色的八爪鱼
xxl-job
提交
1df79bc9
X
xxl-job
项目概览
粉色的八爪鱼
/
xxl-job
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
xxl-job
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1df79bc9
编写于
3月 03, 2016
作者:
X
xueli.xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
远程调度通讯,新增Jetty方式
上级
1b2fb261
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
3 deletion
+102
-3
.gitignore
.gitignore
+1
-0
xxl-job-admin/.gitignore
xxl-job-admin/.gitignore
+1
-2
xxl-job-client-demo/.gitignore
xxl-job-client-demo/.gitignore
+1
-0
xxl-job-client/.gitignore
xxl-job-client/.gitignore
+1
-1
xxl-job-client/src/main/java/com/xxl/job/client/netcom/jetty/XxlJobJettyServer.java
...va/com/xxl/job/client/netcom/jetty/XxlJobJettyServer.java
+55
-0
xxl-job-client/src/main/java/com/xxl/job/client/netcom/jetty/XxlJobJettyServerHandler.java
...xxl/job/client/netcom/jetty/XxlJobJettyServerHandler.java
+43
-0
未找到文件。
.gitignore
浏览文件 @
1df79bc9
/.settings/
/.project
/xxl-job.iml
xxl-job-admin/.gitignore
浏览文件 @
1df79bc9
/target/
/.settings/
/target/
/.classpath
/.project
/
target/
/
xxl-job-admin.iml
\ No newline at end of file
xxl-job-client-demo/.gitignore
浏览文件 @
1df79bc9
...
...
@@ -2,3 +2,4 @@
/.classpath
/.project
/.settings/
/xxl-job-client-demo.iml
xxl-job-client/.gitignore
浏览文件 @
1df79bc9
...
...
@@ -2,4 +2,4 @@
/.classpath
/.project
/.settings/
/
target/
/
xxl-job-client.iml
xxl-job-client/src/main/java/com/xxl/job/client/netcom/jetty/XxlJobJettyServer.java
0 → 100644
浏览文件 @
1df79bc9
package
com.xxl.job.client.netcom.jetty
;
import
org.eclipse.jetty.server.Connector
;
import
org.eclipse.jetty.server.Handler
;
import
org.eclipse.jetty.server.Server
;
import
org.eclipse.jetty.server.handler.HandlerCollection
;
import
org.eclipse.jetty.server.nio.SelectChannelConnector
;
import
org.eclipse.jetty.util.thread.ExecutorThreadPool
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* Created by xuxueli on 2016/3/2 21:14.
*/
public
class
XxlJobJettyServer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
XxlJobJettyServer
.
class
);
private
int
port
=
9999
;
public
void
setPort
(
int
port
)
{
this
.
port
=
port
;
}
public
void
start
()
throws
Exception
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Server
server
=
new
Server
();
server
.
setThreadPool
(
new
ExecutorThreadPool
(
200
,
200
,
30000
));
// 非阻塞
// connector
SelectChannelConnector
connector
=
new
SelectChannelConnector
();
connector
.
setPort
(
port
);
connector
.
setMaxIdleTime
(
30000
);
server
.
setConnectors
(
new
Connector
[]
{
connector
});
// handler
HandlerCollection
handlerc
=
new
HandlerCollection
();
handlerc
.
setHandlers
(
new
Handler
[]{
new
XxlJobJettyServerHandler
()});
server
.
setHandler
(
handlerc
);
try
{
server
.
start
();
logger
.
info
(
">>>>>>>>>>>> xxl-job jetty server start success at port:{}."
,
port
);
server
.
join
();
// block until server ready
logger
.
info
(
">>>>>>>>>>>> xxl-job jetty server join success at port:{}."
,
port
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}).
start
();
}
}
xxl-job-client/src/main/java/com/xxl/job/client/netcom/jetty/XxlJobJettyServerHandler.java
0 → 100644
浏览文件 @
1df79bc9
package
com.xxl.job.client.netcom.jetty
;
import
com.xxl.job.client.handler.HandlerRepository
;
import
org.eclipse.jetty.server.Request
;
import
org.eclipse.jetty.server.handler.AbstractHandler
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by xuxueli on 2016/3/2 21:23.
*/
public
class
XxlJobJettyServerHandler
extends
AbstractHandler
{
@Override
public
void
handle
(
String
s
,
Request
baseRequest
,
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
)
throws
IOException
,
ServletException
{
httpServletRequest
.
setCharacterEncoding
(
"UTF-8"
);
httpServletResponse
.
setCharacterEncoding
(
"UTF-8"
);
Map
<
String
,
String
>
_param
=
new
HashMap
<
String
,
String
>();
if
(
httpServletRequest
.
getParameterMap
()!=
null
&&
httpServletRequest
.
getParameterMap
().
size
()>
0
)
{
for
(
Object
paramKey
:
httpServletRequest
.
getParameterMap
().
keySet
())
{
if
(
paramKey
!=
null
)
{
String
paramKeyStr
=
paramKey
.
toString
();
_param
.
put
(
paramKeyStr
,
httpServletRequest
.
getParameter
(
paramKeyStr
));
}
}
}
String
resp
=
HandlerRepository
.
pushHandleQueue
(
_param
);
httpServletResponse
.
setContentType
(
"text/html;charset=utf-8"
);
httpServletResponse
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
httpServletResponse
.
getWriter
().
println
(
resp
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录