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
Thomas Vachuska
2014-10-22 16:40:44 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
56dbeb18d35c026d849a2522a395ec8e22b4a153
56dbeb18
1 parent
ae968a66
Fixed a defect that allowed ancillary device providers to overwrite primary provider's data.
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
19 deletions
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
View file @
56dbeb1
...
...
@@ -290,12 +290,17 @@ public class GossipDeviceStore
private
DeviceEvent
updateDevice
(
ProviderId
providerId
,
Device
oldDevice
,
Device
newDevice
,
Timestamp
newTimestamp
)
{
// We allow only certain attributes to trigger update
if
(!
Objects
.
equals
(
oldDevice
.
hwVersion
(),
newDevice
.
hwVersion
())
||
!
Objects
.
equals
(
oldDevice
.
swVersion
(),
newDevice
.
swVersion
())
||
!
AnnotationsUtil
.
isEqual
(
oldDevice
.
annotations
(),
newDevice
.
annotations
()))
{
boolean
propertiesChanged
=
!
Objects
.
equals
(
oldDevice
.
hwVersion
(),
newDevice
.
hwVersion
())
||
!
Objects
.
equals
(
oldDevice
.
swVersion
(),
newDevice
.
swVersion
());
boolean
annotationsChanged
=
!
AnnotationsUtil
.
isEqual
(
oldDevice
.
annotations
(),
newDevice
.
annotations
());
// Primary providers can respond to all changes, but ancillary ones
// should respond only to annotation changes.
if
((
providerId
.
isAncillary
()
&&
annotationsChanged
)
||
(!
providerId
.
isAncillary
()
&&
(
propertiesChanged
||
annotationsChanged
)))
{
boolean
replaced
=
devices
.
replace
(
newDevice
.
id
(),
oldDevice
,
newDevice
);
if
(!
replaced
)
{
verify
(
replaced
,
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
View file @
56dbeb1
...
...
@@ -70,15 +70,16 @@ public class SimpleDeviceStore
public
static
final
String
DEVICE_NOT_FOUND
=
"Device with ID %s not found"
;
//
c
ollection of Description given from various providers
//
C
ollection of Description given from various providers
private
final
ConcurrentMap
<
DeviceId
,
Map
<
ProviderId
,
DeviceDescriptions
>>
deviceDescs
=
Maps
.
newConcurrentMap
();
//
c
ache of Device and Ports generated by compositing descriptions from providers
//
C
ache of Device and Ports generated by compositing descriptions from providers
private
final
ConcurrentMap
<
DeviceId
,
Device
>
devices
=
Maps
.
newConcurrentMap
();
private
final
ConcurrentMap
<
DeviceId
,
ConcurrentMap
<
PortNumber
,
Port
>>
devicePorts
=
Maps
.
newConcurrentMap
();
private
final
ConcurrentMap
<
DeviceId
,
ConcurrentMap
<
PortNumber
,
Port
>>
devicePorts
=
Maps
.
newConcurrentMap
();
//
available
(=UP) devices
//
Available
(=UP) devices
private
final
Set
<
DeviceId
>
availableDevices
=
Sets
.
newConcurrentHashSet
();
...
...
@@ -115,13 +116,11 @@ public class SimpleDeviceStore
public
DeviceEvent
createOrUpdateDevice
(
ProviderId
providerId
,
DeviceId
deviceId
,
DeviceDescription
deviceDescription
)
{
Map
<
ProviderId
,
DeviceDescriptions
>
providerDescs
=
getOrCreateDeviceDescriptions
(
deviceId
);
synchronized
(
providerDescs
)
{
// locking per device
DeviceDescriptions
descs
=
getOrCreateProviderDeviceDescriptions
(
providerDescs
,
providerId
,
...
...
@@ -145,7 +144,6 @@ public class SimpleDeviceStore
// Creates the device and returns the appropriate event if necessary.
// Guarded by deviceDescs value (=Device lock)
private
DeviceEvent
createDevice
(
ProviderId
providerId
,
Device
newDevice
)
{
// update composed device cache
Device
oldDevice
=
devices
.
putIfAbsent
(
newDevice
.
id
(),
newDevice
);
verify
(
oldDevice
==
null
,
...
...
@@ -162,14 +160,21 @@ public class SimpleDeviceStore
// Updates the device and returns the appropriate event if necessary.
// Guarded by deviceDescs value (=Device lock)
private
DeviceEvent
updateDevice
(
ProviderId
providerId
,
Device
oldDevice
,
Device
newDevice
)
{
// We allow only certain attributes to trigger update
if
(!
Objects
.
equals
(
oldDevice
.
hwVersion
(),
newDevice
.
hwVersion
())
||
!
Objects
.
equals
(
oldDevice
.
swVersion
(),
newDevice
.
swVersion
())
||
!
AnnotationsUtil
.
isEqual
(
oldDevice
.
annotations
(),
newDevice
.
annotations
()))
{
boolean
propertiesChanged
=
!
Objects
.
equals
(
oldDevice
.
hwVersion
(),
newDevice
.
hwVersion
())
||
!
Objects
.
equals
(
oldDevice
.
swVersion
(),
newDevice
.
swVersion
());
boolean
annotationsChanged
=
!
AnnotationsUtil
.
isEqual
(
oldDevice
.
annotations
(),
newDevice
.
annotations
());
// Primary providers can respond to all changes, but ancillary ones
// should respond only to annotation changes.
if
((
providerId
.
isAncillary
()
&&
annotationsChanged
)
||
(!
providerId
.
isAncillary
()
&&
(
propertiesChanged
||
annotationsChanged
)))
{
boolean
replaced
=
devices
.
replace
(
newDevice
.
id
(),
oldDevice
,
newDevice
);
if
(!
replaced
)
{
// FIXME: Is the enclosing if required here?
verify
(
replaced
,
"Replacing devices cache failed. PID:%s [expected:%s, found:%s, new=%s]"
,
providerId
,
oldDevice
,
devices
.
get
(
newDevice
.
id
())
...
...
@@ -214,7 +219,6 @@ public class SimpleDeviceStore
public
List
<
DeviceEvent
>
updatePorts
(
ProviderId
providerId
,
DeviceId
deviceId
,
List
<
PortDescription
>
portDescriptions
)
{
Device
device
=
devices
.
get
(
deviceId
);
checkArgument
(
device
!=
null
,
DEVICE_NOT_FOUND
,
deviceId
);
...
...
@@ -327,7 +331,6 @@ public class SimpleDeviceStore
private
DeviceDescriptions
getOrCreateProviderDeviceDescriptions
(
Map
<
ProviderId
,
DeviceDescriptions
>
device
,
ProviderId
providerId
,
DeviceDescription
deltaDesc
)
{
synchronized
(
device
)
{
DeviceDescriptions
r
=
device
.
get
(
providerId
);
if
(
r
==
null
)
{
...
...
@@ -447,7 +450,7 @@ public class SimpleDeviceStore
annotations
=
merge
(
annotations
,
e
.
getValue
().
getDeviceDesc
().
annotations
());
}
return
new
DefaultDevice
(
primary
,
deviceId
,
type
,
manufacturer
,
return
new
DefaultDevice
(
primary
,
deviceId
,
type
,
manufacturer
,
hwVersion
,
swVersion
,
serialNumber
,
chassisId
,
annotations
);
}
...
...
Please
register
or
login
to post a comment