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
alshabib
2014-09-22 11:42:28 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
9c8354120fe6195a2e3a50dacf251bcd06acf682
9c835412
2 parents
a7f7ca8e
25236f5b
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
281 additions
and
59 deletions
core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
core/api/src/test/java/org/onlab/onos/net/NetTestTools.java
core/net/pom.xml
core/net/src/main/java/org/onlab/onos/net/topology/impl/PathManager.java
core/net/src/test/java/org/onlab/onos/net/topology/impl/DefaultTopologyProviderTest.java
core/net/src/test/java/org/onlab/onos/net/topology/impl/PathManagerTest.java
core/net/src/test/java/org/onlab/onos/net/topology/impl/TopologyManagerTest.java
features/features.xml
core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
0 → 100644
View file @
9c83541
package
org
.
onlab
.
onos
.
cluster
;
/**
* Service responsible for determining the controller instance mastership of
* a device in a clustered environment. This is the central authority for
* determining mastership, but is not responsible for actually applying it
* to the devices; this falls on the device service.
*/
public
interface
MastershipService
{
// InstanceId getMasterFor(DeviceId deviceId)
// Set<DeviceId> getDevicesOf(InstanceId instanceId);
// MastershipRole requestRoleFor(DeviceId deviceId);
// addListener/removeLister(MastershipListener listener);
// types of events would be MASTER_CHANGED (subject ==> deviceId; master ==> instanceId)
}
core/api/src/test/java/org/onlab/onos/net/NetTestTools.java
0 → 100644
View file @
9c83541
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IpPrefix
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
HostId
.
hostId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
import
static
org
.
onlab
.
packet
.
MacAddress
.
valueOf
;
import
static
org
.
onlab
.
packet
.
VlanId
.
vlanId
;
/**
* Miscellaneous tools for testing core related to the network model.
*/
public
final
class
NetTestTools
{
private
NetTestTools
()
{
}
public
static
final
ProviderId
PID
=
new
ProviderId
(
"of"
,
"foo"
);
// Short-hand for producing a device id from a string
public
static
DeviceId
did
(
String
id
)
{
return
deviceId
(
"of:"
+
id
);
}
// Short-hand for producing a host id from a string
public
static
HostId
hid
(
String
id
)
{
return
hostId
(
"nic:"
+
id
);
}
// Crates a new device with the specified id
public
static
Device
device
(
String
id
)
{
return
new
DefaultDevice
(
PID
,
did
(
id
),
Device
.
Type
.
SWITCH
,
"mfg"
,
"1.0"
,
"1.1"
,
"1234"
);
}
// Crates a new host with the specified id
public
static
Host
host
(
String
id
,
String
did
)
{
return
new
DefaultHost
(
PID
,
hid
(
id
),
valueOf
(
1234
),
vlanId
((
short
)
2
),
new
HostLocation
(
did
(
did
),
portNumber
(
1
),
321
),
new
HashSet
<
IpPrefix
>());
}
// Short-hand for creating a link.
public
static
Link
link
(
String
src
,
int
sp
,
String
dst
,
int
dp
)
{
return
new
DefaultLink
(
PID
,
new
ConnectPoint
(
did
(
src
),
portNumber
(
sp
)),
new
ConnectPoint
(
did
(
dst
),
portNumber
(
dp
)),
Link
.
Type
.
DIRECT
);
}
// Creates a path that leads through the given devices.
public
static
Path
createPath
(
String
...
ids
)
{
List
<
Link
>
links
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
ids
.
length
-
1
;
i
++)
{
links
.
add
(
link
(
ids
[
i
],
i
,
ids
[
i
+
1
],
i
));
}
return
new
DefaultPath
(
PID
,
links
,
ids
.
length
);
}
}
core/net/pom.xml
View file @
9c83541
...
...
@@ -24,14 +24,16 @@
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-
core-trivial
</artifactId>
<
version>
${project.version}
</version
>
<artifactId>
onos-
api
</artifactId>
<
classifier>
tests
</classifier
>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.felix
</groupId>
<artifactId>
org.apache.felix.scr.annotations
</artifactId>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-core-trivial
</artifactId>
<version>
${project.version}
</version>
<scope>
test
</scope>
</dependency>
<!-- TODO Consider removing store dependency.
...
...
@@ -42,6 +44,11 @@
<version>
${project.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.felix
</groupId>
<artifactId>
org.apache.felix.scr.annotations
</artifactId>
</dependency>
</dependencies>
<build>
...
...
core/net/src/main/java/org/onlab/onos/net/topology/impl/PathManager.java
View file @
9c83541
package
org
.
onlab
.
onos
.
net
.
topology
.
impl
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Sets
;
import
org.apache.felix.scr.annotations.Activate
;
...
...
@@ -59,12 +60,12 @@ public class PathManager implements PathService {
protected
HostService
hostService
;
@Activate
public
void
setUp
()
{
public
void
activate
()
{
log
.
info
(
"Started"
);
}
@Deactivate
public
void
tearDown
()
{
public
void
deactivate
()
{
log
.
info
(
"Stopped"
);
}
...
...
@@ -82,6 +83,11 @@ public class PathManager implements PathService {
EdgeLink
srcEdge
=
getEdgeLink
(
src
,
true
);
EdgeLink
dstEdge
=
getEdgeLink
(
dst
,
false
);
// If either edge is null, bail with no paths.
if
(
srcEdge
==
null
||
dstEdge
==
null
)
{
return
ImmutableSet
.
of
();
}
DeviceId
srcDevice
=
srcEdge
!=
NOT_HOST
?
srcEdge
.
dst
().
deviceId
()
:
(
DeviceId
)
src
;
DeviceId
dstDevice
=
dstEdge
!=
NOT_HOST
?
dstEdge
.
src
().
deviceId
()
:
(
DeviceId
)
dst
;
...
...
@@ -117,28 +123,14 @@ public class PathManager implements PathService {
return
NOT_HOST
;
}
// Produces a set of direct edge-to-edge paths.
// Produces a set of edge-to-edge paths using the set of infrastructure
// paths and the given edge links.
private
Set
<
Path
>
edgeToEdgePaths
(
EdgeLink
srcLink
,
EdgeLink
dstLink
)
{
Set
<
Path
>
endToEndPaths
=
Sets
.
newHashSetWithExpectedSize
(
1
);
if
(
srcLink
!=
NOT_HOST
||
dstLink
!=
NOT_HOST
)
{
endToEndPaths
.
add
(
edgeToEdgePath
(
srcLink
,
dstLink
));
}
endToEndPaths
.
add
(
edgeToEdgePath
(
srcLink
,
dstLink
,
null
));
return
endToEndPaths
;
}
// Produces a direct edge-to-edge path.
private
Path
edgeToEdgePath
(
EdgeLink
srcLink
,
EdgeLink
dstLink
)
{
List
<
Link
>
links
=
Lists
.
newArrayListWithCapacity
(
2
);
// Add source and destination edge links only if they are real.
if
(
srcLink
!=
NOT_HOST
)
{
links
.
add
(
srcLink
);
}
if
(
dstLink
!=
NOT_HOST
)
{
links
.
add
(
dstLink
);
}
return
new
DefaultPath
(
PID
,
links
,
2
);
}
// Produces a set of edge-to-edge paths using the set of infrastructure
// paths and the given edge links.
private
Set
<
Path
>
edgeToEdgePaths
(
EdgeLink
srcLink
,
EdgeLink
dstLink
,
Set
<
Path
>
paths
)
{
...
...
@@ -149,14 +141,21 @@ public class PathManager implements PathService {
return
endToEndPaths
;
}
// Produces an edge-to-edge path using the specified infrastructure path
// and edge links.
// Produces a direct edge-to-edge path.
private
Path
edgeToEdgePath
(
EdgeLink
srcLink
,
EdgeLink
dstLink
,
Path
path
)
{
List
<
Link
>
links
=
Lists
.
newArrayListWithCapacity
(
path
.
links
().
size
()
+
2
);
List
<
Link
>
links
=
Lists
.
newArrayListWithCapacity
(
2
);
// Add source and destination edge links only if they are real and
// add the infrastructure path only if it is not null.
if
(
srcLink
!=
NOT_HOST
)
{
links
.
add
(
srcLink
);
}
if
(
path
!=
null
)
{
links
.
addAll
(
path
.
links
());
}
if
(
dstLink
!=
NOT_HOST
)
{
links
.
add
(
dstLink
);
return
new
DefaultPath
(
path
.
providerId
(),
links
,
path
.
cost
()
+
2
);
}
return
new
DefaultPath
(
PID
,
links
,
2
);
}
// Special value for edge link to represent that this is really not an
...
...
core/net/src/test/java/org/onlab/onos/net/topology/impl/DefaultTopologyProviderTest.java
View file @
9c83541
...
...
@@ -25,6 +25,8 @@ import java.util.Set;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
onlab
.
junit
.
TestTools
.
assertAfter
;
import
static
org
.
onlab
.
onos
.
net
.
NetTestTools
.
device
;
import
static
org
.
onlab
.
onos
.
net
.
NetTestTools
.
link
;
import
static
org
.
onlab
.
onos
.
net
.
device
.
DeviceEvent
.
Type
.
DEVICE_ADDED
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.
LINK_ADDED
;
...
...
@@ -79,8 +81,8 @@ public class DefaultTopologyProviderTest {
@Override
public
void
run
()
{
validateSubmission
();
deviceService
.
post
(
new
DeviceEvent
(
DEVICE_ADDED
,
TopologyManagerTest
.
device
(
"z"
),
null
));
linkService
.
post
(
new
LinkEvent
(
LINK_ADDED
,
TopologyManagerTest
.
link
(
"z"
,
1
,
"a"
,
4
)));
deviceService
.
post
(
new
DeviceEvent
(
DEVICE_ADDED
,
device
(
"z"
),
null
));
linkService
.
post
(
new
LinkEvent
(
LINK_ADDED
,
link
(
"z"
,
1
,
"a"
,
4
)));
validateSubmission
();
}
});
...
...
@@ -128,9 +130,9 @@ public class DefaultTopologyProviderTest {
@Override
public
Iterable
<
Device
>
getDevices
()
{
return
ImmutableSet
.
of
(
TopologyManagerTest
.
device
(
"a"
),
TopologyManagerTest
.
device
(
"b"
),
TopologyManagerTest
.
device
(
"c"
),
TopologyManagerTest
.
device
(
"d"
),
TopologyManagerTest
.
device
(
"e"
),
TopologyManagerTest
.
device
(
"f"
));
return
ImmutableSet
.
of
(
device
(
"a"
),
device
(
"b"
),
device
(
"c"
),
device
(
"d"
),
device
(
"e"
),
device
(
"f"
));
}
void
post
(
DeviceEvent
event
)
{
...
...
@@ -146,11 +148,11 @@ public class DefaultTopologyProviderTest {
@Override
public
Iterable
<
Link
>
getLinks
()
{
return
ImmutableSet
.
of
(
TopologyManagerTest
.
link
(
"a"
,
1
,
"b"
,
1
),
TopologyManagerTest
.
link
(
"b"
,
1
,
"a"
,
1
),
TopologyManagerTest
.
link
(
"b"
,
2
,
"c"
,
1
),
TopologyManagerTest
.
link
(
"c"
,
1
,
"b"
,
2
),
TopologyManagerTest
.
link
(
"c"
,
2
,
"d"
,
1
),
TopologyManagerTest
.
link
(
"d"
,
1
,
"c"
,
2
),
TopologyManagerTest
.
link
(
"d"
,
2
,
"a"
,
2
),
TopologyManagerTest
.
link
(
"a"
,
2
,
"d"
,
2
),
TopologyManagerTest
.
link
(
"e"
,
1
,
"f"
,
1
),
TopologyManagerTest
.
link
(
"f"
,
1
,
"e"
,
1
));
return
ImmutableSet
.
of
(
link
(
"a"
,
1
,
"b"
,
1
),
link
(
"b"
,
1
,
"a"
,
1
),
link
(
"b"
,
2
,
"c"
,
1
),
link
(
"c"
,
1
,
"b"
,
2
),
link
(
"c"
,
2
,
"d"
,
1
),
link
(
"d"
,
1
,
"c"
,
2
),
link
(
"d"
,
2
,
"a"
,
2
),
link
(
"a"
,
2
,
"d"
,
2
),
link
(
"e"
,
1
,
"f"
,
1
),
link
(
"f"
,
1
,
"e"
,
1
));
}
void
post
(
LinkEvent
event
)
{
...
...
core/net/src/test/java/org/onlab/onos/net/topology/impl/PathManagerTest.java
0 → 100644
View file @
9c83541
package
org
.
onlab
.
onos
.
net
.
topology
.
impl
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.ElementId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.host.HostServiceAdapter
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.net.topology.LinkWeight
;
import
org.onlab.onos.net.topology.PathService
;
import
org.onlab.onos.net.topology.Topology
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.onos.net.topology.TopologyServiceAdapter
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
onlab
.
onos
.
net
.
NetTestTools
.*;
/**
* Test of the path selection subsystem.
*/
public
class
PathManagerTest
{
private
static
final
ProviderId
PID
=
new
ProviderId
(
"of"
,
"foo"
);
private
PathManager
mgr
;
private
PathService
service
;
private
FakeTopoMgr
fakeTopoMgr
=
new
FakeTopoMgr
();
private
FakeHostMgr
fakeHostMgr
=
new
FakeHostMgr
();
@Before
public
void
setUp
()
{
mgr
=
new
PathManager
();
service
=
mgr
;
mgr
.
topologyService
=
fakeTopoMgr
;
mgr
.
hostService
=
fakeHostMgr
;
mgr
.
activate
();
}
@After
public
void
tearDown
()
{
mgr
.
deactivate
();
}
@Test
public
void
infraToInfra
()
{
DeviceId
src
=
did
(
"src"
);
DeviceId
dst
=
did
(
"dst"
);
fakeTopoMgr
.
paths
.
add
(
createPath
(
"src"
,
"middle"
,
"dst"
));
Set
<
Path
>
paths
=
service
.
getPaths
(
src
,
dst
);
validatePaths
(
paths
,
1
,
2
,
src
,
dst
);
}
@Test
public
void
infraToEdge
()
{
DeviceId
src
=
did
(
"src"
);
HostId
dst
=
hid
(
"dst"
);
fakeTopoMgr
.
paths
.
add
(
createPath
(
"src"
,
"middle"
,
"edge"
));
fakeHostMgr
.
hosts
.
put
(
dst
,
host
(
"dst"
,
"edge"
));
Set
<
Path
>
paths
=
service
.
getPaths
(
src
,
dst
);
validatePaths
(
paths
,
1
,
3
,
src
,
dst
);
}
@Test
public
void
edgeToInfra
()
{
HostId
src
=
hid
(
"src"
);
DeviceId
dst
=
did
(
"dst"
);
fakeTopoMgr
.
paths
.
add
(
createPath
(
"edge"
,
"middle"
,
"dst"
));
fakeHostMgr
.
hosts
.
put
(
src
,
host
(
"src"
,
"edge"
));
Set
<
Path
>
paths
=
service
.
getPaths
(
src
,
dst
);
validatePaths
(
paths
,
1
,
3
,
src
,
dst
);
}
@Test
public
void
edgeToEdge
()
{
HostId
src
=
hid
(
"src"
);
HostId
dst
=
hid
(
"dst"
);
fakeTopoMgr
.
paths
.
add
(
createPath
(
"srcEdge"
,
"middle"
,
"dstEdge"
));
fakeHostMgr
.
hosts
.
put
(
src
,
host
(
"src"
,
"srcEdge"
));
fakeHostMgr
.
hosts
.
put
(
dst
,
host
(
"dst"
,
"dstEdge"
));
Set
<
Path
>
paths
=
service
.
getPaths
(
src
,
dst
);
validatePaths
(
paths
,
1
,
4
,
src
,
dst
);
}
@Test
public
void
edgeToEdgeDirect
()
{
HostId
src
=
hid
(
"src"
);
HostId
dst
=
hid
(
"dst"
);
fakeHostMgr
.
hosts
.
put
(
src
,
host
(
"src"
,
"edge"
));
fakeHostMgr
.
hosts
.
put
(
dst
,
host
(
"dst"
,
"edge"
));
Set
<
Path
>
paths
=
service
.
getPaths
(
src
,
dst
);
validatePaths
(
paths
,
1
,
2
,
src
,
dst
);
}
@Test
public
void
noEdge
()
{
Set
<
Path
>
paths
=
service
.
getPaths
(
hid
(
"src"
),
hid
(
"dst"
));
assertTrue
(
"there should be no paths"
,
paths
.
isEmpty
());
}
// Makes sure the set of paths meets basic expectations.
private
void
validatePaths
(
Set
<
Path
>
paths
,
int
count
,
int
length
,
ElementId
src
,
ElementId
dst
)
{
assertEquals
(
"incorrect path count"
,
count
,
paths
.
size
());
for
(
Path
path
:
paths
)
{
assertEquals
(
"incorrect length"
,
length
,
path
.
links
().
size
());
assertEquals
(
"incorrect source"
,
src
,
path
.
src
().
elementId
());
assertEquals
(
"incorrect destination"
,
dst
,
path
.
dst
().
elementId
());
}
}
// Fake entity to give out paths.
private
class
FakeTopoMgr
extends
TopologyServiceAdapter
implements
TopologyService
{
Set
<
Path
>
paths
=
new
HashSet
<>();
@Override
public
Set
<
Path
>
getPaths
(
Topology
topology
,
DeviceId
src
,
DeviceId
dst
)
{
return
paths
;
}
@Override
public
Set
<
Path
>
getPaths
(
Topology
topology
,
DeviceId
src
,
DeviceId
dst
,
LinkWeight
weight
)
{
return
paths
;
}
}
// Fake entity to give out hosts.
private
class
FakeHostMgr
extends
HostServiceAdapter
implements
HostService
{
private
Map
<
HostId
,
Host
>
hosts
=
new
HashMap
<>();
@Override
public
Host
getHost
(
HostId
hostId
)
{
return
hosts
.
get
(
hostId
);
}
}
}
core/net/src/test/java/org/onlab/onos/net/topology/impl/TopologyManagerTest.java
View file @
9c83541
...
...
@@ -6,10 +6,7 @@ import org.junit.Test;
import
org.onlab.onos.event.Event
;
import
org.onlab.onos.event.impl.TestEventDispatcher
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DefaultDevice
;
import
org.onlab.onos.net.DefaultLink
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.provider.AbstractProvider
;
...
...
@@ -35,7 +32,7 @@ import java.util.Set;
import
static
com
.
google
.
common
.
collect
.
ImmutableSet
.
of
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
NetTestTools
.*
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
import
static
org
.
onlab
.
onos
.
net
.
topology
.
ClusterId
.
clusterId
;
import
static
org
.
onlab
.
onos
.
net
.
topology
.
TopologyEvent
.
Type
.
TOPOLOGY_CHANGED
;
...
...
@@ -184,24 +181,6 @@ public class TopologyManagerTest {
assertEquals
(
"wrong path cost"
,
6.6
,
path
.
cost
(),
0.01
);
}
// Short-hand for creating a link.
public
static
Link
link
(
String
src
,
int
sp
,
String
dst
,
int
dp
)
{
return
new
DefaultLink
(
PID
,
new
ConnectPoint
(
did
(
src
),
portNumber
(
sp
)),
new
ConnectPoint
(
did
(
dst
),
portNumber
(
dp
)),
Link
.
Type
.
DIRECT
);
}
// Crates a new device with the specified id
public
static
Device
device
(
String
id
)
{
return
new
DefaultDevice
(
PID
,
did
(
id
),
Device
.
Type
.
SWITCH
,
"mfg"
,
"1.0"
,
"1.1"
,
"1234"
);
}
// Short-hand for producing a device id from a string
public
static
DeviceId
did
(
String
id
)
{
return
deviceId
(
"of:"
+
id
);
}
protected
void
validateEvents
(
Enum
...
types
)
{
int
i
=
0
;
assertEquals
(
"wrong events received"
,
types
.
length
,
listener
.
events
.
size
());
...
...
features/features.xml
View file @
9c83541
...
...
@@ -8,6 +8,8 @@
<bundle>
mvn:commons-lang/commons-lang/2.6
</bundle>
<bundle>
mvn:com.google.guava/guava/18.0
</bundle>
<bundle>
mvn:io.netty/netty/3.9.2.Final
</bundle>
<bundle>
mvn:com.esotericsoftware.kryo/kryo/2.24.0
</bundle>
<bundle>
mvn:com.esotericsoftware.minlog/minlog/1.3
</bundle>
</feature>
<feature
name=
"onos-thirdparty-web"
version=
"1.0.0"
...
...
Please
register
or
login
to post a comment