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 11:37:44 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
569ca70f12240886bf004f397fc579ebb53e9c85
569ca70f
1 parent
50df38df
Implement BandwidthResourceRequest class and its builder.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
7 deletions
core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java
core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java
core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java
View file @
569ca70
...
...
@@ -3,11 +3,34 @@ package org.onlab.onos.net.resource;
/**
* Representation of a request for bandwidth resource.
*/
public
interface
BandwidthResourceRequest
{
public
final
class
BandwidthResourceRequest
implements
ResourceRequest
{
private
final
Bandwidth
bandwidth
;
/**
* Creates a new {@link BandwidthResourceRequest} with {@link Bandwidth}
* object.
*
* @param bandwidth {@link Bandwidth} object to be requested
*/
public
BandwidthResourceRequest
(
Bandwidth
bandwidth
)
{
this
.
bandwidth
=
bandwidth
;
}
/**
* Creates a new {@link BandwidthResourceRequest} with bandwidth value.
*
* @param bandwidth bandwidth value to be requested
*/
public
BandwidthResourceRequest
(
double
bandwidth
)
{
this
.
bandwidth
=
Bandwidth
.
valueOf
(
bandwidth
);
}
/**
* Returns the bandwidth resource.
*
* @return the bandwidth resource
*/
Bandwidth
bandwidth
();
Bandwidth
bandwidth
()
{
return
bandwidth
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java
View file @
569ca70
...
...
@@ -3,6 +3,6 @@ package org.onlab.onos.net.resource;
/**
* Representation of a request for lambda resource.
*/
public
interface
Lambda
ResourceRequest
{
public
class
LambdaResourceRequest
implements
ResourceRequest
{
}
...
...
core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
View file @
569ca70
package
org
.
onlab
.
onos
.
net
.
resource
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.intent.IntentId
;
import
com.google.common.collect.ImmutableSet
;
/**
* Representation of a request for link resource.
*/
public
interface
LinkResourceRequest
extends
ResourceRequest
{
public
final
class
LinkResourceRequest
implements
ResourceRequest
{
// TODO: should this class be interface?
private
final
IntentId
intentId
;
private
final
Collection
<
Link
>
links
;
private
final
Set
<
ResourceRequest
>
resources
;
/**
* Creates a new link resource request with the given ID, links, and
* resource requests.
*
* @param intentId intent ID related to this request
* @param links a set of links for the request
* @param resources a set of resources to be requested
*/
private
LinkResourceRequest
(
IntentId
intentId
,
Collection
<
Link
>
links
,
Set
<
ResourceRequest
>
resources
)
{
this
.
intentId
=
intentId
;
this
.
links
=
ImmutableSet
.
copyOf
(
links
);
this
.
resources
=
ImmutableSet
.
copyOf
(
resources
);
}
/**
* Returns the {@link IntentId} associated with the request.
*
* @return the {@link IntentId} associated with the request
*/
IntentId
intendId
();
IntentId
intendId
()
{
return
intentId
;
}
/**
* Returns the set of target links.
*
* @return the set of target links
*/
Collection
<
Link
>
links
();
Collection
<
Link
>
links
()
{
return
links
;
}
/**
* Returns the set of resource requests.
*
* @return the set of resource requests
*/
Set
<
ResourceRequest
>
resources
();
Set
<
ResourceRequest
>
resources
()
{
return
resources
;
}
/**
* Returns builder of link resource request.
*
* @param intentId intent ID related to this request
* @param links a set of links for the request
* @return builder of link resource request
*/
public
static
LinkResourceRequest
.
Builder
builder
(
IntentId
intentId
,
Collection
<
Link
>
links
)
{
return
new
Builder
(
intentId
,
links
);
}
/**
* Builder of link resource request.
*/
public
static
final
class
Builder
{
private
IntentId
intentId
;
private
Collection
<
Link
>
links
;
private
Set
<
ResourceRequest
>
resources
;
/**
* Creates a new link resource request.
*
* @param intentId intent ID related to this request
* @param links a set of links for the request
*/
private
Builder
(
IntentId
intentId
,
Collection
<
Link
>
links
)
{
this
.
intentId
=
intentId
;
this
.
links
=
links
;
this
.
resources
=
new
HashSet
<>();
}
/**
* Adds lambda request.
*
* @return self
*/
public
Builder
addLambdaRequest
()
{
resources
.
add
(
new
LambdaResourceRequest
());
return
this
;
}
/**
* Adds bandwidth request with bandwidth value.
*
* @param bandwidth bandwidth value to be requested
* @return self
*/
public
Builder
addBandwidthRequest
(
double
bandwidth
)
{
resources
.
add
(
new
BandwidthResourceRequest
(
bandwidth
));
return
this
;
}
/**
* Returns link resource request.
*
* @return link resource request
*/
public
LinkResourceRequest
build
()
{
return
new
LinkResourceRequest
(
intentId
,
links
,
resources
);
}
}
}
...
...
Please
register
or
login
to post a comment