added onos-start-network and fake distributed stores and fixed mastership bugs/omissions
Change-Id: I6cf9f1a13bf9e8f715bf5d72249431d94878b204
diff --git a/openflow/api/src/main/java/org/onlab/onos/openflow/controller/driver/AbstractOpenFlowSwitch.java b/openflow/api/src/main/java/org/onlab/onos/openflow/controller/driver/AbstractOpenFlowSwitch.java
index 393246b..69ddc71 100644
--- a/openflow/api/src/main/java/org/onlab/onos/openflow/controller/driver/AbstractOpenFlowSwitch.java
+++ b/openflow/api/src/main/java/org/onlab/onos/openflow/controller/driver/AbstractOpenFlowSwitch.java
@@ -93,12 +93,16 @@
@Override
public final void sendMsg(OFMessage m) {
- this.write(m);
+ if (role == RoleState.MASTER) {
+ this.write(m);
+ }
}
@Override
public final void sendMsg(List<OFMessage> msgs) {
- this.write(msgs);
+ if (role == RoleState.MASTER) {
+ this.write(msgs);
+ }
}
@Override
@@ -164,7 +168,9 @@
*/
@Override
public final void handleMessage(OFMessage m) {
- this.agent.processMessage(dpid, m);
+ if (this.role == RoleState.MASTER) {
+ this.agent.processMessage(dpid, m);
+ }
}
@Override
@@ -226,19 +232,34 @@
@Override
public abstract void processDriverHandshakeMessage(OFMessage m);
+
+ // Role Handling
+
@Override
public void setRole(RoleState role) {
try {
- log.info("Sending role {} to switch {}", role, getStringId());
if (this.roleMan.sendRoleRequest(role, RoleRecvStatus.MATCHED_SET_ROLE)) {
- this.role = role;
+ log.info("Sending role {} to switch {}", role, getStringId());
+ if (role == RoleState.SLAVE || role == RoleState.EQUAL) {
+ this.role = role;
+ }
}
} catch (IOException e) {
log.error("Unable to write to switch {}.", this.dpid);
}
}
- // Role Handling
+ @Override
+ public void reassertRole() {
+ if (this.getRole() == RoleState.MASTER) {
+ log.warn("Received permission error from switch {} while " +
+ "being master. Reasserting master role.",
+ this.getStringId());
+ this.setRole(RoleState.MASTER);
+ }
+ }
+
+
@Override
public void handleRole(OFMessage m) throws SwitchStateException {
@@ -246,11 +267,15 @@
RoleRecvStatus rrs = roleMan.deliverRoleReply(rri);
if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
if (rri.getRole() == RoleState.MASTER) {
+ this.role = rri.getRole();
this.transitionToMasterSwitch();
} else if (rri.getRole() == RoleState.EQUAL ||
- rri.getRole() == RoleState.MASTER) {
+ rri.getRole() == RoleState.SLAVE) {
this.transitionToEqualSwitch();
}
+ } else {
+ return;
+ //TODO: tell people that we failed.
}
}
@@ -267,11 +292,15 @@
new RoleReplyInfo(r, null, m.getXid()));
if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
if (r == RoleState.MASTER) {
+ this.role = r;
this.transitionToMasterSwitch();
} else if (r == RoleState.EQUAL ||
r == RoleState.SLAVE) {
this.transitionToEqualSwitch();
}
+ } else {
+ return;
+ //TODO: tell people that we failed.
}
}
@@ -285,12 +314,7 @@
return true;
}
- @Override
- public void reassertRole() {
- if (this.getRole() == RoleState.MASTER) {
- this.setRole(RoleState.MASTER);
- }
- }
+
@Override
public final void setAgent(OpenFlowAgent ag) {
diff --git a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
index 7850a58..75c139d 100644
--- a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
+++ b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
@@ -521,9 +521,7 @@
// if two controllers are master (even if its only for
// a brief period). We might need to see if these errors
// persist before we reassert
- log.warn("Received permission error from switch {} while" +
- "being master. Reasserting master role.",
- h.getSwitchInfoString());
+
h.sw.reassertRole();
} else if (m.getErrType() == OFErrorType.FLOW_MOD_FAILED &&
((OFFlowModFailedErrorMsg) m).getCode() ==
diff --git a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java
index 7eb2445..b47bada 100644
--- a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java
+++ b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java
@@ -142,9 +142,9 @@
}
// OF1.0 switch with support for NX_ROLE_REQUEST vendor extn.
// make Role.EQUAL become Role.SLAVE
+ pendingRole = role;
role = (role == RoleState.EQUAL) ? RoleState.SLAVE : role;
pendingXid = sendNxRoleRequest(role);
- pendingRole = role;
requestPending = true;
} else {
// OF1.3 switch, use OFPT_ROLE_REQUEST message