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
Ayaka Koshibe
2014-09-23 12:46:19 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
afe34ae168b033978cc3da7622abcdab440ed7df
afe34ae1
2 parents
16609696
50d401fe
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
45 changed files
with
408 additions
and
138 deletions
cli/pom.xml
cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
cli/src/main/java/org/onlab/onos/cli/NodesListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/ClusterDevicesCommand.java
cli/src/main/java/org/onlab/onos/cli/net/ClusterLinksCommand.java
cli/src/main/java/org/onlab/onos/cli/net/ClustersListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DeviceRemoveCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DeviceRoleCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/HostsListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/LinksListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/TopologyCommand.java
cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
core/api/src/main/java/org/onlab/onos/net/DefaultPort.java
core/api/src/main/java/org/onlab/onos/net/Port.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceAdminService.java
core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java
core/api/src/main/java/org/onlab/onos/net/host/HostService.java
core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
core/api/src/main/java/org/onlab/onos/net/host/PortAddresses.java
core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
core/net/src/main/java/org/onlab/onos/net/host/impl/DefaultPortAddresses.java
core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java
core/store/src/main/java/org/onlab/onos/store/StoreService.java
core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
core/store/src/main/java/org/onlab/onos/store/device/impl/AbsentInvalidatingLoadingCache.java → core/store/src/main/java/org/onlab/onos/store/impl/AbsentInvalidatingLoadingCache.java
core/store/src/main/java/org/onlab/onos/store/impl/StoreManager.java
core/store/src/main/java/org/onlab/onos/store/device/impl/DefaultPortSerializer.java → core/store/src/main/java/org/onlab/onos/store/serializers/DefaultPortSerializer.java
core/store/src/main/java/org/onlab/onos/store/device/impl/DeviceIdSerializer.java → core/store/src/main/java/org/onlab/onos/store/serializers/DeviceIdSerializer.java
core/store/src/main/java/org/onlab/onos/store/device/impl/IpPrefixSerializer.java → core/store/src/main/java/org/onlab/onos/store/serializers/IpPrefixSerializer.java
core/store/src/main/java/org/onlab/onos/store/device/impl/PortNumberSerializer.java → core/store/src/main/java/org/onlab/onos/store/serializers/PortNumberSerializer.java
core/store/src/main/java/org/onlab/onos/store/device/impl/ProviderIdSerializer.java → core/store/src/main/java/org/onlab/onos/store/serializers/ProviderIdSerializer.java
core/store/src/main/java/org/onlab/onos/store/serializers/package-info.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
pom.xml
tools/dev/bash_profile
tools/test/bin/onos-verify-cell
tools/test/cells/local
utils/osgi/src/main/java/org/onlab/osgi/DefaultServiceDirectory.java
cli/pom.xml
View file @
afe34ae
...
...
@@ -23,6 +23,10 @@
<artifactId>
onos-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onlab-osgi
</artifactId>
</dependency>
<dependency>
<groupId>
org.osgi
</groupId>
<artifactId>
org.osgi.core
</artifactId>
</dependency>
...
...
cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
cli
;
import
org.apache.karaf.shell.console.OsgiCommandSupport
;
import
org.o
sgi.framework.BundleContext
;
import
org.o
sgi.framework.FrameworkUtil
;
import
org.o
nlab.osgi.DefaultServiceDirectory
;
import
org.o
nlab.osgi.ServiceNotFoundException
;
/**
* Base abstraction of Karaf shell commands.
...
...
@@ -17,8 +17,7 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport {
* @return service implementation
*/
public
static
<
T
>
T
get
(
Class
<
T
>
serviceClass
)
{
BundleContext
bc
=
FrameworkUtil
.
getBundle
(
AbstractShellCommand
.
class
).
getBundleContext
();
return
bc
.
getService
(
bc
.
getServiceReference
(
serviceClass
));
return
DefaultServiceDirectory
.
getService
(
serviceClass
);
}
/**
...
...
@@ -41,4 +40,19 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport {
System
.
err
.
println
(
String
.
format
(
format
,
args
));
}
/**
* Executes this command.
*/
protected
abstract
void
execute
();
@Override
protected
Object
doExecute
()
throws
Exception
{
try
{
execute
();
}
catch
(
ServiceNotFoundException
e
)
{
error
(
e
.
getMessage
());
}
return
null
;
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/NodesListCommand.java
View file @
afe34ae
...
...
@@ -29,8 +29,8 @@ public class NodesListCommand extends AbstractShellCommand {
};
@Override
protected
Object
doExecute
()
throws
Exception
{
ClusterService
service
=
get
Service
(
ClusterService
.
class
);
protected
void
execute
()
{
ClusterService
service
=
get
(
ClusterService
.
class
);
List
<
ControllerNode
>
nodes
=
newArrayList
(
service
.
getNodes
());
Collections
.
sort
(
nodes
,
ID_COMPARATOR
);
ControllerNode
self
=
service
.
getLocalNode
();
...
...
@@ -39,7 +39,6 @@ public class NodesListCommand extends AbstractShellCommand {
service
.
getState
(
node
.
id
()),
node
.
equals
(
self
)
?
"*"
:
""
);
}
return
null
;
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/ClusterDevicesCommand.java
View file @
afe34ae
...
...
@@ -31,7 +31,7 @@ public class ClusterDevicesCommand extends ClustersListCommand {
};
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
int
cid
=
Integer
.
parseInt
(
id
);
init
();
TopologyCluster
cluster
=
service
.
getCluster
(
topology
,
clusterId
(
cid
));
...
...
@@ -44,8 +44,6 @@ public class ClusterDevicesCommand extends ClustersListCommand {
print
(
"%s"
,
deviceId
);
}
}
return
null
;
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/ClusterLinksCommand.java
View file @
afe34ae
...
...
@@ -20,7 +20,7 @@ public class ClusterLinksCommand extends ClustersListCommand {
String
id
=
null
;
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
int
cid
=
Integer
.
parseInt
(
id
);
init
();
TopologyCluster
cluster
=
service
.
getCluster
(
topology
,
clusterId
(
cid
));
...
...
@@ -31,7 +31,6 @@ public class ClusterLinksCommand extends ClustersListCommand {
print
(
linkString
(
link
));
}
}
return
null
;
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/ClustersListCommand.java
View file @
afe34ae
...
...
@@ -27,7 +27,7 @@ public class ClustersListCommand extends TopologyCommand {
};
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
init
();
List
<
TopologyCluster
>
clusters
=
Lists
.
newArrayList
(
service
.
getClusters
(
topology
));
Collections
.
sort
(
clusters
,
ID_COMPARATOR
);
...
...
@@ -35,7 +35,6 @@ public class ClustersListCommand extends TopologyCommand {
for
(
TopologyCluster
cluster
:
clusters
)
{
print
(
FMT
,
cluster
.
id
().
index
(),
cluster
.
deviceCount
(),
cluster
.
linkCount
());
}
return
null
;
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
View file @
afe34ae
...
...
@@ -35,7 +35,7 @@ public class DevicePortsListCommand extends DevicesListCommand {
};
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
DeviceService
service
=
getService
(
DeviceService
.
class
);
if
(
uri
==
null
)
{
for
(
Device
device
:
getSortedDevices
(
service
))
{
...
...
@@ -49,7 +49,6 @@ public class DevicePortsListCommand extends DevicesListCommand {
printDevice
(
service
,
device
);
}
}
return
null
;
}
@Override
...
...
cli/src/main/java/org/onlab/onos/cli/net/DeviceRemoveCommand.java
View file @
afe34ae
...
...
@@ -18,9 +18,8 @@ public class DeviceRemoveCommand extends AbstractShellCommand {
String
uri
=
null
;
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
getService
(
DeviceAdminService
.
class
).
removeDevice
(
DeviceId
.
deviceId
(
uri
));
return
null
;
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/DeviceRoleCommand.java
View file @
afe34ae
...
...
@@ -23,11 +23,10 @@ public class DeviceRoleCommand extends AbstractShellCommand {
String
role
=
null
;
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
MastershipRole
mastershipRole
=
MastershipRole
.
valueOf
(
role
.
toUpperCase
());
getService
(
DeviceAdminService
.
class
).
setRole
(
DeviceId
.
deviceId
(
uri
),
mastershipRole
);
return
null
;
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
View file @
afe34ae
...
...
@@ -29,12 +29,11 @@ public class DevicesListCommand extends AbstractShellCommand {
};
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
DeviceService
service
=
getService
(
DeviceService
.
class
);
for
(
Device
device
:
getSortedDevices
(
service
))
{
printDevice
(
service
,
device
);
}
return
null
;
}
/**
...
...
cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
View file @
afe34ae
...
...
@@ -34,14 +34,13 @@ public class FlowsListCommand extends AbstractShellCommand {
};
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
DeviceService
deviceService
=
getService
(
DeviceService
.
class
);
FlowRuleService
service
=
getService
(
FlowRuleService
.
class
);
Map
<
Device
,
List
<
FlowRule
>>
flows
=
getSortedFlows
(
deviceService
,
service
);
for
(
Device
d
:
deviceService
.
getDevices
())
{
printFlows
(
d
,
flows
.
get
(
d
));
}
return
null
;
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/HostsListCommand.java
View file @
afe34ae
...
...
@@ -29,12 +29,11 @@ public class HostsListCommand extends AbstractShellCommand {
};
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
HostService
service
=
getService
(
HostService
.
class
);
for
(
Host
host
:
getSortedHosts
(
service
))
{
printHost
(
host
);
}
return
null
;
}
/**
...
...
cli/src/main/java/org/onlab/onos/cli/net/LinksListCommand.java
View file @
afe34ae
...
...
@@ -23,14 +23,13 @@ public class LinksListCommand extends AbstractShellCommand {
String
uri
=
null
;
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
LinkService
service
=
getService
(
LinkService
.
class
);
Iterable
<
Link
>
links
=
uri
!=
null
?
service
.
getDeviceLinks
(
deviceId
(
uri
))
:
service
.
getLinks
();
for
(
Link
link
:
links
)
{
print
(
linkString
(
link
));
}
return
null
;
}
/**
...
...
cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java
View file @
afe34ae
...
...
@@ -29,13 +29,12 @@ public class PathListCommand extends TopologyCommand {
String
dst
=
null
;
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
init
();
Set
<
Path
>
paths
=
service
.
getPaths
(
topology
,
deviceId
(
src
),
deviceId
(
dst
));
for
(
Path
path
:
paths
)
{
print
(
pathString
(
path
));
}
return
null
;
}
/**
...
...
cli/src/main/java/org/onlab/onos/cli/net/TopologyCommand.java
View file @
afe34ae
...
...
@@ -28,11 +28,10 @@ public class TopologyCommand extends AbstractShellCommand {
}
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
init
();
print
(
FMT
,
topology
.
time
(),
topology
.
deviceCount
(),
topology
.
linkCount
(),
topology
.
clusterCount
(),
topology
.
pathCount
());
return
null
;
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
View file @
afe34ae
...
...
@@ -16,7 +16,7 @@ import org.onlab.onos.net.host.HostService;
public
class
WipeOutCommand
extends
ClustersListCommand
{
@Override
protected
Object
doExecute
()
throws
Exception
{
protected
void
execute
()
{
DeviceAdminService
deviceAdminService
=
get
(
DeviceAdminService
.
class
);
DeviceService
deviceService
=
get
(
DeviceService
.
class
);
for
(
Device
device
:
deviceService
.
getDevices
())
{
...
...
@@ -28,7 +28,6 @@ public class WipeOutCommand extends ClustersListCommand {
for
(
Host
host
:
hostService
.
getHosts
())
{
hostAdminService
.
removeHost
(
host
.
id
());
}
return
null
;
}
...
...
core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
View file @
afe34ae
...
...
@@ -37,6 +37,9 @@ public interface MastershipService {
*/
MastershipRole
requestRoleFor
(
DeviceId
deviceId
);
// TODO: add facet for requesting a different master than the current one;
// abandon mastership (due to loss of connection)
/**
* Adds the specified mastership change listener.
*
...
...
core/api/src/main/java/org/onlab/onos/net/DefaultPort.java
View file @
afe34ae
...
...
@@ -2,13 +2,7 @@ package org.onlab.onos.net;
import
static
com
.
google
.
common
.
base
.
MoreObjects
.
toStringHelper
;
import
java.util.Collections
;
import
java.util.Objects
;
import
java.util.Set
;
import
org.onlab.packet.IpPrefix
;
import
com.google.common.collect.ImmutableSet
;
/**
* Default port implementation.
...
...
@@ -19,36 +13,18 @@ public class DefaultPort implements Port {
private
final
PortNumber
number
;
private
final
boolean
isEnabled
;
// Attributes
private
final
Set
<
IpPrefix
>
ipAddresses
;
/**
* Creates a network element attributed to the specified provider.
*
* @param element parent network element
* @param number port number
* @param isEnabled indicator whether the port is up and active
*/
public
DefaultPort
(
Element
element
,
PortNumber
number
,
boolean
isEnabled
)
{
this
(
element
,
number
,
isEnabled
,
null
);
}
/**
* Creates a network element attributed to the specified provider.
*
* @param element parent network element
* @param number port number
* @param isEnabled indicator whether the port is up and active
* @param ipAddresses set of IP addresses assigned to the port
*/
public
DefaultPort
(
Element
element
,
PortNumber
number
,
boolean
isEnabled
,
Set
<
IpPrefix
>
ipAddresses
)
{
boolean
isEnabled
)
{
this
.
element
=
element
;
this
.
number
=
number
;
this
.
isEnabled
=
isEnabled
;
this
.
ipAddresses
=
(
ipAddresses
==
null
)
?
Collections
.<
IpPrefix
>
emptySet
()
:
ImmutableSet
.
copyOf
(
ipAddresses
);
}
@Override
...
...
@@ -94,9 +70,4 @@ public class DefaultPort implements Port {
return
element
;
}
@Override
public
Set
<
IpPrefix
>
ipAddresses
()
{
return
ipAddresses
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/Port.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
net
;
import
java.util.Set
;
import
org.onlab.packet.IpPrefix
;
/**
* Abstraction of a network port.
...
...
@@ -32,12 +29,4 @@ public interface Port {
// set of port attributes
/**
* Returns the set of IP addresses that are logically configured on this
* port.
*
* @return the set of IP addresses configured on the port. The set is empty
* if no addresses are configured.
*/
Set
<
IpPrefix
>
ipAddresses
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceAdminService.java
View file @
afe34ae
...
...
@@ -15,7 +15,7 @@ public interface DeviceAdminService {
* @param role requested role
* @deprecated Will be removed in favor of MastershipAdminService.setRole()
*/
@Deprecated
//
@Deprecated
void
setRole
(
DeviceId
deviceId
,
MastershipRole
role
);
/**
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
net
.
host
;
import
java.util.Set
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.MacAddress
;
/**
* Service for administering the inventory of end-station hosts.
...
...
@@ -14,4 +19,42 @@ public interface HostAdminService {
*/
void
removeHost
(
HostId
hostId
);
/**
* Binds an IP address and optional MAC address to the given connection
* point.
* <p/>
* This method will overwrite any previously held address information for
* the connection point.
*
* @param ip the IP address to bind to the connection point. This parameter
* is mandatory and cannot be null.
* @param mac the optional MAC address to bind to the connection point. Can
* be set to null if no MAC address needs to be bound.
* @param connectPoint the connection point to bind the addresses to
*/
void
bindAddressesToPort
(
IpAddress
ip
,
MacAddress
mac
,
ConnectPoint
connectPoint
);
/**
* Removes all address information for the given connection point.
*
* @param connectPoint the connection point to remove address information
*/
void
unbindAddressesFromPort
(
ConnectPoint
connectPoint
);
/**
* Returns the addresses information for all connection points.
*
* @return the set of address bindings for all connection points
*/
Set
<
PortAddresses
>
getAddressBindings
();
/**
* Retrieves the addresses that have been bound to the given connection
* point.
*
* @param connectPoint the connection point to retrieve address bindings
* for
* @return addresses bound to the port
*/
PortAddresses
getAddressBindingsForPort
(
ConnectPoint
connectPoint
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostService.java
View file @
afe34ae
...
...
@@ -6,6 +6,7 @@ import org.onlab.onos.net.ConnectPoint;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -87,7 +88,7 @@ public interface HostService {
*
* @param ip IP address of the host to monitor
*/
void
monitorIp
(
IpPrefix
ip
);
void
startMonitoringIp
(
IpAddress
ip
);
/**
* Stops the host service from monitoring an IP address.
...
...
@@ -95,7 +96,18 @@ public interface HostService {
* @param ip IP address to stop monitoring
*/
// TODO clients can cancel other client's requests
void
stopMonitoringIp
(
IpPrefix
ip
);
void
stopMonitoringIp
(
IpAddress
ip
);
/**
* Requests the host service to resolve the MAC address for the given IP
* address.
* <p/>
* This will trigger a notification to the host listeners if the MAC
* address is found.
*
* @param ip IP address to find the MAC address for
*/
void
requestMac
(
IpAddress
ip
);
/**
* Adds the specified host listener.
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
net
.
host
;
import
java.util.Set
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
...
...
@@ -9,8 +11,6 @@ import org.onlab.packet.IpPrefix;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
java.util.Set
;
/**
* Manages inventory of end-station hosts; not intended for direct use.
*/
...
...
@@ -98,4 +98,34 @@ public interface HostStore {
*/
Set
<
Host
>
getConnectedHosts
(
DeviceId
deviceId
);
/**
* Updates the address information for a given port.
*
* @param addresses the port and address information
*/
void
updateAddressBindings
(
PortAddresses
addresses
);
/**
* Removes any previously stored address information for a given connection
* point.
*
* @param connectPoint the connection point
*/
void
removeAddressBindings
(
ConnectPoint
connectPoint
);
/**
* Returns the address bindings stored for all connection points.
*
* @return the set of address bindings
*/
Set
<
PortAddresses
>
getAddressBindings
();
/**
* Returns the address bindings for a particular connection point.
*
* @param connectPoint the connection point to return address information
* for
* @return address information for the connection point
*/
PortAddresses
getAddressBindingsForPort
(
ConnectPoint
connectPoint
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/PortAddresses.java
0 → 100644
View file @
afe34ae
package
org
.
onlab
.
onos
.
net
.
host
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.MacAddress
;
/**
* Represents address information bound to a port.
*/
public
interface
PortAddresses
{
/**
* Returns the connection point this address information is bound to.
*
* @return the connection point
*/
ConnectPoint
connectPoint
();
/**
* Returns the IP address bound to the port.
*
* @return the IP address
*/
IpAddress
ip
();
/**
* Returns the MAC address bound to the port.
*
* @return the MAC address if one is bound, otherwise null
*/
MacAddress
mac
();
}
core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
View file @
afe34ae
...
...
@@ -6,6 +6,7 @@ import org.onlab.onos.net.ConnectPoint;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -55,11 +56,15 @@ public class HostServiceAdapter implements HostService {
}
@Override
public
void
monitorIp
(
IpPrefix
ip
)
{
public
void
startMonitoringIp
(
IpAddress
ip
)
{
}
@Override
public
void
stopMonitoringIp
(
IpPrefix
ip
)
{
public
void
stopMonitoringIp
(
IpAddress
ip
)
{
}
@Override
public
void
requestMac
(
IpAddress
ip
)
{
}
@Override
...
...
core/net/src/main/java/org/onlab/onos/net/host/impl/DefaultPortAddresses.java
0 → 100644
View file @
afe34ae
package
org
.
onlab
.
onos
.
net
.
host
.
impl
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.host.PortAddresses
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.MacAddress
;
public
class
DefaultPortAddresses
implements
PortAddresses
{
private
final
ConnectPoint
connectPoint
;
private
final
IpAddress
ipAddress
;
private
final
MacAddress
macAddress
;
public
DefaultPortAddresses
(
ConnectPoint
connectPoint
,
IpAddress
ip
,
MacAddress
mac
)
{
this
.
connectPoint
=
connectPoint
;
this
.
ipAddress
=
ip
;
this
.
macAddress
=
mac
;
}
@Override
public
ConnectPoint
connectPoint
()
{
return
connectPoint
;
}
@Override
public
IpAddress
ip
()
{
return
ipAddress
;
}
@Override
public
MacAddress
mac
()
{
return
macAddress
;
}
}
core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
View file @
afe34ae
...
...
@@ -26,8 +26,10 @@ import org.onlab.onos.net.host.HostProviderRegistry;
import
org.onlab.onos.net.host.HostProviderService
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.host.HostStore
;
import
org.onlab.onos.net.host.PortAddresses
;
import
org.onlab.onos.net.provider.AbstractProviderRegistry
;
import
org.onlab.onos.net.provider.AbstractProviderService
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -118,13 +120,18 @@ public class HostManager
}
@Override
public
void
monitorIp
(
IpPrefix
ip
)
{
// TODO pass through to
Simple
HostMonitor
public
void
startMonitoringIp
(
IpAddress
ip
)
{
// TODO pass through to HostMonitor
}
@Override
public
void
stopMonitoringIp
(
IpPrefix
ip
)
{
// TODO pass through to SimpleHostMonitor
public
void
stopMonitoringIp
(
IpAddress
ip
)
{
// TODO pass through to HostMonitor
}
@Override
public
void
requestMac
(
IpAddress
ip
)
{
// TODO Auto-generated method stub
}
@Override
...
...
@@ -147,6 +154,27 @@ public class HostManager
}
}
@Override
public
void
bindAddressesToPort
(
IpAddress
ip
,
MacAddress
mac
,
ConnectPoint
connectPoint
)
{
store
.
updateAddressBindings
(
new
DefaultPortAddresses
(
connectPoint
,
ip
,
mac
));
}
@Override
public
void
unbindAddressesFromPort
(
ConnectPoint
connectPoint
)
{
store
.
removeAddressBindings
(
connectPoint
);
}
@Override
public
Set
<
PortAddresses
>
getAddressBindings
()
{
return
store
.
getAddressBindings
();
}
@Override
public
PortAddresses
getAddressBindingsForPort
(
ConnectPoint
connectPoint
)
{
return
store
.
getAddressBindingsForPort
(
connectPoint
);
}
// Personalized host provider service issued to the supplied provider.
private
class
InternalHostProviderService
extends
AbstractProviderService
<
HostProvider
>
...
...
core/net/src/main/java/org/onlab/onos/net/host/impl/HostMonitor.java
View file @
afe34ae
...
...
@@ -6,7 +6,6 @@ import java.util.concurrent.TimeUnit;
import
org.jboss.netty.util.Timeout
;
import
org.jboss.netty.util.TimerTask
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.device.DeviceService
;
...
...
@@ -89,7 +88,7 @@ public class HostMonitor implements TimerTask {
// else (ip isn't in any configured subnet)
// send out all non-external edge ports
for
(
Device
device
:
deviceService
.
getDevices
())
{
/*
for (Device device : deviceService.getDevices()) {
for (Port port : deviceService.getPorts(device.id())) {
for (IpPrefix ip : port.ipAddresses()) {
if (ip.contains(targetIp)) {
...
...
@@ -98,7 +97,7 @@ public class HostMonitor implements TimerTask {
}
}
}
}
}
*/
}
...
...
core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
net
.
device
.
impl
;
import
com.google.common.collect.Iterables
;
import
com.hazelcast.config.Config
;
import
com.hazelcast.core.Hazelcast
;
import
com.hazelcast.core.HazelcastInstance
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.onlab.onos.event.Event
;
import
org.onlab.onos.event.impl.TestEventDispatcher
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
...
...
@@ -23,13 +27,9 @@ import org.onlab.onos.net.device.DeviceService;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.AbstractProvider
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.event.impl.TestEventDispatcher
;
import
org.onlab.onos.store.StoreService
;
import
org.onlab.onos.store.device.impl.DistributedDeviceStore
;
import
com.google.common.collect.Iterables
;
import
com.hazelcast.config.Config
;
import
com.hazelcast.core.Hazelcast
;
import
org.onlab.onos.store.impl.StoreManager
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
...
...
@@ -64,6 +64,7 @@ public class DistributedDeviceManagerTest {
private
DeviceManager
mgr
;
protected
StoreManager
storeManager
;
protected
DeviceService
service
;
protected
DeviceAdminService
admin
;
protected
DeviceProviderRegistry
registry
;
...
...
@@ -89,7 +90,11 @@ public class DistributedDeviceManagerTest {
config
.
getNetworkConfig
().
getJoin
()
.
getMulticastConfig
()
.
setEnabled
(
false
);
dstore
=
new
TestDistributedDeviceStore
(
Hazelcast
.
newHazelcastInstance
(
config
));
storeManager
=
new
TestStoreManager
(
Hazelcast
.
newHazelcastInstance
(
config
));
storeManager
.
activate
();
dstore
=
new
TestDistributedDeviceStore
(
storeManager
);
dstore
.
activate
();
mgr
.
store
=
dstore
;
mgr
.
eventDispatcher
=
new
TestEventDispatcher
();
...
...
@@ -112,7 +117,7 @@ public class DistributedDeviceManagerTest {
mgr
.
deactivate
();
dstore
.
deactivate
();
((
TestDistributedDeviceStore
)
dstore
).
shutdownHz
();
storeManager
.
deactivate
();
}
private
void
connectDevice
(
DeviceId
deviceId
,
String
swVersion
)
{
...
...
@@ -282,20 +287,19 @@ public class DistributedDeviceManagerTest {
}
private
class
TestDistributedDeviceStore
extends
DistributedDeviceStore
{
public
TestDistributedDeviceStore
(
final
HazelcastInstance
hazelcastInstance
)
{
storeService
=
new
StoreService
()
{
@Override
public
HazelcastInstance
getHazelcastInstance
()
{
return
hazelcastInstance
;
}
};
public
TestDistributedDeviceStore
(
StoreService
storeService
)
{
this
.
storeService
=
storeService
;
}
}
/**
* Shutdowns the hazelcast instance.
*/
public
void
shutdownHz
()
{
theInstance
.
shutdown
();
private
class
TestStoreManager
extends
StoreManager
{
TestStoreManager
(
HazelcastInstance
instance
)
{
this
.
instance
=
instance
;
}
@Override
public
void
activate
()
{
setupKryoPool
();
}
}
}
...
...
core/store/src/main/java/org/onlab/onos/store/StoreService.java
View file @
afe34ae
...
...
@@ -15,4 +15,22 @@ public interface StoreService {
*/
HazelcastInstance
getHazelcastInstance
();
/**
* Serializes the specified object into bytes using one of the
* pre-registered serializers.
*
* @param obj object to be serialized
* @return serialized bytes
*/
public
byte
[]
serialize
(
final
Object
obj
);
/**
* Deserializes the specified bytes into an object using one of the
* pre-registered serializers.
*
* @param bytes bytes to be deserialized
* @return deserialized object
*/
public
<
T
>
T
deserialize
(
final
byte
[]
bytes
);
}
...
...
core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
View file @
afe34ae
This diff is collapsed. Click to expand it.
core/store/src/main/java/org/onlab/onos/store/
device/
impl/AbsentInvalidatingLoadingCache.java
→
core/store/src/main/java/org/onlab/onos/store/impl/AbsentInvalidatingLoadingCache.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
package
org
.
onlab
.
onos
.
store
.
impl
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
...
...
core/store/src/main/java/org/onlab/onos/store/impl/StoreManager.java
View file @
afe34ae
...
...
@@ -2,14 +2,33 @@ package org.onlab.onos.store.impl;
import
com.hazelcast.core.Hazelcast
;
import
com.hazelcast.core.HazelcastInstance
;
import
de.javakaffee.kryoserializers.URISerializer
;
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.DefaultDevice
;
import
org.onlab.onos.net.DefaultPort
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Element
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.StoreService
;
import
org.onlab.onos.store.serializers.DefaultPortSerializer
;
import
org.onlab.onos.store.serializers.DeviceIdSerializer
;
import
org.onlab.onos.store.serializers.PortNumberSerializer
;
import
org.onlab.onos.store.serializers.ProviderIdSerializer
;
import
org.onlab.util.KryoPool
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.net.URI
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
/**
* Auxiliary bootstrap of distributed store.
*/
...
...
@@ -20,15 +39,45 @@ public class StoreManager implements StoreService {
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
protected
HazelcastInstance
instance
;
private
KryoPool
serializerPool
;
@Activate
public
void
activate
()
{
instance
=
Hazelcast
.
newHazelcastInstance
();
setupKryoPool
();
log
.
info
(
"Started"
);
}
/**
* Sets up the common serialzers pool.
*/
protected
void
setupKryoPool
()
{
// FIXME Slice out types used in common to separate pool/namespace.
serializerPool
=
KryoPool
.
newBuilder
()
.
register
(
ArrayList
.
class
,
HashMap
.
class
,
Device
.
Type
.
class
,
DefaultDevice
.
class
,
MastershipRole
.
class
,
Port
.
class
,
Element
.
class
)
.
register
(
URI
.
class
,
new
URISerializer
())
.
register
(
ProviderId
.
class
,
new
ProviderIdSerializer
())
.
register
(
DeviceId
.
class
,
new
DeviceIdSerializer
())
.
register
(
PortNumber
.
class
,
new
PortNumberSerializer
())
.
register
(
DefaultPort
.
class
,
new
DefaultPortSerializer
())
.
build
()
.
populate
(
10
);
}
@Deactivate
public
void
deactivate
()
{
instance
.
shutdown
();
log
.
info
(
"Stopped"
);
}
...
...
@@ -36,4 +85,19 @@ public class StoreManager implements StoreService {
public
HazelcastInstance
getHazelcastInstance
()
{
return
instance
;
}
@Override
public
byte
[]
serialize
(
final
Object
obj
)
{
return
serializerPool
.
serialize
(
obj
);
}
@Override
public
<
T
>
T
deserialize
(
final
byte
[]
bytes
)
{
if
(
bytes
==
null
)
{
return
null
;
}
return
serializerPool
.
deserialize
(
bytes
);
}
}
...
...
core/store/src/main/java/org/onlab/onos/store/
device/impl
/DefaultPortSerializer.java
→
core/store/src/main/java/org/onlab/onos/store/
serializers
/DefaultPortSerializer.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
import
java.util.ArrayList
;
import
java.util.Collection
;
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
org.onlab.onos.net.DefaultPort
;
import
org.onlab.onos.net.Element
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.packet.IpPrefix
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
import
com.esotericsoftware.kryo.io.Input
;
import
com.esotericsoftware.kryo.io.Output
;
import
com.esotericsoftware.kryo.serializers.CollectionSerializer
;
import
com.google.common.collect.ImmutableSet
;
// TODO move to util, etc.
/**
...
...
@@ -22,10 +16,6 @@ import com.google.common.collect.ImmutableSet;
public
final
class
DefaultPortSerializer
extends
Serializer
<
DefaultPort
>
{
private
final
CollectionSerializer
ipAddrSerializer
=
new
CollectionSerializer
(
IpPrefix
.
class
,
new
IpPrefixSerializer
(),
false
);
/**
* Default constructor.
*/
...
...
@@ -39,8 +29,6 @@ public final class DefaultPortSerializer extends
kryo
.
writeClassAndObject
(
output
,
object
.
element
());
kryo
.
writeObject
(
output
,
object
.
number
());
output
.
writeBoolean
(
object
.
isEnabled
());
kryo
.
writeObject
(
output
,
object
.
ipAddresses
(),
ipAddrSerializer
);
}
@Override
...
...
@@ -49,11 +37,7 @@ public final class DefaultPortSerializer extends
Element
element
=
(
Element
)
kryo
.
readClassAndObject
(
input
);
PortNumber
number
=
kryo
.
readObject
(
input
,
PortNumber
.
class
);
boolean
isEnabled
=
input
.
readBoolean
();
@SuppressWarnings
(
"unchecked"
)
Collection
<
IpPrefix
>
ipAddresses
=
kryo
.
readObject
(
input
,
ArrayList
.
class
,
ipAddrSerializer
);
return
new
DefaultPort
(
element
,
number
,
isEnabled
,
ImmutableSet
.
copyOf
(
ipAddresses
));
return
new
DefaultPort
(
element
,
number
,
isEnabled
);
}
}
...
...
core/store/src/main/java/org/onlab/onos/store/
device/impl
/DeviceIdSerializer.java
→
core/store/src/main/java/org/onlab/onos/store/
serializers
/DeviceIdSerializer.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
java.net.URI
;
...
...
core/store/src/main/java/org/onlab/onos/store/
device/impl
/IpPrefixSerializer.java
→
core/store/src/main/java/org/onlab/onos/store/
serializers
/IpPrefixSerializer.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
org.onlab.packet.IpPrefix
;
...
...
core/store/src/main/java/org/onlab/onos/store/
device/impl
/PortNumberSerializer.java
→
core/store/src/main/java/org/onlab/onos/store/
serializers
/PortNumberSerializer.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
org.onlab.onos.net.PortNumber
;
...
...
core/store/src/main/java/org/onlab/onos/store/
device/impl
/ProviderIdSerializer.java
→
core/store/src/main/java/org/onlab/onos/store/
serializers
/ProviderIdSerializer.java
View file @
afe34ae
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
org.onlab.onos.net.provider.ProviderId
;
...
...
core/store/src/main/java/org/onlab/onos/store/serializers/package-info.java
0 → 100644
View file @
afe34ae
/**
* Various Kryo serializers for use in distributed stores.
*/
package
org
.
onlab
.
onos
.
store
.
serializers
;
\ No newline at end of file
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
View file @
afe34ae
...
...
@@ -24,15 +24,16 @@ import org.onlab.onos.net.HostId;
import
org.onlab.onos.net.host.HostDescription
;
import
org.onlab.onos.net.host.HostEvent
;
import
org.onlab.onos.net.host.HostStore
;
import
org.onlab.onos.net.host.PortAddresses
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
org.slf4j.Logger
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Multimap
;
import
org.slf4j.Logger
;
/**
* Manages inventory of end-station hosts using trivial in-memory
...
...
@@ -50,6 +51,9 @@ public class SimpleHostStore implements HostStore {
// Hosts tracked by their location
private
final
Multimap
<
ConnectPoint
,
Host
>
locations
=
HashMultimap
.
create
();
private
final
Map
<
ConnectPoint
,
PortAddresses
>
portAddresses
=
new
ConcurrentHashMap
<>();
@Activate
public
void
activate
()
{
log
.
info
(
"Started"
);
...
...
@@ -192,4 +196,24 @@ public class SimpleHostStore implements HostStore {
return
hostset
;
}
@Override
public
void
updateAddressBindings
(
PortAddresses
addresses
)
{
portAddresses
.
put
(
addresses
.
connectPoint
(),
addresses
);
}
@Override
public
void
removeAddressBindings
(
ConnectPoint
connectPoint
)
{
portAddresses
.
remove
(
connectPoint
);
}
@Override
public
Set
<
PortAddresses
>
getAddressBindings
()
{
return
new
HashSet
<>(
portAddresses
.
values
());
}
@Override
public
PortAddresses
getAddressBindingsForPort
(
ConnectPoint
connectPoint
)
{
return
portAddresses
.
get
(
connectPoint
);
}
}
...
...
pom.xml
View file @
afe34ae
...
...
@@ -172,6 +172,11 @@
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onlab-osgi
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onlab-junit
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<scope>
test
</scope>
...
...
tools/dev/bash_profile
View file @
afe34ae
...
...
@@ -46,7 +46,8 @@ alias gui='open http://localhost:8181/onos/tvue'
# Test related conveniences
# SSH to a specified ONOS instance
alias
sshctl
=
onos-ssh
alias
sshctl
=
'onos-ssh'
alias
sshnet
=
'onos-ssh $OCN'
# Applies the settings in the specified cell file or lists current cell definition
# if no cell file is given.
...
...
@@ -62,6 +63,7 @@ function cell {
env | egrep
"ONOS_CELL"
env | egrep
"OCI"
env | egrep
"OC[0-9]+"
| sort
env | egrep
"OCN"
fi
}
...
...
tools/test/bin/onos-verify-cell
View file @
afe34ae
...
...
@@ -6,6 +6,6 @@
[
! -d
"
$ONOS_ROOT
"
]
&&
echo
"ONOS_ROOT is not defined"
>&2
&&
exit
1
.
$ONOS_ROOT
/tools/build/envDefaults
for
node
in
$(
env | sort | egrep
"OC[0-9]+"
| cut -d
=
-f2
)
;
do
for
node
in
$(
env | sort | egrep
"OC[0-9
N
]+"
| cut -d
=
-f2
)
;
do
printf
"%s: "
$node
; ssh -n -o
PasswordAuthentication
=
no
$ONOS_USER
@
$node
date
done
\ No newline at end of file
...
...
tools/test/cells/local
View file @
afe34ae
# Default virtual box ONOS instances 1,2 &
3
# Default virtual box ONOS instances 1,2 &
ONOS mininet box
export OC1="192.168.56.101"
export OC2="192.168.56.102"
export OC3="192.168.56.103"
export OCN="192.168.56.103"
...
...
utils/osgi/src/main/java/org/onlab/osgi/DefaultServiceDirectory.java
View file @
afe34ae
...
...
@@ -7,8 +7,15 @@ import org.osgi.framework.FrameworkUtil;
* Default implementation of the service directory using OSGi framework utilities.
*/
public
class
DefaultServiceDirectory
implements
ServiceDirectory
{
@Override
public
<
T
>
T
get
(
Class
<
T
>
serviceClass
)
{
/**
* Returns the reference to the implementation of the specified service.
*
* @param serviceClass service class
* @param <T> type of service
* @return service implementation
*/
public
static
<
T
>
T
getService
(
Class
<
T
>
serviceClass
)
{
BundleContext
bc
=
FrameworkUtil
.
getBundle
(
serviceClass
).
getBundleContext
();
T
impl
=
bc
.
getService
(
bc
.
getServiceReference
(
serviceClass
));
if
(
impl
==
null
)
{
...
...
@@ -16,4 +23,10 @@ public class DefaultServiceDirectory implements ServiceDirectory {
}
return
impl
;
}
@Override
public
<
T
>
T
get
(
Class
<
T
>
serviceClass
)
{
return
getService
(
serviceClass
);
}
}
...
...
Please
register
or
login
to post a comment