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-17 16:55:50 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a89509948c29e7d8060242fac3f3d44f5491b11
8a895099
1 parent
18dbb7e7
Added support for responding directly via a cluster message received from a peer
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletions
core/api/src/main/java/org/onlab/onos/store/cluster/messaging/ClusterMessage.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
core/api/src/main/java/org/onlab/onos/store/cluster/messaging/ClusterMessage.java
View file @
8a89509
package
org
.
onlab
.
onos
.
store
.
cluster
.
messaging
;
import
java.io.IOException
;
import
org.onlab.onos.cluster.NodeId
;
// TODO: Should payload type be ByteBuffer?
...
...
@@ -49,4 +51,14 @@ public class ClusterMessage {
public
byte
[]
payload
()
{
return
payload
;
}
/**
* Sends a response to the sender.
*
* @param data payload response.
* @throws IOException
*/
public
void
respond
(
byte
[]
data
)
throws
IOException
{
throw
new
IllegalStateException
(
"One can only repond to message recived from others."
);
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
View file @
8a89509
...
...
@@ -158,7 +158,7 @@ public class ClusterCommunicationManager
public
void
handle
(
Message
message
)
{
try
{
ClusterMessage
clusterMessage
=
SERIALIZER
.
decode
(
message
.
payload
());
handler
.
handle
(
clusterMessage
);
handler
.
handle
(
new
InternalClusterMessage
(
clusterMessage
,
message
)
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Exception caught during ClusterMessageHandler"
,
e
);
throw
e
;
...
...
@@ -166,6 +166,21 @@ public class ClusterCommunicationManager
}
}
public
static
final
class
InternalClusterMessage
extends
ClusterMessage
{
private
final
Message
rawMessage
;
public
InternalClusterMessage
(
ClusterMessage
clusterMessage
,
Message
rawMessage
)
{
super
(
clusterMessage
.
sender
(),
clusterMessage
.
subject
(),
clusterMessage
.
payload
());
this
.
rawMessage
=
rawMessage
;
}
@Override
public
void
respond
(
byte
[]
response
)
throws
IOException
{
rawMessage
.
respond
(
response
);
}
}
private
static
final
class
InternalClusterMessageResponse
implements
ClusterMessageResponse
{
private
final
NodeId
sender
;
...
...
Please
register
or
login
to post a comment