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-08 11:20:38 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
253225359a93f1aa00b3b21524107d035ed62e29
25322535
1 parent
8e939d82
Added support for replicating device offline topology events
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStoreMessageSubjects.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
View file @
2532253
...
...
@@ -119,8 +119,10 @@ public class GossipDeviceStore
serializerPool
=
KryoPool
.
newBuilder
()
.
register
(
KryoPoolUtil
.
API
)
.
register
(
InternalDeviceEvent
.
class
,
new
InternalDeviceEventSerializer
())
.
register
(
InternalDeviceOfflineEvent
.
class
,
new
InternalDeviceOfflineEventSerializer
())
.
register
(
InternalPortEvent
.
class
,
new
InternalPortEventSerializer
())
.
register
(
InternalPortStatusEvent
.
class
,
new
InternalPortStatusEventSerializer
())
.
register
(
Timestamp
.
class
)
.
register
(
Timestamped
.
class
)
.
register
(
MastershipBasedTimestamp
.
class
,
new
MastershipBasedTimestampSerializer
())
.
build
()
...
...
@@ -134,6 +136,8 @@ public class GossipDeviceStore
clusterCommunicator
.
addSubscriber
(
GossipDeviceStoreMessageSubjects
.
DEVICE_UPDATE
,
new
InternalDeviceEventListener
());
clusterCommunicator
.
addSubscriber
(
GossipDeviceStoreMessageSubjects
.
DEVICE_OFFLINE
,
new
InternalDeviceOfflineEventListener
());
clusterCommunicator
.
addSubscriber
(
GossipDeviceStoreMessageSubjects
.
PORT_UPDATE
,
new
InternalPortEventListener
());
clusterCommunicator
.
addSubscriber
(
GossipDeviceStoreMessageSubjects
.
PORT_STATUS_UPDATE
,
new
InternalPortStatusEventListener
());
...
...
@@ -177,7 +181,7 @@ public class GossipDeviceStore
try
{
notifyPeers
(
new
InternalDeviceEvent
(
providerId
,
deviceId
,
deltaDesc
));
}
catch
(
IOException
e
)
{
log
.
error
(
"Failed to notify peers of a device update topology event or providerId: "
log
.
error
(
"Failed to notify peers of a device update topology event
f
or providerId: "
+
providerId
+
" and deviceId: "
+
deviceId
,
e
);
}
}
...
...
@@ -280,7 +284,18 @@ public class GossipDeviceStore
@Override
public
DeviceEvent
markOffline
(
DeviceId
deviceId
)
{
Timestamp
timestamp
=
clockService
.
getTimestamp
(
deviceId
);
return
markOfflineInternal
(
deviceId
,
timestamp
);
DeviceEvent
event
=
markOfflineInternal
(
deviceId
,
timestamp
);
if
(
event
!=
null
)
{
log
.
info
(
"Notifying peers of a device offline topology event for deviceId: {}"
,
deviceId
);
try
{
notifyPeers
(
new
InternalDeviceOfflineEvent
(
deviceId
,
timestamp
));
}
catch
(
IOException
e
)
{
log
.
error
(
"Failed to notify peers of a device offline topology event for deviceId: {}"
,
deviceId
);
}
}
return
event
;
}
private
DeviceEvent
markOfflineInternal
(
DeviceId
deviceId
,
Timestamp
timestamp
)
{
...
...
@@ -811,6 +826,14 @@ public class GossipDeviceStore
clusterCommunicator
.
broadcast
(
message
);
}
private
void
notifyPeers
(
InternalDeviceOfflineEvent
event
)
throws
IOException
{
ClusterMessage
message
=
new
ClusterMessage
(
clusterService
.
getLocalNode
().
id
(),
GossipDeviceStoreMessageSubjects
.
DEVICE_OFFLINE
,
SERIALIZER
.
encode
(
event
));
clusterCommunicator
.
broadcast
(
message
);
}
private
void
notifyPeers
(
InternalPortEvent
event
)
throws
IOException
{
ClusterMessage
message
=
new
ClusterMessage
(
clusterService
.
getLocalNode
().
id
(),
...
...
@@ -830,15 +853,32 @@ public class GossipDeviceStore
private
class
InternalDeviceEventListener
implements
ClusterMessageHandler
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
log
.
info
(
"Received device update event from peer: {}"
,
message
.
sender
());
InternalDeviceEvent
event
=
(
InternalDeviceEvent
)
SERIALIZER
.
decode
(
message
.
payload
());
ProviderId
providerId
=
event
.
providerId
();
DeviceId
deviceId
=
event
.
deviceId
();
Timestamped
<
DeviceDescription
>
deviceDescription
=
event
.
deviceDescription
();
createOrUpdateDeviceInternal
(
providerId
,
deviceId
,
deviceDescription
);
}
}
private
class
InternalDeviceOfflineEventListener
implements
ClusterMessageHandler
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
log
.
info
(
"Received device offline event from peer: {}"
,
message
.
sender
());
InternalDeviceOfflineEvent
event
=
(
InternalDeviceOfflineEvent
)
SERIALIZER
.
decode
(
message
.
payload
());
DeviceId
deviceId
=
event
.
deviceId
();
Timestamp
timestamp
=
event
.
timestamp
();
markOfflineInternal
(
deviceId
,
timestamp
);
}
}
private
class
InternalPortEventListener
implements
ClusterMessageHandler
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStoreMessageSubjects.java
View file @
2532253
...
...
@@ -3,13 +3,14 @@ package org.onlab.onos.store.device.impl;
import
org.onlab.onos.store.cluster.messaging.MessageSubject
;
/**
* MessageSubjects used by GossipDeviceStore.
* MessageSubjects used by GossipDeviceStore
peer-peer communication
.
*/
public
final
class
GossipDeviceStoreMessageSubjects
{
private
GossipDeviceStoreMessageSubjects
()
{}
public
static
final
MessageSubject
DEVICE_UPDATE
=
new
MessageSubject
(
"peer-device-update"
);
public
static
final
MessageSubject
DEVICE_OFFLINE
=
new
MessageSubject
(
"peer-device-offline"
);
public
static
final
MessageSubject
PORT_UPDATE
=
new
MessageSubject
(
"peer-port-update"
);
public
static
final
MessageSubject
PORT_STATUS_UPDATE
=
new
MessageSubject
(
"peer-port-status-update"
);
}
...
...
Please
register
or
login
to post a comment