Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
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
liyuan
byit-myth-job
Commits
efed4bac
Commit
efed4bac
authored
May 28, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
还原日志
parent
a866ca24
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
39 deletions
+9
-39
NettyClientHandler.java
...main/java/com/byit/client/handler/NettyClientHandler.java
+0
-3
NettyPluginConnectionClient.java
.../com/byit/client/handler/NettyPluginConnectionClient.java
+2
-5
RpcSpringPluginServerFactory.java
...n/java/com/byit/factory/RpcSpringPluginServerFactory.java
+3
-5
MainNettyPluginServer.java
...ain/java/com/byit/server/netty/MainNettyPluginServer.java
+2
-4
NettyPluginServerHandler.java
...m/byit/server/netty/handler/NettyPluginServerHandler.java
+2
-5
pom.xml
byit-plugin-core/pom.xml
+0
-17
No files found.
byit-plugin-core/myth-plugin-rpc-client/src/main/java/com/byit/client/handler/NettyClientHandler.java
View file @
efed4bac
...
@@ -7,13 +7,11 @@ import com.byit.param.PluginBeat;
...
@@ -7,13 +7,11 @@ import com.byit.param.PluginBeat;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.SimpleChannelInboundHandler
;
import
io.netty.channel.SimpleChannelInboundHandler
;
import
io.netty.handler.timeout.IdleStateEvent
;
import
io.netty.handler.timeout.IdleStateEvent
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
* Netty客户端业务处理类
* Netty客户端业务处理类
* @author huangfu
* @author huangfu
*/
*/
@Slf4j
public
class
NettyClientHandler
extends
SimpleChannelInboundHandler
<
PluginRpcResponsePacket
>
{
public
class
NettyClientHandler
extends
SimpleChannelInboundHandler
<
PluginRpcResponsePacket
>
{
private
PluginClientInitialization
pluginClientInitialization
;
private
PluginClientInitialization
pluginClientInitialization
;
private
PluginConnectClient
pluginConnectClient
;
private
PluginConnectClient
pluginConnectClient
;
...
@@ -34,7 +32,6 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<PluginRpcRes
...
@@ -34,7 +32,6 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<PluginRpcRes
//判断事件是否是心跳事件
//判断事件是否是心跳事件
if
(
evt
instanceof
IdleStateEvent
){
if
(
evt
instanceof
IdleStateEvent
){
pluginConnectClient
.
send
(
PluginBeat
.
PLUGIN_RPC_REQUEST_PACKET
);
pluginConnectClient
.
send
(
PluginBeat
.
PLUGIN_RPC_REQUEST_PACKET
);
log
.
debug
(
"------客户端发送心跳请求-----"
);
}
else
{
}
else
{
super
.
userEventTriggered
(
ctx
,
evt
);
super
.
userEventTriggered
(
ctx
,
evt
);
}
}
...
...
byit-plugin-core/myth-plugin-rpc-client/src/main/java/com/byit/client/handler/NettyPluginConnectionClient.java
View file @
efed4bac
...
@@ -6,7 +6,6 @@ import com.byit.handler.PacketEncodeHandler;
...
@@ -6,7 +6,6 @@ import com.byit.handler.PacketEncodeHandler;
import
com.byit.init.PluginClientInitialization
;
import
com.byit.init.PluginClientInitialization
;
import
com.byit.packet.request.PluginRpcRequestPacket
;
import
com.byit.packet.request.PluginRpcRequestPacket
;
import
com.byit.param.PluginBeat
;
import
com.byit.param.PluginBeat
;
import
com.byit.rpc.remoting.net.params.Beat
;
import
com.byit.utils.IpUtil
;
import
com.byit.utils.IpUtil
;
import
io.netty.bootstrap.Bootstrap
;
import
io.netty.bootstrap.Bootstrap
;
import
io.netty.channel.*
;
import
io.netty.channel.*
;
...
@@ -14,7 +13,6 @@ import io.netty.channel.nio.NioEventLoopGroup;
...
@@ -14,7 +13,6 @@ import io.netty.channel.nio.NioEventLoopGroup;
import
io.netty.channel.socket.SocketChannel
;
import
io.netty.channel.socket.SocketChannel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.netty.handler.timeout.IdleStateHandler
;
import
io.netty.handler.timeout.IdleStateHandler
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -22,7 +20,6 @@ import java.util.concurrent.TimeUnit;
...
@@ -22,7 +20,6 @@ import java.util.concurrent.TimeUnit;
* netty客户端
* netty客户端
* @author huangfu
* @author huangfu
*/
*/
@Slf4j
public
class
NettyPluginConnectionClient
extends
PluginConnectClient
{
public
class
NettyPluginConnectionClient
extends
PluginConnectClient
{
private
EventLoopGroup
group
;
private
EventLoopGroup
group
;
private
Channel
channel
;
private
Channel
channel
;
...
@@ -57,7 +54,7 @@ public class NettyPluginConnectionClient extends PluginConnectClient {
...
@@ -57,7 +54,7 @@ public class NettyPluginConnectionClient extends PluginConnectClient {
this
.
channel
=
bootstrap
.
connect
(
ip
,
port
).
sync
().
channel
();
this
.
channel
=
bootstrap
.
connect
(
ip
,
port
).
sync
().
channel
();
// valid
// valid
if
(!
isValidate
())
{
if
(!
isValidate
())
{
log
.
debug
(
"------关闭链接--------"
);
System
.
err
.
println
(
"------关闭链接--------"
);
close
();
close
();
}
}
...
@@ -66,7 +63,7 @@ public class NettyPluginConnectionClient extends PluginConnectClient {
...
@@ -66,7 +63,7 @@ public class NettyPluginConnectionClient extends PluginConnectClient {
@Override
@Override
public
void
close
()
{
public
void
close
()
{
if
(
this
.
channel
!=
null
&&
isValidate
()){
if
(
this
.
channel
!=
null
&&
isValidate
()){
log
.
warn
(
"------关闭链接{}------"
,
channel
.
id
().
asShortText
(
));
System
.
err
.
println
(
String
.
format
(
"------关闭链接%s------"
,
channel
.
id
().
asShortText
()
));
this
.
channel
.
close
();
this
.
channel
.
close
();
}
}
...
...
byit-plugin-core/myth-plugin-rpc-server/src/main/java/com/byit/factory/RpcSpringPluginServerFactory.java
View file @
efed4bac
...
@@ -2,7 +2,6 @@ package com.byit.factory;
...
@@ -2,7 +2,6 @@ package com.byit.factory;
import
com.byit.task.annotations.TaskHandler
;
import
com.byit.task.annotations.TaskHandler
;
import
com.byit.task.handler.interfaces.IJobHandler
;
import
com.byit.task.handler.interfaces.IJobHandler
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.aop.framework.AdvisedSupport
;
import
org.springframework.aop.framework.AdvisedSupport
;
import
org.springframework.aop.framework.AopProxy
;
import
org.springframework.aop.framework.AopProxy
;
...
@@ -21,7 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -21,7 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
* spring实现
* spring实现
* @author huangfu
* @author huangfu
*/
*/
@Slf4j
public
class
RpcSpringPluginServerFactory
extends
PluginServerFactory
implements
ApplicationContextAware
,
InitializingBean
,
DisposableBean
{
public
class
RpcSpringPluginServerFactory
extends
PluginServerFactory
implements
ApplicationContextAware
,
InitializingBean
,
DisposableBean
{
private
String
address
;
private
String
address
;
private
String
biz
;
private
String
biz
;
...
@@ -70,7 +68,7 @@ public class RpcSpringPluginServerFactory extends PluginServerFactory implements
...
@@ -70,7 +68,7 @@ public class RpcSpringPluginServerFactory extends PluginServerFactory implements
}
}
}
}
}
else
{
}
else
{
log
.
warn
(
"警告!bean {} 不是【com.byit.task.handler.interfaces.IJobHandler】类型!忽略该bean!"
,
key
);
System
.
out
.
println
(
String
.
format
(
"警告!bean %s 不是【com.byit.task.handler.interfaces.IJobHandler】类型!忽略该bean!"
,
key
)
);
}
}
});
});
}
}
...
@@ -90,7 +88,7 @@ public class RpcSpringPluginServerFactory extends PluginServerFactory implements
...
@@ -90,7 +88,7 @@ public class RpcSpringPluginServerFactory extends PluginServerFactory implements
}
}
private
static
Object
getCglibProxyTargetObject
(
Object
proxy
)
throws
Exception
{
private
static
Object
getCglibProxyTargetObject
(
Object
proxy
)
throws
Exception
{
log
.
warn
(
"{}:-------该对象为cglib代理对象-------"
,
proxy
);
System
.
out
.
println
(
String
.
format
(
"%s:-------该对象为cglib代理对象-------"
,
proxy
)
);
Field
h
=
proxy
.
getClass
().
getDeclaredField
(
"CGLIB$CALLBACK_0"
);
Field
h
=
proxy
.
getClass
().
getDeclaredField
(
"CGLIB$CALLBACK_0"
);
h
.
setAccessible
(
true
);
h
.
setAccessible
(
true
);
Object
dynamicAdvisedInterceptor
=
h
.
get
(
proxy
);
Object
dynamicAdvisedInterceptor
=
h
.
get
(
proxy
);
...
@@ -105,7 +103,7 @@ public class RpcSpringPluginServerFactory extends PluginServerFactory implements
...
@@ -105,7 +103,7 @@ public class RpcSpringPluginServerFactory extends PluginServerFactory implements
private
static
Object
getJdkDynamicProxyTargetObject
(
Object
proxy
)
throws
Exception
{
private
static
Object
getJdkDynamicProxyTargetObject
(
Object
proxy
)
throws
Exception
{
log
.
debug
(
"-------{},该对象为jdk代理对象-------"
,
proxy
);
System
.
out
.
println
(
String
.
format
(
"-------%s,该对象为jdk代理对象-------"
,
proxy
)
);
Field
h
=
proxy
.
getClass
().
getSuperclass
().
getDeclaredField
(
"h"
);
Field
h
=
proxy
.
getClass
().
getSuperclass
().
getDeclaredField
(
"h"
);
h
.
setAccessible
(
true
);
h
.
setAccessible
(
true
);
AopProxy
aopProxy
=
(
AopProxy
)
h
.
get
(
proxy
);
AopProxy
aopProxy
=
(
AopProxy
)
h
.
get
(
proxy
);
...
...
byit-plugin-core/myth-plugin-rpc-server/src/main/java/com/byit/server/netty/MainNettyPluginServer.java
View file @
efed4bac
...
@@ -14,7 +14,6 @@ import io.netty.channel.nio.NioEventLoopGroup;
...
@@ -14,7 +14,6 @@ import io.netty.channel.nio.NioEventLoopGroup;
import
io.netty.channel.socket.SocketChannel
;
import
io.netty.channel.socket.SocketChannel
;
import
io.netty.channel.socket.nio.NioServerSocketChannel
;
import
io.netty.channel.socket.nio.NioServerSocketChannel
;
import
io.netty.handler.timeout.IdleStateHandler
;
import
io.netty.handler.timeout.IdleStateHandler
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -23,7 +22,6 @@ import java.util.concurrent.TimeUnit;
...
@@ -23,7 +22,6 @@ import java.util.concurrent.TimeUnit;
* main方法启动
* main方法启动
* @author huangfu
* @author huangfu
*/
*/
@Slf4j
public
class
MainNettyPluginServer
extends
PluginServer
{
public
class
MainNettyPluginServer
extends
PluginServer
{
@Override
@Override
public
void
start
(
PluginServerFactory
pluginServerFactory
)
{
public
void
start
(
PluginServerFactory
pluginServerFactory
)
{
...
@@ -55,7 +53,7 @@ public class MainNettyPluginServer extends PluginServer {
...
@@ -55,7 +53,7 @@ public class MainNettyPluginServer extends PluginServer {
ChannelFuture
closeFuture
=
channelFuture
.
channel
().
closeFuture
().
sync
();
ChannelFuture
closeFuture
=
channelFuture
.
channel
().
closeFuture
().
sync
();
closeFuture
.
addListener
(
future
->{
closeFuture
.
addListener
(
future
->{
if
(
future
.
isSuccess
())
{
if
(
future
.
isSuccess
())
{
log
.
war
n
(
"--------服务关闭---------"
);
System
.
err
.
printl
n
(
"--------服务关闭---------"
);
}
}
});
});
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
@@ -80,7 +78,7 @@ public class MainNettyPluginServer extends PluginServer {
...
@@ -80,7 +78,7 @@ public class MainNettyPluginServer extends PluginServer {
@Override
@Override
public
void
stop
()
{
public
void
stop
()
{
log
.
war
n
(
"--------服务关闭---------"
);
System
.
err
.
printl
n
(
"--------服务关闭---------"
);
super
.
onStop
();
super
.
onStop
();
}
}
}
}
byit-plugin-core/myth-plugin-rpc-server/src/main/java/com/byit/server/netty/handler/NettyPluginServerHandler.java
View file @
efed4bac
...
@@ -13,7 +13,6 @@ import com.byit.task.handler.interfaces.IJobHandler;
...
@@ -13,7 +13,6 @@ import com.byit.task.handler.interfaces.IJobHandler;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.SimpleChannelInboundHandler
;
import
io.netty.channel.SimpleChannelInboundHandler
;
import
io.netty.handler.timeout.IdleStateEvent
;
import
io.netty.handler.timeout.IdleStateEvent
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
...
@@ -22,7 +21,6 @@ import java.util.concurrent.ThreadPoolExecutor;
...
@@ -22,7 +21,6 @@ import java.util.concurrent.ThreadPoolExecutor;
* netty rpc服务器的业务处理
* netty rpc服务器的业务处理
* @author huangfu
* @author huangfu
*/
*/
@Slf4j
public
class
NettyPluginServerHandler
extends
SimpleChannelInboundHandler
<
PluginRpcRequestPacket
>
{
public
class
NettyPluginServerHandler
extends
SimpleChannelInboundHandler
<
PluginRpcRequestPacket
>
{
public
static
final
String
TOKEN_NAME
=
"token"
;
public
static
final
String
TOKEN_NAME
=
"token"
;
...
@@ -44,7 +42,6 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
...
@@ -44,7 +42,6 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
@Override
@Override
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
PluginRpcRequestPacket
msg
)
{
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
PluginRpcRequestPacket
msg
)
{
if
(
PluginBeat
.
BEAT_ID
.
equals
(
msg
.
getRequestId
())){
if
(
PluginBeat
.
BEAT_ID
.
equals
(
msg
.
getRequestId
())){
log
.
info
(
"------接收到客户端的心跳连接-------"
);
return
;
return
;
}
}
PluginRpcResponsePacket
transferPluginRpcResponse
=
new
PluginRpcResponsePacket
();
PluginRpcResponsePacket
transferPluginRpcResponse
=
new
PluginRpcResponsePacket
();
...
@@ -98,7 +95,7 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
...
@@ -98,7 +95,7 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
post
.
header
(
HEADER_TOKEN_NAME
,
"Token"
);
post
.
header
(
HEADER_TOKEN_NAME
,
"Token"
);
post
.
header
(
HEADER_CONTENT_TYPE
,
"application/json"
);
post
.
header
(
HEADER_CONTENT_TYPE
,
"application/json"
);
post
.
body
(
responseStr
).
execute
();
post
.
body
(
responseStr
).
execute
();
log
.
debug
(
"-------消息回复成功-----------"
);
System
.
out
.
println
(
"-------消息回复成功-----------"
);
}
}
/**
/**
...
@@ -116,7 +113,7 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
...
@@ -116,7 +113,7 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
public
void
userEventTriggered
(
ChannelHandlerContext
ctx
,
Object
evt
)
throws
Exception
{
public
void
userEventTriggered
(
ChannelHandlerContext
ctx
,
Object
evt
)
throws
Exception
{
if
(
evt
instanceof
IdleStateEvent
){
if
(
evt
instanceof
IdleStateEvent
){
ctx
.
channel
().
close
();
ctx
.
channel
().
close
();
log
.
debug
(
"-------心跳超时,关闭链接-------"
);
System
.
err
.
println
(
"-------心跳超时,关闭链接-------"
);
}
else
{
}
else
{
super
.
userEventTriggered
(
ctx
,
evt
);
super
.
userEventTriggered
(
ctx
,
evt
);
}
}
...
...
byit-plugin-core/pom.xml
View file @
efed4bac
...
@@ -29,21 +29,5 @@
...
@@ -29,21 +29,5 @@
</snapshotRepository>
</snapshotRepository>
</distributionManagement>
</distributionManagement>
<dependencies>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
</dependency>
</dependencies>
</project>
</project>
\ 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