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-09-24 14:49:18 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f80c9729d62bfd0204fde8b843abc49eb49c873a
f80c9729
1 parent
3f2bbd70
Enahnced link and host stores to extend general store.
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
91 additions
and
17 deletions
core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
core/api/src/main/java/org/onlab/onos/net/host/HostStoreDelegate.java
core/api/src/main/java/org/onlab/onos/net/link/LinkStore.java
core/api/src/main/java/org/onlab/onos/net/link/LinkStoreDelegate.java
core/api/src/main/java/org/onlab/onos/store/AbstractStore.java
core/api/src/main/java/org/onlab/onos/store/Store.java
core/net/src/main/java/org/onlab/onos/cluster/impl/ClusterManager.java
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleLinkStore.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleMastershipStore.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java
View file @
f80c972
...
...
@@ -4,12 +4,13 @@ import java.util.Set;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.store.Store
;
/**
* Manages inventory of mastership roles for devices, across controller
* instances; not intended for direct use.
*/
public
interface
MastershipStore
{
public
interface
MastershipStore
extends
Store
<
MastershipEvent
,
MastershipStoreDelegate
>
{
// three things to map: NodeId, DeviceId, MastershipRole
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
View file @
f80c972
...
...
@@ -5,13 +5,14 @@ import org.onlab.onos.net.DeviceId;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Store
;
import
java.util.List
;
/**
* Manages inventory of infrastructure devices; not intended for direct use.
*/
public
interface
DeviceStore
{
public
interface
DeviceStore
extends
Store
<
DeviceEvent
,
DeviceStoreDelegate
>
{
/**
* Returns the number of devices known to the system.
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
View file @
f80c972
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
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Store
;
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.
*/
public
interface
HostStore
{
public
interface
HostStore
extends
Store
<
HostEvent
,
HostStoreDelegate
>
{
/**
* Creates a new host or updates the existing one based on the specified
...
...
@@ -133,7 +134,7 @@ public interface HostStore {
* Returns the address bindings for a particular connection point.
*
* @param connectPoint the connection point to return address information
* for
*
for
* @return address information for the connection point
*/
PortAddresses
getAddressBindingsForPort
(
ConnectPoint
connectPoint
);
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostStoreDelegate.java
0 → 100644
View file @
f80c972
package
org
.
onlab
.
onos
.
net
.
host
;
import
org.onlab.onos.store.StoreDelegate
;
/**
* Infrastructure link store delegate abstraction.
*/
public
interface
HostStoreDelegate
extends
StoreDelegate
<
HostEvent
>
{
}
core/api/src/main/java/org/onlab/onos/net/link/LinkStore.java
View file @
f80c972
...
...
@@ -4,13 +4,14 @@ import org.onlab.onos.net.ConnectPoint;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Store
;
import
java.util.Set
;
/**
* Manages inventory of infrastructure links; not intended for direct use.
*/
public
interface
LinkStore
{
public
interface
LinkStore
extends
Store
<
LinkEvent
,
LinkStoreDelegate
>
{
/**
* Returns the number of links in the store.
...
...
core/api/src/main/java/org/onlab/onos/net/link/LinkStoreDelegate.java
0 → 100644
View file @
f80c972
package
org
.
onlab
.
onos
.
net
.
link
;
import
org.onlab.onos.store.StoreDelegate
;
/**
* Infrastructure link store delegate abstraction.
*/
public
interface
LinkStoreDelegate
extends
StoreDelegate
<
LinkEvent
>
{
}
core/api/src/main/java/org/onlab/onos/store/AbstractStore.java
View file @
f80c972
...
...
@@ -2,6 +2,8 @@ package org.onlab.onos.store;
import
org.onlab.onos.event.Event
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkState
;
/**
* Base implementation of a store.
*/
...
...
@@ -12,12 +14,21 @@ public class AbstractStore<E extends Event, D extends StoreDelegate<E>>
@Override
public
void
setDelegate
(
D
delegate
)
{
checkState
(
this
.
delegate
==
null
||
this
.
delegate
==
delegate
,
"Store delegate already set"
);
this
.
delegate
=
delegate
;
}
@Override
public
D
getDelegate
()
{
return
delegate
;
public
void
unsetDelegate
(
D
delegate
)
{
if
(
this
.
delegate
==
delegate
)
{
this
.
delegate
=
null
;
}
}
@Override
public
boolean
hasDelegate
()
{
return
delegate
!=
null
;
}
/**
...
...
core/api/src/main/java/org/onlab/onos/store/Store.java
View file @
f80c972
...
...
@@ -12,14 +12,25 @@ public interface Store<E extends Event, D extends StoreDelegate<E>> {
* Sets the delegate on the store.
*
* @param delegate new store delegate
* @throws java.lang.IllegalStateException if a delegate is already
* currently set on the store and is a different one that
*/
void
setDelegate
(
D
delegate
);
/**
*
Get the current store delegat
e.
*
Withdraws the delegate from the stor
e.
*
* @return store delegate
* @param delegate store delegate to withdraw
* @throws java.lang.IllegalArgumentException if the delegate is not
* currently set on the store
*/
D
getDelegate
();
void
unsetDelegate
(
D
delegate
);
/**
* Indicates whether the store has a delegate.
*
* @return true if delegate is set
*/
boolean
hasDelegate
();
}
...
...
core/net/src/main/java/org/onlab/onos/cluster/impl/ClusterManager.java
View file @
f80c972
...
...
@@ -53,6 +53,7 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
@Deactivate
public
void
deactivate
()
{
store
.
unsetDelegate
(
delegate
);
eventDispatcher
.
removeSink
(
ClusterEvent
.
class
);
log
.
info
(
"Stopped"
);
}
...
...
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
View file @
f80c972
...
...
@@ -26,6 +26,7 @@ import org.onlab.onos.net.device.DeviceProviderRegistry;
import
org.onlab.onos.net.device.DeviceProviderService
;
import
org.onlab.onos.net.device.DeviceService
;
import
org.onlab.onos.net.device.DeviceStore
;
import
org.onlab.onos.net.device.DeviceStoreDelegate
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.AbstractProviderRegistry
;
import
org.onlab.onos.net.provider.AbstractProviderService
;
...
...
@@ -33,8 +34,8 @@ import org.slf4j.Logger;
import
java.util.List
;
import
static
org
.
onlab
.
onos
.
net
.
device
.
DeviceEvent
.
Type
.*;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
static
org
.
onlab
.
onos
.
net
.
device
.
DeviceEvent
.
Type
.
DEVICE_MASTERSHIP_CHANGED
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
...
...
@@ -57,6 +58,8 @@ public class DeviceManager
protected
final
AbstractListenerRegistry
<
DeviceEvent
,
DeviceListener
>
listenerRegistry
=
new
AbstractListenerRegistry
<>();
private
DeviceStoreDelegate
delegate
=
new
InternalStoreDelegate
();
private
final
MastershipListener
mastershipListener
=
new
InnerMastershipListener
();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
...
...
@@ -73,6 +76,7 @@ public class DeviceManager
@Activate
public
void
activate
()
{
store
.
setDelegate
(
delegate
);
eventDispatcher
.
addSink
(
DeviceEvent
.
class
,
listenerRegistry
);
mastershipService
.
addListener
(
mastershipListener
);
log
.
info
(
"Started"
);
...
...
@@ -80,6 +84,7 @@ public class DeviceManager
@Deactivate
public
void
deactivate
()
{
store
.
unsetDelegate
(
delegate
);
mastershipService
.
removeListener
(
mastershipListener
);
eventDispatcher
.
removeSink
(
DeviceEvent
.
class
);
log
.
info
(
"Stopped"
);
...
...
@@ -248,4 +253,12 @@ public class DeviceManager
}
}
}
// Store delegate to re-post events emitted from the store.
private
class
InternalStoreDelegate
implements
DeviceStoreDelegate
{
@Override
public
void
notify
(
DeviceEvent
event
)
{
post
(
event
);
}
}
}
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java
View file @
f80c972
...
...
@@ -15,8 +15,10 @@ import org.onlab.onos.net.PortNumber;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.DeviceEvent
;
import
org.onlab.onos.net.device.DeviceStore
;
import
org.onlab.onos.net.device.DeviceStoreDelegate
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.AbstractStore
;
import
org.slf4j.Logger
;
import
java.util.ArrayList
;
...
...
@@ -40,7 +42,9 @@ import static org.slf4j.LoggerFactory.getLogger;
*/
@Component
(
immediate
=
true
)
@Service
public
class
SimpleDeviceStore
implements
DeviceStore
{
public
class
SimpleDeviceStore
extends
AbstractStore
<
DeviceEvent
,
DeviceStoreDelegate
>
implements
DeviceStore
{
private
final
Logger
log
=
getLogger
(
getClass
());
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
View file @
f80c972
...
...
@@ -24,8 +24,10 @@ 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.HostStoreDelegate
;
import
org.onlab.onos.net.host.PortAddresses
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.AbstractStore
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
...
...
@@ -41,7 +43,9 @@ import com.google.common.collect.Multimap;
*/
@Component
(
immediate
=
true
)
@Service
public
class
SimpleHostStore
implements
HostStore
{
public
class
SimpleHostStore
extends
AbstractStore
<
HostEvent
,
HostStoreDelegate
>
implements
HostStore
{
private
final
Logger
log
=
getLogger
(
getClass
());
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleLinkStore.java
View file @
f80c972
...
...
@@ -14,7 +14,9 @@ import org.onlab.onos.net.Link;
import
org.onlab.onos.net.link.LinkDescription
;
import
org.onlab.onos.net.link.LinkEvent
;
import
org.onlab.onos.net.link.LinkStore
;
import
org.onlab.onos.net.link.LinkStoreDelegate
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.AbstractStore
;
import
org.slf4j.Logger
;
import
java.util.Collections
;
...
...
@@ -35,7 +37,9 @@ import static org.slf4j.LoggerFactory.getLogger;
*/
@Component
(
immediate
=
true
)
@Service
public
class
SimpleLinkStore
implements
LinkStore
{
public
class
SimpleLinkStore
extends
AbstractStore
<
LinkEvent
,
LinkStoreDelegate
>
implements
LinkStore
{
private
final
Logger
log
=
getLogger
(
getClass
());
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleMastershipStore.java
View file @
f80c972
...
...
@@ -15,9 +15,11 @@ import org.onlab.onos.cluster.ControllerNode;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.MastershipEvent
;
import
org.onlab.onos.cluster.MastershipStore
;
import
org.onlab.onos.cluster.MastershipStoreDelegate
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.store.AbstractStore
;
import
org.onlab.packet.IpPrefix
;
import
org.slf4j.Logger
;
...
...
@@ -29,7 +31,9 @@ import static org.onlab.onos.cluster.MastershipEvent.Type.*;
*/
@Component
(
immediate
=
true
)
@Service
public
class
SimpleMastershipStore
implements
MastershipStore
{
public
class
SimpleMastershipStore
extends
AbstractStore
<
MastershipEvent
,
MastershipStoreDelegate
>
implements
MastershipStore
{
public
static
final
IpPrefix
LOCALHOST
=
IpPrefix
.
valueOf
(
"127.0.0.1"
);
...
...
Please
register
or
login
to post a comment