Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Madan Jampani
2014-10-21 09:46:15 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
824a7c192a156e1a9d9d3297a815ef1de759b398
824a7c19
1 parent
2fcfde9f
Netty epoll support. Now with updated pom.xml and features.xml to bring in the dependencies
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
12 deletions
features/features.xml
pom.xml
utils/netty/pom.xml
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
features/features.xml
View file @
824a7c1
...
...
@@ -15,6 +15,7 @@
<bundle>
mvn:io.netty/netty-transport/4.0.23.Final
</bundle>
<bundle>
mvn:io.netty/netty-handler/4.0.23.Final
</bundle>
<bundle>
mvn:io.netty/netty-codec/4.0.23.Final
</bundle>
<bundle>
io.netty/netty-transport-native-epoll/4.0.23.Final
</bundle>
<bundle>
mvn:commons-pool/commons-pool/1.6
</bundle>
<bundle>
mvn:com.hazelcast/hazelcast/3.3
</bundle>
...
...
pom.xml
View file @
824a7c1
...
...
@@ -312,6 +312,11 @@
<artifactId>
netty-codec
</artifactId>
<version>
${netty4.version}
</version>
</dependency>
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty-transport-native-epoll
</artifactId>
<version>
${netty4.version}
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
utils/netty/pom.xml
View file @
824a7c1
...
...
@@ -55,6 +55,10 @@
<groupId>
io.netty
</groupId>
<artifactId>
netty-codec
</artifactId>
</dependency>
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty-transport-native-epoll
</artifactId>
</dependency>
</dependencies>
</project>
...
...
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
View file @
824a7c1
...
...
@@ -16,7 +16,12 @@ import io.netty.channel.ChannelHandlerContext;
import
io.netty.channel.ChannelInitializer
;
import
io.netty.channel.ChannelOption
;
import
io.netty.channel.EventLoopGroup
;
import
io.netty.channel.ServerChannel
;
import
io.netty.channel.SimpleChannelInboundHandler
;
import
io.netty.channel.epoll.Epoll
;
import
io.netty.channel.epoll.EpollEventLoopGroup
;
import
io.netty.channel.epoll.EpollServerSocketChannel
;
import
io.netty.channel.epoll.EpollSocketChannel
;
import
io.netty.channel.nio.NioEventLoopGroup
;
import
io.netty.channel.socket.SocketChannel
;
import
io.netty.channel.socket.nio.NioServerSocketChannel
;
...
...
@@ -40,9 +45,6 @@ public class NettyMessagingService implements MessagingService {
private
final
int
port
;
private
final
Endpoint
localEp
;
private
final
EventLoopGroup
bossGroup
=
new
NioEventLoopGroup
();
private
EventLoopGroup
workerGroup
;
private
Class
<?
extends
Channel
>
channelClass
;
private
final
ConcurrentMap
<
String
,
MessageHandler
>
handlers
=
new
ConcurrentHashMap
<>();
private
final
Cache
<
Long
,
AsyncResponse
>
responseFutures
=
CacheBuilder
.
newBuilder
()
.
maximumSize
(
100000
)
...
...
@@ -53,10 +55,32 @@ public class NettyMessagingService implements MessagingService {
private
final
GenericKeyedObjectPool
<
Endpoint
,
Channel
>
channels
=
new
GenericKeyedObjectPool
<
Endpoint
,
Channel
>(
new
OnosCommunicationChannelFactory
());
// TODO: make this configurable.
private
EventLoopGroup
serverGroup
;
private
EventLoopGroup
clientGroup
;
private
Class
<?
extends
ServerChannel
>
serverChannelClass
;
private
Class
<?
extends
Channel
>
clientChannelClass
;
private
void
initEventLoopGroup
()
{
workerGroup
=
new
NioEventLoopGroup
();
channelClass
=
NioSocketChannel
.
class
;
// try Epoll first and if that does work, use nio.
// TODO: make this configurable.
try
{
if
(
Epoll
.
isAvailable
())
{
clientGroup
=
new
EpollEventLoopGroup
();
serverGroup
=
new
EpollEventLoopGroup
();
serverChannelClass
=
EpollServerSocketChannel
.
class
;
clientChannelClass
=
EpollSocketChannel
.
class
;
return
;
}
else
{
log
.
info
(
"Netty epoll support is not available. Proceeding with nio."
);
}
}
catch
(
Throwable
t
)
{
log
.
warn
(
"Failed to initialize epoll sockets. Proceeding with nio."
,
t
);
}
clientGroup
=
new
NioEventLoopGroup
();
serverGroup
=
new
NioEventLoopGroup
();
serverChannelClass
=
NioServerSocketChannel
.
class
;
clientChannelClass
=
NioSocketChannel
.
class
;
}
public
NettyMessagingService
()
{
...
...
@@ -84,8 +108,8 @@ public class NettyMessagingService implements MessagingService {
public
void
deactivate
()
throws
Exception
{
channels
.
close
();
boss
Group
.
shutdownGracefully
();
worker
Group
.
shutdownGracefully
();
server
Group
.
shutdownGracefully
();
client
Group
.
shutdownGracefully
();
}
@Override
...
...
@@ -149,8 +173,8 @@ public class NettyMessagingService implements MessagingService {
b
.
option
(
ChannelOption
.
WRITE_BUFFER_LOW_WATER_MARK
,
8
*
1024
);
// TODO: Need JVM options to configure PooledByteBufAllocator.
b
.
option
(
ChannelOption
.
ALLOCATOR
,
PooledByteBufAllocator
.
DEFAULT
);
b
.
group
(
bossGroup
,
worker
Group
)
.
channel
(
NioServerSocketChannel
.
c
lass
)
b
.
group
(
serverGroup
,
client
Group
)
.
channel
(
serverChannelC
lass
)
.
childHandler
(
new
OnosCommunicationChannelInitializer
())
.
option
(
ChannelOption
.
SO_BACKLOG
,
128
)
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
...
...
@@ -178,10 +202,10 @@ public class NettyMessagingService implements MessagingService {
bootstrap
.
option
(
ChannelOption
.
ALLOCATOR
,
PooledByteBufAllocator
.
DEFAULT
);
bootstrap
.
option
(
ChannelOption
.
WRITE_BUFFER_HIGH_WATER_MARK
,
32
*
1024
);
bootstrap
.
option
(
ChannelOption
.
WRITE_BUFFER_LOW_WATER_MARK
,
8
*
1024
);
bootstrap
.
group
(
worker
Group
);
bootstrap
.
group
(
client
Group
);
// TODO: Make this faster:
// http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0
bootstrap
.
channel
(
channelClass
);
bootstrap
.
channel
(
c
lientC
hannelClass
);
bootstrap
.
option
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
bootstrap
.
handler
(
new
OnosCommunicationChannelInitializer
());
// Start the client.
...
...
Please
register
or
login
to post a comment