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
alshabib
2014-09-22 15:41:29 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
a4b31bf111a5e2d874416714661077cf3749d905
a4b31bf1
2 parents
219ebaae
8b3270fb
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
5 deletions
core/api/src/main/java/org/onlab/onos/cluster/MastershipEvent.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipListener.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
core/api/src/main/java/org/onlab/onos/cluster/MastershipEvent.java
0 → 100644
View file @
a4b31bf
package
org
.
onlab
.
onos
.
cluster
;
import
org.onlab.onos.event.AbstractEvent
;
import
org.onlab.onos.net.DeviceId
;
/**
* Describes infrastructure device event.
*/
public
class
MastershipEvent
extends
AbstractEvent
<
MastershipEvent
.
Type
,
DeviceId
>
{
InstanceId
master
;
/**
* Type of mastership events.
*/
public
enum
Type
{
/**
* Signifies that the master for a device has changed.
*/
MASTER_CHANGED
}
/**
* Creates an event of a given type and for the specified device, master,
* and the current time.
*
* @param type device event type
* @param device event device subject
* @param master master ID subject
*/
protected
MastershipEvent
(
Type
type
,
DeviceId
device
,
InstanceId
master
)
{
super
(
type
,
device
);
this
.
master
=
master
;
}
/**
* Creates an event of a given type and for the specified device, master,
* and time.
*
* @param type mastership event type
* @param device event device subject
* @param master master ID subject
* @param time occurrence time
*/
protected
MastershipEvent
(
Type
type
,
DeviceId
device
,
InstanceId
master
,
long
time
)
{
super
(
type
,
device
,
time
);
this
.
master
=
master
;
}
/**
* Returns the current master's ID as a subject.
*
* @return master ID subject
*/
public
InstanceId
master
()
{
return
master
;
}
}
core/api/src/main/java/org/onlab/onos/cluster/MastershipListener.java
0 → 100644
View file @
a4b31bf
package
org
.
onlab
.
onos
.
cluster
;
import
org.onlab.onos.event.EventListener
;
/**
* Entity capable of receiving device mastership-related events.
*/
public
interface
MastershipListener
extends
EventListener
<
MastershipEvent
>{
}
core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
View file @
a4b31bf
package
org
.
onlab
.
onos
.
cluster
;
import
java.util.Set
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.MastershipRole
;
/**
* Service responsible for determining the controller instance mastership of
* a device in a clustered environment. This is the central authority for
...
...
@@ -8,12 +13,42 @@ package org.onlab.onos.cluster;
*/
public
interface
MastershipService
{
// InstanceId getMasterFor(DeviceId deviceId)
// Set<DeviceId> getDevicesOf(InstanceId instanceId);
/**
* Returns the current master for a given device.
*
* @param deviceId the identifier of the device
* @return the ID of the master controller for the device
*/
InstanceId
getMasterFor
(
DeviceId
deviceId
);
/**
* Returns the devices for which a controller is master.
*
* @param instanceId the ID of the controller
* @return a set of device IDs
*/
Set
<
DeviceId
>
getDevicesOf
(
InstanceId
instanceId
);
/**
* Returns the mastership status of this controller for a given device.
*
* @param deviceId the the identifier of the device
* @return the role of this controller instance
*/
MastershipRole
requestRoleFor
(
DeviceId
deviceId
);
// MastershipRole requestRoleFor(DeviceId deviceId);
/**
* Adds the specified mastership listener.
*
* @param listener the mastership listener
*/
void
addListener
(
MastershipListener
listener
);
// addListener/removeLister(MastershipListener listener);
// types of events would be MASTER_CHANGED (subject ==> deviceId; master ==> instanceId)
/**
* Removes the specified device listener.
*
* @param listener the mastership listener
*/
void
removeListemer
(
MastershipListener
listener
);
}
...
...
Please
register
or
login
to post a comment