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
pankaj
2014-10-09 14:12:15 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
e63108c4aed88f68931e49428b85e7bce5d9e934
e63108c4
2 parents
5364ca97
da147db7
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Show whitespace changes
Inline
Side-by-side
Showing
56 changed files
with
272 additions
and
277 deletions
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
cli/src/main/java/org/onlab/onos/cli/MastersListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DeviceRoleCommand.java
cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
core/api/src/main/java/org/onlab/onos/net/ElementId.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipAdminService.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipAdminService.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipEvent.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipEvent.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipListener.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipListener.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipService.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipStore.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipStoreDelegate.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipStoreDelegate.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipTerm.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipTerm.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipTermService.java → core/api/src/main/java/org/onlab/onos/net/device/DeviceMastershipTermService.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java
core/api/src/main/java/org/onlab/onos/store/ClockProviderService.java
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/Timestamped.java → core/api/src/main/java/org/onlab/onos/store/Timestamped.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/VersionedValue.java → core/api/src/main/java/org/onlab/onos/store/VersionedValue.java
core/api/src/test/java/org/onlab/onos/cluster/MastershipServiceAdapter.java
core/api/src/test/java/org/onlab/onos/cluster/MastershipTermTest.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/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
core/store/dist/src/main/java/org/onlab/onos/store/serializers/ClusterMessageSerializer.java → core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterMessageSerializer.java
core/store/dist/src/main/java/org/onlab/onos/store/serializers/MessageSubjectSerializer.java → core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/MessageSubjectSerializer.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/MastershipBasedTimestamp.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/serializers/MastershipBasedTimestampSerializer.java → core/store/dist/src/main/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampSerializer.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/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/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/DistributedMastershipStore.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/DistributedMastershipStoreTest.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/MastershipTermSerializer.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
openflow/api/src/main/java/org/onlab/onos/openflow/controller/DefaultOpenFlowPacketContext.java
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/Controller.java
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OpenFlowControllerImpl.java
providers/openflow/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowCorePacketContext.java
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
View file @
e63108c
...
...
@@ -170,7 +170,9 @@ public class ReactiveForwarding {
// We don't yet support bufferids in the flowservice so packet out first.
packetOut
(
context
,
portNumber
);
if
(
true
)
{
return
;
}
// Install the flow rule to handle this type of message from now on.
Ethernet
inPkt
=
context
.
inPacket
().
parsed
();
...
...
cli/src/main/java/org/onlab/onos/cli/MastersListCommand.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cli
;
import
com.google.common.collect.Lists
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cluster.ClusterService
;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.MastershipService
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipService
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -22,7 +23,7 @@ public class MastersListCommand extends AbstractShellCommand {
@Override
protected
void
execute
()
{
ClusterService
service
=
get
(
ClusterService
.
class
);
MastershipService
mastershipService
=
get
(
MastershipService
.
class
);
DeviceMastershipService
mastershipService
=
get
(
Device
MastershipService
.
class
);
List
<
ControllerNode
>
nodes
=
newArrayList
(
service
.
getNodes
());
Collections
.
sort
(
nodes
,
Comparators
.
NODE_COMPARATOR
);
ControllerNode
self
=
service
.
getLocalNode
();
...
...
cli/src/main/java/org/onlab/onos/cli/net/DeviceRoleCommand.java
View file @
e63108c
...
...
@@ -3,9 +3,9 @@ package org.onlab.onos.cli.net;
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.MastershipAdminService
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.device.DeviceMastershipAdminService
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
...
...
@@ -30,7 +30,7 @@ public class DeviceRoleCommand extends AbstractShellCommand {
@Override
protected
void
execute
()
{
MastershipAdminService
service
=
get
(
MastershipAdminService
.
class
);
DeviceMastershipAdminService
service
=
get
(
Device
MastershipAdminService
.
class
);
MastershipRole
mastershipRole
=
MastershipRole
.
valueOf
(
role
.
toUpperCase
());
service
.
setRole
(
new
NodeId
(
node
),
deviceId
(
uri
),
mastershipRole
);
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
View file @
e63108c
...
...
@@ -19,17 +19,16 @@ import org.onlab.onos.net.intent.IntentState;
description
=
"Wipes-out the entire network information base, i.e. devices, links, hosts"
)
public
class
WipeOutCommand
extends
ClustersListCommand
{
private
static
final
String
DISCLAIMER
=
"Delete everything please.
"
;
private
static
final
String
PLEASE
=
"please
"
;
@Argument
(
index
=
0
,
name
=
"
disclaimer"
,
description
=
"Device ID
"
,
@Argument
(
index
=
0
,
name
=
"
please"
,
description
=
"Confirmation phrase
"
,
required
=
false
,
multiValued
=
false
)
String
disclaimer
=
null
;
String
please
=
null
;
@Override
protected
void
execute
()
{
if
(
disclaimer
==
null
||
!
disclaimer
.
equals
(
DISCLAIMER
))
{
print
(
"I'm afraid I can't do that!\nPlease acknowledge with phrase: '%s'"
,
DISCLAIMER
);
if
(
please
==
null
||
!
please
.
equals
(
PLEASE
))
{
print
(
"I'm afraid I can't do that!\nSay: %s"
,
PLEASE
);
return
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/ElementId.java
View file @
e63108c
...
...
@@ -9,10 +9,12 @@ import java.util.Objects;
public
abstract
class
ElementId
{
private
final
URI
uri
;
private
final
String
str
;
// Default constructor for serialization
protected
ElementId
()
{
this
.
uri
=
null
;
this
.
str
=
null
;
}
/**
...
...
@@ -22,6 +24,7 @@ public abstract class ElementId {
*/
protected
ElementId
(
URI
uri
)
{
this
.
uri
=
uri
;
this
.
str
=
uri
.
toString
();
}
/**
...
...
@@ -35,7 +38,7 @@ public abstract class ElementId {
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
uri
);
return
Objects
.
hash
(
str
);
}
@Override
...
...
@@ -46,14 +49,14 @@ public abstract class ElementId {
if
(
obj
instanceof
ElementId
)
{
final
ElementId
that
=
(
ElementId
)
obj
;
return
this
.
getClass
()
==
that
.
getClass
()
&&
Objects
.
equals
(
this
.
uri
,
that
.
uri
);
Objects
.
equals
(
this
.
str
,
that
.
str
);
}
return
false
;
}
@Override
public
String
toString
()
{
return
uri
.
toString
()
;
return
str
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipAdminService.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipAdminService.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
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.
*/
public
interface
MastershipAdminService
{
public
interface
Device
MastershipAdminService
{
/**
* Applies the current mastership role for the specified device.
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipEvent.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipEvent.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.event.AbstractEvent
;
import
org.onlab.onos.net.DeviceId
;
/**
* Describes a device mastership event.
*/
public
class
MastershipEvent
extends
AbstractEvent
<
MastershipEvent
.
Type
,
DeviceId
>
{
public
class
DeviceMastershipEvent
extends
AbstractEvent
<
Device
MastershipEvent
.
Type
,
DeviceId
>
{
//do we worry about explicitly setting slaves/equals? probably not,
//to keep it simple
...
...
@@ -30,7 +31,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
* @param device event device subject
* @param master master ID subject
*/
public
MastershipEvent
(
Type
type
,
DeviceId
device
,
NodeId
master
)
{
public
Device
MastershipEvent
(
Type
type
,
DeviceId
device
,
NodeId
master
)
{
super
(
type
,
device
);
this
.
master
=
master
;
}
...
...
@@ -44,7 +45,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
* @param master master ID subject
* @param time occurrence time
*/
public
MastershipEvent
(
Type
type
,
DeviceId
device
,
NodeId
master
,
long
time
)
{
public
Device
MastershipEvent
(
Type
type
,
DeviceId
device
,
NodeId
master
,
long
time
)
{
super
(
type
,
device
,
time
);
this
.
master
=
master
;
}
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipListener.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipListener.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.event.EventListener
;
/**
* Entity capable of receiving device mastership-related events.
*/
public
interface
MastershipListener
extends
EventListener
<
MastershipEvent
>
{
public
interface
DeviceMastershipListener
extends
EventListener
<
Device
MastershipEvent
>
{
}
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipService.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipService.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
package
org
.
onlab
.
onos
.
net
.
device
;
import
java.util.Set
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
...
...
@@ -11,7 +12,7 @@ import org.onlab.onos.net.MastershipRole;
* determining mastership, but is not responsible for actually applying it
* to the devices; this falls on the device service.
*/
public
interface
MastershipService
{
public
interface
Device
MastershipService
{
/**
* Returns the role of the local node for the specified device, without
...
...
@@ -62,20 +63,20 @@ public interface MastershipService {
*
* @return the MastershipTermService for this mastership manager
*/
MastershipTermService
requestTermService
();
Device
MastershipTermService
requestTermService
();
/**
* Adds the specified mastership change listener.
*
* @param listener the mastership listener
*/
void
addListener
(
MastershipListener
listener
);
void
addListener
(
Device
MastershipListener
listener
);
/**
* Removes the specified mastership change listener.
*
* @param listener the mastership listener
*/
void
removeListener
(
MastershipListener
listener
);
void
removeListener
(
Device
MastershipListener
listener
);
}
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipStore.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipStore.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
package
org
.
onlab
.
onos
.
net
.
device
;
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
;
...
...
@@ -10,7 +11,7 @@ import org.onlab.onos.store.Store;
* Manages inventory of mastership roles for devices, across controller
* instances; not intended for direct use.
*/
public
interface
MastershipStore
extends
Store
<
MastershipEvent
,
MastershipStoreDelegate
>
{
public
interface
DeviceMastershipStore
extends
Store
<
DeviceMastershipEvent
,
Device
MastershipStoreDelegate
>
{
// three things to map: NodeId, DeviceId, MastershipRole
...
...
@@ -54,7 +55,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId device identifier
* @return a mastership event
*/
MastershipEvent
setMaster
(
NodeId
nodeId
,
DeviceId
deviceId
);
Device
MastershipEvent
setMaster
(
NodeId
nodeId
,
DeviceId
deviceId
);
/**
* Returns the current master and number of past mastership hand-offs
...
...
@@ -63,7 +64,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId the device identifier
* @return the current master's ID and the term value for device, or null
*/
MastershipTerm
getTermFor
(
DeviceId
deviceId
);
Device
MastershipTerm
getTermFor
(
DeviceId
deviceId
);
/**
* Sets a controller instance's mastership role to STANDBY for a device.
...
...
@@ -74,7 +75,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId device to revoke mastership role for
* @return a mastership event
*/
MastershipEvent
setStandby
(
NodeId
nodeId
,
DeviceId
deviceId
);
Device
MastershipEvent
setStandby
(
NodeId
nodeId
,
DeviceId
deviceId
);
/**
* Allows a controller instance to give up its current role for a device.
...
...
@@ -85,6 +86,6 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId device to revoke mastership role for
* @return a mastership event
*/
MastershipEvent
relinquishRole
(
NodeId
nodeId
,
DeviceId
deviceId
);
Device
MastershipEvent
relinquishRole
(
NodeId
nodeId
,
DeviceId
deviceId
);
}
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipStoreDelegate.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipStoreDelegate.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.store.StoreDelegate
;
/**
* Mastership store delegate abstraction.
*
Device
Mastership store delegate abstraction.
*/
public
interface
MastershipStoreDelegate
extends
StoreDelegate
<
MastershipEvent
>
{
public
interface
DeviceMastershipStoreDelegate
extends
StoreDelegate
<
Device
MastershipEvent
>
{
}
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipTerm.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipTerm.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
package
org
.
onlab
.
onos
.
net
.
device
;
import
java.util.Objects
;
public
final
class
MastershipTerm
{
import
org.onlab.onos.cluster.NodeId
;
public
final
class
DeviceMastershipTerm
{
private
final
NodeId
master
;
private
final
int
termNumber
;
private
MastershipTerm
(
NodeId
master
,
int
term
)
{
private
Device
MastershipTerm
(
NodeId
master
,
int
term
)
{
this
.
master
=
master
;
this
.
termNumber
=
term
;
}
public
static
MastershipTerm
of
(
NodeId
master
,
int
term
)
{
return
new
MastershipTerm
(
master
,
term
);
public
static
Device
MastershipTerm
of
(
NodeId
master
,
int
term
)
{
return
new
Device
MastershipTerm
(
master
,
term
);
}
public
NodeId
master
()
{
...
...
@@ -34,8 +36,8 @@ public final class MastershipTerm {
if
(
this
==
other
)
{
return
true
;
}
if
(
other
instanceof
MastershipTerm
)
{
MastershipTerm
that
=
(
MastershipTerm
)
other
;
if
(
other
instanceof
Device
MastershipTerm
)
{
DeviceMastershipTerm
that
=
(
Device
MastershipTerm
)
other
;
if
(!
this
.
master
.
equals
(
that
.
master
))
{
return
false
;
}
...
...
core/api/src/main/java/org/onlab/onos/
cluster/
MastershipTermService.java
→
core/api/src/main/java/org/onlab/onos/
net/device/Device
MastershipTermService.java
View file @
e63108c
package
org
.
onlab
.
onos
.
cluster
;
package
org
.
onlab
.
onos
.
net
.
device
;
import
org.onlab.onos.net.DeviceId
;
...
...
@@ -6,7 +6,7 @@ import org.onlab.onos.net.DeviceId;
/**
* Service to obtain mastership term information.
*/
public
interface
MastershipTermService
{
public
interface
Device
MastershipTermService
{
// TBD: manage/increment per device mastership change
// or increment on any change
...
...
@@ -16,5 +16,5 @@ public interface MastershipTermService {
* @param deviceId the identifier of the device
* @return current master's term.
*/
MastershipTerm
getMastershipTerm
(
DeviceId
deviceId
);
Device
MastershipTerm
getMastershipTerm
(
DeviceId
deviceId
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java
View file @
e63108c
package
org
.
onlab
.
onos
.
net
.
flow
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.Collections
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Objects
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.instructions.Instruction
;
import
org.onlab.onos.net.flow.instructions.Instructions
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
org.slf4j.Logger
;
import
java.util.Collections
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* Default traffic treatment implementation.
...
...
@@ -70,8 +67,6 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
*/
public
static
final
class
Builder
implements
TrafficTreatment
.
Builder
{
private
final
Logger
log
=
getLogger
(
getClass
());
boolean
drop
=
false
;
List
<
Instruction
>
outputs
=
new
LinkedList
<>();
...
...
@@ -107,7 +102,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
groups
.
add
(
instruction
);
break
;
default
:
log
.
warn
(
"Unknown instruction type {}"
,
instruction
.
type
());
throw
new
IllegalArgumentException
(
"Unknown instruction type: "
+
instruction
.
type
());
}
return
this
;
}
...
...
core/api/src/main/java/org/onlab/onos/store/ClockProviderService.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
//TODO: Consider renaming to DeviceClockProviderService?
/**
...
...
@@ -16,5 +16,5 @@ public interface ClockProviderService {
* @param deviceId device identifier.
* @param term mastership term.
*/
public
void
setMastershipTerm
(
DeviceId
deviceId
,
MastershipTerm
term
);
public
void
setMastershipTerm
(
DeviceId
deviceId
,
Device
MastershipTerm
term
);
}
...
...
core/
store/dist/src/main/java/org/onlab/onos/store/common/impl
/Timestamped.java
→
core/
api/src/main/java/org/onlab/onos/store
/Timestamped.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
.
common
.
impl
;
package
org
.
onlab
.
onos
.
store
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
java.util.Objects
;
import
org.onlab.onos.store.Timestamp
;
import
com.google.common.base.MoreObjects
;
/**
...
...
core/
store/dist/src/main/java/org/onlab/onos/store/device/impl
/VersionedValue.java
→
core/
api/src/main/java/org/onlab/onos/store
/VersionedValue.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
package
org
.
onlab
.
onos
.
store
;
import
java.util.Objects
;
import
org.onlab.onos.store.Timestamp
;
/**
* Wrapper class for a entity that is versioned
* and can either be up or down.
...
...
core/api/src/test/java/org/onlab/onos/cluster/MastershipServiceAdapter.java
View file @
e63108c
...
...
@@ -2,13 +2,16 @@ 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.DeviceMastershipService
;
import
org.onlab.onos.net.device.DeviceMastershipTermService
;
import
java.util.Set
;
/**
* Test adapter for mastership service.
*/
public
class
MastershipServiceAdapter
implements
MastershipService
{
public
class
MastershipServiceAdapter
implements
Device
MastershipService
{
@Override
public
MastershipRole
getLocalRole
(
DeviceId
deviceId
)
{
return
null
;
...
...
@@ -34,15 +37,15 @@ public class MastershipServiceAdapter implements MastershipService {
}
@Override
public
void
addListener
(
MastershipListener
listener
)
{
public
void
addListener
(
Device
MastershipListener
listener
)
{
}
@Override
public
void
removeListener
(
MastershipListener
listener
)
{
public
void
removeListener
(
Device
MastershipListener
listener
)
{
}
@Override
public
MastershipTermService
requestTermService
()
{
public
Device
MastershipTermService
requestTermService
()
{
return
null
;
}
}
...
...
core/api/src/test/java/org/onlab/onos/cluster/MastershipTermTest.java
View file @
e63108c
...
...
@@ -3,6 +3,7 @@ package org.onlab.onos.cluster;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
com.google.common.testing.EqualsTester
;
...
...
@@ -11,10 +12,10 @@ public class MastershipTermTest {
private
static
final
NodeId
N1
=
new
NodeId
(
"foo"
);
private
static
final
NodeId
N2
=
new
NodeId
(
"bar"
);
private
static
final
MastershipTerm
TERM1
=
MastershipTerm
.
of
(
N1
,
0
);
private
static
final
MastershipTerm
TERM2
=
MastershipTerm
.
of
(
N2
,
1
);
private
static
final
MastershipTerm
TERM3
=
MastershipTerm
.
of
(
N2
,
1
);
private
static
final
MastershipTerm
TERM4
=
MastershipTerm
.
of
(
N1
,
1
);
private
static
final
DeviceMastershipTerm
TERM1
=
Device
MastershipTerm
.
of
(
N1
,
0
);
private
static
final
DeviceMastershipTerm
TERM2
=
Device
MastershipTerm
.
of
(
N2
,
1
);
private
static
final
DeviceMastershipTerm
TERM3
=
Device
MastershipTerm
.
of
(
N2
,
1
);
private
static
final
DeviceMastershipTerm
TERM4
=
Device
MastershipTerm
.
of
(
N1
,
1
);
@Test
public
void
basics
()
{
...
...
@@ -24,7 +25,7 @@ public class MastershipTermTest {
@Test
public
void
testEquality
()
{
new
EqualsTester
().
addEqualityGroup
(
MastershipTerm
.
of
(
N1
,
0
),
TERM1
)
new
EqualsTester
().
addEqualityGroup
(
Device
MastershipTerm
.
of
(
N1
,
0
),
TERM1
)
.
addEqualityGroup
(
TERM2
,
TERM3
)
.
addEqualityGroup
(
TERM4
);
}
...
...
core/net/src/main/java/org/onlab/onos/cluster/impl/MastershipManager.java
View file @
e63108c
...
...
@@ -14,25 +14,25 @@ import org.apache.felix.scr.annotations.Service;
import
org.onlab.onos.cluster.ClusterEvent
;
import
org.onlab.onos.cluster.ClusterEventListener
;
import
org.onlab.onos.cluster.ClusterService
;
import
org.onlab.onos.cluster.MastershipAdminService
;
import
org.onlab.onos.cluster.MastershipEvent
;
import
org.onlab.onos.cluster.MastershipListener
;
import
org.onlab.onos.cluster.MastershipService
;
import
org.onlab.onos.cluster.MastershipStore
;
import
org.onlab.onos.cluster.MastershipStoreDelegate
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.MastershipTermService
;
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.DeviceMastershipService
;
import
org.onlab.onos.net.device.DeviceMastershipStore
;
import
org.onlab.onos.net.device.DeviceMastershipStoreDelegate
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.net.device.DeviceMastershipTermService
;
import
org.slf4j.Logger
;
@Component
(
immediate
=
true
)
@Service
public
class
MastershipManager
implements
MastershipService
,
MastershipAdminService
{
implements
DeviceMastershipService
,
Device
MastershipAdminService
{
private
static
final
String
NODE_ID_NULL
=
"Node ID cannot be null"
;
private
static
final
String
DEVICE_ID_NULL
=
"Device ID cannot be null"
;
...
...
@@ -40,13 +40,13 @@ implements MastershipService, MastershipAdminService {
private
final
Logger
log
=
getLogger
(
getClass
());
protected
final
AbstractListenerRegistry
<
MastershipEvent
,
MastershipListener
>
protected
final
AbstractListenerRegistry
<
DeviceMastershipEvent
,
Device
MastershipListener
>
listenerRegistry
=
new
AbstractListenerRegistry
<>();
private
final
MastershipStoreDelegate
delegate
=
new
InternalDelegate
();
private
final
Device
MastershipStoreDelegate
delegate
=
new
InternalDelegate
();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
MastershipStore
store
;
protected
Device
MastershipStore
store
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
EventDeliveryService
eventDispatcher
;
...
...
@@ -58,7 +58,7 @@ implements MastershipService, MastershipAdminService {
@Activate
public
void
activate
()
{
eventDispatcher
.
addSink
(
MastershipEvent
.
class
,
listenerRegistry
);
eventDispatcher
.
addSink
(
Device
MastershipEvent
.
class
,
listenerRegistry
);
clusterService
.
addListener
(
clusterListener
);
store
.
setDelegate
(
delegate
);
log
.
info
(
"Started"
);
...
...
@@ -66,7 +66,7 @@ implements MastershipService, MastershipAdminService {
@Deactivate
public
void
deactivate
()
{
eventDispatcher
.
removeSink
(
MastershipEvent
.
class
);
eventDispatcher
.
removeSink
(
Device
MastershipEvent
.
class
);
clusterService
.
removeListener
(
clusterListener
);
store
.
unsetDelegate
(
delegate
);
log
.
info
(
"Stopped"
);
...
...
@@ -78,7 +78,7 @@ implements MastershipService, MastershipAdminService {
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
checkNotNull
(
role
,
ROLE_NULL
);
MastershipEvent
event
=
null
;
Device
MastershipEvent
event
=
null
;
if
(
role
.
equals
(
MastershipRole
.
MASTER
))
{
event
=
store
.
setMaster
(
nodeId
,
deviceId
);
}
else
{
...
...
@@ -98,7 +98,7 @@ implements MastershipService, MastershipAdminService {
@Override
public
void
relinquishMastership
(
DeviceId
deviceId
)
{
MastershipEvent
event
=
null
;
Device
MastershipEvent
event
=
null
;
event
=
store
.
relinquishRole
(
clusterService
.
getLocalNode
().
id
(),
deviceId
);
...
...
@@ -127,18 +127,18 @@ implements MastershipService, MastershipAdminService {
@Override
public
MastershipTermService
requestTermService
()
{
public
Device
MastershipTermService
requestTermService
()
{
return
new
InternalMastershipTermService
();
}
@Override
public
void
addListener
(
MastershipListener
listener
)
{
public
void
addListener
(
Device
MastershipListener
listener
)
{
checkNotNull
(
listener
);
listenerRegistry
.
addListener
(
listener
);
}
@Override
public
void
removeListener
(
MastershipListener
listener
)
{
public
void
removeListener
(
Device
MastershipListener
listener
)
{
checkNotNull
(
listener
);
listenerRegistry
.
removeListener
(
listener
);
}
...
...
@@ -146,16 +146,16 @@ implements MastershipService, MastershipAdminService {
// FIXME: provide wiring to allow events to be triggered by changes within the store
// Posts the specified event to the local event dispatcher.
private
void
post
(
MastershipEvent
event
)
{
private
void
post
(
Device
MastershipEvent
event
)
{
if
(
event
!=
null
&&
eventDispatcher
!=
null
)
{
eventDispatcher
.
post
(
event
);
}
}
private
class
InternalMastershipTermService
implements
MastershipTermService
{
private
class
InternalMastershipTermService
implements
Device
MastershipTermService
{
@Override
public
MastershipTerm
getMastershipTerm
(
DeviceId
deviceId
)
{
public
Device
MastershipTerm
getMastershipTerm
(
DeviceId
deviceId
)
{
return
store
.
getTermFor
(
deviceId
);
}
...
...
@@ -181,10 +181,10 @@ implements MastershipService, MastershipAdminService {
}
public
class
InternalDelegate
implements
MastershipStoreDelegate
{
public
class
InternalDelegate
implements
Device
MastershipStoreDelegate
{
@Override
public
void
notify
(
MastershipEvent
event
)
{
public
void
notify
(
Device
MastershipEvent
event
)
{
log
.
info
(
"dispatching mastership event {}"
,
event
);
eventDispatcher
.
post
(
event
);
}
...
...
core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
View file @
e63108c
...
...
@@ -13,11 +13,6 @@ import org.apache.felix.scr.annotations.Reference;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.cluster.ClusterService
;
import
org.onlab.onos.cluster.MastershipEvent
;
import
org.onlab.onos.cluster.MastershipListener
;
import
org.onlab.onos.cluster.MastershipService
;
import
org.onlab.onos.cluster.MastershipTermService
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.event.AbstractListenerRegistry
;
import
org.onlab.onos.event.EventDeliveryService
;
...
...
@@ -36,6 +31,11 @@ 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.DeviceMastershipEvent
;
import
org.onlab.onos.net.device.DeviceMastershipListener
;
import
org.onlab.onos.net.device.DeviceMastershipService
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
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
;
...
...
@@ -64,7 +64,7 @@ public class DeviceManager
private
final
DeviceStoreDelegate
delegate
=
new
InternalStoreDelegate
();
private
final
MastershipListener
mastershipListener
=
new
InternalMastershipListener
();
private
final
Device
MastershipListener
mastershipListener
=
new
InternalMastershipListener
();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
DeviceStore
store
;
...
...
@@ -76,9 +76,9 @@ public class DeviceManager
protected
ClusterService
clusterService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
MastershipService
mastershipService
;
protected
Device
MastershipService
mastershipService
;
protected
MastershipTermService
termService
;
protected
Device
MastershipTermService
termService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
ClockProviderService
clockProviderService
;
...
...
@@ -209,7 +209,7 @@ public class DeviceManager
return
;
}
MastershipTerm
term
=
mastershipService
.
requestTermService
()
Device
MastershipTerm
term
=
mastershipService
.
requestTermService
()
.
getMastershipTerm
(
deviceId
);
if
(!
term
.
master
().
equals
(
clusterService
.
getLocalNode
().
id
()))
{
// lost mastership after requestRole told this instance was MASTER.
...
...
@@ -320,16 +320,16 @@ public class DeviceManager
}
// Intercepts mastership events
private
class
InternalMastershipListener
implements
MastershipListener
{
private
class
InternalMastershipListener
implements
Device
MastershipListener
{
@Override
public
void
event
(
MastershipEvent
event
)
{
public
void
event
(
Device
MastershipEvent
event
)
{
final
DeviceId
did
=
event
.
subject
();
if
(
isAvailable
(
did
))
{
final
NodeId
myNodeId
=
clusterService
.
getLocalNode
().
id
();
if
(
myNodeId
.
equals
(
event
.
master
()))
{
MastershipTerm
term
=
termService
.
getMastershipTerm
(
did
);
Device
MastershipTerm
term
=
termService
.
getMastershipTerm
(
did
);
if
(
term
.
master
().
equals
(
myNodeId
))
{
// only set the new term if I am the master
...
...
core/net/src/test/java/org/onlab/onos/cluster/impl/MastershipManagerTest.java
View file @
e63108c
...
...
@@ -10,11 +10,11 @@ import org.onlab.onos.cluster.ClusterService;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.ControllerNode.State
;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.MastershipService
;
import
org.onlab.onos.cluster.MastershipTermService
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.event.impl.TestEventDispatcher
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipService
;
import
org.onlab.onos.net.device.DeviceMastershipTermService
;
import
org.onlab.onos.store.trivial.impl.SimpleMastershipStore
;
import
org.onlab.packet.IpPrefix
;
...
...
@@ -34,7 +34,7 @@ public class MastershipManagerTest {
private
static
final
DeviceId
DEV_OTHER
=
DeviceId
.
deviceId
(
"of:2"
);
private
MastershipManager
mgr
;
protected
MastershipService
service
;
protected
Device
MastershipService
service
;
@Before
public
void
setUp
()
{
...
...
@@ -120,7 +120,7 @@ public class MastershipManagerTest {
@Test
public
void
termService
()
{
MastershipTermService
ts
=
mgr
.
requestTermService
();
Device
MastershipTermService
ts
=
mgr
.
requestTermService
();
//term = 0 for both
mgr
.
setRole
(
NID_LOCAL
,
DEV_MASTER
,
MASTER
);
...
...
core/net/src/test/java/org/onlab/onos/net/device/impl/DeviceManagerTest.java
View file @
e63108c
...
...
@@ -11,8 +11,6 @@ import org.onlab.onos.cluster.ClusterService;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.MastershipServiceAdapter
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.MastershipTermService
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.cluster.ControllerNode.State
;
import
org.onlab.onos.event.Event
;
...
...
@@ -32,6 +30,8 @@ import org.onlab.onos.net.device.DeviceProvider;
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.DeviceMastershipTerm
;
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
;
...
...
@@ -290,12 +290,12 @@ public class DeviceManagerTest {
}
@Override
public
MastershipTermService
requestTermService
()
{
return
new
MastershipTermService
()
{
public
Device
MastershipTermService
requestTermService
()
{
return
new
Device
MastershipTermService
()
{
@Override
public
MastershipTerm
getMastershipTerm
(
DeviceId
deviceId
)
{
public
Device
MastershipTerm
getMastershipTerm
(
DeviceId
deviceId
)
{
// FIXME: just returning something not null
return
MastershipTerm
.
of
(
NID_LOCAL
,
1
);
return
Device
MastershipTerm
.
of
(
NID_LOCAL
,
1
);
}
};
}
...
...
@@ -339,7 +339,7 @@ public class DeviceManagerTest {
ClockProviderService
{
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
MastershipTerm
term
)
{
public
void
setMastershipTerm
(
DeviceId
deviceId
,
Device
MastershipTerm
term
)
{
// TODO Auto-generated method stub
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
View file @
e63108c
...
...
@@ -6,6 +6,7 @@ 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
;
import
org.apache.felix.scr.annotations.Deactivate
;
...
...
@@ -23,10 +24,8 @@ 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.serializers.ClusterMessageSerializer
;
import
org.onlab.onos.store.serializers.KryoPoolUtil
;
import
org.onlab.onos.store.serializers.KryoSerializer
;
import
org.onlab.onos.store.serializers.MessageSubjectSerializer
;
import
org.onlab.util.KryoPool
;
import
org.onlab.netty.Endpoint
;
import
org.onlab.netty.Message
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/
serializers
/ClusterMessageSerializer.java
→
core/store/dist/src/main/java/org/onlab/onos/store/
cluster/messaging/impl
/ClusterMessageSerializer.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
.
serializers
;
package
org
.
onlab
.
onos
.
store
.
cluster
.
messaging
.
impl
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.store.cluster.messaging.ClusterMessage
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/
serializers
/MessageSubjectSerializer.java
→
core/store/dist/src/main/java/org/onlab/onos/store/
cluster/messaging/impl
/MessageSubjectSerializer.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
.
serializers
;
package
org
.
onlab
.
onos
.
store
.
cluster
.
messaging
.
impl
;
import
org.onlab.onos.store.cluster.messaging.MessageSubject
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/AntiEntropyReply.java
View file @
e63108c
...
...
@@ -4,7 +4,7 @@ import java.util.Map;
import
java.util.Set
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.store.
device.impl.
VersionedValue
;
import
org.onlab.onos.store.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/MastershipBasedTimestamp.java
→
core/store/dist/src/main/java/org/onlab/onos/store/common/impl/
Device
MastershipBasedTimestamp.java
View file @
e63108c
...
...
@@ -13,7 +13,7 @@ import com.google.common.collect.ComparisonChain;
* Default implementation of Timestamp.
* TODO: Better documentation.
*/
public
final
class
MastershipBasedTimestamp
implements
Timestamp
{
public
final
class
Device
MastershipBasedTimestamp
implements
Timestamp
{
private
final
int
termNumber
;
private
final
int
sequenceNumber
;
...
...
@@ -24,16 +24,16 @@ public final class MastershipBasedTimestamp implements Timestamp {
* @param termNumber the mastership termNumber
* @param sequenceNumber the sequenceNumber number within the termNumber
*/
public
MastershipBasedTimestamp
(
int
termNumber
,
int
sequenceNumber
)
{
public
Device
MastershipBasedTimestamp
(
int
termNumber
,
int
sequenceNumber
)
{
this
.
termNumber
=
termNumber
;
this
.
sequenceNumber
=
sequenceNumber
;
}
@Override
public
int
compareTo
(
Timestamp
o
)
{
checkArgument
(
o
instanceof
MastershipBasedTimestamp
,
checkArgument
(
o
instanceof
Device
MastershipBasedTimestamp
,
"Must be MastershipBasedTimestamp"
,
o
);
MastershipBasedTimestamp
that
=
(
MastershipBasedTimestamp
)
o
;
DeviceMastershipBasedTimestamp
that
=
(
Device
MastershipBasedTimestamp
)
o
;
return
ComparisonChain
.
start
()
.
compare
(
this
.
termNumber
,
that
.
termNumber
)
...
...
@@ -51,10 +51,10 @@ public final class MastershipBasedTimestamp implements Timestamp {
if
(
this
==
obj
)
{
return
true
;
}
if
(!(
obj
instanceof
MastershipBasedTimestamp
))
{
if
(!(
obj
instanceof
Device
MastershipBasedTimestamp
))
{
return
false
;
}
MastershipBasedTimestamp
that
=
(
MastershipBasedTimestamp
)
obj
;
DeviceMastershipBasedTimestamp
that
=
(
Device
MastershipBasedTimestamp
)
obj
;
return
Objects
.
equals
(
this
.
termNumber
,
that
.
termNumber
)
&&
Objects
.
equals
(
this
.
sequenceNumber
,
that
.
sequenceNumber
);
}
...
...
@@ -87,7 +87,7 @@ public final class MastershipBasedTimestamp implements Timestamp {
// Default constructor for serialization
@Deprecated
protected
MastershipBasedTimestamp
()
{
protected
Device
MastershipBasedTimestamp
()
{
this
.
termNumber
=
-
1
;
this
.
sequenceNumber
=
-
1
;
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/
serializers
/MastershipBasedTimestampSerializer.java
→
core/store/dist/src/main/java/org/onlab/onos/store/
common/impl
/MastershipBasedTimestampSerializer.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
org.onlab.onos.store.common.impl.MastershipBasedTimestamp
;
package
org
.
onlab
.
onos
.
store
.
common
.
impl
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
...
...
@@ -9,12 +7,12 @@ import com.esotericsoftware.kryo.io.Output;
// To be used if Timestamp ever needs to cross bundle boundary.
/**
* Kryo Serializer for {@link MastershipBasedTimestamp}.
* Kryo Serializer for {@link
Device
MastershipBasedTimestamp}.
*/
public
class
MastershipBasedTimestampSerializer
extends
Serializer
<
MastershipBasedTimestamp
>
{
public
class
MastershipBasedTimestampSerializer
extends
Serializer
<
Device
MastershipBasedTimestamp
>
{
/**
* Creates a serializer for {@link MastershipBasedTimestamp}.
* Creates a serializer for {@link
Device
MastershipBasedTimestamp}.
*/
public
MastershipBasedTimestampSerializer
()
{
// non-null, immutable
...
...
@@ -22,15 +20,15 @@ public class MastershipBasedTimestampSerializer extends Serializer<MastershipBas
}
@Override
public
void
write
(
Kryo
kryo
,
Output
output
,
MastershipBasedTimestamp
object
)
{
public
void
write
(
Kryo
kryo
,
Output
output
,
Device
MastershipBasedTimestamp
object
)
{
output
.
writeInt
(
object
.
termNumber
());
output
.
writeInt
(
object
.
sequenceNumber
());
}
@Override
public
MastershipBasedTimestamp
read
(
Kryo
kryo
,
Input
input
,
Class
<
MastershipBasedTimestamp
>
type
)
{
public
DeviceMastershipBasedTimestamp
read
(
Kryo
kryo
,
Input
input
,
Class
<
Device
MastershipBasedTimestamp
>
type
)
{
final
int
term
=
input
.
readInt
();
final
int
sequence
=
input
.
readInt
();
return
new
MastershipBasedTimestamp
(
term
,
sequence
);
return
new
Device
MastershipBasedTimestamp
(
term
,
sequence
);
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/DeviceAntiEntropyAdvertisement.java
View file @
e63108c
...
...
@@ -8,6 +8,7 @@ import org.onlab.onos.cluster.NodeId;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.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 @
e63108c
...
...
@@ -10,6 +10,7 @@ import org.onlab.onos.cluster.NodeId;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.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 @
e63108c
...
...
@@ -10,12 +10,12 @@ import org.apache.felix.scr.annotations.Activate;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.net.DeviceId
;
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.store.common.impl.MastershipBasedTimestamp
;
import
org.onlab.onos.store.common.impl.
Device
MastershipBasedTimestamp
;
import
org.slf4j.Logger
;
/**
...
...
@@ -29,7 +29,7 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
// TODO: Implement per device ticker that is reset to 0 at the beginning of a new term.
private
final
AtomicInteger
ticker
=
new
AtomicInteger
(
0
);
private
ConcurrentMap
<
DeviceId
,
MastershipTerm
>
deviceMastershipTerms
=
new
ConcurrentHashMap
<>();
private
ConcurrentMap
<
DeviceId
,
Device
MastershipTerm
>
deviceMastershipTerms
=
new
ConcurrentHashMap
<>();
@Activate
public
void
activate
()
{
...
...
@@ -43,15 +43,15 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
@Override
public
Timestamp
getTimestamp
(
DeviceId
deviceId
)
{
MastershipTerm
term
=
deviceMastershipTerms
.
get
(
deviceId
);
Device
MastershipTerm
term
=
deviceMastershipTerms
.
get
(
deviceId
);
if
(
term
==
null
)
{
throw
new
IllegalStateException
(
"Requesting timestamp for a deviceId without mastership"
);
}
return
new
MastershipBasedTimestamp
(
term
.
termNumber
(),
ticker
.
incrementAndGet
());
return
new
Device
MastershipBasedTimestamp
(
term
.
termNumber
(),
ticker
.
incrementAndGet
());
}
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
MastershipTerm
term
)
{
public
void
setMastershipTerm
(
DeviceId
deviceId
,
Device
MastershipTerm
term
)
{
deviceMastershipTerms
.
put
(
deviceId
,
term
);
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
View file @
e63108c
...
...
@@ -35,14 +35,14 @@ 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
;
import
org.onlab.onos.store.common.impl.MastershipBasedTimestamp
;
import
org.onlab.onos.store.common.impl.
Timestamped
;
import
org.onlab.onos.store.common.impl.
Device
MastershipBasedTimestamp
;
import
org.onlab.onos.store.common.impl.
MastershipBasedTimestampSerializer
;
import
org.onlab.onos.store.serializers.KryoPoolUtil
;
import
org.onlab.onos.store.serializers.KryoSerializer
;
import
org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer
;
import
org.onlab.util.KryoPool
;
import
org.onlab.util.NewConcurrentHashMap
;
import
org.slf4j.Logger
;
...
...
@@ -125,7 +125,7 @@ public class GossipDeviceStore
.
register
(
InternalPortStatusEvent
.
class
,
new
InternalPortStatusEventSerializer
())
.
register
(
Timestamp
.
class
)
.
register
(
Timestamped
.
class
)
.
register
(
MastershipBasedTimestamp
.
class
,
new
MastershipBasedTimestampSerializer
())
.
register
(
Device
MastershipBasedTimestamp
.
class
,
new
MastershipBasedTimestampSerializer
())
.
build
()
.
populate
(
1
);
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEvent.java
View file @
e63108c
...
...
@@ -3,7 +3,7 @@ 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.provider.ProviderId
;
import
org.onlab.onos.store.
common.impl.
Timestamped
;
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 @
e63108c
...
...
@@ -3,7 +3,7 @@ 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.provider.ProviderId
;
import
org.onlab.onos.store.
common.impl.
Timestamped
;
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/InternalPortEvent.java
View file @
e63108c
...
...
@@ -5,7 +5,7 @@ import java.util.List;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.
common.impl.
Timestamped
;
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 @
e63108c
...
...
@@ -5,7 +5,7 @@ import java.util.List;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.
common.impl.
Timestamped
;
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 @
e63108c
...
...
@@ -3,7 +3,7 @@ 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.provider.ProviderId
;
import
org.onlab.onos.store.
common.impl.
Timestamped
;
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 @
e63108c
...
...
@@ -3,7 +3,7 @@ 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.provider.ProviderId
;
import
org.onlab.onos.store.
common.impl.
Timestamped
;
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 @
e63108c
...
...
@@ -31,7 +31,7 @@ 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.
device.impl.
VersionedValue
;
import
org.onlab.onos.store.VersionedValue
;
import
org.slf4j.Logger
;
import
com.google.common.collect.HashMultimap
;
...
...
core/store/dist/src/test/java/org/onlab/onos/store/common/impl/MastershipBasedTimestampTest.java
View file @
e63108c
...
...
@@ -6,26 +6,25 @@ import java.nio.ByteBuffer;
import
org.junit.Test
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer
;
import
org.onlab.util.KryoPool
;
import
com.google.common.testing.EqualsTester
;
/**
* Test of {@link MastershipBasedTimestamp}.
* Test of {@link
Device
MastershipBasedTimestamp}.
*/
public
class
MastershipBasedTimestampTest
{
private
static
final
Timestamp
TS_1_1
=
new
MastershipBasedTimestamp
(
1
,
1
);
private
static
final
Timestamp
TS_1_2
=
new
MastershipBasedTimestamp
(
1
,
2
);
private
static
final
Timestamp
TS_2_1
=
new
MastershipBasedTimestamp
(
2
,
1
);
private
static
final
Timestamp
TS_2_2
=
new
MastershipBasedTimestamp
(
2
,
2
);
private
static
final
Timestamp
TS_1_1
=
new
Device
MastershipBasedTimestamp
(
1
,
1
);
private
static
final
Timestamp
TS_1_2
=
new
Device
MastershipBasedTimestamp
(
1
,
2
);
private
static
final
Timestamp
TS_2_1
=
new
Device
MastershipBasedTimestamp
(
2
,
1
);
private
static
final
Timestamp
TS_2_2
=
new
Device
MastershipBasedTimestamp
(
2
,
2
);
@Test
public
final
void
testBasic
()
{
final
int
termNumber
=
5
;
final
int
sequenceNumber
=
6
;
MastershipBasedTimestamp
ts
=
new
MastershipBasedTimestamp
(
termNumber
,
DeviceMastershipBasedTimestamp
ts
=
new
Device
MastershipBasedTimestamp
(
termNumber
,
sequenceNumber
);
assertEquals
(
termNumber
,
ts
.
termNumber
());
...
...
@@ -35,7 +34,7 @@ public class MastershipBasedTimestampTest {
@Test
public
final
void
testCompareTo
()
{
assertTrue
(
TS_1_1
.
compareTo
(
TS_1_1
)
==
0
);
assertTrue
(
TS_1_1
.
compareTo
(
new
MastershipBasedTimestamp
(
1
,
1
))
==
0
);
assertTrue
(
TS_1_1
.
compareTo
(
new
Device
MastershipBasedTimestamp
(
1
,
1
))
==
0
);
assertTrue
(
TS_1_1
.
compareTo
(
TS_1_2
)
<
0
);
assertTrue
(
TS_1_2
.
compareTo
(
TS_1_1
)
>
0
);
...
...
@@ -49,14 +48,14 @@ public class MastershipBasedTimestampTest {
@Test
public
final
void
testEqualsObject
()
{
new
EqualsTester
()
.
addEqualityGroup
(
new
MastershipBasedTimestamp
(
1
,
1
),
new
MastershipBasedTimestamp
(
1
,
1
),
TS_1_1
)
.
addEqualityGroup
(
new
MastershipBasedTimestamp
(
1
,
2
),
new
MastershipBasedTimestamp
(
1
,
2
),
TS_1_2
)
.
addEqualityGroup
(
new
MastershipBasedTimestamp
(
2
,
1
),
new
MastershipBasedTimestamp
(
2
,
1
),
TS_2_1
)
.
addEqualityGroup
(
new
MastershipBasedTimestamp
(
2
,
2
),
new
MastershipBasedTimestamp
(
2
,
2
),
TS_2_2
)
.
addEqualityGroup
(
new
Device
MastershipBasedTimestamp
(
1
,
1
),
new
Device
MastershipBasedTimestamp
(
1
,
1
),
TS_1_1
)
.
addEqualityGroup
(
new
Device
MastershipBasedTimestamp
(
1
,
2
),
new
Device
MastershipBasedTimestamp
(
1
,
2
),
TS_1_2
)
.
addEqualityGroup
(
new
Device
MastershipBasedTimestamp
(
2
,
1
),
new
Device
MastershipBasedTimestamp
(
2
,
1
),
TS_2_1
)
.
addEqualityGroup
(
new
Device
MastershipBasedTimestamp
(
2
,
2
),
new
Device
MastershipBasedTimestamp
(
2
,
2
),
TS_2_2
)
.
testEquals
();
}
...
...
@@ -64,7 +63,7 @@ public class MastershipBasedTimestampTest {
public
final
void
testKryoSerializable
()
{
final
ByteBuffer
buffer
=
ByteBuffer
.
allocate
(
1
*
1024
*
1024
);
final
KryoPool
kryos
=
KryoPool
.
newBuilder
()
.
register
(
MastershipBasedTimestamp
.
class
)
.
register
(
Device
MastershipBasedTimestamp
.
class
)
.
build
();
kryos
.
serialize
(
TS_2_1
,
buffer
);
...
...
@@ -80,7 +79,7 @@ public class MastershipBasedTimestampTest {
public
final
void
testKryoSerializableWithHandcraftedSerializer
()
{
final
ByteBuffer
buffer
=
ByteBuffer
.
allocate
(
1
*
1024
*
1024
);
final
KryoPool
kryos
=
KryoPool
.
newBuilder
()
.
register
(
MastershipBasedTimestamp
.
class
,
new
MastershipBasedTimestampSerializer
())
.
register
(
Device
MastershipBasedTimestamp
.
class
,
new
MastershipBasedTimestampSerializer
())
.
build
();
kryos
.
serialize
(
TS_1_2
,
buffer
);
...
...
core/store/dist/src/test/java/org/onlab/onos/store/common/impl/TimestampedTest.java
View file @
e63108c
...
...
@@ -6,6 +6,7 @@ import java.nio.ByteBuffer;
import
org.junit.Test
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.Timestamped
;
import
org.onlab.util.KryoPool
;
import
com.google.common.testing.EqualsTester
;
...
...
@@ -15,9 +16,9 @@ import com.google.common.testing.EqualsTester;
*/
public
class
TimestampedTest
{
private
static
final
Timestamp
TS_1_1
=
new
MastershipBasedTimestamp
(
1
,
1
);
private
static
final
Timestamp
TS_1_2
=
new
MastershipBasedTimestamp
(
1
,
2
);
private
static
final
Timestamp
TS_2_1
=
new
MastershipBasedTimestamp
(
2
,
1
);
private
static
final
Timestamp
TS_1_1
=
new
Device
MastershipBasedTimestamp
(
1
,
1
);
private
static
final
Timestamp
TS_1_2
=
new
Device
MastershipBasedTimestamp
(
1
,
2
);
private
static
final
Timestamp
TS_2_1
=
new
Device
MastershipBasedTimestamp
(
2
,
1
);
@Test
public
final
void
testHashCode
()
{
...
...
@@ -79,7 +80,7 @@ public class TimestampedTest {
final
ByteBuffer
buffer
=
ByteBuffer
.
allocate
(
1
*
1024
*
1024
);
final
KryoPool
kryos
=
KryoPool
.
newBuilder
()
.
register
(
Timestamped
.
class
,
MastershipBasedTimestamp
.
class
)
Device
MastershipBasedTimestamp
.
class
)
.
build
();
Timestamped
<
String
>
original
=
new
Timestamped
<>(
"foobar"
,
TS_1_1
);
...
...
core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
View file @
e63108c
...
...
@@ -25,7 +25,6 @@ import org.onlab.onos.cluster.ClusterService;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.ControllerNode.State
;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.Annotations
;
import
org.onlab.onos.net.DefaultAnnotations
;
...
...
@@ -40,6 +39,7 @@ 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.DeviceMastershipTerm
;
import
org.onlab.onos.net.device.PortDescription
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.store.ClockService
;
...
...
@@ -113,8 +113,8 @@ public class GossipDeviceStoreTest {
deviceClockManager
.
activate
();
clockService
=
deviceClockManager
;
deviceClockManager
.
setMastershipTerm
(
DID1
,
MastershipTerm
.
of
(
MYSELF
,
1
));
deviceClockManager
.
setMastershipTerm
(
DID2
,
MastershipTerm
.
of
(
MYSELF
,
2
));
deviceClockManager
.
setMastershipTerm
(
DID1
,
Device
MastershipTerm
.
of
(
MYSELF
,
1
));
deviceClockManager
.
setMastershipTerm
(
DID2
,
Device
MastershipTerm
.
of
(
MYSELF
,
2
));
ClusterCommunicationService
clusterCommunicator
=
new
TestClusterCommunicationService
();
ClusterService
clusterService
=
new
TestClusterService
();
...
...
core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
→
core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/Distributed
Device
MastershipStore.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
.
cluster
.
impl
;
import
static
org
.
onlab
.
onos
.
cluster
.
MastershipEvent
.
Type
.
MASTER_CHANGED
;
import
static
org
.
onlab
.
onos
.
net
.
device
.
Device
MastershipEvent
.
Type
.
MASTER_CHANGED
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -12,13 +12,13 @@ import org.apache.felix.scr.annotations.Reference;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.cluster.ClusterService
;
import
org.onlab.onos.cluster.MastershipEvent
;
import
org.onlab.onos.cluster.MastershipStore
;
import
org.onlab.onos.cluster.MastershipStoreDelegate
;
import
org.onlab.onos.cluster.MastershipTerm
;
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.DeviceMastershipStore
;
import
org.onlab.onos.net.device.DeviceMastershipStoreDelegate
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.store.common.AbstractHazelcastStore
;
import
com.google.common.collect.ImmutableSet
;
...
...
@@ -32,9 +32,9 @@ import com.hazelcast.core.MultiMap;
*/
@Component
(
immediate
=
true
)
@Service
public
class
DistributedMastershipStore
extends
AbstractHazelcastStore
<
MastershipEvent
,
MastershipStoreDelegate
>
implements
MastershipStore
{
public
class
Distributed
Device
MastershipStore
extends
AbstractHazelcastStore
<
DeviceMastershipEvent
,
Device
MastershipStoreDelegate
>
implements
Device
MastershipStore
{
//arbitrary lock name
private
static
final
String
LOCK
=
"lock"
;
...
...
@@ -100,7 +100,7 @@ implements MastershipStore {
}
@Override
public
MastershipEvent
setMaster
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipEvent
setMaster
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
byte
[]
did
=
serialize
(
deviceId
);
byte
[]
nid
=
serialize
(
nodeId
);
...
...
@@ -123,12 +123,12 @@ implements MastershipStore {
masters
.
put
(
did
,
nid
);
evict
(
nid
,
did
);
updateTerm
(
did
);
return
new
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
);
return
new
Device
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
);
case
NONE:
masters
.
put
(
did
,
nid
);
evict
(
nid
,
did
);
updateTerm
(
did
);
return
new
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
);
return
new
Device
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
);
default
:
log
.
warn
(
"unknown Mastership Role {}"
,
role
);
return
null
;
...
...
@@ -191,21 +191,21 @@ implements MastershipStore {
}
@Override
public
MastershipTerm
getTermFor
(
DeviceId
deviceId
)
{
public
Device
MastershipTerm
getTermFor
(
DeviceId
deviceId
)
{
byte
[]
did
=
serialize
(
deviceId
);
if
((
masters
.
get
(
did
)
==
null
)
||
(
terms
.
get
(
did
)
==
null
))
{
return
null
;
}
return
MastershipTerm
.
of
(
return
Device
MastershipTerm
.
of
(
(
NodeId
)
deserialize
(
masters
.
get
(
did
)),
terms
.
get
(
did
));
}
@Override
public
MastershipEvent
setStandby
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipEvent
setStandby
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
byte
[]
did
=
serialize
(
deviceId
);
byte
[]
nid
=
serialize
(
nodeId
);
MastershipEvent
event
=
null
;
Device
MastershipEvent
event
=
null
;
ILock
lock
=
theInstance
.
getLock
(
LOCK
);
lock
.
lock
();
...
...
@@ -231,10 +231,10 @@ implements MastershipStore {
}
@Override
public
MastershipEvent
relinquishRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipEvent
relinquishRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
byte
[]
did
=
serialize
(
deviceId
);
byte
[]
nid
=
serialize
(
nodeId
);
MastershipEvent
event
=
null
;
Device
MastershipEvent
event
=
null
;
ILock
lock
=
theInstance
.
getLock
(
LOCK
);
lock
.
lock
();
...
...
@@ -260,7 +260,7 @@ implements MastershipStore {
}
//helper to fetch a new master candidate for a given device.
private
MastershipEvent
reelect
(
NodeId
current
,
DeviceId
deviceId
)
{
private
Device
MastershipEvent
reelect
(
NodeId
current
,
DeviceId
deviceId
)
{
byte
[]
did
=
serialize
(
deviceId
);
byte
[]
nid
=
serialize
(
current
);
...
...
@@ -281,7 +281,7 @@ implements MastershipStore {
evict
(
backup
,
did
);
Integer
term
=
terms
.
get
(
did
);
terms
.
put
(
did
,
++
term
);
return
new
MastershipEvent
(
return
new
Device
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
(
NodeId
)
deserialize
(
backup
));
}
}
...
...
@@ -320,7 +320,7 @@ implements MastershipStore {
@Override
protected
void
onAdd
(
DeviceId
deviceId
,
NodeId
nodeId
)
{
notifyDelegate
(
new
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
));
notifyDelegate
(
new
Device
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
));
}
@Override
...
...
core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStoreTest.java
→
core/store/hz/cluster/src/test/java/org/onlab/onos/store/cluster/impl/Distributed
Device
MastershipStoreTest.java
View file @
e63108c
...
...
@@ -21,12 +21,12 @@ import org.onlab.onos.cluster.ClusterService;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.ControllerNode.State
;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.MastershipEvent
;
import
org.onlab.onos.cluster.MastershipEvent.Type
;
import
org.onlab.onos.cluster.MastershipStoreDelegate
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipEvent
;
import
org.onlab.onos.net.device.DeviceMastershipStoreDelegate
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.net.device.DeviceMastershipEvent.Type
;
import
org.onlab.onos.store.common.StoreManager
;
import
org.onlab.onos.store.common.StoreService
;
import
org.onlab.onos.store.common.TestStoreManager
;
...
...
@@ -40,7 +40,7 @@ import com.hazelcast.core.Hazelcast;
/**
* Test of the Hazelcast-based distributed MastershipStore implementation.
*/
public
class
DistributedMastershipStoreTest
{
public
class
Distributed
Device
MastershipStoreTest
{
private
static
final
DeviceId
DID1
=
DeviceId
.
deviceId
(
"of:01"
);
private
static
final
DeviceId
DID2
=
DeviceId
.
deviceId
(
"of:02"
);
...
...
@@ -54,8 +54,8 @@ public class DistributedMastershipStoreTest {
private
static
final
ControllerNode
CN1
=
new
DefaultControllerNode
(
N1
,
IP
);
private
static
final
ControllerNode
CN2
=
new
DefaultControllerNode
(
N2
,
IP
);
private
DistributedMastershipStore
dms
;
private
TestDistributedMastershipStore
testStore
;
private
Distributed
Device
MastershipStore
dms
;
private
TestDistributed
Device
MastershipStore
testStore
;
private
KryoSerializer
serializationMgr
;
private
StoreManager
storeMgr
;
...
...
@@ -77,11 +77,11 @@ public class DistributedMastershipStoreTest {
serializationMgr
=
new
KryoSerializer
();
dms
=
new
TestDistributedMastershipStore
(
storeMgr
,
serializationMgr
);
dms
=
new
TestDistributed
Device
MastershipStore
(
storeMgr
,
serializationMgr
);
dms
.
clusterService
=
new
TestClusterService
();
dms
.
activate
();
testStore
=
(
TestDistributedMastershipStore
)
dms
;
testStore
=
(
TestDistributed
Device
MastershipStore
)
dms
;
}
@After
...
...
@@ -133,7 +133,7 @@ public class DistributedMastershipStoreTest {
assertEquals
(
"wrong role for NONE:"
,
MASTER
,
dms
.
requestRole
(
DID1
));
assertTrue
(
"wrong state for store:"
,
!
dms
.
terms
.
isEmpty
());
assertEquals
(
"wrong term"
,
MastershipTerm
.
of
(
N1
,
0
),
dms
.
getTermFor
(
DID1
));
Device
MastershipTerm
.
of
(
N1
,
0
),
dms
.
getTermFor
(
DID1
));
//CN2 now local. DID2 has N1 as MASTER so N2 is STANDBY
testStore
.
setCurrent
(
CN2
);
...
...
@@ -143,7 +143,7 @@ public class DistributedMastershipStoreTest {
//change term and requestRole() again; should persist
testStore
.
increment
(
DID2
);
assertEquals
(
"wrong role for STANDBY:"
,
STANDBY
,
dms
.
requestRole
(
DID2
));
assertEquals
(
"wrong term"
,
MastershipTerm
.
of
(
N1
,
1
),
dms
.
getTermFor
(
DID2
));
assertEquals
(
"wrong term"
,
Device
MastershipTerm
.
of
(
N1
,
1
),
dms
.
getTermFor
(
DID2
));
}
@Test
...
...
@@ -155,15 +155,15 @@ public class DistributedMastershipStoreTest {
//switch over to N2
assertEquals
(
"wrong event:"
,
Type
.
MASTER_CHANGED
,
dms
.
setMaster
(
N2
,
DID1
).
type
());
assertEquals
(
"wrong term"
,
MastershipTerm
.
of
(
N2
,
1
),
dms
.
getTermFor
(
DID1
));
assertEquals
(
"wrong term"
,
Device
MastershipTerm
.
of
(
N2
,
1
),
dms
.
getTermFor
(
DID1
));
//orphan switch - should be rare case
assertEquals
(
"wrong event:"
,
Type
.
MASTER_CHANGED
,
dms
.
setMaster
(
N2
,
DID2
).
type
());
assertEquals
(
"wrong term"
,
MastershipTerm
.
of
(
N2
,
0
),
dms
.
getTermFor
(
DID2
));
assertEquals
(
"wrong term"
,
Device
MastershipTerm
.
of
(
N2
,
0
),
dms
.
getTermFor
(
DID2
));
//disconnect and reconnect - sign of failing re-election or single-instance channel
testStore
.
reset
(
true
,
false
,
false
);
dms
.
setMaster
(
N2
,
DID2
);
assertEquals
(
"wrong term"
,
MastershipTerm
.
of
(
N2
,
1
),
dms
.
getTermFor
(
DID2
));
assertEquals
(
"wrong term"
,
Device
MastershipTerm
.
of
(
N2
,
1
),
dms
.
getTermFor
(
DID2
));
}
@Test
...
...
@@ -211,9 +211,9 @@ public class DistributedMastershipStoreTest {
//shamelessly copy other distributed store tests
final
CountDownLatch
addLatch
=
new
CountDownLatch
(
1
);
MastershipStoreDelegate
checkAdd
=
new
MastershipStoreDelegate
()
{
DeviceMastershipStoreDelegate
checkAdd
=
new
Device
MastershipStoreDelegate
()
{
@Override
public
void
notify
(
MastershipEvent
event
)
{
public
void
notify
(
Device
MastershipEvent
event
)
{
assertEquals
(
"wrong event:"
,
Type
.
MASTER_CHANGED
,
event
.
type
());
assertEquals
(
"wrong subject"
,
DID1
,
event
.
subject
());
assertEquals
(
"wrong subject"
,
N1
,
event
.
master
());
...
...
@@ -227,9 +227,9 @@ public class DistributedMastershipStoreTest {
assertTrue
(
"Add event fired"
,
addLatch
.
await
(
1
,
TimeUnit
.
SECONDS
));
}
private
class
TestDistributedMastershipStore
extends
DistributedMastershipStore
{
public
TestDistributedMastershipStore
(
StoreService
storeService
,
private
class
TestDistributed
Device
MastershipStore
extends
Distributed
Device
MastershipStore
{
public
TestDistributed
Device
MastershipStore
(
StoreService
storeService
,
KryoSerializer
kryoSerialization
)
{
this
.
storeService
=
storeService
;
this
.
serializer
=
kryoSerialization
;
...
...
core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockProviderService.java
View file @
e63108c
...
...
@@ -2,8 +2,8 @@ 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.cluster.MastershipTerm
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.store.ClockProviderService
;
// FIXME: Code clone in onos-core-trivial, onos-core-hz-net
...
...
@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService;
public
class
NoOpClockProviderService
implements
ClockProviderService
{
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
MastershipTerm
term
)
{
public
void
setMastershipTerm
(
DeviceId
deviceId
,
Device
MastershipTerm
term
)
{
}
}
...
...
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
View file @
e63108c
...
...
@@ -7,7 +7,6 @@ import java.util.HashMap;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DefaultAnnotations
;
...
...
@@ -24,6 +23,7 @@ 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.DeviceMastershipTerm
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
...
...
@@ -74,7 +74,7 @@ public final class KryoPoolUtil {
.
register
(
LinkKey
.
class
,
new
LinkKeySerializer
())
.
register
(
ConnectPoint
.
class
,
new
ConnectPointSerializer
())
.
register
(
DefaultLink
.
class
,
new
DefaultLinkSerializer
())
.
register
(
MastershipTerm
.
class
,
new
MastershipTermSerializer
())
.
register
(
Device
MastershipTerm
.
class
,
new
MastershipTermSerializer
())
.
register
(
MastershipRole
.
class
,
new
MastershipRoleSerializer
())
.
build
();
...
...
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/MastershipTermSerializer.java
View file @
e63108c
package
org
.
onlab
.
onos
.
store
.
serializers
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
com.esotericsoftware.kryo.Kryo
;
import
com.esotericsoftware.kryo.Serializer
;
import
com.esotericsoftware.kryo.io.Input
;
import
com.esotericsoftware.kryo.io.Output
;
/**
* Kryo Serializer for {@link org.onlab.onos.
cluster.
MastershipTerm}.
* Kryo Serializer for {@link org.onlab.onos.
net.device.Device
MastershipTerm}.
*/
public
class
MastershipTermSerializer
extends
Serializer
<
MastershipTerm
>
{
public
class
MastershipTermSerializer
extends
Serializer
<
Device
MastershipTerm
>
{
/**
* Creates {@link MastershipTerm} serializer instance.
* Creates {@link
Device
MastershipTerm} serializer instance.
*/
public
MastershipTermSerializer
()
{
// non-null, immutable
...
...
@@ -21,14 +22,14 @@ public class MastershipTermSerializer extends Serializer<MastershipTerm> {
}
@Override
public
MastershipTerm
read
(
Kryo
kryo
,
Input
input
,
Class
<
MastershipTerm
>
type
)
{
public
DeviceMastershipTerm
read
(
Kryo
kryo
,
Input
input
,
Class
<
Device
MastershipTerm
>
type
)
{
final
NodeId
node
=
new
NodeId
(
input
.
readString
());
final
int
term
=
input
.
readInt
();
return
MastershipTerm
.
of
(
node
,
term
);
return
Device
MastershipTerm
.
of
(
node
,
term
);
}
@Override
public
void
write
(
Kryo
kryo
,
Output
output
,
MastershipTerm
object
)
{
public
void
write
(
Kryo
kryo
,
Output
output
,
Device
MastershipTerm
object
)
{
output
.
writeString
(
object
.
master
().
toString
());
output
.
writeInt
(
object
.
termNumber
());
}
...
...
core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
View file @
e63108c
...
...
@@ -10,7 +10,6 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.Annotations
;
import
org.onlab.onos.net.ConnectPoint
;
...
...
@@ -25,6 +24,7 @@ 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.DeviceMastershipTerm
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.packet.IpAddress
;
import
org.onlab.packet.IpPrefix
;
...
...
@@ -114,7 +114,7 @@ public class KryoSerializerTest {
testSerialized
(
PID
);
testSerialized
(
PIDA
);
testSerialized
(
new
NodeId
(
"bar"
));
testSerialized
(
MastershipTerm
.
of
(
new
NodeId
(
"foo"
),
2
));
testSerialized
(
Device
MastershipTerm
.
of
(
new
NodeId
(
"foo"
),
2
));
for
(
MastershipRole
role
:
MastershipRole
.
values
())
{
testSerialized
(
role
);
}
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/NoOpClockProviderService.java
View file @
e63108c
...
...
@@ -2,8 +2,8 @@ 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.cluster.MastershipTerm
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.store.ClockProviderService
;
//FIXME: Code clone in onos-core-trivial, onos-core-hz-net
...
...
@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService;
public
class
NoOpClockProviderService
implements
ClockProviderService
{
@Override
public
void
setMastershipTerm
(
DeviceId
deviceId
,
MastershipTerm
term
)
{
public
void
setMastershipTerm
(
DeviceId
deviceId
,
Device
MastershipTerm
term
)
{
}
}
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStore.java
View file @
e63108c
...
...
@@ -15,18 +15,18 @@ import org.apache.felix.scr.annotations.Deactivate;
import
org.apache.felix.scr.annotations.Service
;
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.MastershipTerm
;
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.DeviceMastershipStore
;
import
org.onlab.onos.net.device.DeviceMastershipStoreDelegate
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
org.onlab.onos.store.AbstractStore
;
import
org.onlab.packet.IpPrefix
;
import
org.slf4j.Logger
;
import
static
org
.
onlab
.
onos
.
cluster
.
MastershipEvent
.
Type
.*;
import
static
org
.
onlab
.
onos
.
net
.
device
.
Device
MastershipEvent
.
Type
.*;
/**
* Manages inventory of controller mastership over devices using
...
...
@@ -35,8 +35,8 @@ import static org.onlab.onos.cluster.MastershipEvent.Type.*;
@Component
(
immediate
=
true
)
@Service
public
class
SimpleMastershipStore
extends
AbstractStore
<
MastershipEvent
,
MastershipStoreDelegate
>
implements
MastershipStore
{
extends
AbstractStore
<
DeviceMastershipEvent
,
Device
MastershipStoreDelegate
>
implements
Device
MastershipStore
{
private
final
Logger
log
=
getLogger
(
getClass
());
...
...
@@ -63,7 +63,7 @@ public class SimpleMastershipStore
}
@Override
public
MastershipEvent
setMaster
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipEvent
setMaster
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
synchronized
(
this
)
{
...
...
@@ -86,7 +86,7 @@ public class SimpleMastershipStore
}
}
return
new
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
);
return
new
Device
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
nodeId
);
}
@Override
...
...
@@ -164,17 +164,17 @@ public class SimpleMastershipStore
}
@Override
public
MastershipTerm
getTermFor
(
DeviceId
deviceId
)
{
public
Device
MastershipTerm
getTermFor
(
DeviceId
deviceId
)
{
if
((
masterMap
.
get
(
deviceId
)
==
null
)
||
(
termMap
.
get
(
deviceId
)
==
null
))
{
return
null
;
}
return
MastershipTerm
.
of
(
return
Device
MastershipTerm
.
of
(
masterMap
.
get
(
deviceId
),
termMap
.
get
(
deviceId
).
get
());
}
@Override
public
MastershipEvent
setStandby
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipEvent
setStandby
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
MastershipRole
role
=
getRole
(
nodeId
,
deviceId
);
synchronized
(
this
)
{
switch
(
role
)
{
...
...
@@ -185,7 +185,7 @@ public class SimpleMastershipStore
}
else
{
masterMap
.
put
(
deviceId
,
backup
);
termMap
.
get
(
deviceId
).
incrementAndGet
();
return
new
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
backup
);
return
new
Device
MastershipEvent
(
MASTER_CHANGED
,
deviceId
,
backup
);
}
case
STANDBY:
case
NONE:
...
...
@@ -215,7 +215,7 @@ public class SimpleMastershipStore
}
@Override
public
MastershipEvent
relinquishRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
public
Device
MastershipEvent
relinquishRole
(
NodeId
nodeId
,
DeviceId
deviceId
)
{
return
setStandby
(
nodeId
,
deviceId
);
}
...
...
core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleMastershipStoreTest.java
View file @
e63108c
...
...
@@ -6,9 +6,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.onlab.onos.cluster.MastershipTerm
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceMastershipTerm
;
import
com.google.common.collect.Sets
;
...
...
@@ -16,7 +16,7 @@ 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
.
cluster
.
MastershipEvent
.
Type
.*;
import
static
org
.
onlab
.
onos
.
net
.
device
.
Device
MastershipEvent
.
Type
.*;
/**
* Test for the simple MastershipStore implementation.
...
...
@@ -98,12 +98,12 @@ public class SimpleMastershipStoreTest {
@Test
public
void
getTermFor
()
{
put
(
DID1
,
N1
,
true
,
true
);
assertEquals
(
"wrong term"
,
MastershipTerm
.
of
(
N1
,
0
),
sms
.
getTermFor
(
DID1
));
assertEquals
(
"wrong term"
,
Device
MastershipTerm
.
of
(
N1
,
0
),
sms
.
getTermFor
(
DID1
));
//switch to N2 and back - 2 term switches
sms
.
setMaster
(
N2
,
DID1
);
sms
.
setMaster
(
N1
,
DID1
);
assertEquals
(
"wrong term"
,
MastershipTerm
.
of
(
N1
,
2
),
sms
.
getTermFor
(
DID1
));
assertEquals
(
"wrong term"
,
Device
MastershipTerm
.
of
(
N1
,
2
),
sms
.
getTermFor
(
DID1
));
}
@Test
...
...
openflow/api/src/main/java/org/onlab/onos/openflow/controller/DefaultOpenFlowPacketContext.java
View file @
e63108c
package
org
.
onlab
.
onos
.
openflow
.
controller
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.Collections
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
org.onlab.packet.Ethernet
;
import
org.projectfloodlight.openflow.protocol.OFPacketIn
;
import
org.projectfloodlight.openflow.protocol.OFPacketOut
;
...
...
@@ -13,11 +8,11 @@ import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
import
org.projectfloodlight.openflow.protocol.match.MatchField
;
import
org.projectfloodlight.openflow.types.OFBufferId
;
import
org.projectfloodlight.openflow.types.OFPort
;
import
org.slf4j.Logger
;
public
final
class
DefaultOpenFlowPacketContext
implements
OpenFlowPacketContext
{
import
java.util.Collections
;
import
java.util.concurrent.atomic.AtomicBoolean
;
private
final
Logger
log
=
getLogger
(
getClass
());
public
final
class
DefaultOpenFlowPacketContext
implements
OpenFlowPacketContext
{
private
final
AtomicBoolean
free
=
new
AtomicBoolean
(
true
);
private
final
AtomicBoolean
isBuilt
=
new
AtomicBoolean
(
false
);
...
...
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/Controller.java
View file @
e63108c
...
...
@@ -157,9 +157,7 @@ public class Controller {
}
log
.
debug
(
"OpenFlow port set to {}"
,
this
.
openFlowPort
);
String
threads
=
configParams
.
get
(
"workerthreads"
);
if
(
threads
!=
null
)
{
this
.
workerThreads
=
Integer
.
parseInt
(
threads
);
}
this
.
workerThreads
=
threads
!=
null
?
Integer
.
parseInt
(
threads
)
:
16
;
log
.
debug
(
"Number of worker threads set to {}"
,
this
.
workerThreads
);
}
...
...
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OpenFlowControllerImpl.java
View file @
e63108c
...
...
@@ -44,7 +44,6 @@ public class OpenFlowControllerImpl implements OpenFlowController {
private
final
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
16
,
namedThreads
(
"of-event-%d"
));
protected
ConcurrentHashMap
<
Dpid
,
OpenFlowSwitch
>
connectedSwitches
=
new
ConcurrentHashMap
<
Dpid
,
OpenFlowSwitch
>();
protected
ConcurrentHashMap
<
Dpid
,
OpenFlowSwitch
>
activeMasterSwitches
=
...
...
providers/openflow/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowCorePacketContext.java
View file @
e63108c
package
org
.
onlab
.
onos
.
provider
.
of
.
packet
.
impl
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.List
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.instructions.Instruction
;
import
org.onlab.onos.net.flow.instructions.Instruction.Type
;
...
...
@@ -14,16 +10,16 @@ import org.onlab.onos.net.packet.OutboundPacket;
import
org.onlab.onos.openflow.controller.OpenFlowPacketContext
;
import
org.onlab.packet.Ethernet
;
import
org.projectfloodlight.openflow.types.OFPort
;
import
org.slf4j.Logger
;
public
class
OpenFlowCorePacketContext
extends
DefaultPacketContext
{
import
java.util.List
;
private
final
Logger
log
=
getLogger
(
getClass
());
public
class
OpenFlowCorePacketContext
extends
DefaultPacketContext
{
private
final
OpenFlowPacketContext
ofPktCtx
;
protected
OpenFlowCorePacketContext
(
long
time
,
InboundPacket
inPkt
,
OutboundPacket
outPkt
,
boolean
block
,
OpenFlowPacketContext
ofPktCtx
)
{
OutboundPacket
outPkt
,
boolean
block
,
OpenFlowPacketContext
ofPktCtx
)
{
super
(
time
,
inPkt
,
outPkt
,
block
);
this
.
ofPktCtx
=
ofPktCtx
;
}
...
...
@@ -38,7 +34,6 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
eth
.
deserialize
(
outPacket
().
data
().
array
(),
0
,
outPacket
().
data
().
array
().
length
);
sendPacket
(
eth
);
}
}
...
...
@@ -61,6 +56,7 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
}
ofPktCtx
.
send
();
}
private
OFPort
buildPort
(
PortNumber
port
)
{
return
OFPort
.
of
((
int
)
port
.
toLong
());
}
...
...
Please
register
or
login
to post a comment