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
Toshio Koide
2014-10-30 11:14:09 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
69e5257d324d79f97a637d2f01de7408475dbac7
69e5257d
1 parent
bce74250
Fix bugs on SimpleLinkResourceStore.
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
7 deletions
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkResourceStore.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkResourceStore.java
View file @
69e5257
...
...
@@ -15,7 +15,8 @@
*/
package
org
.
onlab
.
onos
.
store
.
trivial
.
impl
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.*;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkState
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.Collections
;
...
...
@@ -65,6 +66,13 @@ public class SimpleLinkResourceStore implements LinkResourceStore {
log
.
info
(
"Stopped"
);
}
/**
* Returns free resources for a given link obtaining from topology
* information.
*
* @param link the target link
* @return free resources
*/
private
Set
<
ResourceAllocation
>
readOriginalFreeResources
(
Link
link
)
{
// TODO read capacity and lambda resources from topology
Set
<
ResourceAllocation
>
allocations
=
new
HashSet
<>();
...
...
@@ -75,6 +83,15 @@ public class SimpleLinkResourceStore implements LinkResourceStore {
return
allocations
;
}
/**
* Finds and returns {@link BandwidthResourceAllocation} object from a given
* set.
*
* @param freeRes a set of ResourceAllocation object.
* @return {@link BandwidthResourceAllocation} object if found, otherwise
* {@link BandwidthResourceAllocation} object with 0 bandwidth
*
*/
private
BandwidthResourceAllocation
getBandwidth
(
Set
<
ResourceAllocation
>
freeRes
)
{
for
(
ResourceAllocation
res
:
freeRes
)
{
if
(
res
.
type
()
==
ResourceType
.
BANDWIDTH
)
{
...
...
@@ -84,12 +101,16 @@ public class SimpleLinkResourceStore implements LinkResourceStore {
return
new
BandwidthResourceAllocation
(
Bandwidth
.
valueOf
(
0
));
}
/**
* Subtracts given resources from free resources for given link.
*
* @param link the target link
* @param allocations the resources to be subtracted
*/
private
void
subtractFreeResources
(
Link
link
,
LinkResourceAllocations
allocations
)
{
// TODO Use lock or version for updating freeResources.
checkNotNull
(
link
);
Set
<
ResourceAllocation
>
freeRes
=
freeResources
.
get
(
link
);
checkNotNull
(
freeRes
);
freeRes
=
new
HashSet
<>(
freeRes
);
Set
<
ResourceAllocation
>
freeRes
=
new
HashSet
<>(
getFreeResources
(
link
));
Set
<
ResourceAllocation
>
subRes
=
allocations
.
getResourceAllocation
(
link
);
for
(
ResourceAllocation
res
:
subRes
)
{
switch
(
res
.
type
())
{
...
...
@@ -114,11 +135,15 @@ public class SimpleLinkResourceStore implements LinkResourceStore {
}
/**
* Adds given resources to free resources for given link.
*
* @param link the target link
* @param allocations the resources to be added
*/
private
void
addFreeResources
(
Link
link
,
LinkResourceAllocations
allocations
)
{
// TODO Use lock or version for updating freeResources.
Set
<
ResourceAllocation
>
freeRes
=
freeResources
.
get
(
link
);
checkNotNull
(
freeRes
);
freeRes
=
new
HashSet
<>(
freeRes
);
Set
<
ResourceAllocation
>
freeRes
=
new
HashSet
<>(
getFreeResources
(
link
));
Set
<
ResourceAllocation
>
addRes
=
allocations
.
getResourceAllocation
(
link
);
for
(
ResourceAllocation
res
:
addRes
)
{
switch
(
res
.
type
())
{
...
...
Please
register
or
login
to post a comment