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-10-17 09:46:07 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
a7edda0200b232025dc3229c7a2d130e45401e42
a7edda02
2 parents
e1cf87d9
ce430a48
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
210 additions
and
7 deletions
apps/sdnip/src/main/java/org/onlab/onos/sdnip/PeerConnectivity.java → apps/sdnip/src/main/java/org/onlab/onos/sdnip/PeerConnectivityManager.java
apps/sdnip/src/main/java/org/onlab/onos/sdnip/SdnIp.java
apps/sdnip/src/test/java/org/onlab/onos/sdnip/PeerConnectivityManagerTest.java
core/api/src/main/java/org/onlab/onos/net/topology/Topology.java
core/store/dist/pom.xml
core/store/dist/src/main/java/org/onlab/onos/store/flow/ReplicaInfoService.java
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/ReplicaInfoManager.java
core/store/dist/src/test/java/org/onlab/onos/store/flow/impl/ReplicaInfoManagerTest.java
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
apps/sdnip/src/main/java/org/onlab/onos/sdnip/PeerConnectivity.java
→
apps/sdnip/src/main/java/org/onlab/onos/sdnip/PeerConnectivity
Manager
.java
View file @
a7edda0
...
...
@@ -25,10 +25,10 @@ import org.slf4j.LoggerFactory;
/**
* Manages the connectivity requirements between peers.
*/
public
class
PeerConnectivity
{
public
class
PeerConnectivity
Manager
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
PeerConnectivity
.
class
);
PeerConnectivity
Manager
.
class
);
// TODO these shouldn't be defined here
private
static
final
short
BGP_PORT
=
179
;
...
...
@@ -41,7 +41,7 @@ public class PeerConnectivity {
// TODO this sucks.
private
int
intentId
=
0
;
public
PeerConnectivity
(
SdnIpConfigService
configInfoService
,
public
PeerConnectivity
Manager
(
SdnIpConfigService
configInfoService
,
InterfaceService
interfaceService
,
IntentService
intentService
)
{
this
.
configInfoService
=
configInfoService
;
this
.
interfaceService
=
interfaceService
;
...
...
apps/sdnip/src/main/java/org/onlab/onos/sdnip/SdnIp.java
View file @
a7edda0
...
...
@@ -36,7 +36,7 @@ public class SdnIp implements SdnIpService {
protected
HostService
hostService
;
private
SdnIpConfigReader
config
;
private
PeerConnectivity
peerConnectivity
;
private
PeerConnectivity
Manager
peerConnectivity
;
private
Router
router
;
private
BgpSessionManager
bgpSessionManager
;
...
...
@@ -49,7 +49,7 @@ public class SdnIp implements SdnIpService {
InterfaceService
interfaceService
=
new
HostServiceBasedInterfaceService
(
hostService
);
peerConnectivity
=
new
PeerConnectivity
(
config
,
interfaceService
,
intentService
);
peerConnectivity
=
new
PeerConnectivity
Manager
(
config
,
interfaceService
,
intentService
);
peerConnectivity
.
start
();
router
=
new
Router
(
intentService
,
hostService
,
config
,
interfaceService
);
...
...
@@ -79,4 +79,8 @@ public class SdnIp implements SdnIpService {
public
Collection
<
RouteEntry
>
getRoutes
()
{
return
router
.
getRoutes
();
}
static
String
dpidToUri
(
String
dpid
)
{
return
"of:"
+
dpid
.
replace
(
":"
,
""
);
}
}
...
...
apps/sdnip/src/test/java/org/onlab/onos/sdnip/PeerConnectivityManagerTest.java
0 → 100644
View file @
a7edda0
This diff is collapsed. Click to expand it.
core/api/src/main/java/org/onlab/onos/net/topology/Topology.java
View file @
a7edda0
...
...
@@ -7,6 +7,8 @@ import org.onlab.onos.net.Provided;
*/
public
interface
Topology
extends
Provided
{
// FIXME: Following is not true right now. It is actually System.nanoTime(),
// which has no relation to epoch time, wall clock, etc.
/**
* Returns the time, specified in milliseconds since start of epoch,
* when the topology became active and made available.
...
...
core/store/dist/pom.xml
View file @
a7edda0
...
...
@@ -52,6 +52,12 @@
<artifactId>
easymock
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-api
</artifactId>
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
...
...
core/store/dist/src/main/java/org/onlab/onos/store/flow/ReplicaInfoService.java
View file @
a7edda0
...
...
@@ -3,7 +3,7 @@ package org.onlab.onos.store.flow;
import
org.onlab.onos.net.DeviceId
;
/**
* Service to return where the
R
eplica should be placed.
* Service to return where the
r
eplica should be placed.
*/
public
interface
ReplicaInfoService
{
...
...
@@ -15,4 +15,19 @@ public interface ReplicaInfoService {
* @return placement information
*/
ReplicaInfo
getReplicaInfoFor
(
DeviceId
deviceId
);
/**
* Adds the specified replica placement info change listener.
*
* @param listener the replica placement info change listener
*/
void
addListener
(
ReplicaInfoEventListener
listener
);
/**
* Removes the specified replica placement info change listener.
*
* @param listener the replica placement info change listener
*/
void
removeListener
(
ReplicaInfoEventListener
listener
);
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/ReplicaInfoManager.java
View file @
a7edda0
package
org
.
onlab
.
onos
.
store
.
flow
.
impl
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
static
org
.
onlab
.
onos
.
store
.
flow
.
ReplicaInfoEvent
.
Type
.
MASTER_CHANGED
;
...
...
@@ -66,6 +67,16 @@ public class ReplicaInfoManager implements ReplicaInfoService {
Collections
.<
NodeId
>
emptyList
());
}
@Override
public
void
addListener
(
ReplicaInfoEventListener
listener
)
{
listenerRegistry
.
addListener
(
checkNotNull
(
listener
));
}
@Override
public
void
removeListener
(
ReplicaInfoEventListener
listener
)
{
listenerRegistry
.
removeListener
(
checkNotNull
(
listener
));
}
final
class
InternalMastershipListener
implements
MastershipListener
{
@Override
...
...
core/store/dist/src/test/java/org/onlab/onos/store/flow/impl/ReplicaInfoManagerTest.java
0 → 100644
View file @
a7edda0
package
org
.
onlab
.
onos
.
store
.
flow
.
impl
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkState
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.event.AbstractListenerRegistry
;
import
org.onlab.onos.event.DefaultEventSinkRegistry
;
import
org.onlab.onos.event.Event
;
import
org.onlab.onos.event.EventDeliveryService
;
import
org.onlab.onos.event.EventSink
;
import
org.onlab.onos.mastership.MastershipEvent
;
import
org.onlab.onos.mastership.MastershipEvent.Type
;
import
org.onlab.onos.mastership.MastershipListener
;
import
org.onlab.onos.mastership.MastershipService
;
import
org.onlab.onos.mastership.MastershipServiceAdapter
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.store.flow.ReplicaInfo
;
import
org.onlab.onos.store.flow.ReplicaInfoEvent
;
import
org.onlab.onos.store.flow.ReplicaInfoEventListener
;
import
org.onlab.onos.store.flow.ReplicaInfoService
;
import
com.google.common.base.Optional
;
import
com.google.common.collect.Maps
;
public
class
ReplicaInfoManagerTest
{
private
static
final
DeviceId
DID1
=
DeviceId
.
deviceId
(
"of:1"
);
private
static
final
DeviceId
DID2
=
DeviceId
.
deviceId
(
"of:2"
);
private
static
final
NodeId
NID1
=
new
NodeId
(
"foo"
);
private
ReplicaInfoManager
mgr
;
private
ReplicaInfoService
service
;
private
AbstractListenerRegistry
<
MastershipEvent
,
MastershipListener
>
mastershipListenerRegistry
;
private
TestEventDispatcher
eventDispatcher
;
@Before
public
void
setUp
()
throws
Exception
{
mastershipListenerRegistry
=
new
AbstractListenerRegistry
<>();
mgr
=
new
ReplicaInfoManager
();
service
=
mgr
;
eventDispatcher
=
new
TestEventDispatcher
();
mgr
.
eventDispatcher
=
eventDispatcher
;
mgr
.
mastershipService
=
new
TestMastershipService
();
// register dummy mastership event source
mgr
.
eventDispatcher
.
addSink
(
MastershipEvent
.
class
,
mastershipListenerRegistry
);
mgr
.
activate
();
}
@After
public
void
tearDown
()
throws
Exception
{
mgr
.
deactivate
();
}
@Test
public
void
testGetReplicaInfoFor
()
{
ReplicaInfo
info1
=
service
.
getReplicaInfoFor
(
DID1
);
assertEquals
(
Optional
.
of
(
NID1
),
info1
.
master
());
// backups are always empty for now
assertEquals
(
Collections
.
emptyList
(),
info1
.
backups
());
ReplicaInfo
info2
=
service
.
getReplicaInfoFor
(
DID2
);
assertEquals
(
"There's no master"
,
Optional
.
absent
(),
info2
.
master
());
// backups are always empty for now
assertEquals
(
Collections
.
emptyList
(),
info2
.
backups
());
}
@Test
public
void
testReplicaInfoEvent
()
throws
InterruptedException
{
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
service
.
addListener
(
new
MasterNodeCheck
(
latch
,
DID1
,
NID1
));
// fake MastershipEvent
eventDispatcher
.
post
(
new
MastershipEvent
(
Type
.
MASTER_CHANGED
,
DID1
,
NID1
));
assertTrue
(
latch
.
await
(
1
,
TimeUnit
.
SECONDS
));
}
private
final
class
MasterNodeCheck
implements
ReplicaInfoEventListener
{
private
final
CountDownLatch
latch
;
private
Optional
<
NodeId
>
expectedMaster
;
private
DeviceId
expectedDevice
;
MasterNodeCheck
(
CountDownLatch
latch
,
DeviceId
did
,
NodeId
nid
)
{
this
.
latch
=
latch
;
this
.
expectedMaster
=
Optional
.
fromNullable
(
nid
);
this
.
expectedDevice
=
did
;
}
@Override
public
void
event
(
ReplicaInfoEvent
event
)
{
assertEquals
(
expectedDevice
,
event
.
subject
());
assertEquals
(
expectedMaster
,
event
.
replicaInfo
().
master
());
// backups are always empty for now
assertEquals
(
Collections
.
emptyList
(),
event
.
replicaInfo
().
backups
());
latch
.
countDown
();
}
}
private
final
class
TestMastershipService
extends
MastershipServiceAdapter
implements
MastershipService
{
private
Map
<
DeviceId
,
NodeId
>
masters
;
TestMastershipService
()
{
masters
=
Maps
.
newHashMap
();
masters
.
put
(
DID1
,
NID1
);
// DID2 has no master
}
@Override
public
NodeId
getMasterFor
(
DeviceId
deviceId
)
{
return
masters
.
get
(
deviceId
);
}
@Override
public
void
addListener
(
MastershipListener
listener
)
{
mastershipListenerRegistry
.
addListener
(
listener
);
}
@Override
public
void
removeListener
(
MastershipListener
listener
)
{
mastershipListenerRegistry
.
removeListener
(
listener
);
}
}
// code clone
/**
* Implements event delivery system that delivers events synchronously, or
* in-line with the post method invocation.
*/
private
static
class
TestEventDispatcher
extends
DefaultEventSinkRegistry
implements
EventDeliveryService
{
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
@Override
public
void
post
(
Event
event
)
{
EventSink
sink
=
getSink
(
event
.
getClass
());
checkState
(
sink
!=
null
,
"No sink for event %s"
,
event
);
sink
.
process
(
event
);
}
}
}
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
a7edda0
...
...
@@ -172,7 +172,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
*/
private
List
<
PortDescription
>
buildPortDescriptions
(
List
<
OFPortDesc
>
ports
)
{
final
List
<
PortDescription
>
portDescs
=
new
ArrayList
<>();
final
List
<
PortDescription
>
portDescs
=
new
ArrayList
<>(
ports
.
size
()
);
for
(
OFPortDesc
port
:
ports
)
{
portDescs
.
add
(
buildPortDescription
(
port
));
}
...
...
Please
register
or
login
to post a comment