Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
tom
2014-09-23 13:21:00 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
8414f3db4bb52915147267106c1c3792f21abed6
8414f3db
2 parents
caf3bf78
afe34ae1
Merge remote-tracking branch 'origin/master'
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
1 deletions
core/api/src/main/java/org/onlab/onos/cluster/MastershipProvider.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipProviderService.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java
core/net/src/main/java/org/onlab/onos/cluster/impl/MastershipManager.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipProvider.java
0 → 100644
View file @
8414f3d
package
org
.
onlab
.
onos
.
cluster
;
import
org.onlab.onos.net.provider.Provider
;
public
interface
MastershipProvider
extends
Provider
{
}
core/api/src/main/java/org/onlab/onos/cluster/MastershipProviderService.java
0 → 100644
View file @
8414f3d
package
org
.
onlab
.
onos
.
cluster
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
import
org.onlab.onos.net.provider.ProviderService
;
public
interface
MastershipProviderService
extends
ProviderService
<
MastershipProvider
>
{
/**
* Signals the core that mastership has changed for a device.
*
* @param deviceId the device ID
* @param role the new mastership role of this controller instance
*/
void
roleChanged
(
DeviceId
deviceId
,
MastershipRole
role
);
}
core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java
View file @
8414f3d
...
...
@@ -25,7 +25,7 @@ public interface MastershipStore {
MastershipRole
role
);
/**
* Adds or updates
the
mastership information for a device.
* Adds or updates mastership information for a device.
*
* @param instance controller instance identifier
* @param deviceId device identifier
...
...
core/net/src/main/java/org/onlab/onos/cluster/impl/MastershipManager.java
0 → 100644
View file @
8414f3d
package
org
.
onlab
.
onos
.
cluster
.
impl
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.Set
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.cluster.MastershipAdminService
;
import
org.onlab.onos.cluster.MastershipEvent
;
import
org.onlab.onos.cluster.MastershipListener
;
import
org.onlab.onos.cluster.MastershipProvider
;
import
org.onlab.onos.cluster.MastershipProviderService
;
import
org.onlab.onos.cluster.MastershipService
;
import
org.onlab.onos.cluster.MastershipStore
;
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.provider.AbstractProviderService
;
import
org.slf4j.Logger
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
public
class
MastershipManager
implements
MastershipService
,
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"
;
private
static
final
String
ROLE_NULL
=
"Mastership role cannot be null"
;
private
final
Logger
log
=
getLogger
(
getClass
());
protected
final
AbstractListenerRegistry
<
MastershipEvent
,
MastershipListener
>
listenerRegistry
=
new
AbstractListenerRegistry
<>();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
MastershipStore
store
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
EventDeliveryService
eventDispatcher
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
ClusterManager
clusterManager
;
@Activate
public
void
activate
()
{
eventDispatcher
.
addSink
(
MastershipEvent
.
class
,
listenerRegistry
);
log
.
info
(
"Started"
);
}
@Deactivate
public
void
deactivate
()
{
eventDispatcher
.
removeSink
(
MastershipEvent
.
class
);
log
.
info
(
"Stopped"
);
}
@Override
public
void
setRole
(
NodeId
nodeId
,
DeviceId
deviceId
,
MastershipRole
role
)
{
checkNotNull
(
nodeId
,
NODE_ID_NULL
);
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
checkNotNull
(
role
,
ROLE_NULL
);
store
.
setRole
(
nodeId
,
deviceId
,
role
);
}
@Override
public
NodeId
getMasterFor
(
DeviceId
deviceId
)
{
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
return
store
.
getMaster
(
deviceId
);
}
@Override
public
Set
<
DeviceId
>
getDevicesOf
(
NodeId
nodeId
)
{
checkNotNull
(
nodeId
,
NODE_ID_NULL
);
return
store
.
getDevices
(
nodeId
);
}
@Override
public
MastershipRole
requestRoleFor
(
DeviceId
deviceId
)
{
checkNotNull
(
deviceId
,
DEVICE_ID_NULL
);
NodeId
id
=
clusterManager
.
getLocalNode
().
id
();
return
store
.
getRole
(
id
,
deviceId
);
}
@Override
public
void
addListener
(
MastershipListener
listener
)
{
checkNotNull
(
listener
);
listenerRegistry
.
addListener
(
listener
);
}
@Override
public
void
removeListener
(
MastershipListener
listener
)
{
checkNotNull
(
listener
);
listenerRegistry
.
removeListener
(
listener
);
}
private
class
InternalMastershipProviderService
extends
AbstractProviderService
<
MastershipProvider
>
implements
MastershipProviderService
{
protected
InternalMastershipProviderService
(
MastershipProvider
provider
)
{
super
(
provider
);
}
@Override
public
void
roleChanged
(
DeviceId
deviceId
,
MastershipRole
role
)
{
// TODO Auto-generated method stub
}
}
// Posts the specified event to the local event dispatcher.
private
void
post
(
MastershipEvent
event
)
{
if
(
event
!=
null
&&
eventDispatcher
!=
null
)
{
eventDispatcher
.
post
(
event
);
}
}
}
Please
register
or
login
to post a comment