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-10-01 20:35:01 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
27ae0e60b5829ed859000553f38ba5fe4bb2061f
27ae0e60
1 parent
8e493796
Working on model annotations; still in progress.
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
38 deletions
core/api/src/main/java/org/onlab/onos/net/AbstractAnnotated.java
core/api/src/main/java/org/onlab/onos/net/AbstractModel.java
core/api/src/main/java/org/onlab/onos/net/Description.java
core/api/src/main/java/org/onlab/onos/net/device/DefaultDeviceDescription.java
core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
core/api/src/main/java/org/onlab/onos/net/topology/DefaultGraphDescription.java
core/api/src/main/java/org/onlab/onos/net/AbstractAnnotated.java
0 → 100644
View file @
27ae0e6
package
org
.
onlab
.
onos
.
net
;
import
com.google.common.collect.ImmutableSet
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkArgument
;
/**
* Base abstraction of an annotated entity.
*/
public
class
AbstractAnnotated
implements
Annotated
{
private
static
final
Map
<
String
,
String
>
EMPTY
=
new
HashMap
<>();
private
final
Map
<
String
,
String
>
annotations
;
// For serialization
protected
AbstractAnnotated
()
{
this
.
annotations
=
EMPTY
;
}
/**
* Creates a new entity, annotated with the specified annotations.
*
* @param annotations optional key/value annotations map
*/
protected
AbstractAnnotated
(
Map
<
String
,
String
>[]
annotations
)
{
checkArgument
(
annotations
.
length
<=
1
,
"Only one set of annotations is expected"
);
this
.
annotations
=
annotations
.
length
==
1
?
annotations
[
0
]
:
EMPTY
;
}
@Override
public
Set
<
String
>
annotationKeys
()
{
return
ImmutableSet
.
copyOf
(
annotations
.
keySet
());
}
@Override
public
String
annotation
(
String
key
)
{
return
annotations
.
get
(
key
);
}
}
core/api/src/main/java/org/onlab/onos/net/AbstractModel.java
View file @
27ae0e6
package
org
.
onlab
.
onos
.
net
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Maps
;
import
org.onlab.onos.net.provider.ProviderId
;
import
java.util.Map
;
import
java.util.Set
;
/**
* Base implementation of a network model entity.
*/
public
class
AbstractModel
implements
Provided
,
Annotat
ed
{
public
class
AbstractModel
extends
AbstractAnnotated
implements
Provid
ed
{
private
final
ProviderId
providerId
;
// FIXME: figure out whether to make this concurrent or immutable
private
final
Map
<
String
,
String
>
annotations
=
Maps
.
newHashMap
();
// For serialization
public
AbstractModel
()
{
providerId
=
null
;
}
/**
* Creates a model entity attributed to the specified provider.
* Creates a model entity attributed to the specified provider and
* optionally annotated.
*
* @param providerId identity of the provider
* @param annotations optional key/value annotations
*/
protected
AbstractModel
(
ProviderId
providerId
)
{
@SafeVarargs
protected
AbstractModel
(
ProviderId
providerId
,
Map
<
String
,
String
>...
annotations
)
{
super
(
annotations
);
this
.
providerId
=
providerId
;
}
...
...
@@ -36,13 +35,4 @@ public class AbstractModel implements Provided, Annotated {
return
providerId
;
}
@Override
public
Set
<
String
>
annotationKeys
()
{
return
ImmutableSet
.
copyOf
(
annotations
.
keySet
());
}
@Override
public
String
annotation
(
String
key
)
{
return
annotations
.
get
(
key
);
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/Description.java
View file @
27ae0e6
...
...
@@ -3,5 +3,5 @@ package org.onlab.onos.net;
/**
* Base abstraction of a piece of information about network elements.
*/
public
interface
Description
{
public
interface
Description
extends
Annotated
{
}
...
...
core/api/src/main/java/org/onlab/onos/net/device/DefaultDeviceDescription.java
View file @
27ae0e6
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.net.AbstractAnnotated
;
import
java.net.URI
;
import
java.util.Map
;
import
static
com
.
google
.
common
.
base
.
MoreObjects
.
toStringHelper
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
...
...
@@ -9,7 +12,8 @@ import static org.onlab.onos.net.Device.Type;
/**
* Default implementation of immutable device description entity.
*/
public
class
DefaultDeviceDescription
implements
DeviceDescription
{
public
class
DefaultDeviceDescription
extends
AbstractAnnotated
implements
DeviceDescription
{
private
final
URI
uri
;
private
final
Type
type
;
private
final
String
manufacturer
;
...
...
@@ -26,10 +30,14 @@ public class DefaultDeviceDescription implements DeviceDescription {
* @param hwVersion device HW version
* @param swVersion device SW version
* @param serialNumber device serial number
* @param annotations optional key/value annotations map
*/
@SafeVarargs
public
DefaultDeviceDescription
(
URI
uri
,
Type
type
,
String
manufacturer
,
String
hwVersion
,
String
swVersion
,
String
serialNumber
)
{
String
serialNumber
,
Map
<
String
,
String
>...
annotations
)
{
super
(
annotations
);
this
.
uri
=
checkNotNull
(
uri
,
"Device URI cannot be null"
);
this
.
type
=
checkNotNull
(
type
,
"Device type cannot be null"
);
this
.
manufacturer
=
manufacturer
;
...
...
core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
View file @
27ae0e6
package
org
.
onlab
.
onos
.
net
.
host
;
import
static
com
.
google
.
common
.
base
.
MoreObjects
.
toStringHelper
;
import
java.util.HashSet
;
import
java.util.Set
;
import
com.google.common.collect.ImmutableSet
;
import
org.onlab.onos.net.AbstractAnnotated
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
com.google.common.collect.ImmutableSet
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
static
com
.
google
.
common
.
base
.
MoreObjects
.
toStringHelper
;
public
class
DefaultHostDescription
implements
HostDescription
{
/**
* Default implementation of an immutable host description.
*/
public
class
DefaultHostDescription
extends
AbstractAnnotated
implements
HostDescription
{
private
final
MacAddress
mac
;
private
final
VlanId
vlan
;
private
final
HostLocation
location
;
private
final
Set
<
IpPrefix
>
ips
;
/**
* Creates a host description using the supplied information.
*
* @param mac host MAC address
* @param vlan host VLAN identifier
* @param location host location
* @param annotations optional key/value annotations map
*/
@SafeVarargs
public
DefaultHostDescription
(
MacAddress
mac
,
VlanId
vlan
,
HostLocation
loc
)
{
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
loc
;
this
.
ips
=
new
HashSet
<
IpPrefix
>();
HostLocation
location
,
Map
<
String
,
String
>...
annotations
)
{
this
(
mac
,
vlan
,
location
,
new
HashSet
<
IpPrefix
>(),
annotations
);
}
/**
* Creates a host description using the supplied information.
*
* @param mac host MAC address
* @param vlan host VLAN identifier
* @param location host location
* @param ips of host IP addresses
* @param annotations optional key/value annotations map
*/
@SafeVarargs
public
DefaultHostDescription
(
MacAddress
mac
,
VlanId
vlan
,
HostLocation
loc
,
Set
<
IpPrefix
>
ips
)
{
HostLocation
location
,
Set
<
IpPrefix
>
ips
,
Map
<
String
,
String
>...
annotations
)
{
super
(
annotations
);
this
.
mac
=
mac
;
this
.
vlan
=
vlan
;
this
.
location
=
loc
;
this
.
ips
=
new
HashSet
<
IpPrefix
>(
ips
);
this
.
location
=
loc
ation
;
this
.
ips
=
new
HashSet
<>(
ips
);
}
@Override
...
...
core/api/src/main/java/org/onlab/onos/net/topology/DefaultGraphDescription.java
View file @
27ae0e6
...
...
@@ -2,6 +2,7 @@ package org.onlab.onos.net.topology;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Maps
;
import
org.onlab.onos.net.AbstractAnnotated
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
...
...
@@ -12,7 +13,8 @@ import java.util.Map;
/**
* Default implementation of an immutable topology graph data carrier.
*/
public
class
DefaultGraphDescription
implements
GraphDescription
{
public
class
DefaultGraphDescription
extends
AbstractAnnotated
implements
GraphDescription
{
private
final
long
nanos
;
private
final
ImmutableSet
<
TopologyVertex
>
vertexes
;
...
...
@@ -28,8 +30,13 @@ public class DefaultGraphDescription implements GraphDescription {
* @param nanos time in nanos of when the topology description was created
* @param devices collection of infrastructure devices
* @param links collection of infrastructure links
* @param annotations optional key/value annotations map
*/
public
DefaultGraphDescription
(
long
nanos
,
Iterable
<
Device
>
devices
,
Iterable
<
Link
>
links
)
{
@SafeVarargs
public
DefaultGraphDescription
(
long
nanos
,
Iterable
<
Device
>
devices
,
Iterable
<
Link
>
links
,
Map
<
String
,
String
>...
annotations
)
{
super
(
annotations
);
this
.
nanos
=
nanos
;
this
.
vertexes
=
buildVertexes
(
devices
);
this
.
edges
=
buildEdges
(
links
);
...
...
Please
register
or
login
to post a comment