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
Sho SHIMIZU
2015-10-06 10:52:12 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1bd72c2f8356509e1ef2024cf0b957dd714422a4
1bd72c2f
1 parent
eca9f355
Reduce duplicated code
Change-Id: Iac8f2c0ec7336d936425701976e090b413186d8d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
29 deletions
core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
View file @
1bd72c2
...
...
@@ -230,11 +230,13 @@ public class ConsistentLinkResourceStore extends
free
.
put
(
ResourceType
.
BANDWIDTH
,
value
);
Set
<
ResourceAllocation
>
lmd
=
caps
.
get
(
ResourceType
.
LAMBDA
);
Set
<
ResourceAllocation
>
freeL
=
getFreeLambdaResources
(
link
,
lmd
,
allocations
);
Set
<
ResourceAllocation
>
freeL
=
getFreeResources
(
link
,
lmd
,
allocations
,
LambdaResourceAllocation
.
class
);
free
.
put
(
ResourceType
.
LAMBDA
,
freeL
);
Set
<
ResourceAllocation
>
mpls
=
caps
.
get
(
ResourceType
.
MPLS_LABEL
);
Set
<
ResourceAllocation
>
freeLabel
=
getFreeLabelResources
(
link
,
mpls
,
allocations
);
Set
<
ResourceAllocation
>
freeLabel
=
getFreeResources
(
link
,
mpls
,
allocations
,
MplsLabelResourceAllocation
.
class
);
free
.
put
(
ResourceType
.
MPLS_LABEL
,
freeLabel
);
return
free
;
...
...
@@ -261,44 +263,27 @@ public class ConsistentLinkResourceStore extends
new
BandwidthResourceAllocation
(
new
BandwidthResource
(
Bandwidth
.
bps
(
freeBw
))));
}
private
Set
<
ResourceAllocation
>
getFreeLambdaResources
(
Link
link
,
Set
<
ResourceAllocation
>
lmd
,
List
<
LinkResourceAllocations
>
allocations
)
{
if
(
lmd
==
null
||
lmd
.
isEmpty
())
{
private
Set
<
ResourceAllocation
>
getFreeResources
(
Link
link
,
Set
<
ResourceAllocation
>
resources
,
List
<
LinkResourceAllocations
>
allocations
,
Class
<?
extends
ResourceAllocation
>
cls
)
{
if
(
resources
==
null
||
resources
.
isEmpty
())
{
// nothing left
return
Collections
.
emptySet
();
}
Set
<
ResourceAllocation
>
freeL
=
lmd
.
stream
()
.
filter
(
x
->
x
instanceof
LambdaResourceAllocation
)
Set
<
ResourceAllocation
>
freeL
=
resources
.
stream
()
.
filter
(
cls:
:
isInstance
)
.
collect
(
Collectors
.
toSet
());
// enumerate current allocations, removing resources
List
<
ResourceAllocation
>
allocated
Lambda
=
allocations
.
stream
()
List
<
ResourceAllocation
>
allocated
=
allocations
.
stream
()
.
flatMap
(
x
->
x
.
getResourceAllocation
(
link
).
stream
())
.
filter
(
x
->
x
instanceof
LambdaResourceAllocation
)
.
filter
(
cls:
:
isInstance
)
.
collect
(
Collectors
.
toList
());
freeL
.
removeAll
(
allocated
Lambda
);
freeL
.
removeAll
(
allocated
);
return
freeL
;
}
private
Set
<
ResourceAllocation
>
getFreeLabelResources
(
Link
link
,
Set
<
ResourceAllocation
>
mpls
,
List
<
LinkResourceAllocations
>
allocations
)
{
if
(
mpls
==
null
||
mpls
.
isEmpty
())
{
// nothing left
return
Collections
.
emptySet
();
}
Set
<
ResourceAllocation
>
freeLabel
=
mpls
.
stream
()
.
filter
(
x
->
x
instanceof
MplsLabelResourceAllocation
)
.
collect
(
Collectors
.
toSet
());
// enumerate current allocations, removing resources
List
<
ResourceAllocation
>
allocatedLabel
=
allocations
.
stream
()
.
flatMap
(
x
->
x
.
getResourceAllocation
(
link
).
stream
())
.
filter
(
x
->
x
instanceof
MplsLabelResourceAllocation
)
.
collect
(
Collectors
.
toList
());
freeLabel
.
removeAll
(
allocatedLabel
);
return
freeLabel
;
}
@Override
public
void
allocateResources
(
LinkResourceAllocations
allocations
)
{
checkNotNull
(
allocations
);
...
...
Please
register
or
login
to post a comment