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-07 17:26:25 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
29e5dfd82b97b642ebc39ac2a61f66fbd3a61db9
29e5dfd8
1 parent
ce2a9586
Added logging to netty
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
utils/netty/src/main/java/org/onlab/netty/MessageEncoder.java
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
View file @
29e5dfd
...
...
@@ -8,11 +8,16 @@ import io.netty.handler.codec.ReplayingDecoder;
import
java.util.Arrays
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* Decoder for inbound messages.
*/
public
class
MessageDecoder
extends
ReplayingDecoder
<
DecoderState
>
{
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
private
final
NettyMessagingService
messagingService
;
private
static
final
KryoSerializer
SERIALIZER
=
new
KryoSerializer
();
...
...
@@ -57,4 +62,10 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> {
checkState
(
false
,
"Must not be here"
);
}
}
@Override
public
void
exceptionCaught
(
ChannelHandlerContext
context
,
Throwable
cause
)
{
log
.
error
(
"Exception inside channel handling pipeline."
,
cause
);
context
.
close
();
}
}
...
...
utils/netty/src/main/java/org/onlab/netty/MessageEncoder.java
View file @
29e5dfd
package
org
.
onlab
.
netty
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.ChannelHandler.Sharable
;
import
io.netty.channel.ChannelHandlerContext
;
...
...
@@ -11,6 +14,8 @@ import io.netty.handler.codec.MessageToByteEncoder;
@Sharable
public
class
MessageEncoder
extends
MessageToByteEncoder
<
InternalMessage
>
{
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
// onosiscool in ascii
public
static
final
byte
[]
PREAMBLE
=
"onosiscool"
.
getBytes
();
public
static
final
int
HEADER_VERSION
=
1
;
...
...
@@ -47,4 +52,10 @@ public class MessageEncoder extends MessageToByteEncoder<InternalMessage> {
// write payload.
out
.
writeBytes
(
payload
);
}
@Override
public
void
exceptionCaught
(
ChannelHandlerContext
context
,
Throwable
cause
)
{
log
.
error
(
"Exception inside channel handling pipeline."
,
cause
);
context
.
close
();
}
}
...
...
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
View file @
29e5dfd
...
...
@@ -248,6 +248,7 @@ public class NettyMessagingService implements MessagingService {
@Override
public
void
exceptionCaught
(
ChannelHandlerContext
context
,
Throwable
cause
)
{
log
.
error
(
"Exception inside channel handling pipeline."
,
cause
);
context
.
close
();
}
}
...
...
Please
register
or
login
to post a comment