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
tom
2014-10-01 14:59:20 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
481b76296d281cee3fca85dfad8067773220e76a
481b7629
2 parents
1cd74ae7
5f6739c0
Merge remote-tracking branch 'origin/master'
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
26 deletions
core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosDistributedDeviceStore.java
core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStoreTest.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
View file @
481b762
...
...
@@ -48,6 +48,7 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
DeviceEvent
createOrUpdateDevice
(
ProviderId
providerId
,
DeviceId
deviceId
,
DeviceDescription
deviceDescription
);
// TODO: We may need to enforce that ancillary cannot interfere this state
/**
* Removes the specified infrastructure device.
*
...
...
@@ -60,22 +61,24 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
* Updates the ports of the specified infrastructure device using the given
* list of port descriptions. The list is assumed to be comprehensive.
*
* @param providerId provider identifier
* @param deviceId device identifier
* @param portDescriptions list of port descriptions
* @return ready to send events describing what occurred; empty list if no change
*/
List
<
DeviceEvent
>
updatePorts
(
DeviceId
deviceId
,
List
<
DeviceEvent
>
updatePorts
(
ProviderId
providerId
,
DeviceId
deviceId
,
List
<
PortDescription
>
portDescriptions
);
/**
* Updates the port status of the specified infrastructure device using the
* given port description.
*
* @param providerId provider identifier
* @param deviceId device identifier
* @param portDescription port description
* @return ready to send event describing what occurred; null if no change
*/
DeviceEvent
updatePortStatus
(
DeviceId
deviceId
,
DeviceEvent
updatePortStatus
(
ProviderId
providerId
,
DeviceId
deviceId
,
PortDescription
portDescription
);
/**
...
...
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
View file @
481b762
...
...
@@ -228,8 +228,9 @@ public class DeviceManager
checkNotNull
(
portDescriptions
,
"Port descriptions list cannot be null"
);
checkValidity
();
List
<
DeviceEvent
>
events
=
store
.
updatePorts
(
deviceId
,
portDescriptions
);
this
.
provider
().
id
();
List
<
DeviceEvent
>
events
=
store
.
updatePorts
(
this
.
provider
().
id
(),
deviceId
,
portDescriptions
);
for
(
DeviceEvent
event
:
events
)
{
post
(
event
);
}
...
...
@@ -241,8 +242,8 @@ public class DeviceManager
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
checkNotNull
(
portDescription
,
PORT_DESCRIPTION_NULL
);
checkValidity
();
DeviceEvent
event
=
store
.
updatePortStatus
(
deviceId
,
portDescription
);
DeviceEvent
event
=
store
.
updatePortStatus
(
this
.
provider
().
id
()
,
deviceId
,
portDescription
);
if
(
event
!=
null
)
{
log
.
info
(
"Device {} port {} status changed"
,
deviceId
,
event
.
port
().
number
());
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosDistributedDeviceStore.java
View file @
481b762
...
...
@@ -192,7 +192,7 @@ public class OnosDistributedDeviceStore
}
@Override
public
List
<
DeviceEvent
>
updatePorts
(
DeviceId
deviceId
,
public
List
<
DeviceEvent
>
updatePorts
(
ProviderId
providerId
,
DeviceId
deviceId
,
List
<
PortDescription
>
portDescriptions
)
{
List
<
DeviceEvent
>
events
=
new
ArrayList
<>();
synchronized
(
this
)
{
...
...
@@ -296,7 +296,7 @@ public class OnosDistributedDeviceStore
}
@Override
public
DeviceEvent
updatePortStatus
(
DeviceId
deviceId
,
public
DeviceEvent
updatePortStatus
(
ProviderId
providerId
,
DeviceId
deviceId
,
PortDescription
portDescription
)
{
VersionedValue
<
Device
>
device
=
devices
.
get
(
deviceId
);
checkArgument
(
device
!=
null
,
DEVICE_NOT_FOUND
,
deviceId
);
...
...
core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
View file @
481b762
...
...
@@ -221,7 +221,7 @@ public class DistributedDeviceStore
}
@Override
public
List
<
DeviceEvent
>
updatePorts
(
DeviceId
deviceId
,
public
List
<
DeviceEvent
>
updatePorts
(
ProviderId
providerId
,
DeviceId
deviceId
,
List
<
PortDescription
>
portDescriptions
)
{
List
<
DeviceEvent
>
events
=
new
ArrayList
<>();
synchronized
(
this
)
{
...
...
@@ -319,7 +319,7 @@ public class DistributedDeviceStore
}
@Override
public
DeviceEvent
updatePortStatus
(
DeviceId
deviceId
,
public
DeviceEvent
updatePortStatus
(
ProviderId
providerId
,
DeviceId
deviceId
,
PortDescription
portDescription
)
{
synchronized
(
this
)
{
Device
device
=
devices
.
getUnchecked
(
deviceId
).
orNull
();
...
...
core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
View file @
481b762
...
...
@@ -201,7 +201,7 @@ public class DistributedDeviceStoreTest {
new
DefaultPortDescription
(
P2
,
true
)
);
List
<
DeviceEvent
>
events
=
deviceStore
.
updatePorts
(
DID1
,
pds
);
List
<
DeviceEvent
>
events
=
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
Set
<
PortNumber
>
expectedPorts
=
Sets
.
newHashSet
(
P1
,
P2
);
for
(
DeviceEvent
event
:
events
)
{
...
...
@@ -220,7 +220,7 @@ public class DistributedDeviceStoreTest {
new
DefaultPortDescription
(
P3
,
true
)
);
events
=
deviceStore
.
updatePorts
(
DID1
,
pds2
);
events
=
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds2
);
assertFalse
(
"event should be triggered"
,
events
.
isEmpty
());
for
(
DeviceEvent
event
:
events
)
{
PortNumber
num
=
event
.
port
().
number
();
...
...
@@ -243,7 +243,7 @@ public class DistributedDeviceStoreTest {
new
DefaultPortDescription
(
P1
,
false
),
new
DefaultPortDescription
(
P2
,
true
)
);
events
=
deviceStore
.
updatePorts
(
DID1
,
pds3
);
events
=
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds3
);
assertFalse
(
"event should be triggered"
,
events
.
isEmpty
());
for
(
DeviceEvent
event
:
events
)
{
PortNumber
num
=
event
.
port
().
number
();
...
...
@@ -268,9 +268,9 @@ public class DistributedDeviceStoreTest {
List
<
PortDescription
>
pds
=
Arrays
.<
PortDescription
>
asList
(
new
DefaultPortDescription
(
P1
,
true
)
);
deviceStore
.
updatePorts
(
DID1
,
pds
);
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
DeviceEvent
event
=
deviceStore
.
updatePortStatus
(
DID1
,
DeviceEvent
event
=
deviceStore
.
updatePortStatus
(
PID
,
DID1
,
new
DefaultPortDescription
(
P1
,
false
));
assertEquals
(
PORT_UPDATED
,
event
.
type
());
assertDevice
(
DID1
,
SW1
,
event
.
subject
());
...
...
@@ -286,7 +286,7 @@ public class DistributedDeviceStoreTest {
new
DefaultPortDescription
(
P1
,
true
),
new
DefaultPortDescription
(
P2
,
true
)
);
deviceStore
.
updatePorts
(
DID1
,
pds
);
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
Set
<
PortNumber
>
expectedPorts
=
Sets
.
newHashSet
(
P1
,
P2
);
List
<
Port
>
ports
=
deviceStore
.
getPorts
(
DID1
);
...
...
@@ -309,7 +309,7 @@ public class DistributedDeviceStoreTest {
new
DefaultPortDescription
(
P1
,
true
),
new
DefaultPortDescription
(
P2
,
false
)
);
deviceStore
.
updatePorts
(
DID1
,
pds
);
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
Port
port1
=
deviceStore
.
getPort
(
DID1
,
P1
);
assertEquals
(
P1
,
port1
.
number
());
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
View file @
481b762
...
...
@@ -143,7 +143,7 @@ public class SimpleDeviceStore
}
@Override
public
List
<
DeviceEvent
>
updatePorts
(
DeviceId
deviceId
,
public
List
<
DeviceEvent
>
updatePorts
(
ProviderId
providerId
,
DeviceId
deviceId
,
List
<
PortDescription
>
portDescriptions
)
{
List
<
DeviceEvent
>
events
=
new
ArrayList
<>();
synchronized
(
this
)
{
...
...
@@ -221,7 +221,7 @@ public class SimpleDeviceStore
}
@Override
public
DeviceEvent
updatePortStatus
(
DeviceId
deviceId
,
public
DeviceEvent
updatePortStatus
(
ProviderId
providerId
,
DeviceId
deviceId
,
PortDescription
portDescription
)
{
synchronized
(
this
)
{
Device
device
=
devices
.
get
(
deviceId
);
...
...
core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStoreTest.java
View file @
481b762
...
...
@@ -182,7 +182,7 @@ public class SimpleDeviceStoreTest {
new
DefaultPortDescription
(
P2
,
true
)
);
List
<
DeviceEvent
>
events
=
deviceStore
.
updatePorts
(
DID1
,
pds
);
List
<
DeviceEvent
>
events
=
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
Set
<
PortNumber
>
expectedPorts
=
Sets
.
newHashSet
(
P1
,
P2
);
for
(
DeviceEvent
event
:
events
)
{
...
...
@@ -201,7 +201,7 @@ public class SimpleDeviceStoreTest {
new
DefaultPortDescription
(
P3
,
true
)
);
events
=
deviceStore
.
updatePorts
(
DID1
,
pds2
);
events
=
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds2
);
assertFalse
(
"event should be triggered"
,
events
.
isEmpty
());
for
(
DeviceEvent
event
:
events
)
{
PortNumber
num
=
event
.
port
().
number
();
...
...
@@ -224,7 +224,7 @@ public class SimpleDeviceStoreTest {
new
DefaultPortDescription
(
P1
,
false
),
new
DefaultPortDescription
(
P2
,
true
)
);
events
=
deviceStore
.
updatePorts
(
DID1
,
pds3
);
events
=
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds3
);
assertFalse
(
"event should be triggered"
,
events
.
isEmpty
());
for
(
DeviceEvent
event
:
events
)
{
PortNumber
num
=
event
.
port
().
number
();
...
...
@@ -249,9 +249,9 @@ public class SimpleDeviceStoreTest {
List
<
PortDescription
>
pds
=
Arrays
.<
PortDescription
>
asList
(
new
DefaultPortDescription
(
P1
,
true
)
);
deviceStore
.
updatePorts
(
DID1
,
pds
);
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
DeviceEvent
event
=
deviceStore
.
updatePortStatus
(
DID1
,
DeviceEvent
event
=
deviceStore
.
updatePortStatus
(
PID
,
DID1
,
new
DefaultPortDescription
(
P1
,
false
));
assertEquals
(
PORT_UPDATED
,
event
.
type
());
assertDevice
(
DID1
,
SW1
,
event
.
subject
());
...
...
@@ -267,7 +267,7 @@ public class SimpleDeviceStoreTest {
new
DefaultPortDescription
(
P1
,
true
),
new
DefaultPortDescription
(
P2
,
true
)
);
deviceStore
.
updatePorts
(
DID1
,
pds
);
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
Set
<
PortNumber
>
expectedPorts
=
Sets
.
newHashSet
(
P1
,
P2
);
List
<
Port
>
ports
=
deviceStore
.
getPorts
(
DID1
);
...
...
@@ -290,7 +290,7 @@ public class SimpleDeviceStoreTest {
new
DefaultPortDescription
(
P1
,
true
),
new
DefaultPortDescription
(
P2
,
false
)
);
deviceStore
.
updatePorts
(
DID1
,
pds
);
deviceStore
.
updatePorts
(
PID
,
DID1
,
pds
);
Port
port1
=
deviceStore
.
getPort
(
DID1
,
P1
);
assertEquals
(
P1
,
port1
.
number
());
...
...
Please
register
or
login
to post a comment