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
tom
2014-10-08 10:42:56 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
297dfc0c4d58530705d21ab248416412dbe8566f
297dfc0c
1 parent
8e939d82
Enhanced HostLocation and DefaultEdgeLink to allow easier construction.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
2 deletions
core/api/src/main/java/org/onlab/onos/net/DefaultEdgeLink.java
core/api/src/main/java/org/onlab/onos/net/HostLocation.java
core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java
core/api/src/main/java/org/onlab/onos/net/DefaultEdgeLink.java
View file @
297dfc0
...
...
@@ -3,6 +3,7 @@ package org.onlab.onos.net;
import
org.onlab.onos.net.provider.ProviderId
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkArgument
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
/**
* Default edge link model implementation.
...
...
@@ -52,10 +53,14 @@ public class DefaultEdgeLink extends DefaultLink implements EdgeLink {
* for network-to-host direction
* @return new phantom edge link
*/
public
static
DefaultEdgeLink
createEdgeLink
(
HostLocation
edgePort
,
public
static
DefaultEdgeLink
createEdgeLink
(
ConnectPoint
edgePort
,
boolean
isIngress
)
{
checkNotNull
(
edgePort
,
"Edge port cannot be null"
);
HostLocation
location
=
(
edgePort
instanceof
HostLocation
)
?
(
HostLocation
)
edgePort
:
new
HostLocation
(
edgePort
,
0
);
return
new
DefaultEdgeLink
(
ProviderId
.
NONE
,
new
ConnectPoint
(
HostId
.
NONE
,
PortNumber
.
P0
),
edgePort
,
isIngress
);
location
,
isIngress
);
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/HostLocation.java
View file @
297dfc0
...
...
@@ -22,6 +22,17 @@ public class HostLocation extends ConnectPoint {
}
/**
* Creates a new host location derived from the supplied connection point.
*
* @param connectPoint connection point
* @param time time when detected, in millis since start of epoch
*/
public
HostLocation
(
ConnectPoint
connectPoint
,
long
time
)
{
super
(
connectPoint
.
deviceId
(),
connectPoint
.
port
());
this
.
time
=
time
;
}
/**
* Returns the time when the location was established, given in
* milliseconds since start of epoch.
*
...
...
core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java
View file @
297dfc0
...
...
@@ -5,6 +5,7 @@ import org.junit.Test;
import
org.onlab.onos.net.provider.ProviderId
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
DefaultEdgeLink
.
createEdgeLink
;
import
static
org
.
onlab
.
onos
.
net
.
DefaultLinkTest
.
cp
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
HostId
.
hostId
;
...
...
@@ -55,4 +56,24 @@ public class DefaultEdgeLinkTest {
assertEquals
(
"incorrect time"
,
123L
,
link
.
hostLocation
().
time
());
}
@Test
public
void
phantomIngress
()
{
HostLocation
hostLocation
=
new
HostLocation
(
DID1
,
P1
,
123L
);
EdgeLink
link
=
createEdgeLink
(
hostLocation
,
true
);
assertEquals
(
"incorrect dst"
,
hostLocation
,
link
.
dst
());
assertEquals
(
"incorrect type"
,
Link
.
Type
.
EDGE
,
link
.
type
());
assertEquals
(
"incorrect connect point"
,
hostLocation
,
link
.
hostLocation
());
assertEquals
(
"incorrect time"
,
123L
,
link
.
hostLocation
().
time
());
}
@Test
public
void
phantomEgress
()
{
ConnectPoint
hostLocation
=
new
ConnectPoint
(
DID1
,
P1
);
EdgeLink
link
=
createEdgeLink
(
hostLocation
,
false
);
assertEquals
(
"incorrect src"
,
hostLocation
,
link
.
src
());
assertEquals
(
"incorrect type"
,
Link
.
Type
.
EDGE
,
link
.
type
());
assertEquals
(
"incorrect connect point"
,
hostLocation
,
link
.
hostLocation
());
assertEquals
(
"incorrect time"
,
0L
,
link
.
hostLocation
().
time
());
}
}
...
...
Please
register
or
login
to post a comment