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-10 17:55:17 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c944fd062545df6df150a0af37c33fca93c4254a
c944fd06
1 parent
3988db04
stoppign starting works nicely
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
14 deletions
of/ctl/src/main/java/org/onlab/onos/of/drivers/impl/OFSwitchImplOVS13.java
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
of/ctl/src/main/java/org/onlab/onos/of/drivers/impl/OFSwitchImplOVS13.java
View file @
c944fd0
package
org
.
onlab
.
onos
.
of
.
drivers
.
impl
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicBoolean
;
...
...
@@ -135,7 +136,7 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch {
@Override
public
void
write
(
OFMessage
msg
)
{
channel
.
write
(
msg
);
channel
.
write
(
Collections
.
singletonList
(
msg
)
);
}
...
...
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
c944fd0
...
...
@@ -14,6 +14,7 @@ import org.apache.felix.scr.annotations.Deactivate;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
...
...
@@ -66,14 +67,22 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
public
void
activate
()
{
providerService
=
providerRegistry
.
register
(
this
);
controller
.
addListener
(
listener
);
for
(
OpenFlowSwitch
sw
:
controller
.
getSwitches
())
{
listener
.
switchAdded
(
new
Dpid
(
sw
.
getId
()));
}
LOG
.
info
(
"Started"
);
}
@Deactivate
public
void
deactivate
()
{
for
(
OpenFlowSwitch
sw
:
controller
.
getSwitches
())
{
providerService
.
deviceDisconnected
(
DeviceId
.
deviceId
(
"of:"
+
Long
.
toHexString
(
sw
.
getId
())));
}
providerRegistry
.
unregister
(
this
);
controller
.
removeListener
(
listener
);
providerService
=
null
;
LOG
.
info
(
"Stopped"
);
}
...
...
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
View file @
c944fd0
...
...
@@ -86,6 +86,7 @@ public class LinkDiscovery implements TimerTask {
private
final
OpenFlowController
ctrl
;
private
final
LinkProviderService
linkProvider
;
private
final
Map
<
Integer
,
OFPortDesc
>
ports
;
private
Timeout
timeout
;
/**
* Instantiates discovery manager for the given physical switch. Creates a
...
...
@@ -127,7 +128,7 @@ public class LinkDiscovery implements TimerTask {
addPort
(
port
);
}
}
Timer
.
getTimer
().
newTimeout
(
this
,
this
.
probeRate
,
timeout
=
Timer
.
getTimer
().
newTimeout
(
this
,
this
.
probeRate
,
TimeUnit
.
MILLISECONDS
);
this
.
log
.
debug
(
"Started discovery manager for switch {}"
,
sw
.
getId
());
...
...
@@ -186,6 +187,10 @@ public class LinkDiscovery implements TimerTask {
portnum
);
}
}
ConnectPoint
cp
=
new
ConnectPoint
(
DeviceId
.
deviceId
(
"of:"
+
Long
.
toHexString
(
sw
.
getId
())),
PortNumber
.
portNumber
(
port
.
getPortNo
().
getPortNumber
()));
linkProvider
.
linksVanished
(
cp
);
}
...
...
@@ -380,14 +385,19 @@ public class LinkDiscovery implements TimerTask {
}
// reschedule timer
Timer
.
getTimer
().
newTimeout
(
this
,
this
.
probeRate
,
timeout
=
Timer
.
getTimer
().
newTimeout
(
this
,
this
.
probeRate
,
TimeUnit
.
MILLISECONDS
);
}
public
void
removeAllPorts
()
{
for
(
OFPortDesc
port
:
sw
.
getPort
s
())
{
for
(
OFPortDesc
port
:
ports
.
value
s
())
{
removePort
(
port
);
}
}
public
void
stop
()
{
removeAllPorts
();
timeout
.
cancel
();
}
}
...
...
providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
View file @
c944fd0
...
...
@@ -10,9 +10,7 @@ import org.apache.felix.scr.annotations.Component;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.link.LinkProvider
;
import
org.onlab.onos.net.link.LinkProviderRegistry
;
import
org.onlab.onos.net.link.LinkProviderService
;
...
...
@@ -20,10 +18,10 @@ import org.onlab.onos.net.provider.AbstractProvider;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.of.controller.Dpid
;
import
org.onlab.onos.of.controller.OpenFlowController
;
import
org.onlab.onos.of.controller.OpenFlowSwitch
;
import
org.onlab.onos.of.controller.OpenFlowSwitchListener
;
import
org.onlab.onos.of.controller.PacketContext
;
import
org.onlab.onos.of.controller.PacketListener
;
import
org.onlab.timer.Timer
;
import
org.projectfloodlight.openflow.protocol.OFPortConfig
;
import
org.projectfloodlight.openflow.protocol.OFPortDesc
;
import
org.projectfloodlight.openflow.protocol.OFPortState
;
...
...
@@ -51,6 +49,8 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
private
final
InternalLinkProvider
listener
=
new
InternalLinkProvider
();
private
final
Map
<
Dpid
,
LinkDiscovery
>
discoverers
=
new
ConcurrentHashMap
<>();
/**
* Creates an OpenFlow link provider.
*/
...
...
@@ -63,23 +63,28 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
providerService
=
providerRegistry
.
register
(
this
);
controller
.
addListener
(
listener
);
controller
.
addPacketListener
(
0
,
listener
);
for
(
OpenFlowSwitch
sw
:
controller
.
getSwitches
())
{
listener
.
switchAdded
(
new
Dpid
(
sw
.
getId
()));
}
log
.
info
(
"Started"
);
}
@Deactivate
public
void
deactivate
()
{
for
(
LinkDiscovery
ld
:
discoverers
.
values
())
{
ld
.
stop
();
}
providerRegistry
.
unregister
(
this
);
controller
.
removeListener
(
listener
);
controller
.
removePacketListener
(
listener
);
providerService
=
null
;
Timer
.
getTimer
().
stop
();
log
.
info
(
"Stopped"
);
}
private
class
InternalLinkProvider
implements
PacketListener
,
OpenFlowSwitchListener
{
private
final
Map
<
Dpid
,
LinkDiscovery
>
discoverers
=
new
ConcurrentHashMap
<>();
@Override
public
void
handlePacket
(
PacketContext
pktCtx
)
{
...
...
@@ -102,7 +107,7 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
@Override
public
void
switchRemoved
(
Dpid
dpid
)
{
LinkDiscovery
ld
=
this
.
discoverers
.
remove
(
dpid
);
LinkDiscovery
ld
=
discoverers
.
remove
(
dpid
);
if
(
ld
!=
null
)
{
ld
.
removeAllPorts
();
}
...
...
@@ -122,10 +127,9 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
if
(
enabled
)
{
ld
.
addPort
(
port
);
}
else
{
ConnectPoint
cp
=
new
ConnectPoint
(
DeviceId
.
deviceId
(
"of:"
+
Long
.
toHexString
(
dpid
.
value
())),
PortNumber
.
portNumber
(
port
.
getPortNo
().
getPortNumber
()));
providerService
.
linksVanished
(
cp
);
/*
* remove port calls linkVanished
*/
ld
.
removePort
(
port
);
}
...
...
Please
register
or
login
to post a comment