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
Thomas Vachuska
2014-11-11 14:57:48 -0800
Browse Files
Options
Browse Files
Download
Plain Diff
Committed by
Gerrit Code Review
2014-11-11 14:57:48 -0800
Commit
e9aad0939f876f7e2642d4b4adc8d611402b79ab
e9aad093
2 parents
ea80eb44
fe129db5
Merge "Aggregate definition of annotation key for latency into a single file"
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
7 deletions
core/api/src/main/java/org/onlab/onos/net/AnnotationKeys.java
core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
core/api/src/test/java/org/onlab/onos/net/intent/constraint/LatencyConstraintTest.java
core/api/src/main/java/org/onlab/onos/net/AnnotationKeys.java
0 → 100644
View file @
e9aad09
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
onlab
.
onos
.
net
;
/**
* Collection of keys for annotation.
* Definitions of annotation keys needs to be here to avoid scattering.
*/
public
final
class
AnnotationKeys
{
// Prohibit instantiation
private
AnnotationKeys
()
{}
/**
* Annotation key for latency.
*/
public
static
final
String
LATENCY
=
"latency"
;
}
core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
View file @
e9aad09
...
...
@@ -25,14 +25,13 @@ import java.time.Duration;
import
java.time.temporal.ChronoUnit
;
import
java.util.Objects
;
import
static
org
.
onlab
.
onos
.
net
.
AnnotationKeys
.
LATENCY
;
/**
* Constraint that evaluates the latency through a path.
*/
public
class
LatencyConstraint
implements
Constraint
{
// TODO: formalize the key for latency all over the codes.
private
static
final
String
LATENCY_KEY
=
"latency"
;
private
final
Duration
latency
;
/**
...
...
@@ -49,7 +48,7 @@ public class LatencyConstraint implements Constraint {
@Override
public
double
cost
(
Link
link
,
LinkResourceService
resourceService
)
{
String
value
=
link
.
annotations
().
value
(
LATENCY
_KEY
);
String
value
=
link
.
annotations
().
value
(
LATENCY
);
double
latencyInMicroSec
;
try
{
...
...
core/api/src/test/java/org/onlab/onos/net/intent/constraint/LatencyConstraintTest.java
View file @
e9aad09
...
...
@@ -37,6 +37,7 @@ import static org.easymock.EasyMock.createMock;
import
static
org
.
hamcrest
.
Matchers
.
closeTo
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
onlab
.
onos
.
net
.
AnnotationKeys
.
LATENCY
;
import
static
org
.
onlab
.
onos
.
net
.
DefaultLinkTest
.
cp
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
DIRECT
;
...
...
@@ -51,7 +52,6 @@ public class LatencyConstraintTest {
private
static
final
PortNumber
PN3
=
PortNumber
.
portNumber
(
3
);
private
static
final
PortNumber
PN4
=
PortNumber
.
portNumber
(
4
);
private
static
final
ProviderId
PROVIDER_ID
=
new
ProviderId
(
"of"
,
"foo"
);
private
static
final
String
LATENCY_KEY
=
"latency"
;
private
static
final
String
LATENCY1
=
"3.0"
;
private
static
final
String
LATENCY2
=
"4.0"
;
...
...
@@ -66,8 +66,8 @@ public class LatencyConstraintTest {
public
void
setUp
()
{
linkResourceService
=
createMock
(
LinkResourceService
.
class
);
Annotations
annotations1
=
DefaultAnnotations
.
builder
().
set
(
LATENCY
_KEY
,
LATENCY1
).
build
();
Annotations
annotations2
=
DefaultAnnotations
.
builder
().
set
(
LATENCY
_KEY
,
LATENCY2
).
build
();
Annotations
annotations1
=
DefaultAnnotations
.
builder
().
set
(
LATENCY
,
LATENCY1
).
build
();
Annotations
annotations2
=
DefaultAnnotations
.
builder
().
set
(
LATENCY
,
LATENCY2
).
build
();
link1
=
new
DefaultLink
(
PROVIDER_ID
,
cp
(
DID1
,
PN1
),
cp
(
DID2
,
PN2
),
DIRECT
,
annotations1
);
link2
=
new
DefaultLink
(
PROVIDER_ID
,
cp
(
DID2
,
PN3
),
cp
(
DID3
,
PN4
),
DIRECT
,
annotations2
);
...
...
Please
register
or
login
to post a comment