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-08-26 10:40:29 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d3097b0a43a7670439707100203ab8e35606abb8
d3097b0a
1 parent
18567e93
Added a simple device manager to have a working provider broker.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
7 deletions
net/api/src/main/java/org/onlab/onos/net/Link.java
net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
net/core/src/main/java/org/onlab/onos/net/impl/SimpleDeviceManager.java
net/api/src/main/java/org/onlab/onos/net/Link.java
View file @
d3097b0
...
...
@@ -18,8 +18,9 @@ public interface Link extends Provided { // TODO: Also should extend graph Edge
/**
* Signifies that this link is potentially comprised from multiple
* underlying segments or hops, e.g. optical links, tunnel links,
* multi-hop links spanning 'dark' switches
* underlying segments or hops, and as such should be used to tag
* links traversing optical paths, tunnels or intervening 'dark'
* switches.
*/
INDIRECT
}
...
...
net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
View file @
d3097b0
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.provider.ProviderService
;
...
...
@@ -19,28 +20,31 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> {
* @param deviceDescription information about network device
* @return mastership role chosen by the provider service
*/
MastershipRole
deviceConnected
(
DeviceDescription
deviceDescription
);
MastershipRole
deviceConnected
(
Device
Id
deviceId
,
Device
Description
deviceDescription
);
/**
* Signals the core that a device has disconnected or is no longer reachable.
*
* @param device
Description
device to be removed
* @param device
Id identity of the
device to be removed
*/
void
deviceDisconnected
(
Device
Description
deviceDescription
);
void
deviceDisconnected
(
Device
Id
deviceId
);
/**
* Sends information about all ports of a device. It is up to the core to
* determine what has changed.
* <p/>
*
* @param deviceId identity of the device
* @param ports list of device ports
*/
void
updatePorts
(
List
<
PortDescription
>
ports
);
void
updatePorts
(
DeviceId
deviceId
,
List
<
PortDescription
>
ports
);
/**
* Used to notify the core about port status change of a single port.
*
* @param deviceId identity of the device
* @param port description of the port that changed
*/
void
portStatusChanged
(
PortDescription
port
);
void
portStatusChanged
(
DeviceId
deviceId
,
PortDescription
port
);
}
...
...
net/core/src/main/java/org/onlab/onos/net/impl/SimpleDeviceManager.java
0 → 100644
View file @
d3097b0
package
org
.
onlab
.
onos
.
net
.
impl
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.DeviceProvider
;
import
org.onlab.onos.net.device.DeviceProviderBroker
;
import
org.onlab.onos.net.device.DeviceProviderService
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.AbstractProviderBroker
;
import
org.onlab.onos.net.provider.AbstractProviderService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.List
;
/**
* Provides basic implementation of the device SB & NB APIs.
*/
@Component
(
immediate
=
true
)
@Service
public
class
SimpleDeviceManager
implements
DeviceProviderBroker
{
private
Logger
log
=
LoggerFactory
.
getLogger
(
SimpleDeviceManager
.
class
);
private
final
DeviceProviderBroker
broker
=
new
InternalBroker
();
@Activate
public
void
activate
()
{
log
.
info
(
"Started"
);
}
@Deactivate
public
void
deactivate
()
{
log
.
info
(
"Stopped"
);
}
@Override
public
DeviceProviderService
register
(
DeviceProvider
provider
)
{
return
broker
.
register
(
provider
);
}
@Override
public
void
unregister
(
DeviceProvider
provider
)
{
broker
.
unregister
(
provider
);
}
// Internal delegate for tracking various providers and issuing them a
// personalized provider service.
private
class
InternalBroker
extends
AbstractProviderBroker
<
DeviceProvider
,
DeviceProviderService
>
implements
DeviceProviderBroker
{
@Override
protected
DeviceProviderService
createProviderService
(
DeviceProvider
provider
)
{
return
new
InternalDeviceProviderService
(
provider
);
}
}
// Personalized device provider service issued to the supplied provider.
private
class
InternalDeviceProviderService
extends
AbstractProviderService
<
DeviceProvider
>
implements
DeviceProviderService
{
public
InternalDeviceProviderService
(
DeviceProvider
provider
)
{
super
(
provider
);
}
@Override
public
MastershipRole
deviceConnected
(
DeviceId
deviceId
,
DeviceDescription
deviceDescription
)
{
log
.
info
(
"Device {} connected: {}"
,
deviceId
,
deviceDescription
);
return
MastershipRole
.
MASTER
;
}
@Override
public
void
deviceDisconnected
(
DeviceId
deviceId
)
{
log
.
info
(
"Device {} disconnected"
,
deviceId
);
}
@Override
public
void
updatePorts
(
DeviceId
deviceId
,
List
<
PortDescription
>
ports
)
{
// FIXME: fix the interface to accept DeviceId separately
log
.
info
(
"Device {} ports updated: {}"
,
ports
);
}
@Override
public
void
portStatusChanged
(
DeviceId
deviceId
,
PortDescription
port
)
{
log
.
info
(
"Device {} port status changed: {}"
,
deviceId
,
port
);
}
}
}
Please
register
or
login
to post a comment