Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pentaLiker
DolphinScheduler
提交
2327da77
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,体验更适合开发者的 AI 搜索 >>
提交
2327da77
编写于
1月 12, 2021
作者:
C
CalvinKirs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rpc
上级
e2472846
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
141 addition
and
7 deletion
+141
-7
dolphinscheduler-remote/pom.xml
dolphinscheduler-remote/pom.xml
+13
-0
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingClient.java
...g/apache/dolphinscheduler/remote/NettyRemotingClient.java
+0
-2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
...g/apache/dolphinscheduler/remote/NettyRemotingServer.java
+0
-1
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/decoder/NettyDecoder.java
.../apache/dolphinscheduler/remote/decoder/NettyDecoder.java
+44
-0
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/decoder/NettyEncoder.java
.../apache/dolphinscheduler/remote/decoder/NettyEncoder.java
+32
-0
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyClientHandler.java
...e/dolphinscheduler/remote/handler/NettyClientHandler.java
+0
-2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyServerHandler.java
...e/dolphinscheduler/remote/handler/NettyServerHandler.java
+0
-2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/serialize/ProtoStuffUtils.java
...he/dolphinscheduler/remote/serialize/ProtoStuffUtils.java
+52
-0
未找到文件。
dolphinscheduler-remote/pom.xml
浏览文件 @
2327da77
...
...
@@ -51,6 +51,19 @@
<groupId>
net.bytebuddy
</groupId>
<artifactId>
byte-buddy
</artifactId>
</dependency>
<!--protostuff-->
<!-- https://mvnrepository.com/artifact/io.protostuff/protostuff-core -->
<dependency>
<groupId>
io.protostuff
</groupId>
<artifactId>
protostuff-core
</artifactId>
<version>
1.7.2
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.protostuff/protostuff-runtime -->
<dependency>
<groupId>
io.protostuff
</groupId>
<artifactId>
protostuff-runtime
</artifactId>
<version>
1.7.2
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingClient.java
浏览文件 @
2327da77
...
...
@@ -19,8 +19,6 @@ package org.apache.dolphinscheduler.remote;
import
org.apache.dolphinscheduler.remote.codec.NettyDecoder
;
import
org.apache.dolphinscheduler.remote.codec.NettyEncoder
;
import
org.apache.dolphinscheduler.remote.command.Command
;
import
org.apache.dolphinscheduler.remote.command.CommandType
;
import
org.apache.dolphinscheduler.remote.config.NettyClientConfig
;
import
org.apache.dolphinscheduler.remote.exceptions.RemotingException
;
import
org.apache.dolphinscheduler.remote.exceptions.RemotingTimeoutException
;
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
浏览文件 @
2327da77
...
...
@@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.remote;
import
org.apache.dolphinscheduler.remote.codec.NettyDecoder
;
import
org.apache.dolphinscheduler.remote.codec.NettyEncoder
;
import
org.apache.dolphinscheduler.remote.command.CommandType
;
import
org.apache.dolphinscheduler.remote.config.NettyServerConfig
;
import
org.apache.dolphinscheduler.remote.handler.NettyServerHandler
;
import
org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor
;
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/decoder/NettyDecoder.java
0 → 100644
浏览文件 @
2327da77
package
org.apache.dolphinscheduler.remote.decoder
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.handler.codec.ByteToMessageDecoder
;
import
org.apache.dolphinscheduler.remote.serialize.ProtoStuffUtils
;
import
java.util.List
;
/**
* @author jiangli
* @date 2021-01-12 18:53
*/
public
class
NettyDecoder
extends
ByteToMessageDecoder
{
private
Class
<?>
genericClass
;
// 构造函数传入向反序列化的class
public
NettyDecoder
(
Class
<?>
genericClass
)
{
this
.
genericClass
=
genericClass
;
}
@Override
protected
void
decode
(
ChannelHandlerContext
channelHandlerContext
,
ByteBuf
byteBuf
,
List
<
Object
>
list
)
throws
Exception
{
if
(
byteBuf
.
readableBytes
()
<
4
)
{
return
;
}
byteBuf
.
markReaderIndex
();
int
dataLength
=
byteBuf
.
readInt
();
if
(
dataLength
<
0
)
{
channelHandlerContext
.
close
();
}
if
(
byteBuf
.
readableBytes
()
<
dataLength
)
{
byteBuf
.
resetReaderIndex
();
}
//将ByteBuf转换为byte[]
byte
[]
data
=
new
byte
[
dataLength
];
byteBuf
.
readBytes
(
data
);
//将data转换成object
Object
obj
=
ProtoStuffUtils
.
deserialize
(
data
,
genericClass
);
list
.
add
(
obj
);
}
}
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/decoder/NettyEncoder.java
0 → 100644
浏览文件 @
2327da77
package
org.apache.dolphinscheduler.remote.decoder
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.handler.codec.MessageToByteEncoder
;
import
org.apache.dolphinscheduler.remote.serialize.ProtoStuffUtils
;
/**
* @author jiangli
* @date 2021-01-12 18:52
*/
public
class
NettyEncoder
extends
MessageToByteEncoder
{
private
Class
<?>
genericClass
;
// 构造函数传入向反序列化的class
public
NettyEncoder
(
Class
<?>
genericClass
)
{
this
.
genericClass
=
genericClass
;
}
@Override
protected
void
encode
(
ChannelHandlerContext
channelHandlerContext
,
Object
o
,
ByteBuf
byteBuf
)
throws
Exception
{
if
(
genericClass
.
isInstance
(
o
))
{
byte
[]
data
=
ProtoStuffUtils
.
serialize
(
o
);
byteBuf
.
writeInt
(
data
.
length
);
byteBuf
.
writeBytes
(
data
);
}
}
}
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyClientHandler.java
浏览文件 @
2327da77
...
...
@@ -18,8 +18,6 @@
package
org.apache.dolphinscheduler.remote.handler
;
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.future.ResponseFuture
;
import
org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor
;
import
org.apache.dolphinscheduler.remote.utils.ChannelUtils
;
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyServerHandler.java
浏览文件 @
2327da77
...
...
@@ -18,8 +18,6 @@
package
org.apache.dolphinscheduler.remote.handler
;
import
org.apache.dolphinscheduler.remote.NettyRemotingServer
;
import
org.apache.dolphinscheduler.remote.command.Command
;
import
org.apache.dolphinscheduler.remote.command.CommandType
;
import
org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor
;
import
org.apache.dolphinscheduler.remote.utils.ChannelUtils
;
import
org.apache.dolphinscheduler.remote.utils.Pair
;
...
...
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/serialize/ProtoStuffUtils.java
0 → 100644
浏览文件 @
2327da77
package
org.apache.dolphinscheduler.remote.serialize
;
import
io.protostuff.LinkedBuffer
;
import
io.protostuff.ProtostuffIOUtil
;
import
io.protostuff.Schema
;
import
io.protostuff.runtime.RuntimeSchema
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author jiangli
* @date 2021-01-12 18:56
*/
public
class
ProtoStuffUtils
{
private
static
LinkedBuffer
buffer
=
LinkedBuffer
.
allocate
(
LinkedBuffer
.
DEFAULT_BUFFER_SIZE
);
private
static
Map
<
Class
<?>,
Schema
<?>>
schemaCache
=
new
ConcurrentHashMap
<>();
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
byte
[]
serialize
(
T
obj
)
{
Class
<
T
>
clazz
=
(
Class
<
T
>)
obj
.
getClass
();
Schema
<
T
>
schema
=
getSchema
(
clazz
);
byte
[]
data
;
try
{
data
=
ProtostuffIOUtil
.
toByteArray
(
obj
,
schema
,
buffer
);
}
finally
{
buffer
.
clear
();
}
return
data
;
}
@SuppressWarnings
(
"unchecked"
)
private
static
<
T
>
Schema
<
T
>
getSchema
(
Class
<
T
>
clazz
)
{
Schema
<
T
>
schema
=
(
Schema
<
T
>)
schemaCache
.
get
(
clazz
);
if
(
schema
==
null
)
{
schema
=
RuntimeSchema
.
getSchema
(
clazz
);
if
(
schema
==
null
)
{
schemaCache
.
put
(
clazz
,
schema
);
}
}
return
schema
;
}
public
static
<
T
>
T
deserialize
(
byte
[]
bytes
,
Class
<
T
>
clazz
)
{
Schema
<
T
>
schema
=
getSchema
(
clazz
);
T
obj
=
schema
.
newMessage
();
ProtostuffIOUtil
.
mergeFrom
(
bytes
,
obj
,
schema
);
return
obj
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录