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-23 14:08:36 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ca0fcff106004c46d2e519eaa0961e9270b96d59
ca0fcff1
1 parent
9e622ac4
Implement fake requestResources() method.
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
2 deletions
core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java
core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java
core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java
core/api/src/main/java/org/onlab/onos/net/resource/ResourceRequest.java
core/net/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceAllocations.java
core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java
core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java
View file @
ca0fcff
...
...
@@ -33,4 +33,9 @@ public class BandwidthResourceRequest implements ResourceRequest {
public
Bandwidth
bandwidth
()
{
return
bandwidth
;
}
@Override
public
ResourceType
type
()
{
return
ResourceType
.
BANDWIDTH
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java
View file @
ca0fcff
...
...
@@ -34,6 +34,12 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest {
this
.
resources
=
ImmutableSet
.
copyOf
(
resources
);
}
@Override
public
ResourceType
type
()
{
return
null
;
}
@Override
public
IntentId
intendId
()
{
return
intentId
;
...
...
core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java
View file @
ca0fcff
...
...
@@ -5,4 +5,9 @@ package org.onlab.onos.net.resource;
*/
public
class
LambdaResourceRequest
implements
ResourceRequest
{
@Override
public
ResourceType
type
()
{
return
ResourceType
.
LAMBDA
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/resource/ResourceRequest.java
View file @
ca0fcff
...
...
@@ -4,5 +4,11 @@ package org.onlab.onos.net.resource;
* Abstraction of resource request.
*/
public
interface
ResourceRequest
{
/**
* Returns the resource type.
*
* @return the resource type
*/
ResourceType
type
();
}
...
...
core/net/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceAllocations.java
0 → 100644
View file @
ca0fcff
package
org
.
onlab
.
onos
.
net
.
resource
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Set
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.intent.IntentId
;
/**
* Implementation of {@link LinkResourceAllocations}.
*/
public
class
DefaultLinkResourceAllocations
implements
LinkResourceAllocations
{
private
final
LinkResourceRequest
request
;
private
final
Map
<
Link
,
Set
<
ResourceAllocation
>>
allocations
;
/**
* Creates a new link resource allocations.
*
* @param request requested resources
* @param allocations allocated resources
*/
protected
DefaultLinkResourceAllocations
(
LinkResourceRequest
request
,
Map
<
Link
,
Set
<
ResourceAllocation
>>
allocations
)
{
this
.
request
=
request
;
this
.
allocations
=
allocations
;
}
@Override
public
IntentId
intendId
()
{
return
request
.
intendId
();
}
@Override
public
Collection
<
Link
>
links
()
{
return
request
.
links
();
}
@Override
public
Set
<
ResourceRequest
>
resources
()
{
return
request
.
resources
();
}
@Override
public
ResourceType
type
()
{
return
null
;
}
@Override
public
Set
<
ResourceAllocation
>
getResourceAllocation
(
Link
link
)
{
Set
<
ResourceAllocation
>
result
=
allocations
.
get
(
link
);
if
(
result
==
null
)
{
result
=
Collections
.
emptySet
();
}
return
result
;
}
}
core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java
View file @
ca0fcff
...
...
@@ -2,6 +2,10 @@ package org.onlab.onos.net.resource;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
...
...
@@ -10,6 +14,8 @@ import org.onlab.onos.net.Link;
import
org.onlab.onos.net.intent.IntentId
;
import
org.slf4j.Logger
;
import
com.google.common.collect.Sets
;
/**
* Provides basic implementation of link resources allocation.
*/
...
...
@@ -31,8 +37,30 @@ public class LinkResourceManager implements LinkResourceService {
@Override
public
LinkResourceAllocations
requestResources
(
LinkResourceRequest
req
)
{
// TODO Auto-generated method stub
return
null
;
// TODO implement it using a resource data store.
ResourceAllocation
alloc
=
null
;
for
(
ResourceRequest
r:
req
.
resources
())
{
switch
(
r
.
type
())
{
case
BANDWIDTH:
log
.
info
(
"requestResources() always returns requested bandwidth"
);
BandwidthResourceRequest
br
=
(
BandwidthResourceRequest
)
r
;
alloc
=
new
BandwidthResourceAllocation
(
br
.
bandwidth
());
break
;
case
LAMBDA:
log
.
info
(
"requestResources() always returns lambda 7"
);
alloc
=
new
LambdaResourceAllocation
(
Lambda
.
valueOf
(
7
));
break
;
default
:
break
;
}
}
Map
<
Link
,
Set
<
ResourceAllocation
>>
allocations
=
new
HashMap
<>();
for
(
Link
link:
req
.
links
())
{
allocations
.
put
(
link
,
Sets
.
newHashSet
(
alloc
));
}
return
new
DefaultLinkResourceAllocations
(
req
,
allocations
);
}
@Override
...
...
Please
register
or
login
to post a comment