Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
7c668a06
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c668a06
编写于
1月 05, 2018
作者:
N
Nikita
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
KQueue support added. #1215
上级
1beed1dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
11 deletion
+88
-11
redisson/pom.xml
redisson/pom.xml
+7
-0
redisson/src/main/java/org/redisson/config/Config.java
redisson/src/main/java/org/redisson/config/Config.java
+26
-10
redisson/src/main/java/org/redisson/config/TransportMode.java
...sson/src/main/java/org/redisson/config/TransportMode.java
+41
-0
redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java
...org/redisson/connection/MasterSlaveConnectionManager.java
+14
-1
未找到文件。
redisson/pom.xml
浏览文件 @
7c668a06
...
...
@@ -31,12 +31,19 @@
</profiles>
<dependencies>
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty-transport-native-kqueue
</artifactId>
<version>
4.1.19.Final
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty-transport-native-epoll
</artifactId>
<version>
4.1.19.Final
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty-common
</artifactId>
...
...
redisson/src/main/java/org/redisson/config/Config.java
浏览文件 @
7c668a06
...
...
@@ -78,7 +78,7 @@ public class Config {
*/
private
boolean
referenceEnabled
=
true
;
private
boolean
useLinuxNativeEpoll
;
private
TransportMode
transportMode
=
TransportMode
.
NIO
;
private
EventLoopGroup
eventLoopGroup
;
...
...
@@ -106,6 +106,8 @@ public class Config {
setReferenceCodecProvider
(
oldConf
.
getReferenceCodecProvider
());
setReferenceEnabled
(
oldConf
.
isReferenceEnabled
());
setEventLoopGroup
(
oldConf
.
getEventLoopGroup
());
setTransportMode
(
oldConf
.
getTransportMode
());
if
(
oldConf
.
getSingleServerConfig
()
!=
null
)
{
setSingleServerConfig
(
new
SingleServerConfig
(
oldConf
.
getSingleServerConfig
()));
}
...
...
@@ -455,23 +457,36 @@ public class Config {
throw
new
IllegalStateException
(
"Replication servers config already used!"
);
}
}
/**
*
Activates an unix socket if servers binded to loopback interface.
*
Also used for epoll transport activation.
*
<b>netty-transport-native-epoll</b> library should be in classpath
*
Transport mode
*
<p>
*
Default is {@link TransportMode#NIO}
*
* @param
useLinuxNativeEpoll flag
* @param
transportMode param
* @return config
*/
public
Config
setTransportMode
(
TransportMode
transportMode
)
{
this
.
transportMode
=
transportMode
;
return
this
;
}
public
TransportMode
getTransportMode
()
{
return
transportMode
;
}
/**
* Use {@link #setTransportMode(TransportMode)}
*/
@Deprecated
public
Config
setUseLinuxNativeEpoll
(
boolean
useLinuxNativeEpoll
)
{
this
.
useLinuxNativeEpoll
=
useLinuxNativeEpoll
;
if
(
useLinuxNativeEpoll
)
{
setTransportMode
(
TransportMode
.
EPOLL
);
}
return
this
;
}
public
boolean
isUseLinuxNativeEpoll
()
{
return
useLinuxNativeEpoll
;
return
getTransportMode
()
==
TransportMode
.
EPOLL
;
}
/**
...
...
@@ -515,12 +530,13 @@ public class Config {
/**
* Use external EventLoopGroup. EventLoopGroup processes all
* Netty connection tied
with
Redis servers. Each EventLoopGroup creates
* Netty connection tied
to
Redis servers. Each EventLoopGroup creates
* own threads and each Redisson client creates own EventLoopGroup by default.
* So if there are multiple Redisson instances in same JVM
* it would be useful to share one EventLoopGroup among them.
* <p>
* Only {@link io.netty.channel.epoll.EpollEventLoopGroup} or
* Only {@link io.netty.channel.epoll.EpollEventLoopGroup},
* {@link io.netty.channel.kqueue.KQueueEventLoopGroup}
* {@link io.netty.channel.nio.NioEventLoopGroup} can be used.
* <p>
* The caller is responsible for closing the EventLoopGroup.
...
...
redisson/src/main/java/org/redisson/config/TransportMode.java
0 → 100644
浏览文件 @
7c668a06
/**
* Copyright 2016 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.redisson.config
;
/**
*
* @author Nikita Koksharov
*
*/
public
enum
TransportMode
{
/**
* Use NIO transport.
*/
NIO
,
/**
* Use EPOLL transport. Activates an unix socket if servers binded to loopback interface.
* Requires <b>netty-transport-native-epoll</b> lib in classpath.
*/
EPOLL
,
/**
* Use KQUEUE transport. Requires <b>netty-transport-native-kqueue</b> lib in classpath.
*/
KQUEUE
,
}
redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java
浏览文件 @
7c668a06
...
...
@@ -50,6 +50,7 @@ import org.redisson.command.CommandSyncService;
import
org.redisson.config.BaseMasterSlaveServersConfig
;
import
org.redisson.config.Config
;
import
org.redisson.config.MasterSlaveServersConfig
;
import
org.redisson.config.TransportMode
;
import
org.redisson.misc.InfinitySemaphoreLatch
;
import
org.redisson.misc.RPromise
;
import
org.redisson.misc.RedissonPromise
;
...
...
@@ -63,6 +64,9 @@ import io.netty.channel.EventLoopGroup;
import
io.netty.channel.epoll.EpollDatagramChannel
;
import
io.netty.channel.epoll.EpollEventLoopGroup
;
import
io.netty.channel.epoll.EpollSocketChannel
;
import
io.netty.channel.kqueue.KQueueDatagramChannel
;
import
io.netty.channel.kqueue.KQueueEventLoopGroup
;
import
io.netty.channel.kqueue.KQueueSocketChannel
;
import
io.netty.channel.nio.NioEventLoopGroup
;
import
io.netty.channel.socket.SocketChannel
;
import
io.netty.channel.socket.nio.NioDatagramChannel
;
...
...
@@ -175,7 +179,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
public
MasterSlaveConnectionManager
(
Config
cfg
)
{
Version
.
logVersion
();
if
(
cfg
.
isUseLinuxNativeEpoll
()
)
{
if
(
cfg
.
getTransportMode
()
==
TransportMode
.
EPOLL
)
{
if
(
cfg
.
getEventLoopGroup
()
==
null
)
{
this
.
group
=
new
EpollEventLoopGroup
(
cfg
.
getNettyThreads
(),
new
DefaultThreadFactory
(
"redisson-netty"
));
}
else
{
...
...
@@ -184,6 +188,15 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
this
.
socketChannelClass
=
EpollSocketChannel
.
class
;
this
.
resolverGroup
=
new
DnsAddressResolverGroup
(
EpollDatagramChannel
.
class
,
DnsServerAddressStreamProviders
.
platformDefault
());
}
else
if
(
cfg
.
getTransportMode
()
==
TransportMode
.
KQUEUE
)
{
if
(
cfg
.
getEventLoopGroup
()
==
null
)
{
this
.
group
=
new
KQueueEventLoopGroup
(
cfg
.
getNettyThreads
(),
new
DefaultThreadFactory
(
"redisson-netty"
));
}
else
{
this
.
group
=
cfg
.
getEventLoopGroup
();
}
this
.
socketChannelClass
=
KQueueSocketChannel
.
class
;
this
.
resolverGroup
=
new
DnsAddressResolverGroup
(
KQueueDatagramChannel
.
class
,
DnsServerAddressStreamProviders
.
platformDefault
());
}
else
{
if
(
cfg
.
getEventLoopGroup
()
==
null
)
{
this
.
group
=
new
NioEventLoopGroup
(
cfg
.
getNettyThreads
(),
new
DefaultThreadFactory
(
"redisson-netty"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录