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-20 15:18:37 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c9051db21be5a3d14b199fad3378990e1f6334fb
c9051db2
1 parent
d796391b
Starting point for designing a resource manager API.
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
232 additions
and
0 deletions
core/api/src/main/java/org/onlab/onos/net/resource/Bandwidth.java
core/api/src/main/java/org/onlab/onos/net/resource/Lambda.java
core/api/src/main/java/org/onlab/onos/net/resource/LinkResource.java
core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
core/api/src/main/java/org/onlab/onos/net/resource/LinkResources.java
core/api/src/main/java/org/onlab/onos/net/resource/Bandwidth.java
0 → 100644
View file @
c9051db
package
org
.
onlab
.
onos
.
net
.
resource
;
import
java.util.Objects
;
/**
* Representation of bandwidth resource.
*/
public
final
class
Bandwidth
extends
LinkResource
{
private
final
double
bandwidth
;
/**
* Creates a new instance with given bandwidth.
*
* @param bandwidth bandwidth value to be assigned
*/
private
Bandwidth
(
double
bandwidth
)
{
this
.
bandwidth
=
bandwidth
;
}
/**
* Creates a new instance with given bandwidth.
*
* @param bandwidth bandwidth value to be assigned
* @return {@link Bandwidth} instance with given bandwidth
*/
public
static
Bandwidth
valueOf
(
double
bandwidth
)
{
return
new
Bandwidth
(
bandwidth
);
}
/**
* Returns bandwidth as a double value.
*
* @return bandwidth as a double value
*/
public
double
toDouble
()
{
return
bandwidth
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
Bandwidth
)
{
Bandwidth
that
=
(
Bandwidth
)
obj
;
return
Objects
.
equals
(
this
.
bandwidth
,
that
.
bandwidth
);
}
return
false
;
}
@Override
public
int
hashCode
()
{
return
Objects
.
hashCode
(
this
.
bandwidth
);
}
@Override
public
String
toString
()
{
return
String
.
valueOf
(
this
.
bandwidth
);
}
}
core/api/src/main/java/org/onlab/onos/net/resource/Lambda.java
0 → 100644
View file @
c9051db
package
org
.
onlab
.
onos
.
net
.
resource
;
import
java.util.Objects
;
/**
* Representation of lambda resource.
*/
public
final
class
Lambda
extends
LinkResource
{
private
final
int
lambda
;
/**
* Creates a new instance with given lambda.
*
* @param lambda lambda value to be assigned
*/
private
Lambda
(
int
lambda
)
{
this
.
lambda
=
lambda
;
}
/**
* Creates a new instance with given lambda.
*
* @param lambda lambda value to be assigned
* @return {@link Lambda} instance with given lambda
*/
public
static
Lambda
valueOf
(
int
lambda
)
{
return
new
Lambda
(
lambda
);
}
/**
* Returns lambda as an int value.
* @return lambda as an int value
*/
public
int
toInt
()
{
return
lambda
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
Lambda
)
{
Lambda
that
=
(
Lambda
)
obj
;
return
Objects
.
equals
(
this
.
lambda
,
that
.
lambda
);
}
return
false
;
}
@Override
public
int
hashCode
()
{
return
Objects
.
hashCode
(
this
.
lambda
);
}
@Override
public
String
toString
()
{
return
String
.
valueOf
(
this
.
lambda
);
}
}
core/api/src/main/java/org/onlab/onos/net/resource/LinkResource.java
0 → 100644
View file @
c9051db
package
org
.
onlab
.
onos
.
net
.
resource
;
/**
* Abstraction of link resource.
*/
public
abstract
class
LinkResource
{
}
core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
0 → 100644
View file @
c9051db
package
org
.
onlab
.
onos
.
net
.
resource
;
import
java.util.Map
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.intent.IntentId
;
import
org.onlab.onos.net.intent.PathIntent
;
/**
* Service for providing link resource allocation.
*/
public
interface
LinkResourceService
{
/**
* Allocates resources along the path.
* <p>
* Tries to allocate given resources on the links along the path specified
* by the given intent.
*
* @param res resources to be allocated
* @param intent an intent to be used for specifying the path
*/
void
allocateResource
(
LinkResources
res
,
PathIntent
intent
);
/**
* Releases resources along the path.
*
* @param intentId an ID for the intent for specifying the path
*/
void
releaseResource
(
IntentId
intentId
);
/**
* Returns all allocated resources to each link.
*
* @return allocated resources to each link with {@link IntentId}
*/
Map
<
Link
,
Map
<
IntentId
,
LinkResources
>>
allocatedResources
();
/**
* Returns all allocated resources to given link.
*
* @param link a target link
* @return allocated resources to the target link with {@link IntentId}
*/
Map
<
IntentId
,
LinkResources
>
allocatedResources
(
Link
link
);
/**
* Returns available resources for each link.
*
* @return available resources for each link
*/
Map
<
Link
,
LinkResources
>
availableResources
();
/**
* Returns available resources for given link.
* @param link a target link
* @return available resources for the target link
*/
LinkResource
availableResources
(
Link
link
);
}
core/api/src/main/java/org/onlab/onos/net/resource/LinkResources.java
0 → 100644
View file @
c9051db
package
org
.
onlab
.
onos
.
net
.
resource
;
import
java.util.Set
;
/**
* Abstraction of a resources of a link.
*/
public
interface
LinkResources
{
/**
* Returns resources as a set of {@link LinkResource}s.
*
* @return a set of {@link LinkResource}s
*/
Set
<
LinkResource
>
resources
();
/**
* Builder of {@link LinkResources}.
*/
public
interface
Builder
{
/**
* Adds bandwidth resource.
* <p>
* This operation adds given bandwidth to previous bandwidth and
* generates single bandwidth resource.
*
* @param bandwidth bandwidth value to be added
* @return self
*/
public
Builder
addBandwidth
(
double
bandwidth
);
/**
* Adds lambda resource.
*
* @param lambda lambda value to be added
* @return self
*/
public
Builder
addLambda
(
int
lambda
);
/**
* Builds an immutable link resources.
*
* @return link resources
*/
public
LinkResources
build
();
}
}
Please
register
or
login
to post a comment