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 16:46:12 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
871009392c53b15e9271e3f9908fafbc0496633c
87100939
1 parent
61d59dac
Added NettyMessagingService constructor that accepts both ip and port
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
utils/netty/src/main/java/org/onlab/netty/InternalMessage.java
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
View file @
8710093
...
...
@@ -67,7 +67,7 @@ public class ClusterCommunicationManager
@Activate
public
void
activate
()
{
ControllerNode
localNode
=
clusterService
.
getLocalNode
();
NettyMessagingService
netty
=
new
NettyMessagingService
(
localNode
.
tcpPort
());
NettyMessagingService
netty
=
new
NettyMessagingService
(
localNode
.
ip
().
toString
(),
localNode
.
tcpPort
());
// FIXME: workaround until it becomes a service.
try
{
netty
.
activate
();
...
...
utils/netty/src/main/java/org/onlab/netty/InternalMessage.java
View file @
8710093
...
...
@@ -44,8 +44,7 @@ public final class InternalMessage implements Message {
public
void
respond
(
byte
[]
data
)
throws
IOException
{
Builder
builder
=
new
Builder
(
messagingService
);
InternalMessage
message
=
builder
.
withId
(
this
.
id
)
// FIXME: Sender should be messagingService.localEp.
.
withSender
(
this
.
sender
)
.
withSender
(
messagingService
.
localEp
())
.
withPayload
(
data
)
.
withType
(
REPLY_MESSAGE_TYPE
)
.
build
();
...
...
utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
View file @
8710093
...
...
@@ -42,7 +42,6 @@ public class NettyMessagingService implements MessagingService {
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
private
final
int
port
;
private
final
Endpoint
localEp
;
private
final
ConcurrentMap
<
String
,
MessageHandler
>
handlers
=
new
ConcurrentHashMap
<>();
private
final
Cache
<
Long
,
AsyncResponse
>
responseFutures
=
CacheBuilder
.
newBuilder
()
...
...
@@ -77,6 +76,10 @@ public class NettyMessagingService implements MessagingService {
clientChannelClass
=
NioSocketChannel
.
class
;
}
public
NettyMessagingService
(
String
ip
,
int
port
)
{
localEp
=
new
Endpoint
(
ip
,
port
);
}
public
NettyMessagingService
()
{
// TODO: Default port should be configurable.
this
(
8080
);
...
...
@@ -84,7 +87,6 @@ public class NettyMessagingService implements MessagingService {
// FIXME: Constructor should not throw exceptions.
public
NettyMessagingService
(
int
port
)
{
this
.
port
=
port
;
try
{
localEp
=
new
Endpoint
(
java
.
net
.
InetAddress
.
getLocalHost
().
getHostName
(),
port
);
}
catch
(
UnknownHostException
e
)
{
...
...
@@ -106,6 +108,14 @@ public class NettyMessagingService implements MessagingService {
clientGroup
.
shutdownGracefully
();
}
/**
* Returns the local endpoint for this instance.
* @return local end point.
*/
public
Endpoint
localEp
()
{
return
localEp
;
}
@Override
public
void
sendAsync
(
Endpoint
ep
,
String
type
,
byte
[]
payload
)
throws
IOException
{
InternalMessage
message
=
new
InternalMessage
.
Builder
(
this
)
...
...
@@ -127,7 +137,7 @@ public class NettyMessagingService implements MessagingService {
channels
.
returnObject
(
ep
,
channel
);
}
}
catch
(
Exception
e
)
{
throw
new
IOException
(
e
);
throw
new
IOException
(
"Failed to send message to "
+
ep
.
toString
(),
e
);
}
}
...
...
@@ -174,7 +184,7 @@ public class NettyMessagingService implements MessagingService {
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
// Bind and start to accept incoming connections.
b
.
bind
(
port
).
sync
();
b
.
bind
(
localEp
.
port
()
).
sync
();
}
private
class
OnosCommunicationChannelFactory
...
...
Please
register
or
login
to post a comment