Skip to content
Snippets Groups Projects
Commit cb07c688 authored by Monoreet Mutsuddi's avatar Monoreet Mutsuddi
Browse files

dont update Switch/Port table on SLAVE

parent 5f87ec5f
No related branches found
No related tags found
No related merge requests found
......@@ -354,6 +354,10 @@ public class Controller implements IFloodlightProviderService,
@Override
public void setRole(Role role) {
if (role == null) throw new NullPointerException("Role can not be null.");
if (role == Role.MASTER && this.role == Role.SLAVE) {
// Reset db state to Inactive for all switches.
updateAllInactiveSwitchInfo();
}
// Need to synchronize to ensure a reliable ordering on role request
// messages send and to ensure the list of connected switches is stable
......@@ -369,10 +373,6 @@ public class Controller implements IFloodlightProviderService,
Role oldRole = this.role;
this.role = role;
if (role == Role.MASTER) {
updateAllInactiveSwitchInfo();
}
log.debug("Submitting role change request to role {}", role);
roleChanger.submitRequest(connectedSwitches, role);
......@@ -1487,6 +1487,9 @@ public class Controller implements IFloodlightProviderService,
// **************
protected void updateAllInactiveSwitchInfo() {
if (role == Role.SLAVE) {
return;
}
String controllerId = getControllerId();
String[] switchColumns = { SWITCH_DATAPATH_ID,
SWITCH_CONTROLLER_ID,
......@@ -1544,6 +1547,9 @@ public class Controller implements IFloodlightProviderService,
}
protected void updateActiveSwitchInfo(IOFSwitch sw) {
if (role == Role.SLAVE) {
return;
}
// Obtain the row info for the switch
Map<String, Object> switchInfo = new HashMap<String, Object>();
String datapathIdString = sw.getStringId();
......@@ -1588,6 +1594,9 @@ public class Controller implements IFloodlightProviderService,
}
protected void updateInactiveSwitchInfo(IOFSwitch sw) {
if (role == Role.SLAVE) {
return;
}
log.debug("Update DB with inactiveSW {}", sw);
// Update the controller info in the storage source to be inactive
Map<String, Object> switchInfo = new HashMap<String, Object>();
......@@ -1599,6 +1608,9 @@ public class Controller implements IFloodlightProviderService,
}
protected void updatePortInfo(IOFSwitch sw, OFPhysicalPort port) {
if (role == Role.SLAVE) {
return;
}
String datapathIdString = sw.getStringId();
Map<String, Object> portInfo = new HashMap<String, Object>();
int portNumber = U16.f(port.getPortNumber());
......@@ -1672,6 +1684,9 @@ public class Controller implements IFloodlightProviderService,
}
protected void removePortInfo(IOFSwitch sw, short portNumber) {
if (role == Role.SLAVE) {
return;
}
String datapathIdString = sw.getStringId();
String id = datapathIdString + "|" + portNumber;
storageSource.deleteRowAsync(PORT_TABLE_NAME, id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment