Skip to content
Snippets Groups Projects
Commit 71e8403e authored by kwanggithub's avatar kwanggithub
Browse files

Merge branch 'backport' of ../bsc/bigswitchcontroller

parents 3b9514b6 e6275863
No related branches found
No related tags found
No related merge requests found
......@@ -374,6 +374,16 @@ public interface IOFSwitch {
* @return value for name
*/
Object getAttribute(String name);
/**
* Check if the given attribute is present and if so whether it is equal
* to "other"
* @param name the name of the attribute to check
* @param other the object to compare the attribute against.
* @return true iff the specified attribute is set and equals() the given
* other object.
*/
boolean attributeEquals(String name, Object other);
/**
* Set properties for switch specific behavior
......
......@@ -147,13 +147,20 @@ public abstract class OFSwitchBase implements IOFSwitch {
this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, new Boolean(true));
}
@Override
public boolean attributeEquals(String name, Object other) {
Object attr = this.attributes.get(name);
if (attr == null)
return false;
return attr.equals(other);
}
@Override
public Object getAttribute(String name) {
if (this.attributes.containsKey(name)) {
return this.attributes.get(name);
}
return null;
// returns null if key doesn't exist
return this.attributes.get(name);
}
@Override
......@@ -172,6 +179,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
return this.attributes.containsKey(name);
}
@Override
@JsonIgnore
public void setChannel(Channel channel) {
this.channel = channel;
......@@ -452,6 +460,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
this.floodlightProvider = floodlightProvider;
}
@Override
@JsonIgnore
public void setThreadPoolService(IThreadPoolService tp) {
this.threadPool = tp;
......@@ -560,6 +569,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
* switch list from being modified out from under the listeners.
* @return
*/
@Override
@JsonIgnore
public Lock getListenerReadLock() {
return listenerLock.readLock();
......@@ -572,6 +582,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
* message from the switch.
* @return
*/
@Override
@JsonIgnore
public Lock getListenerWriteLock() {
return listenerLock.writeLock();
......@@ -581,6 +592,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
* Get the IP Address for the switch
* @return the inet address
*/
@Override
@JsonSerialize(using=ToStringSerializer.class)
public SocketAddress getInetAddress() {
return channel.getRemoteAddress();
......
......@@ -187,7 +187,7 @@ public class RoleChanger {
@LogMessageDoc(level="ERROR",
message="RoleRequestWorker task had an uncaught exception.",
explanation="An unknown occured while processing an HA " +
"role change event.",
"role change event.",
recommendation=LogMessageDoc.GENERIC_ACTION)
protected class RoleRequestWorker extends Thread {
@Override
......@@ -278,7 +278,7 @@ public class RoleChanger {
message="Failed to send role request message " +
"to switch {switch}: {message}. Disconnecting",
explanation="An I/O error occurred while attempting to change " +
"the switch HA role.",
"the switch HA role.",
recommendation=LogMessageDoc.CHECK_SWITCH)
protected void sendRoleRequest(Collection<IOFSwitch> switches,
Role role, long cookie) {
......@@ -331,7 +331,7 @@ public class RoleChanger {
message="Timeout while waiting for role reply from switch {switch}."
+ " Disconnecting",
explanation="Timed out waiting for the switch to respond to " +
"a request to change the HA role.",
"a request to change the HA role.",
recommendation=LogMessageDoc.CHECK_SWITCH)
protected void verifyRoleReplyReceived(Collection<IOFSwitch> switches,
long cookie) {
......@@ -425,8 +425,11 @@ public class RoleChanger {
* @return
*/
public boolean checkFirstPendingRoleRequestXid (IOFSwitch sw, int xid) {
LinkedList<PendingRoleRequestEntry> pendingRoleRequests =
pendingRequestMap.get(sw);
LinkedList<PendingRoleRequestEntry> pendingRoleRequests;
if (sw == null) {
return false;
}
pendingRoleRequests = pendingRequestMap.get(sw);
if (pendingRoleRequests == null) {
return false;
}
......
......@@ -390,6 +390,19 @@ public class RoleChangerTest {
roleChanger.checkFirstPendingRoleRequestXid(sw, xid));
}
@Test
public void testCheckFirstPendingRoleRequestNullSw() {
int xid = 54321;
long cookie = 232323;
Role role = Role.MASTER;
OFSwitchImpl sw = new OFSwitchImpl();
setupPendingRoleRequest(sw, xid, role, cookie);
// pass null as sw object, which is true during handshake
assertEquals(false,
roleChanger.checkFirstPendingRoleRequestXid(null, xid));
roleChanger.pendingRequestMap.get(sw).clear();
}
@Test
public void testCheckFirstPendingRoleRequestCookie() {
int xid = 54321;
......
......@@ -398,4 +398,10 @@ public class OFMessageDamperMockSwitch implements IOFSwitch {
return null;
}
@Override
public boolean attributeEquals(String name, Object other) {
fail("Unexpected method call");
return false;
}
}
\ No newline at end of file
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