本文整理汇总了Java中net.floodlightcontroller.core.HARole.STANDBY属性的典型用法代码示例。如果您正苦于以下问题:Java HARole.STANDBY属性的具体用法?Java HARole.STANDBY怎么用?Java HARole.STANDBY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.floodlightcontroller.core.HARole
的用法示例。
在下文中一共展示了HARole.STANDBY属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
@Override
public void run() {
try {
if (ldUpdates.peek() != null) {
updateTopology();
}
handleMiscellaneousPeriodicEvents();
}
catch (Exception e) {
log.error("Error in topology instance task thread", e);
} finally {
if (floodlightProviderService.getRole() != HARole.STANDBY) {
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS, TimeUnit.MILLISECONDS);
}
}
}
示例2: startUp
@Override
public void startUp(FloodlightModuleContext context) {
clearCurrentTopology();
// Initialize role to floodlight provider role.
this.role = floodlightProviderService.getRole();
ScheduledExecutorService ses = threadPoolService.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());
if (role != HARole.STANDBY) {
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS, TimeUnit.MILLISECONDS);
}
linkDiscoveryService.addListener(this);
floodlightProviderService.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProviderService.addHAListener(this.haListener);
addRestletRoutable();
}
示例3: switchAddedToStore
/**
* Called when we receive a store notification about a new or updated
* switch.
* @param sw
*/
private synchronized void switchAddedToStore(IOFSwitch sw) {
if (floodlightProvider.getRole() != HARole.STANDBY) {
return; // only read from store if slave
}
DatapathId dpid = sw.getId();
IOFSwitch oldSw = syncedSwitches.put(dpid, sw);
if (oldSw == null) {
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.ADDED));
} else {
// The switch already exists in storage, see if anything
// has changed
sendNotificationsIfSwitchDiffers(oldSw, sw);
}
}
示例4: startUp
@Override
public void startUp(FloodlightModuleContext context) {
clearCurrentTopology();
// Initialize role to floodlight provider role.
this.role = floodlightProviderService.getRole();
ScheduledExecutorService ses = threadPoolService.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());
if (role != HARole.STANDBY)
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
TimeUnit.MILLISECONDS);
linkDiscoveryService.addListener(this);
floodlightProviderService.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProviderService.addHAListener(this.haListener);
addRestletRoutable();
}
示例5: getInitialRole
@LogMessageDocs({
@LogMessageDoc(message="Controller role set to {role}",
explanation="Setting the initial HA role to "),
@LogMessageDoc(level="ERROR",
message="Invalid current role value: {role}",
explanation="An invalid HA role value was read from the " +
"properties file",
recommendation=LogMessageDoc.CHECK_CONTROLLER)
})
protected HARole getInitialRole(Map<String, String> configParams) {
HARole role = HARole.STANDBY;
String roleString = configParams.get("role");
if (roleString != null) {
try {
role = HARole.valueOfBackwardsCompatible(roleString);
}
catch (IllegalArgumentException exc) {
log.error("Invalid current role value: {}", roleString);
}
}
log.info("Controller role set to {}", role);
return role;
}
示例6: setRole
/**
* Set the controller's new role and notify switches.
*
* This method updates the controllers current role and notifies all
* connected switches of the new role is different from the current
* role. We dampen calls to this method. See class description for
* details.
*
* @param role The new role.
* @param roleChangeDescription A textual description of why the role
* was changed. For information purposes only.
* @throws NullPointerException if role or roleChangeDescription is null
*/
public synchronized void setRole(@Nonnull HARole role, @Nonnull String roleChangeDescription) {
Preconditions.checkNotNull(role, "role must not be null");
Preconditions.checkNotNull(roleChangeDescription, "roleChangeDescription must not be null");
if (role == getRole()) {
counters.setSameRole.increment();
log.debug("Received role request for {} but controller is "
+ "already {}. Ignoring it.", role, this.getRole());
return;
}
if (this.getRole() == HARole.STANDBY && role == HARole.ACTIVE) {
// At this point we are guaranteed that we will execute the code
// below exactly once during the lifetime of this process! And
// it will be a to MASTER transition
counters.setRoleMaster.increment();
}
log.info("Received role request for {} (reason: {})."
+ " Initiating transition", role, roleChangeDescription);
currentRoleInfo =
new RoleInfo(role, roleChangeDescription, new Date());
controller.addUpdateToQueue(new HARoleUpdate(role));
controller.addUpdateToQueue(new SwitchRoleUpdate(role));
}
示例7: dispatch
@Override
public void dispatch() {
if (log.isDebugEnabled()) {
log.debug("Dispatching HA Role update newRole = {}",
newRole);
}
for (IHAListener listener : controller.haListeners.getOrderedListeners()) {
if (log.isTraceEnabled()) {
log.trace("Calling HAListener {} with transitionTo{}",
listener.getName(), newRole);
}
switch(newRole) {
case ACTIVE:
listener.transitionToActive();
break;
case STANDBY:
listener.transitionToStandby();
break;
}
}
controller.setNotifiedRole(newRole);
if(newRole == HARole.STANDBY) {
String reason = String.format("Received role request to "
+ "transition from ACTIVE to STANDBY (reason: %s)",
getRoleInfo().getRoleChangeDescription());
shutdownService.terminate(reason, 0);
}
}
示例8: switchRemovedFromStore
/**
* Called when we receive a store notification about a switch that
* has been removed from the sync store
* @param dpid
*/
private synchronized void switchRemovedFromStore(DatapathId dpid) {
if (floodlightProvider.getRole() != HARole.STANDBY) {
return; // only read from store if slave
}
IOFSwitch oldSw = syncedSwitches.remove(dpid);
if (oldSw != null) {
addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
} else {
// TODO: the switch was deleted (tombstone) before we ever
// knew about it (or was deleted repeatedly). Can this
// happen? When/how?
}
}
示例9: run
@Override
public void run() {
try {
if (ldUpdates.peek() != null)
updateTopology();
handleMiscellaneousPeriodicEvents();
}
catch (Exception e) {
log.error("Error in topology instance task thread", e);
} finally {
if (floodlightProviderService.getRole() != HARole.STANDBY)
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
TimeUnit.MILLISECONDS);
}
}
示例10: dispatch
@Override
public void dispatch() {
if (log.isDebugEnabled()) {
log.debug("Dispatching HA Role update newRole = {}",
newRole);
}
for (IHAListener listener : controller.haListeners.getOrderedListeners()) {
if (log.isTraceEnabled()) {
log.trace("Calling HAListener {} with transitionTo{}",
listener.getName(), newRole);
}
switch(newRole) {
case ACTIVE:
listener.transitionToActive();
break;
case STANDBY:
listener.transitionToStandby();
case EQUAL:
listener.transitionToEQUAL();
break;
}
}
controller.setNotifiedRole(newRole);
if(newRole == HARole.STANDBY) {
String reason = String.format("Received role request to "
+ "transition from ACTIVE to STANDBY (reason: %s)",
getRoleInfo().getRoleChangeDescription());
shutdownService.terminate(reason, 0);
}
}
示例11: getInitialRole
/**
* Sets the initial role based on properties in the config params.
* It looks for two different properties.
* If the "role" property is specified then the value should be
* either "EQUAL", "MASTER", or "SLAVE" and the role of the
* controller is set to the specified value. If the "role" property
* is not specified then it looks next for the "role.path" property.
* In this case the value should be the path to a property file in
* the file system that contains a property called "floodlight.role"
* which can be one of the values listed above for the "role" property.
* The idea behind the "role.path" mechanism is that you have some
* separate heartbeat and master controller election algorithm that
* determines the role of the controller. When a role transition happens,
* it updates the current role in the file specified by the "role.path"
* file. Then if floodlight restarts for some reason it can get the
* correct current role of the controller from the file.
* @param configParams The config params for the FloodlightProvider service
* @return A valid role if role information is specified in the
* config params, otherwise null
*/
protected HARole getInitialRole(Map<String, String> configParams) {
HARole role = HARole.STANDBY;
String roleString = configParams.get("role");
if (roleString != null) {
try {
role = HARole.valueOfBackwardsCompatible(roleString);
}
catch (IllegalArgumentException exc) {
log.error("Invalid current role value: {}", roleString);
}
}
log.info("Controller role set to {}", role);
return role;
}