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 00:18:21 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
64b7aacb893938019d869cb1695f7d7140552c6a
64b7aacb
1 parent
a29cea3b
Added more event and listener interface definitions.
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
376 additions
and
44 deletions
net/api/src/main/java/org/onlab/onos/net/ConnectPoint.java
net/api/src/main/java/org/onlab/onos/net/Device.java
net/api/src/main/java/org/onlab/onos/net/DeviceId.java
net/api/src/main/java/org/onlab/onos/net/Host.java
net/api/src/main/java/org/onlab/onos/net/Link.java
net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java
net/api/src/main/java/org/onlab/onos/net/device/DeviceListener.java
net/api/src/main/java/org/onlab/onos/net/host/HostEvent.java
net/api/src/main/java/org/onlab/onos/net/host/HostListener.java
net/api/src/main/java/org/onlab/onos/net/link/LinkEvent.java
net/api/src/main/java/org/onlab/onos/net/link/LinkListener.java
net/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderBroker.java
net/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderService.java
net/api/src/main/java/org/onlab/onos/net/provider/Provided.java
net/api/src/main/java/org/onlab/onos/net/provider/Provider.java
net/api/src/main/java/org/onlab/onos/net/provider/ProviderBroker.java
net/api/src/main/java/org/onlab/onos/net/provider/ProviderId.java
net/api/src/main/java/org/onlab/onos/net/provider/ProviderService.java
net/api/src/main/java/org/onlab/onos/net/ConnectPoint.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
;
/**
* Abstraction of a network connection point expressed as a pair of the
* device identifier and the device port number.
*/
public
interface
ConnectPoint
{
/**
* Returns the connection device identifier.
*
* @return device id
*/
DeviceId
deviceId
();
/**
* Returns the connection port number.
*
* @return port number
*/
PortNumber
port
();
}
net/api/src/main/java/org/onlab/onos/net/Device.java
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.onos.net.provider.Provided
;
/**
* Representation of an network infrastructure device.
*/
public
class
Device
{
public
interface
Device
extends
Provided
{
// type, e.g. switch, router, firewall, ips, controller
...
...
net/api/src/main/java/org/onlab/onos/net/DeviceId.java
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
;
import
java.net.URI
;
import
java.util.Objects
;
import
static
com
.
google
.
common
.
base
.
Objects
.
toStringHelper
;
/**
* Immutable representaion of a device identity.
* Immutable representa
t
ion of a device identity.
*/
public
class
DeviceId
{
...
...
@@ -22,4 +25,25 @@ public class DeviceId {
return
uri
;
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
uri
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
DeviceId
other
=
(
DeviceId
)
obj
;
return
Objects
.
equals
(
this
.
uri
,
other
.
uri
);
}
@Override
public
String
toString
()
{
return
toStringHelper
(
this
).
add
(
"uri"
,
uri
).
toString
();
}
}
...
...
net/api/src/main/java/org/onlab/onos/net/Host.java
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.onos.net.provider.Provided
;
/**
* Abstraction of an end-station host on the network, essentially a NIC.
*/
public
class
Host
{
public
interface
Host
extends
Provided
{
// MAC, IP(s), optional VLAN ID
...
...
net/api/src/main/java/org/onlab/onos/net/Link.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
;
import
org.onlab.onos.net.provider.Provided
;
/**
* Abstraction of a network infrastructure link.
*/
public
interface
Link
extends
Provided
{
// TODO: Also should extend graph Edge
/**
* Returns the link source connection point.
*
* @return link source connection point
*/
ConnectPoint
src
();
/**
* Returns the link destination connection point.
*
* @return link destination connection point
*/
ConnectPoint
dst
();
}
net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java
View file @
64b7aac
...
...
@@ -12,16 +12,24 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
* Type of device events.
*/
public
enum
Type
{
/** Signifies that a new device has been detected. */
/**
* Signifies that a new device has been detected.
*/
DEVICE_ADDED
,
/** Signifies that a device has been removed. */
/**
* Signifies that a device has been removed.
*/
DEVICE_REMOVED
,
/** Signifies that a device has been administratively suspended. */
/**
* Signifies that a device has been administratively suspended.
*/
DEVICE_SUSPENDED
,
/** Signifies that a device has come online or has gone offline. */
/**
* Signifies that a device has come online or has gone offline.
*/
DEVICE_AVAILABILITY_CHANGED
,
/**
...
...
@@ -32,25 +40,25 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
}
/**
* Creates an event of a given type and for the specified
subject
and the
* Creates an event of a given type and for the specified
device
and the
* current time.
*
* @param type event type
* @param
subject event
subject
* @param type
device
event type
* @param
device event device
subject
*/
public
DeviceEvent
(
Type
type
,
Device
subject
)
{
super
(
type
,
subject
);
public
DeviceEvent
(
Type
type
,
Device
device
)
{
super
(
type
,
device
);
}
/**
* Creates an event of a given type and for the specified
subject
and time.
* Creates an event of a given type and for the specified
device
and time.
*
* @param type event type
* @param
subject event
subject
* @param type
device
event type
* @param
device event device
subject
* @param time occurrence time
*/
public
DeviceEvent
(
Type
type
,
Device
subject
,
long
time
)
{
super
(
type
,
subject
,
time
);
public
DeviceEvent
(
Type
type
,
Device
device
,
long
time
)
{
super
(
type
,
device
,
time
);
}
}
...
...
net/api/src/main/java/org/onlab/onos/net/device/DeviceListener.java
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.event.EventListener
;
/**
* Entity capable of receiving device related events.
* Entity capable of receiving
infrastructure
device related events.
*/
public
interface
DeviceListener
{
public
interface
DeviceListener
extends
EventListener
<
DeviceEvent
>
{
}
...
...
net/api/src/main/java/org/onlab/onos/net/host/HostEvent.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
host
;
import
org.onlab.onos.event.AbstractEvent
;
import
org.onlab.onos.net.Host
;
/**
* Describes end-station host event.
*/
public
class
HostEvent
extends
AbstractEvent
<
HostEvent
.
Type
,
Host
>
{
/**
* Type of host events.
*/
public
enum
Type
{
/**
* Signifies that a new host has been detected.
*/
HOST_ADDED
,
/**
* Signifies that a host has been removed.
*/
HOST_REMOVED
,
/**
* Signifies that a host location has changed.
*/
HOST_MOVED
}
/**
* Creates an event of a given type and for the specified host and the
* current time.
*
* @param type host event type
* @param host event host subject
*/
public
HostEvent
(
Type
type
,
Host
host
)
{
super
(
type
,
host
);
}
/**
* Creates an event of a given type and for the specified host and time.
*
* @param type host event type
* @param host event host subject
* @param time occurrence time
*/
public
HostEvent
(
Type
type
,
Host
host
,
long
time
)
{
super
(
type
,
host
,
time
);
}
}
net/api/src/main/java/org/onlab/onos/net/host/HostListener.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
host
;
import
org.onlab.onos.event.EventListener
;
/**
* Entity capable of receiving end-station host related events.
*/
public
interface
HostListener
extends
EventListener
<
HostEvent
>
{
}
net/api/src/main/java/org/onlab/onos/net/link/LinkEvent.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
link
;
import
org.onlab.onos.event.AbstractEvent
;
import
org.onlab.onos.net.Link
;
/**
* Describes infrastructure link event.
*/
public
class
LinkEvent
extends
AbstractEvent
<
LinkEvent
.
Type
,
Link
>
{
/**
* Type of link events.
*/
public
enum
Type
{
/**
* Signifies that a new link has been detected.
*/
LINK_ADDED
,
/**
* Signifies that a link has been removed.
*/
LINK_REMOVED
}
/**
* Creates an event of a given type and for the specified link and the
* current time.
*
* @param type link event type
* @param link event link subject
*/
public
LinkEvent
(
Type
type
,
Link
link
)
{
super
(
type
,
link
);
}
/**
* Creates an event of a given type and for the specified link and time.
*
* @param type link event type
* @param link event link subject
* @param time occurrence time
*/
public
LinkEvent
(
Type
type
,
Link
link
,
long
time
)
{
super
(
type
,
link
,
time
);
}
}
net/api/src/main/java/org/onlab/onos/net/link/LinkListener.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
link
;
import
org.onlab.onos.event.EventListener
;
/**
* Entity capable of receiving infrastructure link related events.
*/
public
interface
LinkListener
extends
EventListener
<
LinkEvent
>
{
}
net/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderBroker.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
provider
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkArgument
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
/**
* Base implementation of provider broker.
*
* @param <P> type of the information provider
* @param <S> type of the provider service
*/
public
abstract
class
AbstractProviderBroker
<
P
extends
Provider
,
S
extends
ProviderService
>
implements
ProviderBroker
<
P
,
S
>
{
private
final
Map
<
ProviderId
,
S
>
services
=
new
HashMap
<>();
/**
* Creates a new provider service bound to the specified provider.
*
* @param provider provider
* @return provider service
*/
protected
abstract
S
createProviderService
(
P
provider
);
@Override
public
synchronized
S
register
(
P
provider
)
{
checkNotNull
(
provider
,
"Provider cannot be null"
);
checkArgument
(!
services
.
containsKey
(
provider
),
"Provider %s already registered"
,
provider
.
id
());
S
service
=
createProviderService
(
provider
);
services
.
put
(
provider
.
id
(),
service
);
return
service
;
}
@Override
public
synchronized
void
unregister
(
P
provider
)
{
checkNotNull
(
provider
,
"Provider cannot be null"
);
S
service
=
services
.
get
(
provider
);
checkArgument
(
service
!=
null
,
"Provider %s not registered"
,
provider
.
id
());
if
(
service
instanceof
AbstractProviderService
)
{
((
AbstractProviderService
)
service
).
invalidate
();
}
services
.
remove
(
provider
);
}
}
net/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderService.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
provider
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkState
;
/**
* Base implementation of a provider service, which tracks the provider to
* which it is issued and can be invalidated.
*
* @param <P> type of the information provider
*/
public
abstract
class
AbstractProviderService
<
P
extends
Provider
>
implements
ProviderService
<
P
>
{
private
boolean
isValid
=
true
;
private
final
P
provider
;
/**
* Creates a provider service on behalf of the specified provider.
*
* @param provider provider to which this service is being issued
*/
protected
AbstractProviderService
(
P
provider
)
{
this
.
provider
=
provider
;
}
/**
* Invalidates this provider service.
*/
public
void
invalidate
()
{
isValid
=
false
;
}
/**
* Checks the validity of this provider service.
*
* @throws java.lang.IllegalStateException if the service is no longer valid
*/
public
void
checkValidity
()
{
checkState
(
isValid
,
"Provider service is no longer valid"
);
}
@Override
public
P
provider
()
{
return
provider
;
}
}
net/api/src/main/java/org/onlab/onos/net/provider/Provided.java
0 → 100644
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
provider
;
/**
* Abstraction of an entity supplied by a provider.
*/
public
interface
Provided
{
/**
* Returns the identifier of the provider which supplied the entity.
*
* @return provider identification
*/
ProviderId
id
();
}
net/api/src/main/java/org/onlab/onos/net/provider/Provider.java
View file @
64b7aac
...
...
@@ -5,6 +5,11 @@ package org.onlab.onos.net.provider;
*/
public
interface
Provider
{
/**
* Returns the provider identifier.
*
* @return provider identification
*/
ProviderId
id
();
}
...
...
net/api/src/main/java/org/onlab/onos/net/provider/ProviderBroker.java
View file @
64b7aac
...
...
@@ -3,10 +3,10 @@ package org.onlab.onos.net.provider;
/**
* Broker used for registering/unregistering information providers with the core.
*
* @param <
T
> type of the information provider
* @param <
P
> type of the information provider
* @param <S> type of the provider service
*/
public
interface
ProviderBroker
<
T
extends
Provider
,
S
extends
ProviderService
>
{
public
interface
ProviderBroker
<
P
extends
Provider
,
S
extends
ProviderService
<
P
>
>
{
/**
* Registers the supplied provider with the core.
...
...
@@ -14,14 +14,15 @@ public interface ProviderBroker<T extends Provider, S extends ProviderService> {
* @param provider provider to be registered
* @return provider service for injecting information into core
*/
S
register
(
T
provider
);
S
register
(
P
provider
);
/**
* Unregisters the supplied provider. As a result the previously issued
* provider service will be invalidated.
* provider service will be invalidated and any subsequent invocations
* of its methods may throw {@link java.lang.IllegalStateException}.
*
* @param provider provider to be unregistered
*/
void
unregister
(
T
provider
);
void
unregister
(
P
provider
);
}
...
...
net/api/src/main/java/org/onlab/onos/net/provider/ProviderId.java
View file @
64b7aac
package
org
.
onlab
.
onos
.
net
.
provider
;
import
java.util.Objects
;
import
static
com
.
google
.
common
.
base
.
Objects
.
toStringHelper
;
/**
* Notion of provider identity.
*/
...
...
@@ -7,37 +11,37 @@ public class ProviderId {
private
final
String
id
;
/**
* Creates a new provider identifier from the specified string.
* The providers are expected to follow the reverse DNS convention, e.g.
* {@code org.onlab.onos.provider.of.device}
*
* @param id string identifier
*/
public
ProviderId
(
String
id
)
{
this
.
id
=
id
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
ProviderId
that
=
(
ProviderId
)
o
;
if
(!
id
.
equals
(
that
.
id
))
{
return
false
;
public
int
hashCode
()
{
return
Objects
.
hash
(
id
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
@Override
public
int
hashCode
()
{
return
id
.
hashCode
();
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
ProviderId
other
=
(
ProviderId
)
obj
;
return
Objects
.
equals
(
this
.
id
,
other
.
id
);
}
@Override
public
String
toString
()
{
return
"ProviderId{"
+
"id='"
+
id
+
'\''
+
'}'
;
return
toStringHelper
(
this
).
add
(
"id"
,
id
).
toString
();
}
}
...
...
net/api/src/main/java/org/onlab/onos/net/provider/ProviderService.java
View file @
64b7aac
...
...
@@ -3,6 +3,16 @@ package org.onlab.onos.net.provider;
/**
* Abstraction of a service through which providers can inject information
* about the network environment into the core.
*
* @param <P> type of the information provider
*/
public
interface
ProviderService
{
public
interface
ProviderService
<
P
extends
Provider
>
{
/**
* Returns the provider to which this service has been issued.
*
* @return provider to which this service has been assigned
*/
P
provider
();
}
...
...
Please
register
or
login
to post a comment