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-14 23:27:57 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
255618f776c5c811fd696896fecae1cde520f129
255618f7
1 parent
312a2989
GossipHostStore: Added listeners for handling peer messages
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
core/store/dist/src/main/java/org/onlab/onos/store/host/impl/GossipHostStore.java
core/store/dist/src/main/java/org/onlab/onos/store/host/impl/GossipHostStore.java
View file @
255618f
...
...
@@ -30,6 +30,7 @@ import org.onlab.onos.store.AbstractStore;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.cluster.messaging.ClusterCommunicationService
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessage
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessageHandler
;
import
org.onlab.onos.store.cluster.messaging.MessageSubject
;
import
org.onlab.onos.store.common.impl.Timestamped
;
import
org.onlab.onos.store.serializers.DistributedStoreSerializers
;
...
...
@@ -95,6 +96,11 @@ public class GossipHostStore
@Activate
public
void
activate
()
{
clusterCommunicator
.
addSubscriber
(
GossipHostStoreMessageSubjects
.
HOST_UPDATED
,
new
InternalHostEventListener
());
clusterCommunicator
.
addSubscriber
(
GossipHostStoreMessageSubjects
.
HOST_REMOVED
,
new
InternalHostRemovedEventListener
());
log
.
info
(
"Started"
);
}
...
...
@@ -392,4 +398,40 @@ public class GossipHostStore
SERIALIZER
.
encode
(
event
));
clusterCommunicator
.
broadcast
(
message
);
}
private
void
notifyDelegateIfNotNull
(
HostEvent
event
)
{
if
(
event
!=
null
)
{
notifyDelegate
(
event
);
}
}
private
class
InternalHostEventListener
implements
ClusterMessageHandler
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
log
.
info
(
"Received host update event from peer: {}"
,
message
.
sender
());
InternalHostEvent
event
=
(
InternalHostEvent
)
SERIALIZER
.
decode
(
message
.
payload
());
ProviderId
providerId
=
event
.
providerId
();
HostId
hostId
=
event
.
hostId
();
HostDescription
hostDescription
=
event
.
hostDescription
();
Timestamp
timestamp
=
event
.
timestamp
();
notifyDelegateIfNotNull
(
createOrUpdateHostInternal
(
providerId
,
hostId
,
hostDescription
,
timestamp
));
}
}
private
class
InternalHostRemovedEventListener
implements
ClusterMessageHandler
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
log
.
info
(
"Received host removed event from peer: {}"
,
message
.
sender
());
InternalHostRemovedEvent
event
=
(
InternalHostRemovedEvent
)
SERIALIZER
.
decode
(
message
.
payload
());
HostId
hostId
=
event
.
hostId
();
Timestamp
timestamp
=
event
.
timestamp
();
notifyDelegateIfNotNull
(
removeHostInternal
(
hostId
,
timestamp
));
}
}
}
...
...
Please
register
or
login
to post a comment