Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pentaLiker
DolphinScheduler
提交
0db19065
DolphinScheduler
项目概览
pentaLiker
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0db19065
编写于
1月 15, 2021
作者:
C
CalvinKirs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rpc test
上级
985a4fc9
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
27 addition
and
15 deletion
+27
-15
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/MainTest.java
...java/org/apache/dolphinscheduler/remote/rpc/MainTest.java
+8
-8
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/client/ConsumerInterceptor.java
...lphinscheduler/remote/rpc/client/ConsumerInterceptor.java
+2
-2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/remote/NettyClient.java
...pache/dolphinscheduler/remote/rpc/remote/NettyClient.java
+10
-5
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/remote/NettyClientHandler.java
...olphinscheduler/remote/rpc/remote/NettyClientHandler.java
+7
-0
未找到文件。
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/MainTest.java
浏览文件 @
0db19065
...
...
@@ -17,16 +17,16 @@ import org.apache.dolphinscheduler.remote.utils.Host;
public
class
MainTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
NettyServer
nettyServer
=
new
NettyServer
(
new
NettyServerConfig
());
NettyServer
nettyServer
=
new
NettyServer
(
new
NettyServerConfig
());
// NettyClient nettyClient=new NettyClient(new NettyClientConfig());
Host
host
=
new
Host
(
"127.0.0.1"
,
12366
);
IRpcClient
rpcClient
=
new
RpcClient
();
IUserService
userService
=
rpcClient
.
create
(
UserService
.
class
);
userService
.
say
(
"calvin"
);
Host
host
=
new
Host
(
"127.0.0.1"
,
12366
);
IRpcClient
rpcClient
=
new
RpcClient
();
IUserService
userService
=
rpcClient
.
create
(
UserService
.
class
);
String
result
=
userService
.
say
(
"calvin"
);
System
.
out
.
println
(
"我是你爸爸吧"
+
result
);
// nettyClient.sendMsg(host,rpcRequest);
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/client/ConsumerInterceptor.java
浏览文件 @
0db19065
...
...
@@ -37,8 +37,8 @@ public class ConsumerInterceptor {
System
.
out
.
println
(
invoker
.
invoke
(
request
));
NettyClient
nettyClient
=
new
NettyClient
(
new
NettyClientConfig
());
Host
host
=
new
Host
(
"127.0.0.1"
,
12336
);
nettyClient
.
sendMsg
(
host
,
request
);
return
null
;
return
nettyClient
.
sendMsg
(
host
,
request
);
}
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/remote/NettyClient.java
浏览文件 @
0db19065
...
...
@@ -31,6 +31,7 @@ import org.apache.dolphinscheduler.remote.utils.NettyUtils;
import
java.net.InetSocketAddress
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
...
...
@@ -171,16 +172,20 @@ public class NettyClient {
System
.
out
.
println
(
"netty client start"
);
}
public
void
sendMsg
(
Host
host
,
RpcRequest
request
)
{
public
Object
sendMsg
(
Host
host
,
RpcRequest
request
)
{
Channel
channel
=
getChannel
(
host
);
assert
channel
!=
null
;
// ctx.writeAndFlush(Unpooled.copiedBuffer
RpcFuture
future
=
new
RpcFuture
();
RpcRequestTable
.
put
(
request
.
getRequestId
(),
future
);
channel
.
writeAndFlush
(
request
);
// System.out.println();
// channel.writeAndFlush( ProtoStuffUtils.serialize(request));
Object
result
=
null
;
try
{
result
=
future
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/rpc/remote/NettyClientHandler.java
浏览文件 @
0db19065
...
...
@@ -11,8 +11,10 @@ import io.netty.handler.timeout.IdleStateEvent;
import
org.apache.dolphinscheduler.remote.NettyRemotingClient
;
import
org.apache.dolphinscheduler.remote.command.Command
;
import
org.apache.dolphinscheduler.remote.command.CommandType
;
import
org.apache.dolphinscheduler.remote.rpc.client.RpcRequestTable
;
import
org.apache.dolphinscheduler.remote.rpc.common.RpcRequest
;
import
org.apache.dolphinscheduler.remote.rpc.common.RpcResponse
;
import
org.apache.dolphinscheduler.remote.rpc.future.RpcFuture
;
import
java.net.InetSocketAddress
;
...
...
@@ -47,6 +49,11 @@ public class NettyClientHandler extends ChannelInboundHandlerAdapter {
public
void
channelRead
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
System
.
out
.
println
(
"收到消息"
);
RpcResponse
rsp
=
(
RpcResponse
)
msg
;
RpcFuture
rpcFuture
=
RpcRequestTable
.
get
(
rsp
.
getRequestId
());
if
(
null
!=
rpcFuture
){
RpcRequestTable
.
remove
(
rsp
.
getRequestId
());
rpcFuture
.
done
(
rsp
);
}
System
.
out
.
println
(
rsp
.
getResult
().
toString
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录