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
alshabib
2014-10-20 17:17:38 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
f4f23fcdf4806c350c7846420dbafee1e978e39c
f4f23fcd
2 parents
9eab22f0
d8cf5664
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
features/features.xml
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
features/features.xml
View file @
f4f23fc
...
...
@@ -29,18 +29,21 @@
<bundle>
mvn:org.onlab.onos/onlab-nio/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:com.fasterxml.jackson.core/jackson-core/2.4.2
</bundle>
<bundle>
mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.2
</bundle>
<bundle>
mvn:com.fasterxml.jackson.core/jackson-databind/2.4.2
</bundle>
<!-- FIXME: we should switch to use fasterxml jackson -->
<bundle>
mvn:org.codehaus.jackson/jackson-core-asl/1.9.13
</bundle>
<bundle>
mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.13
</bundle>
<bundle>
mvn:org.onlab.onos/onlab-thirdparty/1.0.0-SNAPSHOT
</bundle>
</feature>
<feature
name=
"onos-thirdparty-web"
version=
"1.0.0"
description=
"ONOS 3rd party dependencies"
>
<feature>
war
</feature>
<bundle>
mvn:com.fasterxml.jackson.core/jackson-core/2.4.2
</bundle>
<bundle>
mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.2
</bundle>
<bundle>
mvn:com.fasterxml.jackson.core/jackson-databind/2.4.2
</bundle>
<feature>
onos-thirdparty-base
</feature>
<bundle>
mvn:com.sun.jersey/jersey-core/1.18.1
</bundle>
<bundle>
mvn:com.sun.jersey/jersey-server/1.18.1
</bundle>
<bundle>
mvn:com.sun.jersey/jersey-servlet/1.18.1
</bundle>
...
...
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
View file @
f4f23fc
...
...
@@ -16,7 +16,11 @@ 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.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 +44,10 @@ public class NettyMessagingService implements MessagingService {
private
final
int
port
;
private
final
Endpoint
localEp
;
private
final
EventLoopGroup
bossGroup
=
new
NioEventLoopGroup
()
;
private
EventLoopGroup
bossGroup
;
private
EventLoopGroup
workerGroup
;
private
Class
<?
extends
Channel
>
channelClass
;
private
Class
<?
extends
Channel
>
clientChannelClass
;
private
Class
<?
extends
ServerChannel
>
serverChannelClass
;
private
final
ConcurrentMap
<
String
,
MessageHandler
>
handlers
=
new
ConcurrentHashMap
<>();
private
final
Cache
<
Long
,
AsyncResponse
>
responseFutures
=
CacheBuilder
.
newBuilder
()
.
maximumSize
(
100000
)
...
...
@@ -55,8 +60,17 @@ public class NettyMessagingService implements MessagingService {
// TODO: make this configurable.
private
void
initEventLoopGroup
()
{
workerGroup
=
new
NioEventLoopGroup
();
channelClass
=
NioSocketChannel
.
class
;
try
{
bossGroup
=
new
EpollEventLoopGroup
();
workerGroup
=
new
EpollEventLoopGroup
();
clientChannelClass
=
EpollSocketChannel
.
class
;
serverChannelClass
=
EpollServerSocketChannel
.
class
;
}
catch
(
Throwable
th
)
{
bossGroup
=
new
NioEventLoopGroup
();
workerGroup
=
new
NioEventLoopGroup
();
serverChannelClass
=
NioServerSocketChannel
.
class
;
clientChannelClass
=
NioSocketChannel
.
class
;
}
}
public
NettyMessagingService
()
{
...
...
@@ -150,7 +164,7 @@ public class NettyMessagingService implements MessagingService {
// TODO: Need JVM options to configure PooledByteBufAllocator.
b
.
option
(
ChannelOption
.
ALLOCATOR
,
PooledByteBufAllocator
.
DEFAULT
);
b
.
group
(
bossGroup
,
workerGroup
)
.
channel
(
NioServerSocketChannel
.
c
lass
)
.
channel
(
serverChannelC
lass
)
.
childHandler
(
new
OnosCommunicationChannelInitializer
())
.
option
(
ChannelOption
.
SO_BACKLOG
,
128
)
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
...
...
@@ -181,7 +195,7 @@ public class NettyMessagingService implements MessagingService {
bootstrap
.
group
(
workerGroup
);
// 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