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
Madan Jampani
2014-10-09 15:01:17 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
195af6e6b27c23c7beb98f4cd425e7d7ffff1ecd
195af6e6
1 parent
da147db7
Refactored code in an attempt to break dependency cycles
Hide whitespace changes
Inline
Side-by-side
Showing
59 changed files
with
275 additions
and
361 deletions
cli/src/main/java/org/onlab/onos/cli/net/DeviceRoleCommand.java
cli/src/main/java/org/onlab/onos/cli/net/RoleCompleter.java
core/api/src/main/java/org/onlab/onos/store/ClockProviderService.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceClockProviderService.java
core/api/src/main/java/org/onlab/onos/store/ClockService.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceClockService.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipAdminService.java
core/api/src/main/java/org/onlab/onos/net/MastershipRole.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipRole.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipService.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipStore.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
core/api/src/main/java/org/onlab/onos/net/device/DeviceService.java
core/api/src/main/java/org/onlab/onos/store/Timestamp.java → core/api/src/main/java/org/onlab/onos/net/device/Timestamp.java
core/api/src/main/java/org/onlab/onos/store/Timestamped.java → core/api/src/main/java/org/onlab/onos/net/device/Timestamped.java
core/api/src/main/java/org/onlab/onos/store/VersionedValue.java → core/api/src/main/java/org/onlab/onos/net/device/VersionedValue.java
core/api/src/test/java/org/onlab/onos/cluster/MastershipServiceAdapter.java
core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java
core/net/src/main/java/org/onlab/onos/cluster/impl/MastershipManager.java
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
core/net/src/test/java/org/onlab/onos/cluster/impl/MastershipManagerTest.java
core/net/src/test/java/org/onlab/onos/net/device/impl/DeviceManagerTest.java
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
core/net/src/test/java/org/onlab/onos/net/link/impl/LinkManagerTest.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterManagementMessageSubjects.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterNodesDelegate.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyAdvertisement.java
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyReply.java
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/DeviceMastershipBasedTimestamp.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyAdvertisement.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyReply.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceClockManager.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEvent.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEvent.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEventSerializer.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceRemovedEvent.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEvent.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEvent.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEventSerializer.java
core/store/dist/src/main/java/org/onlab/onos/store/link/impl/OnosDistributedLinkStore.java
core/store/dist/src/test/java/org/onlab/onos/store/cluster/impl/ClusterCommunicationManagerTest.java
core/store/dist/src/test/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampTest.java
core/store/dist/src/test/java/org/onlab/onos/store/common/impl/TimestampedTest.java
core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStore.java
core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStoreTest.java
core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockProviderService.java
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/MastershipRoleSerializer.java
core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/NoOpClockProviderService.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStore.java
core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStoreTest.java
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
providers/openflow/device/src/test/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProviderTest.java
cli/src/main/java/org/onlab/onos/cli/net/DeviceRoleCommand.java
View file @
195af6e
...
...
@@ -4,8 +4,8 @@ import org.apache.karaf.shell.commands.Argument;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cli.AbstractShellCommand
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipAdminService
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
...
...
@@ -31,7 +31,7 @@ public class DeviceRoleCommand extends AbstractShellCommand {
@Override
protected
void
execute
()
{
DeviceMastershipAdminService
service
=
get
(
DeviceMastershipAdminService
.
class
);
MastershipRole
mastershipRole
=
MastershipRole
.
valueOf
(
role
.
toUpperCase
());
DeviceMastershipRole
mastershipRole
=
Device
MastershipRole
.
valueOf
(
role
.
toUpperCase
());
service
.
setRole
(
new
NodeId
(
node
),
deviceId
(
uri
),
mastershipRole
);
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/RoleCompleter.java
View file @
195af6e
...
...
@@ -2,7 +2,7 @@ package org.onlab.onos.cli.net;
import
org.apache.karaf.shell.console.Completer
;
import
org.apache.karaf.shell.console.completer.StringsCompleter
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.
device.Device
MastershipRole
;
import
java.util.List
;
import
java.util.SortedSet
;
...
...
@@ -16,9 +16,9 @@ public class RoleCompleter implements Completer {
// Delegate string completer
StringsCompleter
delegate
=
new
StringsCompleter
();
SortedSet
<
String
>
strings
=
delegate
.
getStrings
();
strings
.
add
(
MastershipRole
.
MASTER
.
toString
().
toLowerCase
());
strings
.
add
(
MastershipRole
.
STANDBY
.
toString
().
toLowerCase
());
strings
.
add
(
MastershipRole
.
NONE
.
toString
().
toLowerCase
());
strings
.
add
(
Device
MastershipRole
.
MASTER
.
toString
().
toLowerCase
());
strings
.
add
(
Device
MastershipRole
.
STANDBY
.
toString
().
toLowerCase
());
strings
.
add
(
Device
MastershipRole
.
NONE
.
toString
().
toLowerCase
());
// Now let the completer do the work for figuring out what to offer.
return
delegate
.
complete
(
buffer
,
cursor
,
candidates
);
...
...
core/api/src/main/java/org/onlab/onos/
store/
ClockProviderService.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
ClockProviderService.java
View file @
195af6e
package
org
.
onlab
.
onos
.
stor
e
;
package
org
.
onlab
.
onos
.
net
.
devic
e
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
//TODO: Consider renaming to DeviceClockProviderService?
/**
* Interface for feeding term information to a logical clock service
* that vends per device timestamps.
*/
public
interface
ClockProviderService
{
public
interface
Device
ClockProviderService
{
/**
* Updates the mastership term for the specified deviceId.
...
...
@@ -16,5 +15,5 @@ public interface ClockProviderService {
* @param deviceId device identifier.
* @param term mastership term.
*/
public
void
setMastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
);
public
void
set
Device
MastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
);
}
...
...
core/api/src/main/java/org/onlab/onos/
store/
ClockService.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
ClockService.java
View file @
195af6e
package
org
.
onlab
.
onos
.
stor
e
;
package
org
.
onlab
.
onos
.
net
.
devic
e
;
import
org.onlab.onos.net.DeviceId
;
...
...
@@ -6,7 +6,7 @@ import org.onlab.onos.net.DeviceId;
/**
* Interface for a logical clock service that vends per device timestamps.
*/
public
interface
ClockService
{
public
interface
Device
ClockService
{
/**
* Returns a new timestamp for the specified deviceId.
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipAdminService.java
View file @
195af6e
...
...
@@ -2,7 +2,6 @@ package org.onlab.onos.net.device;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
/**
* Service for administering the inventory of device masterships.
...
...
@@ -16,6 +15,6 @@ public interface DeviceMastershipAdminService {
* @param deviceId device identifier
* @param role requested role
*/
void
setRole
(
NodeId
instance
,
DeviceId
deviceId
,
MastershipRole
role
);
void
setRole
(
NodeId
instance
,
DeviceId
deviceId
,
Device
MastershipRole
role
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/MastershipRole.java
→
core/api/src/main/java/org/onlab/onos/net/
device/Device
MastershipRole.java
View file @
195af6e
package
org
.
onlab
.
onos
.
net
;
package
org
.
onlab
.
onos
.
net
.
device
;
/**
* Representation of a relationship role of a controller instance to a device
* or a region of network environment.
*/
public
enum
MastershipRole
{
public
enum
Device
MastershipRole
{
/**
* Represents a relationship where the controller instance is the master
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipService.java
View file @
195af6e
...
...
@@ -4,7 +4,6 @@ import java.util.Set;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
/**
* Service responsible for determining the controller instance mastership of
...
...
@@ -21,7 +20,7 @@ public interface DeviceMastershipService {
* @param deviceId the the identifier of the device
* @return role of the current node
*/
MastershipRole
getLocalRole
(
DeviceId
deviceId
);
Device
MastershipRole
getLocalRole
(
DeviceId
deviceId
);
/**
* Returns the mastership status of the local controller for a given
...
...
@@ -30,7 +29,7 @@ public interface DeviceMastershipService {
* @param deviceId the the identifier of the device
* @return the role of this controller instance
*/
MastershipRole
requestRoleFor
(
DeviceId
deviceId
);
Device
MastershipRole
requestRoleFor
(
DeviceId
deviceId
);
/**
* Abandons mastership of the specified device on the local node thus
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipStore.java
View file @
195af6e
...
...
@@ -4,7 +4,6 @@ import java.util.Set;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.store.Store
;
/**
...
...
@@ -21,7 +20,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
* @param deviceId device identifier
* @return established or newly negotiated mastership role
*/
MastershipRole
requestRole
(
DeviceId
deviceId
);
Device
MastershipRole
requestRole
(
DeviceId
deviceId
);
/**
* Returns the role of a device for a specific controller instance.
...
...
@@ -30,7 +29,7 @@ public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, Devi
* @param deviceId the device identifiers
* @return the role
*/
MastershipRole
getRole
(
NodeId
nodeId
,
DeviceId
deviceId
);
Device
MastershipRole
getRole
(
NodeId
nodeId
,
DeviceId
deviceId
);
/**
* Returns the master for a device.
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
View file @
195af6e
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.provider.Provider
;
/**
...
...
@@ -30,6 +29,6 @@ public interface DeviceProvider extends Provider {
* @param device affected device
* @param newRole newly determined mastership role
*/
void
roleChanged
(
Device
device
,
MastershipRole
newRole
);
void
roleChanged
(
Device
device
,
Device
MastershipRole
newRole
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
View file @
195af6e
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
;
import
java.util.List
;
...
...
@@ -53,6 +52,6 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> {
* @param deviceId identity of the device
* @param role mastership role that was asserted but failed
*/
void
unableToAssertRole
(
DeviceId
deviceId
,
MastershipRole
role
);
void
unableToAssertRole
(
DeviceId
deviceId
,
Device
MastershipRole
role
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/device/DeviceService.java
View file @
195af6e
...
...
@@ -2,7 +2,6 @@ package org.onlab.onos.net.device;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
...
...
@@ -43,7 +42,7 @@ public interface DeviceService {
* @return designated mastership role
*/
//XXX do we want this method here when MastershipService already does?
MastershipRole
getRole
(
DeviceId
deviceId
);
Device
MastershipRole
getRole
(
DeviceId
deviceId
);
/**
...
...
core/api/src/main/java/org/onlab/onos/
stor
e/Timestamp.java
→
core/api/src/main/java/org/onlab/onos/
net/devic
e/Timestamp.java
View file @
195af6e
package
org
.
onlab
.
onos
.
stor
e
;
package
org
.
onlab
.
onos
.
net
.
devic
e
;
/**
* Opaque version structure.
...
...
core/api/src/main/java/org/onlab/onos/
stor
e/Timestamped.java
→
core/api/src/main/java/org/onlab/onos/
net/devic
e/Timestamped.java
View file @
195af6e
package
org
.
onlab
.
onos
.
stor
e
;
package
org
.
onlab
.
onos
.
net
.
devic
e
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
...
...
core/api/src/main/java/org/onlab/onos/
stor
e/VersionedValue.java
→
core/api/src/main/java/org/onlab/onos/
net/devic
e/VersionedValue.java
View file @
195af6e
package
org
.
onlab
.
onos
.
stor
e
;
package
org
.
onlab
.
onos
.
net
.
devic
e
;
import
java.util.Objects
;
...
...
core/api/src/test/java/org/onlab/onos/cluster/MastershipServiceAdapter.java
View file @
195af6e
package
org
.
onlab
.
onos
.
cluster
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipListener
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipService
;
import
org.onlab.onos.net.device.DeviceMastershipTermService
;
...
...
@@ -13,12 +13,12 @@ import java.util.Set;
*/
public
class
MastershipServiceAdapter
implements
DeviceMastershipService
{
@Override
public
MastershipRole
getLocalRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
getLocalRole
(
DeviceId
deviceId
)
{
return
null
;
}
@Override
public
MastershipRole
requestRoleFor
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
requestRoleFor
(
DeviceId
deviceId
)
{
return
null
;
}
...
...
core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java
View file @
195af6e
...
...
@@ -2,7 +2,6 @@ package org.onlab.onos.net.device;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
...
...
@@ -28,7 +27,7 @@ public class DeviceServiceAdapter implements DeviceService {
}
@Override
public
MastershipRole
getRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
getRole
(
DeviceId
deviceId
)
{
return
null
;
}
...
...
core/net/src/main/java/org/onlab/onos/cluster/impl/MastershipManager.java
View file @
195af6e
...
...
@@ -18,10 +18,10 @@ import org.onlab.onos.cluster.NodeId;
import
org.onlab.onos.event.AbstractListenerRegistry
;
import
org.onlab.onos.event.EventDeliveryService
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipAdminService
;
import
org.onlab.onos.net.device.DeviceMastershipEvent
;
import
org.onlab.onos.net.device.DeviceMastershipListener
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipService
;
import
org.onlab.onos.net.device.DeviceMastershipStore
;
import
org.onlab.onos.net.device.DeviceMastershipStoreDelegate
;
...
...
@@ -73,13 +73,13 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
}
@Override
public
void
setRole
(
NodeId
nodeId
,
DeviceId
deviceId
,
MastershipRole
role
)
{
public
void
setRole
(
NodeId
nodeId
,
DeviceId
deviceId
,
Device
MastershipRole
role
)
{
checkNotNull
(
nodeId
,
NODE_ID_NULL
);
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
checkNotNull
(
role
,
ROLE_NULL
);
DeviceMastershipEvent
event
=
null
;
if
(
role
.
equals
(
MastershipRole
.
MASTER
))
{
if
(
role
.
equals
(
Device
MastershipRole
.
MASTER
))
{
event
=
store
.
setMaster
(
nodeId
,
deviceId
);
}
else
{
event
=
store
.
setStandby
(
nodeId
,
deviceId
);
...
...
@@ -91,7 +91,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
}
@Override
public
MastershipRole
getLocalRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
getLocalRole
(
DeviceId
deviceId
)
{
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
return
store
.
getRole
(
clusterService
.
getLocalNode
().
id
(),
deviceId
);
}
...
...
@@ -108,7 +108,7 @@ implements DeviceMastershipService, DeviceMastershipAdminService {
}
@Override
public
MastershipRole
requestRoleFor
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
requestRoleFor
(
DeviceId
deviceId
)
{
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
return
store
.
requestRole
(
deviceId
);
}
...
...
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
View file @
195af6e
...
...
@@ -18,13 +18,14 @@ import org.onlab.onos.event.AbstractListenerRegistry;
import
org.onlab.onos.event.EventDeliveryService
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DeviceAdminService
;
import
org.onlab.onos.net.device.DeviceClockProviderService
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.DeviceEvent
;
import
org.onlab.onos.net.device.DeviceListener
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceProvider
;
import
org.onlab.onos.net.device.DeviceProviderRegistry
;
import
org.onlab.onos.net.device.DeviceProviderService
;
...
...
@@ -39,7 +40,6 @@ import org.onlab.onos.net.device.DeviceMastershipTermService;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.AbstractProviderRegistry
;
import
org.onlab.onos.net.provider.AbstractProviderService
;
import
org.onlab.onos.store.ClockProviderService
;
import
org.slf4j.Logger
;
/**
...
...
@@ -81,7 +81,7 @@ public class DeviceManager
protected
DeviceMastershipTermService
termService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
ClockProviderService
clockProviderService
;
protected
Device
ClockProviderService
clockProviderService
;
@Activate
public
void
activate
()
{
...
...
@@ -117,7 +117,7 @@ public class DeviceManager
}
@Override
public
MastershipRole
getRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
getRole
(
DeviceId
deviceId
)
{
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
return
mastershipService
.
getLocalRole
(
deviceId
);
}
...
...
@@ -142,8 +142,8 @@ public class DeviceManager
}
// Applies the specified role to the device; ignores NONE
private
void
applyRole
(
DeviceId
deviceId
,
MastershipRole
newRole
)
{
if
(
newRole
.
equals
(
MastershipRole
.
NONE
))
{
private
void
applyRole
(
DeviceId
deviceId
,
Device
MastershipRole
newRole
)
{
if
(
newRole
.
equals
(
Device
MastershipRole
.
NONE
))
{
Device
device
=
store
.
getDevice
(
deviceId
);
// FIXME: Device might not be there yet. (eventual consistent)
if
(
device
==
null
)
{
...
...
@@ -201,9 +201,9 @@ public class DeviceManager
log
.
info
(
"Device {} connected"
,
deviceId
);
// check my Role
MastershipRole
role
=
mastershipService
.
requestRoleFor
(
deviceId
);
Device
MastershipRole
role
=
mastershipService
.
requestRoleFor
(
deviceId
);
if
(
role
!=
MastershipRole
.
MASTER
)
{
if
(
role
!=
Device
MastershipRole
.
MASTER
)
{
// TODO: Do we need to explicitly tell the Provider that
// this instance is no longer the MASTER? probably not
return
;
...
...
@@ -216,7 +216,7 @@ public class DeviceManager
return
;
}
// tell clock provider if this instance is the master
clockProviderService
.
setMastershipTerm
(
deviceId
,
term
);
clockProviderService
.
set
Device
MastershipTerm
(
deviceId
,
term
);
DeviceEvent
event
=
store
.
createOrUpdateDevice
(
provider
().
id
(),
deviceId
,
deviceDescription
);
...
...
@@ -255,7 +255,7 @@ public class DeviceManager
// but if I was the last STANDBY connection, etc. and no one else
// was there to mark the device offline, this instance may need to
// temporarily request for Master Role and mark offline.
if
(!
mastershipService
.
getLocalRole
(
deviceId
).
equals
(
MastershipRole
.
MASTER
))
{
if
(!
mastershipService
.
getLocalRole
(
deviceId
).
equals
(
Device
MastershipRole
.
MASTER
))
{
log
.
debug
(
"Device {} disconnected, but I am not the master"
,
deviceId
);
//let go of any role anyways
mastershipService
.
relinquishMastership
(
deviceId
);
...
...
@@ -302,11 +302,11 @@ public class DeviceManager
}
@Override
public
void
unableToAssertRole
(
DeviceId
deviceId
,
MastershipRole
role
)
{
public
void
unableToAssertRole
(
DeviceId
deviceId
,
Device
MastershipRole
role
)
{
// FIXME: implement response to this notification
log
.
warn
(
"Failed to assert role [{}] onto Device {}"
,
role
,
deviceId
);
if
(
role
==
MastershipRole
.
MASTER
)
{
if
(
role
==
Device
MastershipRole
.
MASTER
)
{
mastershipService
.
relinquishMastership
(
deviceId
);
}
}
...
...
@@ -333,16 +333,16 @@ public class DeviceManager
if
(
term
.
master
().
equals
(
myNodeId
))
{
// only set the new term if I am the master
clockProviderService
.
setMastershipTerm
(
did
,
term
);
clockProviderService
.
set
Device
MastershipTerm
(
did
,
term
);
}
applyRole
(
did
,
MastershipRole
.
MASTER
);
applyRole
(
did
,
Device
MastershipRole
.
MASTER
);
}
else
{
applyRole
(
did
,
MastershipRole
.
STANDBY
);
applyRole
(
did
,
Device
MastershipRole
.
STANDBY
);
}
}
else
{
//device dead to node, give up
mastershipService
.
relinquishMastership
(
did
);
applyRole
(
did
,
MastershipRole
.
STANDBY
);
applyRole
(
did
,
Device
MastershipRole
.
STANDBY
);
}
}
}
...
...
core/net/src/test/java/org/onlab/onos/cluster/impl/MastershipManagerTest.java
View file @
195af6e
...
...
@@ -20,7 +20,7 @@ import org.onlab.packet.IpPrefix;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
onlab
.
onos
.
net
.
MastershipRole
.*;
import
static
org
.
onlab
.
onos
.
net
.
device
.
Device
MastershipRole
.*;
/**
* Test codifying the mastership service contracts.
...
...
core/net/src/test/java/org/onlab/onos/net/device/impl/DeviceManagerTest.java
View file @
195af6e
...
...
@@ -17,15 +17,16 @@ 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
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
import
org.onlab.onos.net.device.DeviceAdminService
;
import
org.onlab.onos.net.device.DeviceClockProviderService
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.DeviceEvent
;
import
org.onlab.onos.net.device.DeviceListener
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceProvider
;
import
org.onlab.onos.net.device.DeviceProviderRegistry
;
import
org.onlab.onos.net.device.DeviceProviderService
;
...
...
@@ -35,7 +36,6 @@ import org.onlab.onos.net.device.DeviceMastershipTermService;
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.store.ClockProviderService
;
import
org.onlab.onos.store.trivial.impl.SimpleDeviceStore
;
import
org.onlab.packet.IpPrefix
;
...
...
@@ -161,7 +161,7 @@ public class DeviceManagerTest {
@Test
public
void
getRole
()
{
connectDevice
(
DID1
,
SW1
);
assertEquals
(
"incorrect role"
,
MastershipRole
.
MASTER
,
service
.
getRole
(
DID1
));
assertEquals
(
"incorrect role"
,
Device
MastershipRole
.
MASTER
,
service
.
getRole
(
DID1
));
}
@Ignore
(
"disabled until we settle the device-mastership wiring"
)
...
...
@@ -169,9 +169,9 @@ public class DeviceManagerTest {
public
void
setRole
()
throws
InterruptedException
{
connectDevice
(
DID1
,
SW1
);
validateEvents
(
DEVICE_ADDED
,
DEVICE_MASTERSHIP_CHANGED
);
assertEquals
(
"incorrect role"
,
MastershipRole
.
STANDBY
,
service
.
getRole
(
DID1
));
assertEquals
(
"incorrect role"
,
Device
MastershipRole
.
STANDBY
,
service
.
getRole
(
DID1
));
assertEquals
(
"incorrect device"
,
DID1
,
provider
.
deviceReceived
.
id
());
assertEquals
(
"incorrect role"
,
MastershipRole
.
STANDBY
,
provider
.
roleReceived
);
assertEquals
(
"incorrect role"
,
Device
MastershipRole
.
STANDBY
,
provider
.
roleReceived
);
}
@Test
...
...
@@ -246,7 +246,7 @@ public class DeviceManagerTest {
private
class
TestProvider
extends
AbstractProvider
implements
DeviceProvider
{
private
Device
deviceReceived
;
private
MastershipRole
roleReceived
;
private
Device
MastershipRole
roleReceived
;
public
TestProvider
()
{
super
(
PID
);
...
...
@@ -257,7 +257,7 @@ public class DeviceManagerTest {
}
@Override
public
void
roleChanged
(
Device
device
,
MastershipRole
newRole
)
{
public
void
roleChanged
(
Device
device
,
Device
MastershipRole
newRole
)
{
deviceReceived
=
device
;
roleReceived
=
newRole
;
}
...
...
@@ -275,8 +275,8 @@ public class DeviceManagerTest {
private
static
class
TestMastershipService
extends
MastershipServiceAdapter
{
@Override
public
MastershipRole
getLocalRole
(
DeviceId
deviceId
)
{
return
MastershipRole
.
MASTER
;
public
Device
MastershipRole
getLocalRole
(
DeviceId
deviceId
)
{
return
Device
MastershipRole
.
MASTER
;
}
@Override
...
...
@@ -285,8 +285,8 @@ public class DeviceManagerTest {
}
@Override
public
MastershipRole
requestRoleFor
(
DeviceId
deviceId
)
{
return
MastershipRole
.
MASTER
;
public
Device
MastershipRole
requestRoleFor
(
DeviceId
deviceId
)
{
return
Device
MastershipRole
.
MASTER
;
}
@Override
...
...
@@ -336,10 +336,10 @@ public class DeviceManagerTest {
}
private
final
class
TestClockProviderService
implements
ClockProviderService
{
Device
ClockProviderService
{
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
public
void
set
Device
MastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
// TODO Auto-generated method stub
}
}
...
...
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
View file @
195af6e
...
...
@@ -24,10 +24,10 @@ import org.onlab.onos.net.DefaultDevice;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.Device.Type
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DeviceListener
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceService
;
import
org.onlab.onos.net.flow.CompletedBatchOperation
;
import
org.onlab.onos.net.flow.DefaultFlowEntry
;
...
...
@@ -364,7 +364,7 @@ public class FlowRuleManagerTest {
}
@Override
public
MastershipRole
getRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
getRole
(
DeviceId
deviceId
)
{
return
null
;
}
...
...
core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
View file @
195af6e
...
...
@@ -19,10 +19,10 @@ import org.onlab.onos.net.ConnectPoint;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DeviceListener
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceService
;
import
org.onlab.onos.net.flow.instructions.Instruction
;
import
org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction
;
...
...
@@ -189,7 +189,7 @@ public class HostMonitorTest {
}
@Override
public
MastershipRole
getRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
getRole
(
DeviceId
deviceId
)
{
return
null
;
}
...
...
core/net/src/test/java/org/onlab/onos/net/link/impl/LinkManagerTest.java
View file @
195af6e
package
org
.
onlab
.
onos
.
net
.
link
.
impl
;
import
com.google.common.collect.ImmutableSet
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -9,7 +10,6 @@ import org.onlab.onos.net.ConnectPoint;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.link.DefaultLinkDescription
;
import
org.onlab.onos.net.link.LinkAdminService
;
...
...
@@ -22,6 +22,7 @@ import org.onlab.onos.net.link.LinkService;
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.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.impl.DeviceManager
;
import
org.onlab.onos.store.trivial.impl.SimpleLinkStore
;
...
...
@@ -243,7 +244,7 @@ public class LinkManagerTest {
private
class
TestProvider
extends
AbstractProvider
implements
LinkProvider
{
private
Device
deviceReceived
;
private
MastershipRole
roleReceived
;
private
Device
MastershipRole
roleReceived
;
public
TestProvider
()
{
super
(
PID
);
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterManagementMessageSubjects.java
View file @
195af6e
...
...
@@ -6,5 +6,5 @@ public final class ClusterManagementMessageSubjects {
// avoid instantiation
private
ClusterManagementMessageSubjects
()
{}
public
static
final
MessageSubject
CLUSTER_MEMBERSHIP_EVENT
=
new
MessageSubject
(
"
CLUSTER_MEMBERSHIP_EVENT
"
);
public
static
final
MessageSubject
CLUSTER_MEMBERSHIP_EVENT
=
new
MessageSubject
(
"
cluster-membership-event
"
);
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/ClusterNodesDelegate.java
View file @
195af6e
package
org
.
onlab
.
onos
.
store
.
cluster
.
impl
;
import
org.onlab.onos.cluster.
Default
ControllerNode
;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.packet.IpPrefix
;
...
...
@@ -18,7 +18,7 @@ public interface ClusterNodesDelegate {
* @param tcpPort node TCP listen port
* @return the controller node
*/
Default
ControllerNode
nodeDetected
(
NodeId
nodeId
,
IpPrefix
ip
,
int
tcpPort
);
ControllerNode
nodeDetected
(
NodeId
nodeId
,
IpPrefix
ip
,
int
tcpPort
);
/**
* Notifies about cluster node going offline.
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
View file @
195af6e
package
org
.
onlab
.
onos
.
store
.
cluster
.
impl
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.cache.RemovalListener
;
import
com.google.common.cache.RemovalNotification
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.felix.scr.annotations.Activate
;
...
...
@@ -18,8 +14,16 @@ import org.onlab.onos.cluster.DefaultControllerNode;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.store.AbstractStore
;
import
org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService
;
import
org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager
;
import
org.onlab.onos.store.cluster.messaging.ClusterCommunicationService
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessage
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessageHandler
;
import
org.onlab.onos.store.cluster.messaging.MessageSubject
;
import
org.onlab.onos.store.cluster.messaging.impl.ClusterMessageSerializer
;
import
org.onlab.onos.store.cluster.messaging.impl.MessageSubjectSerializer
;
import
org.onlab.onos.store.serializers.KryoPoolUtil
;
import
org.onlab.onos.store.serializers.KryoSerializer
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.util.KryoPool
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -27,7 +31,6 @@ import java.io.IOException;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
onlab
.
onos
.
cluster
.
ControllerNode
.
State
;
import
static
org
.
onlab
.
packet
.
IpPrefix
.
valueOf
;
...
...
@@ -43,17 +46,33 @@ public class DistributedClusterStore
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
private
Default
ControllerNode
localNode
;
private
final
Map
<
NodeId
,
Default
ControllerNode
>
nodes
=
new
ConcurrentHashMap
<>();
private
ControllerNode
localNode
;
private
final
Map
<
NodeId
,
ControllerNode
>
nodes
=
new
ConcurrentHashMap
<>();
private
final
Map
<
NodeId
,
State
>
states
=
new
ConcurrentHashMap
<>();
private
final
Cache
<
NodeId
,
ControllerNode
>
livenessCache
=
CacheBuilder
.
newBuilder
()
.
maximumSize
(
1000
)
.
expireAfterWrite
(
ClusterCommunicationManager
.
HEART_BEAT_INTERVAL_MILLIS
*
3
,
TimeUnit
.
MILLISECONDS
)
.
removalListener
(
new
LivenessCacheRemovalListener
()).
build
();
private
static
final
KryoSerializer
SERIALIZER
=
new
KryoSerializer
()
{
@Override
protected
void
setupKryoPool
()
{
serializerPool
=
KryoPool
.
newBuilder
()
.
register
(
KryoPoolUtil
.
API
)
.
register
(
ClusterMessage
.
class
,
new
ClusterMessageSerializer
())
.
register
(
ClusterMembershipEvent
.
class
)
.
register
(
byte
[].
class
)
.
register
(
MessageSubject
.
class
,
new
MessageSubjectSerializer
())
.
build
()
.
populate
(
1
);
}
};
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
private
ClusterCommunicationAdminService
clusterCommunicationAdminService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
private
ClusterCommunicationService
clusterCommunicator
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
private
ClusterMonitorService
clusterMonitor
;
private
final
ClusterNodesDelegate
nodesDelegate
=
new
InnerNodesDelegate
();
@Activate
...
...
@@ -61,10 +80,15 @@ public class DistributedClusterStore
loadClusterDefinition
();
establishSelfIdentity
();
// Start-up the comm service and prime it with the loaded nodes.
clusterCommunicationAdminService
.
initialize
(
localNode
,
nodesDelegate
);
for
(
DefaultControllerNode
node
:
nodes
.
values
())
{
clusterCommunicationAdminService
.
addNode
(
node
);
clusterCommunicator
.
addSubscriber
(
ClusterManagementMessageSubjects
.
CLUSTER_MEMBERSHIP_EVENT
,
new
ClusterMembershipEventListener
());
// Start-up the monitor service and prime it with the loaded nodes.
clusterMonitor
.
initialize
(
localNode
,
nodesDelegate
);
for
(
ControllerNode
node
:
nodes
.
values
())
{
clusterMonitor
.
addNode
(
node
);
}
log
.
info
(
"Started"
);
}
...
...
@@ -130,22 +154,78 @@ public class DistributedClusterStore
@Override
public
ControllerNode
addNode
(
NodeId
nodeId
,
IpPrefix
ip
,
int
tcpPort
)
{
DefaultControllerNode
node
=
new
DefaultControllerNode
(
nodeId
,
ip
,
tcpPort
);
nodes
.
put
(
nodeId
,
node
);
clusterCommunicationAdminService
.
addNode
(
node
);
addNodeInternal
(
node
);
try
{
clusterCommunicator
.
broadcast
(
new
ClusterMessage
(
localNode
.
id
(),
ClusterManagementMessageSubjects
.
CLUSTER_MEMBERSHIP_EVENT
,
SERIALIZER
.
encode
(
new
ClusterMembershipEvent
(
ClusterMembershipEventType
.
NEW_MEMBER
,
node
))));
}
catch
(
IOException
e
)
{
// TODO: In a setup where cluster membership is not static (i.e. not everything has the same picture)
// we'll need a more consistent/dependable way to replicate membership events.
log
.
error
(
"Failed to notify peers of a new cluster member"
,
e
);
}
return
node
;
}
private
void
addNodeInternal
(
ControllerNode
node
)
{
nodes
.
put
(
node
.
id
(),
node
);
}
@Override
public
void
removeNode
(
NodeId
nodeId
)
{
ControllerNode
node
=
removeNodeInternal
(
nodeId
);
if
(
node
!=
null
)
{
try
{
clusterCommunicator
.
broadcast
(
new
ClusterMessage
(
localNode
.
id
(),
ClusterManagementMessageSubjects
.
CLUSTER_MEMBERSHIP_EVENT
,
SERIALIZER
.
encode
(
new
ClusterMembershipEvent
(
ClusterMembershipEventType
.
LEAVING_MEMBER
,
node
))));
}
catch
(
IOException
e
)
{
// TODO: In a setup where cluster membership is not static (i.e. not everything has the same picture)
// we'll need a more consistent/dependable way to replicate membership events.
log
.
error
(
"Failed to notify peers of a existing cluster member leaving."
,
e
);
}
}
}
private
ControllerNode
removeNodeInternal
(
NodeId
nodeId
)
{
if
(
nodeId
.
equals
(
localNode
.
id
()))
{
nodes
.
clear
();
nodes
.
put
(
localNode
.
id
(),
localNode
);
return
localNode
;
}
// Remove the other node.
ControllerNode
node
=
nodes
.
remove
(
nodeId
);
return
node
;
}
}
else
{
// Remove the other node.
DefaultControllerNode
node
=
nodes
.
remove
(
nodeId
);
if
(
node
!=
null
)
{
clusterCommunicationAdminService
.
removeNode
(
node
);
private
class
ClusterMembershipEventListener
implements
ClusterMessageHandler
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
log
.
info
(
"Received cluster membership event from peer: {}"
,
message
.
sender
());
ClusterMembershipEvent
event
=
(
ClusterMembershipEvent
)
SERIALIZER
.
decode
(
message
.
payload
());
if
(
event
.
type
()
==
ClusterMembershipEventType
.
NEW_MEMBER
)
{
log
.
info
(
"Node {} is added"
,
event
.
node
().
id
());
addNodeInternal
(
event
.
node
());
}
if
(
event
.
type
()
==
ClusterMembershipEventType
.
LEAVING_MEMBER
)
{
log
.
info
(
"Node {} is removed "
,
event
.
node
().
id
());
removeNodeInternal
(
event
.
node
().
id
());
}
}
}
...
...
@@ -153,13 +233,12 @@ public class DistributedClusterStore
// Entity to handle back calls from the connection manager.
private
class
InnerNodesDelegate
implements
ClusterNodesDelegate
{
@Override
public
Default
ControllerNode
nodeDetected
(
NodeId
nodeId
,
IpPrefix
ip
,
int
tcpPort
)
{
Default
ControllerNode
node
=
nodes
.
get
(
nodeId
);
public
ControllerNode
nodeDetected
(
NodeId
nodeId
,
IpPrefix
ip
,
int
tcpPort
)
{
ControllerNode
node
=
nodes
.
get
(
nodeId
);
if
(
node
==
null
)
{
node
=
(
DefaultControllerNode
)
addNode
(
nodeId
,
ip
,
tcpPort
);
}
states
.
put
(
nodeId
,
State
.
ACTIVE
);
livenessCache
.
put
(
nodeId
,
node
);
return
node
;
}
...
...
@@ -173,14 +252,4 @@ public class DistributedClusterStore
removeNode
(
nodeId
);
}
}
private
class
LivenessCacheRemovalListener
implements
RemovalListener
<
NodeId
,
ControllerNode
>
{
@Override
public
void
onRemoval
(
RemovalNotification
<
NodeId
,
ControllerNode
>
entry
)
{
NodeId
nodeId
=
entry
.
getKey
();
log
.
warn
(
"Failed to receive heartbeats from controller: "
+
nodeId
);
nodesDelegate
.
nodeVanished
(
nodeId
);
}
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
View file @
195af6e
...
...
@@ -4,8 +4,6 @@ import static com.google.common.base.Preconditions.checkArgument;
import
java.io.IOException
;
import
java.util.Set
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
...
...
@@ -16,10 +14,6 @@ import org.apache.felix.scr.annotations.Service;
import
org.onlab.onos.cluster.ClusterService
;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.store.cluster.impl.ClusterMembershipEvent
;
import
org.onlab.onos.store.cluster.impl.ClusterMembershipEventType
;
import
org.onlab.onos.store.cluster.impl.ClusterNodesDelegate
;
import
org.onlab.onos.store.cluster.messaging.ClusterCommunicationAdminService
;
import
org.onlab.onos.store.cluster.messaging.ClusterCommunicationService
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessage
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessageHandler
;
...
...
@@ -38,7 +32,7 @@ import org.slf4j.LoggerFactory;
@Component
(
immediate
=
true
)
@Service
public
class
ClusterCommunicationManager
implements
ClusterCommunicationService
,
ClusterCommunicationAdminService
{
implements
ClusterCommunicationService
{
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
...
...
@@ -47,10 +41,6 @@ public class ClusterCommunicationManager
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
private
ClusterService
clusterService
;
private
ClusterNodesDelegate
nodesDelegate
;
private
final
Timer
timer
=
new
Timer
(
"onos-controller-heatbeats"
);
public
static
final
long
HEART_BEAT_INTERVAL_MILLIS
=
1000L
;
// TODO: This probably should not be a OSGi service.
private
MessagingService
messagingService
;
...
...
@@ -60,7 +50,6 @@ public class ClusterCommunicationManager
serializerPool
=
KryoPool
.
newBuilder
()
.
register
(
KryoPoolUtil
.
API
)
.
register
(
ClusterMessage
.
class
,
new
ClusterMessageSerializer
())
.
register
(
ClusterMembershipEvent
.
class
)
.
register
(
byte
[].
class
)
.
register
(
MessageSubject
.
class
,
new
MessageSubjectSerializer
())
.
build
()
...
...
@@ -134,61 +123,6 @@ public class ClusterCommunicationManager
messagingService
.
registerHandler
(
subject
.
value
(),
new
InternalClusterMessageHandler
(
subscriber
));
}
@Override
public
void
initialize
(
ControllerNode
localNode
,
ClusterNodesDelegate
delegate
)
{
this
.
localNode
=
localNode
;
this
.
nodesDelegate
=
delegate
;
this
.
addSubscriber
(
new
MessageSubject
(
"CLUSTER_MEMBERSHIP_EVENT"
),
new
ClusterMemebershipEventHandler
());
timer
.
schedule
(
new
KeepAlive
(),
0
,
HEART_BEAT_INTERVAL_MILLIS
);
}
@Override
public
void
addNode
(
ControllerNode
node
)
{
//members.put(node.id(), node);
}
@Override
public
void
removeNode
(
ControllerNode
node
)
{
broadcast
(
new
ClusterMessage
(
localNode
.
id
(),
new
MessageSubject
(
"CLUSTER_MEMBERSHIP_EVENT"
),
SERIALIZER
.
encode
(
new
ClusterMembershipEvent
(
ClusterMembershipEventType
.
LEAVING_MEMBER
,
node
))));
//members.remove(node.id());
}
// Sends a heart beat to all peers.
private
class
KeepAlive
extends
TimerTask
{
@Override
public
void
run
()
{
broadcast
(
new
ClusterMessage
(
localNode
.
id
(),
new
MessageSubject
(
"CLUSTER_MEMBERSHIP_EVENT"
),
SERIALIZER
.
encode
(
new
ClusterMembershipEvent
(
ClusterMembershipEventType
.
HEART_BEAT
,
localNode
))));
}
}
private
class
ClusterMemebershipEventHandler
implements
ClusterMessageHandler
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
ClusterMembershipEvent
event
=
SERIALIZER
.
decode
(
message
.
payload
());
ControllerNode
node
=
event
.
node
();
if
(
event
.
type
()
==
ClusterMembershipEventType
.
HEART_BEAT
)
{
log
.
info
(
"Node {} sent a hearbeat"
,
node
.
id
());
nodesDelegate
.
nodeDetected
(
node
.
id
(),
node
.
ip
(),
node
.
tcpPort
());
}
else
if
(
event
.
type
()
==
ClusterMembershipEventType
.
LEAVING_MEMBER
)
{
log
.
info
(
"Node {} is leaving"
,
node
.
id
());
nodesDelegate
.
nodeRemoved
(
node
.
id
());
}
else
if
(
event
.
type
()
==
ClusterMembershipEventType
.
UNREACHABLE_MEMBER
)
{
log
.
info
(
"Node {} is unreachable"
,
node
.
id
());
nodesDelegate
.
nodeVanished
(
node
.
id
());
}
}
}
private
final
class
InternalClusterMessageHandler
implements
MessageHandler
{
private
final
ClusterMessageHandler
handler
;
...
...
@@ -208,4 +142,4 @@ public class ClusterCommunicationManager
}
}
}
}
}
\ No newline at end of file
...
...
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyAdvertisement.java
View file @
195af6e
...
...
@@ -3,7 +3,7 @@ package org.onlab.onos.store.common.impl;
import
java.util.Map
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
import
com.google.common.collect.ImmutableMap
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyReply.java
View file @
195af6e
...
...
@@ -4,7 +4,7 @@ import java.util.Map;
import
java.util.Set
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.
stor
e.VersionedValue
;
import
org.onlab.onos.
net.devic
e.VersionedValue
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableSet
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/DeviceMastershipBasedTimestamp.java
View file @
195af6e
...
...
@@ -4,7 +4,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import
java.util.Objects
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
import
com.google.common.base.MoreObjects
;
import
com.google.common.collect.ComparisonChain
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyAdvertisement.java
View file @
195af6e
...
...
@@ -7,8 +7,8 @@ import java.util.Map;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
stor
e.VersionedValue
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.VersionedValue
;
import
org.onlab.onos.store.common.impl.AntiEntropyAdvertisement
;
// TODO DeviceID needs to be changed to something like (ProviderID, DeviceID)
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyReply.java
View file @
195af6e
...
...
@@ -9,8 +9,8 @@ import java.util.Set;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
stor
e.VersionedValue
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.VersionedValue
;
import
org.onlab.onos.store.common.impl.AntiEntropyReply
;
import
com.google.common.collect.ImmutableMap
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceClockManager.java
View file @
195af6e
...
...
@@ -11,10 +11,10 @@ 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.device.DeviceClockProviderService
;
import
org.onlab.onos.net.device.DeviceClockService
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.store.ClockProviderService
;
import
org.onlab.onos.store.ClockService
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.net.device.Timestamp
;
import
org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp
;
import
org.slf4j.Logger
;
...
...
@@ -23,7 +23,7 @@ import org.slf4j.Logger;
*/
@Component
(
immediate
=
true
)
@Service
public
class
DeviceClockManager
implements
ClockService
,
ClockProviderService
{
public
class
DeviceClockManager
implements
DeviceClockService
,
Device
ClockProviderService
{
private
final
Logger
log
=
getLogger
(
getClass
());
...
...
@@ -51,7 +51,7 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
}
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
public
void
set
Device
MastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
deviceMastershipTerms
.
put
(
deviceId
,
term
);
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
View file @
195af6e
...
...
@@ -26,16 +26,16 @@ import org.onlab.onos.net.PortNumber;
import
org.onlab.onos.net.SparseAnnotations
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
import
org.onlab.onos.net.device.DeviceClockService
;
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.device.Timestamp
;
import
org.onlab.onos.net.device.Timestamped
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.AbstractStore
;
import
org.onlab.onos.store.ClockService
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.Timestamped
;
import
org.onlab.onos.store.cluster.messaging.ClusterCommunicationService
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessage
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessageHandler
;
...
...
@@ -105,7 +105,7 @@ public class GossipDeviceStore
private
final
Set
<
DeviceId
>
availableDevices
=
Sets
.
newConcurrentHashSet
();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
ClockService
clockService
;
protected
Device
ClockService
clockService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
ClusterCommunicationService
clusterCommunicator
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEvent.java
View file @
195af6e
...
...
@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.Timestamped
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Timestamped
;
/**
* Information published by GossipDeviceStore to notify peers of a device
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java
View file @
195af6e
...
...
@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.Timestamped
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Timestamped
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEvent.java
View file @
195af6e
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
/**
* Information published by GossipDeviceStore to notify peers of a device
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEventSerializer.java
View file @
195af6e
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceRemovedEvent.java
View file @
195af6e
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
/**
* Information published by GossipDeviceStore to notify peers of a device
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEvent.java
View file @
195af6e
...
...
@@ -4,8 +4,8 @@ import java.util.List;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.device.Timestamped
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Timestamped
;
/**
* Information published by GossipDeviceStore to notify peers of a port
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java
View file @
195af6e
...
...
@@ -4,8 +4,8 @@ import java.util.List;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.device.Timestamped
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Timestamped
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEvent.java
View file @
195af6e
...
...
@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.device.Timestamped
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Timestamped
;
/**
* Information published by GossipDeviceStore to notify peers of a port
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortStatusEventSerializer.java
View file @
195af6e
...
...
@@ -2,8 +2,8 @@ package org.onlab.onos.store.device.impl;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.device.Timestamped
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.Timestamped
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/link/impl/OnosDistributedLinkStore.java
View file @
195af6e
...
...
@@ -23,15 +23,15 @@ import org.onlab.onos.net.DefaultLink;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.LinkKey
;
import
org.onlab.onos.net.device.DeviceClockService
;
import
org.onlab.onos.net.device.Timestamp
;
import
org.onlab.onos.net.device.VersionedValue
;
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.onlab.onos.store.ClockService
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.VersionedValue
;
import
org.slf4j.Logger
;
import
com.google.common.collect.HashMultimap
;
...
...
@@ -71,7 +71,7 @@ public class OnosDistributedLinkStore
private
final
Multimap
<
DeviceId
,
VersionedValue
<
Link
>>
dstLinks
=
HashMultimap
.
create
();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
ClockService
clockService
;
protected
Device
ClockService
clockService
;
@Activate
public
void
activate
()
{
...
...
core/store/dist/src/test/java/org/onlab/onos/store/cluster/impl/ClusterCommunicationManagerTest.java
View file @
195af6e
...
...
@@ -2,8 +2,6 @@ package org.onlab.onos.store.cluster.impl;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.store.cluster.messaging.impl.ClusterCommunicationManager
;
...
...
@@ -11,12 +9,6 @@ import org.onlab.onos.store.cluster.messaging.impl.MessageSerializer;
import
org.onlab.netty.NettyMessagingService
;
import
org.onlab.packet.IpPrefix
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* Tests of the cluster communication manager.
*/
...
...
@@ -33,9 +25,6 @@ public class ClusterCommunicationManagerTest {
private
ClusterCommunicationManager
ccm1
;
private
ClusterCommunicationManager
ccm2
;
private
TestDelegate
cnd1
=
new
TestDelegate
();
private
TestDelegate
cnd2
=
new
TestDelegate
();
private
DefaultControllerNode
node1
=
new
DefaultControllerNode
(
N1
,
IP
,
P1
);
private
DefaultControllerNode
node2
=
new
DefaultControllerNode
(
N2
,
IP
,
P2
);
...
...
@@ -48,15 +37,10 @@ public class ClusterCommunicationManagerTest {
messagingService
.
activate
();
ccm1
=
new
ClusterCommunicationManager
();
// ccm1.serializationService = messageSerializer;
ccm1
.
activate
();
ccm2
=
new
ClusterCommunicationManager
();
// ccm2.serializationService = messageSerializer;
ccm2
.
activate
();
ccm1
.
initialize
(
node1
,
cnd1
);
ccm2
.
initialize
(
node2
,
cnd2
);
}
@After
...
...
@@ -64,70 +48,4 @@ public class ClusterCommunicationManagerTest {
ccm1
.
deactivate
();
ccm2
.
deactivate
();
}
@Ignore
(
"FIXME: failing randomly?"
)
@Test
public
void
connect
()
throws
Exception
{
cnd1
.
latch
=
new
CountDownLatch
(
1
);
cnd2
.
latch
=
new
CountDownLatch
(
1
);
ccm1
.
addNode
(
node2
);
validateDelegateEvent
(
cnd1
,
Op
.
DETECTED
,
node2
.
id
());
validateDelegateEvent
(
cnd2
,
Op
.
DETECTED
,
node1
.
id
());
}
@Test
@Ignore
public
void
disconnect
()
throws
Exception
{
cnd1
.
latch
=
new
CountDownLatch
(
1
);
cnd2
.
latch
=
new
CountDownLatch
(
1
);
ccm1
.
addNode
(
node2
);
validateDelegateEvent
(
cnd1
,
Op
.
DETECTED
,
node2
.
id
());
validateDelegateEvent
(
cnd2
,
Op
.
DETECTED
,
node1
.
id
());
cnd1
.
latch
=
new
CountDownLatch
(
1
);
cnd2
.
latch
=
new
CountDownLatch
(
1
);
ccm1
.
deactivate
();
//
// validateDelegateEvent(cnd2, Op.VANISHED, node1.id());
}
private
void
validateDelegateEvent
(
TestDelegate
delegate
,
Op
op
,
NodeId
nodeId
)
throws
InterruptedException
{
assertTrue
(
"did not connect in time"
,
delegate
.
latch
.
await
(
2500
,
TimeUnit
.
MILLISECONDS
));
assertEquals
(
"incorrect event"
,
op
,
delegate
.
op
);
assertEquals
(
"incorrect event node"
,
nodeId
,
delegate
.
nodeId
);
}
enum
Op
{
DETECTED
,
VANISHED
,
REMOVED
};
private
class
TestDelegate
implements
ClusterNodesDelegate
{
Op
op
;
CountDownLatch
latch
;
NodeId
nodeId
;
@Override
public
DefaultControllerNode
nodeDetected
(
NodeId
nodeId
,
IpPrefix
ip
,
int
tcpPort
)
{
latch
(
nodeId
,
Op
.
DETECTED
);
return
new
DefaultControllerNode
(
nodeId
,
ip
,
tcpPort
);
}
@Override
public
void
nodeVanished
(
NodeId
nodeId
)
{
latch
(
nodeId
,
Op
.
VANISHED
);
}
@Override
public
void
nodeRemoved
(
NodeId
nodeId
)
{
latch
(
nodeId
,
Op
.
REMOVED
);
}
private
void
latch
(
NodeId
nodeId
,
Op
op
)
{
this
.
op
=
op
;
this
.
nodeId
=
nodeId
;
latch
.
countDown
();
}
}
}
}
\ No newline at end of file
...
...
core/store/dist/src/test/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampTest.java
View file @
195af6e
...
...
@@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import
java.nio.ByteBuffer
;
import
org.junit.Test
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
import
org.onlab.util.KryoPool
;
import
com.google.common.testing.EqualsTester
;
...
...
core/store/dist/src/test/java/org/onlab/onos/store/common/impl/TimestampedTest.java
View file @
195af6e
...
...
@@ -5,8 +5,8 @@ import static org.junit.Assert.*;
import
java.nio.ByteBuffer
;
import
org.junit.Test
;
import
org.onlab.onos.
stor
e.Timestamp
;
import
org.onlab.onos.
stor
e.Timestamped
;
import
org.onlab.onos.
net.devic
e.Timestamp
;
import
org.onlab.onos.
net.devic
e.Timestamped
;
import
org.onlab.util.KryoPool
;
import
com.google.common.testing.EqualsTester
;
...
...
core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
View file @
195af6e
...
...
@@ -35,6 +35,7 @@ import org.onlab.onos.net.PortNumber;
import
org.onlab.onos.net.SparseAnnotations
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
import
org.onlab.onos.net.device.DeviceClockService
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.DeviceEvent
;
import
org.onlab.onos.net.device.DeviceStore
;
...
...
@@ -42,7 +43,6 @@ import org.onlab.onos.net.device.DeviceStoreDelegate;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.ClockService
;
import
org.onlab.onos.store.cluster.messaging.ClusterCommunicationService
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessage
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessageHandler
;
...
...
@@ -96,7 +96,7 @@ public class GossipDeviceStoreTest {
private
DeviceStore
deviceStore
;
private
DeviceClockManager
deviceClockManager
;
private
ClockService
clockService
;
private
Device
ClockService
clockService
;
@BeforeClass
public
static
void
setUpBeforeClass
()
throws
Exception
{
...
...
@@ -113,8 +113,8 @@ public class GossipDeviceStoreTest {
deviceClockManager
.
activate
();
clockService
=
deviceClockManager
;
deviceClockManager
.
setMastershipTerm
(
DID1
,
DeviceMastershipTerm
.
of
(
MYSELF
,
1
));
deviceClockManager
.
setMastershipTerm
(
DID2
,
DeviceMastershipTerm
.
of
(
MYSELF
,
2
));
deviceClockManager
.
set
Device
MastershipTerm
(
DID1
,
DeviceMastershipTerm
.
of
(
MYSELF
,
1
));
deviceClockManager
.
set
Device
MastershipTerm
(
DID2
,
DeviceMastershipTerm
.
of
(
MYSELF
,
2
));
ClusterCommunicationService
clusterCommunicator
=
new
TestClusterCommunicationService
();
ClusterService
clusterService
=
new
TestClusterService
();
...
...
@@ -556,7 +556,7 @@ public class GossipDeviceStoreTest {
private
static
final
class
TestGossipDeviceStore
extends
GossipDeviceStore
{
public
TestGossipDeviceStore
(
ClockService
clockService
,
Device
ClockService
clockService
,
ClusterService
clusterService
,
ClusterCommunicationService
clusterCommunicator
)
{
this
.
clockService
=
clockService
;
...
...
core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStore.java
View file @
195af6e
...
...
@@ -14,8 +14,8 @@ import org.apache.felix.scr.annotations.Service;
import
org.onlab.onos.cluster.ClusterService
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipEvent
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipStore
;
import
org.onlab.onos.net.device.DeviceMastershipStoreDelegate
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
...
...
@@ -76,7 +76,7 @@ implements DeviceMastershipStore {
}
@Override
public
MastershipRole
getRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipRole
getRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
byte
[]
did
=
serialize
(
deviceId
);
byte
[]
nid
=
serialize
(
nodeId
);
...
...
@@ -84,17 +84,17 @@ implements DeviceMastershipStore {
if
(
current
==
null
)
{
if
(
standbys
.
containsEntry
(
did
,
nid
))
{
//was previously standby, or set to standby from master
return
MastershipRole
.
STANDBY
;
return
Device
MastershipRole
.
STANDBY
;
}
else
{
return
MastershipRole
.
NONE
;
return
Device
MastershipRole
.
NONE
;
}
}
else
{
if
(
current
.
equals
(
nodeId
))
{
//*should* be in unusable, not always
return
MastershipRole
.
MASTER
;
return
Device
MastershipRole
.
MASTER
;
}
else
{
//may be in backups or unusable from earlier retirement
return
MastershipRole
.
STANDBY
;
return
Device
MastershipRole
.
STANDBY
;
}
}
}
...
...
@@ -107,7 +107,7 @@ implements DeviceMastershipStore {
ILock
lock
=
theInstance
.
getLock
(
LOCK
);
lock
.
lock
();
try
{
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
Device
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
switch
(
role
)
{
case
MASTER:
//reinforce mastership
...
...
@@ -157,7 +157,7 @@ implements DeviceMastershipStore {
}
@Override
public
MastershipRole
requestRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
requestRole
(
DeviceId
deviceId
)
{
NodeId
local
=
clusterService
.
getLocalNode
().
id
();
byte
[]
did
=
serialize
(
deviceId
);
byte
[]
lnid
=
serialize
(
local
);
...
...
@@ -165,7 +165,7 @@ implements DeviceMastershipStore {
ILock
lock
=
theInstance
.
getLock
(
LOCK
);
lock
.
lock
();
try
{
MastershipRole
role
=
getRole
(
local
,
deviceId
);
Device
MastershipRole
role
=
getRole
(
local
,
deviceId
);
switch
(
role
)
{
case
MASTER:
evict
(
lnid
,
did
);
...
...
@@ -179,7 +179,7 @@ implements DeviceMastershipStore {
masters
.
put
(
did
,
lnid
);
evict
(
lnid
,
did
);
updateTerm
(
did
);
role
=
MastershipRole
.
MASTER
;
role
=
Device
MastershipRole
.
MASTER
;
break
;
default
:
log
.
warn
(
"unknown Mastership Role {}"
,
role
);
...
...
@@ -210,7 +210,7 @@ implements DeviceMastershipStore {
ILock
lock
=
theInstance
.
getLock
(
LOCK
);
lock
.
lock
();
try
{
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
Device
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
switch
(
role
)
{
case
MASTER:
event
=
reelect
(
nodeId
,
deviceId
);
...
...
@@ -239,7 +239,7 @@ implements DeviceMastershipStore {
ILock
lock
=
theInstance
.
getLock
(
LOCK
);
lock
.
lock
();
try
{
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
Device
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
switch
(
role
)
{
case
MASTER:
event
=
reelect
(
nodeId
,
deviceId
);
...
...
core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/DistributedDeviceMastershipStoreTest.java
View file @
195af6e
...
...
@@ -3,7 +3,7 @@ package org.onlab.onos.store.cluster.impl;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
onlab
.
onos
.
net
.
MastershipRole
.*;
import
static
org
.
onlab
.
onos
.
net
.
device
.
Device
MastershipRole
.*;
import
java.util.Map
;
import
java.util.Set
;
...
...
core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockProviderService.java
View file @
195af6e
...
...
@@ -3,18 +3,18 @@ package org.onlab.onos.store.device.impl;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceClockProviderService
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.store.ClockProviderService
;
// FIXME: Code clone in onos-core-trivial, onos-core-hz-net
/**
* Dummy implementation of {@link ClockProviderService}.
* Dummy implementation of {@link
Device
ClockProviderService}.
*/
@Component
(
immediate
=
true
)
@Service
public
class
NoOpClockProviderService
implements
ClockProviderService
{
public
class
NoOpClockProviderService
implements
Device
ClockProviderService
{
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
public
void
set
Device
MastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
}
}
...
...
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
View file @
195af6e
...
...
@@ -18,11 +18,11 @@ import org.onlab.onos.net.DeviceId;
import
org.onlab.onos.net.Element
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.LinkKey
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.Port
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IpAddress
;
...
...
@@ -59,7 +59,7 @@ public final class KryoPoolUtil {
DefaultControllerNode
.
class
,
DefaultDevice
.
class
,
DefaultDeviceDescription
.
class
,
MastershipRole
.
class
,
Device
MastershipRole
.
class
,
Port
.
class
,
DefaultPortDescription
.
class
,
Element
.
class
,
...
...
@@ -75,7 +75,7 @@ public final class KryoPoolUtil {
.
register
(
ConnectPoint
.
class
,
new
ConnectPointSerializer
())
.
register
(
DefaultLink
.
class
,
new
DefaultLinkSerializer
())
.
register
(
DeviceMastershipTerm
.
class
,
new
MastershipTermSerializer
())
.
register
(
MastershipRole
.
class
,
new
MastershipRoleSerializer
())
.
register
(
Device
MastershipRole
.
class
,
new
MastershipRoleSerializer
())
.
build
();
...
...
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/MastershipRoleSerializer.java
View file @
195af6e
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.
device.Device
MastershipRole
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
...
...
@@ -8,12 +8,12 @@ import com.esotericsoftware.kryo.io.Input;
import
com.esotericsoftware.kryo.io.Output
;
/**
* Kryo Serializer for {@link org.onlab.onos.net.MastershipRole}.
* Kryo Serializer for {@link org.onlab.onos.net.
device.Device
MastershipRole}.
*/
public
class
MastershipRoleSerializer
extends
Serializer
<
MastershipRole
>
{
public
class
MastershipRoleSerializer
extends
Serializer
<
Device
MastershipRole
>
{
/**
* Creates {@link MastershipRole} serializer instance.
* Creates {@link
Device
MastershipRole} serializer instance.
*/
public
MastershipRoleSerializer
()
{
// non-null, immutable
...
...
@@ -21,13 +21,13 @@ public class MastershipRoleSerializer extends Serializer<MastershipRole> {
}
@Override
public
MastershipRole
read
(
Kryo
kryo
,
Input
input
,
Class
<
MastershipRole
>
type
)
{
public
DeviceMastershipRole
read
(
Kryo
kryo
,
Input
input
,
Class
<
Device
MastershipRole
>
type
)
{
final
String
role
=
kryo
.
readObject
(
input
,
String
.
class
);
return
MastershipRole
.
valueOf
(
role
);
return
Device
MastershipRole
.
valueOf
(
role
);
}
@Override
public
void
write
(
Kryo
kryo
,
Output
output
,
MastershipRole
object
)
{
public
void
write
(
Kryo
kryo
,
Output
output
,
Device
MastershipRole
object
)
{
kryo
.
writeObject
(
output
,
object
.
toString
());
}
...
...
core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
View file @
195af6e
...
...
@@ -21,9 +21,9 @@ import org.onlab.onos.net.Device;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.LinkKey
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.SparseAnnotations
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IpAddress
;
...
...
@@ -115,7 +115,7 @@ public class KryoSerializerTest {
testSerialized
(
PIDA
);
testSerialized
(
new
NodeId
(
"bar"
));
testSerialized
(
DeviceMastershipTerm
.
of
(
new
NodeId
(
"foo"
),
2
));
for
(
MastershipRole
role
:
MastershipRole
.
values
())
{
for
(
DeviceMastershipRole
role
:
Device
MastershipRole
.
values
())
{
testSerialized
(
role
);
}
}
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/NoOpClockProviderService.java
View file @
195af6e
...
...
@@ -3,18 +3,18 @@ package org.onlab.onos.store.trivial.impl;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceClockProviderService
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.store.ClockProviderService
;
//FIXME: Code clone in onos-core-trivial, onos-core-hz-net
/**
* Dummy implementation of {@link ClockProviderService}.
* Dummy implementation of {@link
Device
ClockProviderService}.
*/
@Component
(
immediate
=
true
)
@Service
public
class
NoOpClockProviderService
implements
ClockProviderService
{
public
class
NoOpClockProviderService
implements
Device
ClockProviderService
{
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
public
void
set
Device
MastershipTerm
(
DeviceId
deviceId
,
DeviceMastershipTerm
term
)
{
}
}
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStore.java
View file @
195af6e
...
...
@@ -17,8 +17,8 @@ import org.onlab.onos.cluster.ControllerNode;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipEvent
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipStore
;
import
org.onlab.onos.net.device.DeviceMastershipStoreDelegate
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
...
...
@@ -64,7 +64,7 @@ public class SimpleMastershipStore
@Override
public
DeviceMastershipEvent
setMaster
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
Device
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
synchronized
(
this
)
{
switch
(
role
)
{
...
...
@@ -106,10 +106,10 @@ public class SimpleMastershipStore
}
@Override
public
MastershipRole
requestRole
(
DeviceId
deviceId
)
{
public
Device
MastershipRole
requestRole
(
DeviceId
deviceId
)
{
//query+possible reelection
NodeId
node
=
instance
.
id
();
MastershipRole
role
=
getRole
(
node
,
deviceId
);
Device
MastershipRole
role
=
getRole
(
node
,
deviceId
);
switch
(
role
)
{
case
MASTER:
...
...
@@ -121,7 +121,7 @@ public class SimpleMastershipStore
if
(
rel
==
null
)
{
masterMap
.
put
(
deviceId
,
node
);
termMap
.
put
(
deviceId
,
new
AtomicInteger
());
role
=
MastershipRole
.
MASTER
;
role
=
Device
MastershipRole
.
MASTER
;
}
backups
.
add
(
node
);
}
...
...
@@ -132,7 +132,7 @@ public class SimpleMastershipStore
masterMap
.
put
(
deviceId
,
node
);
termMap
.
put
(
deviceId
,
new
AtomicInteger
());
backups
.
add
(
node
);
role
=
MastershipRole
.
MASTER
;
role
=
Device
MastershipRole
.
MASTER
;
}
break
;
default
:
...
...
@@ -142,22 +142,22 @@ public class SimpleMastershipStore
}
@Override
public
MastershipRole
getRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipRole
getRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
//just query
NodeId
current
=
masterMap
.
get
(
deviceId
);
MastershipRole
role
;
Device
MastershipRole
role
;
if
(
current
==
null
)
{
if
(
backups
.
contains
(
nodeId
))
{
role
=
MastershipRole
.
STANDBY
;
role
=
Device
MastershipRole
.
STANDBY
;
}
else
{
role
=
MastershipRole
.
NONE
;
role
=
Device
MastershipRole
.
NONE
;
}
}
else
{
if
(
current
.
equals
(
nodeId
))
{
role
=
MastershipRole
.
MASTER
;
role
=
Device
MastershipRole
.
MASTER
;
}
else
{
role
=
MastershipRole
.
STANDBY
;
role
=
Device
MastershipRole
.
STANDBY
;
}
}
return
role
;
...
...
@@ -175,7 +175,7 @@ public class SimpleMastershipStore
@Override
public
DeviceMastershipEvent
setStandby
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
Device
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
synchronized
(
this
)
{
switch
(
role
)
{
case
MASTER:
...
...
core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStoreTest.java
View file @
195af6e
...
...
@@ -15,8 +15,8 @@ import com.google.common.collect.Sets;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
onlab
.
onos
.
net
.
MastershipRole
.*;
import
static
org
.
onlab
.
onos
.
net
.
device
.
DeviceMastershipEvent
.
Type
.*;
import
static
org
.
onlab
.
onos
.
net
.
device
.
DeviceMastershipRole
.*;
/**
* Test for the simple MastershipStore implementation.
...
...
providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
View file @
195af6e
...
...
@@ -7,11 +7,11 @@ import org.apache.felix.scr.annotations.Reference;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
import
org.onlab.onos.net.device.DeviceDescription
;
import
org.onlab.onos.net.device.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceProvider
;
import
org.onlab.onos.net.device.DeviceProviderRegistry
;
import
org.onlab.onos.net.device.DeviceProviderService
;
...
...
@@ -91,7 +91,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
}
@Override
public
void
roleChanged
(
Device
device
,
MastershipRole
newRole
)
{
public
void
roleChanged
(
Device
device
,
Device
MastershipRole
newRole
)
{
switch
(
newRole
)
{
case
MASTER:
controller
.
setRole
(
dpid
(
device
.
id
().
uri
()),
RoleState
.
MASTER
);
...
...
@@ -144,16 +144,16 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
@Override
public
void
roleAssertFailed
(
Dpid
dpid
,
RoleState
role
)
{
MastershipRole
failed
;
Device
MastershipRole
failed
;
switch
(
role
)
{
case
MASTER:
failed
=
MastershipRole
.
MASTER
;
failed
=
Device
MastershipRole
.
MASTER
;
break
;
case
EQUAL:
failed
=
MastershipRole
.
STANDBY
;
failed
=
Device
MastershipRole
.
STANDBY
;
break
;
case
SLAVE:
failed
=
MastershipRole
.
NONE
;
failed
=
Device
MastershipRole
.
NONE
;
break
;
default
:
LOG
.
warn
(
"unknown role {}"
,
role
);
...
...
providers/openflow/device/src/test/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProviderTest.java
View file @
195af6e
...
...
@@ -5,7 +5,7 @@ import static org.junit.Assert.assertNotNull;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
onlab
.
onos
.
net
.
Device
.
Type
.*;
import
static
org
.
onlab
.
onos
.
net
.
MastershipRole
.*;
import
static
org
.
onlab
.
onos
.
net
.
device
.
Device
MastershipRole
.*;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
@@ -20,8 +20,8 @@ import org.junit.Test;
import
org.onlab.onos.net.DefaultDevice
;
import
org.onlab.onos.net.Device
;
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.DeviceMastershipRole
;
import
org.onlab.onos.net.device.DeviceProvider
;
import
org.onlab.onos.net.device.DeviceProviderRegistry
;
import
org.onlab.onos.net.device.DeviceProviderService
;
...
...
@@ -143,7 +143,7 @@ public class OpenFlowDeviceProviderTest {
Set
<
DeviceId
>
connected
=
new
HashSet
<>();
Multimap
<
DeviceId
,
PortDescription
>
ports
=
HashMultimap
.
create
();
PortDescription
descr
=
null
;
Map
<
MastershipRole
,
Dpid
>
roles
=
new
HashMap
<>();
Map
<
Device
MastershipRole
,
Dpid
>
roles
=
new
HashMap
<>();
@Override
public
DeviceProviderService
register
(
DeviceProvider
provider
)
{
...
...
@@ -195,7 +195,7 @@ public class OpenFlowDeviceProviderTest {
}
@Override
public
void
unableToAssertRole
(
DeviceId
deviceId
,
MastershipRole
role
)
{
public
void
unableToAssertRole
(
DeviceId
deviceId
,
Device
MastershipRole
role
)
{
roles
.
put
(
role
,
Dpid
.
dpid
(
deviceId
.
uri
()));
}
...
...
Please
register
or
login
to post a comment