diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java index e20c11250966cce8914ae87e1802d5d253a8a5c8..2a6162e70648e7830ae4dbabd3056485cd16143e 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java @@ -105,13 +105,6 @@ public interface IOFSwitch { */ public void disconnectOutputStream(); - /** - * FIXME: remove getChannel(). All access to the channel should be through - * wrapper functions in IOFSwitch - * @return - */ - public Channel getChannel(); - /** * Returns switch features from features Reply * @return diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 55eb924ddb6a596c6aa2a2845bce1faf46ba635f..81a91c5f7f024ee93e182d479acd27a11a02ba85 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -865,7 +865,7 @@ public class Controller implements IFloodlightProviderService, break; default: log.error("Invalid role value in role reply message"); - sw.getChannel().close(); + sw.disconnectOutputStream(); return; } @@ -1123,7 +1123,7 @@ public class Controller implements IFloodlightProviderService, // to make sure that the switch eventually accepts one // of our requests or disconnect the switch. This feels // cumbersome. - sw.getChannel().close(); + sw.disconnectOutputStream(); } } // Once we support OF 1.2, we'd add code to handle it here. @@ -1479,7 +1479,7 @@ public class Controller implements IFloodlightProviderService, // a "Not removing Switch ... already removed debug message. // TODO: Figure out a way to handle this that avoids the // spurious debug message. - oldSw.getChannel().close(); + oldSw.disconnectOutputStream(); } finally { oldSw.getListenerWriteLock().unlock(); diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java index 9aef5c1b4be6da9084dd46c9c396b722117d1ff0..4167df9bdfdec78663dea38d9da1f69e25b77233 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java +++ b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java @@ -167,12 +167,6 @@ public class OFSwitchImpl implements IOFSwitch { return this.attributes.containsKey(name); } - @Override - @JsonIgnore - public Channel getChannel() { - return this.channel; - } - @JsonIgnore public void setChannel(Channel channel) { this.channel = channel; diff --git a/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java b/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java index cf13919c06c55150a5ebd1673594203a6dd768ce..2e66069f43c278380ba2fa4003648dfd44c1591e 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java +++ b/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java @@ -288,7 +288,7 @@ public class RoleChanger { log.warn("Failed to send role request message " + "to switch {}: {}. Disconnecting", sw, e); - sw.getChannel().close(); + sw.disconnectOutputStream(); iter.remove(); } catch (HARoleUnsupportedException e) { // Switch doesn't support HA role, remove if role is slave @@ -297,7 +297,7 @@ public class RoleChanger { "role request messages from a controller that went to SLAVE mode"); // Closing the channel should result in a call to // channelDisconnect which updates all state - sw.getChannel().close(); + sw.disconnectOutputStream(); iter.remove(); } } diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index 45e02915901cb759c3dd6b76efb439e4e14e344d..a4daaa11543abcf2ba011a2c9fbe7312a92a2f4d 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -2000,15 +2000,12 @@ IFloodlightModule, IInfoProvider, IHAListener { evTopoSwitch = new EventHistoryTopologySwitch(); } evTopoSwitch.dpid = sw.getId(); - if ((sw.getChannel() != null) && - (SocketAddress.class.isInstance( - sw.getChannel().getRemoteAddress()))) { - evTopoSwitch.ipv4Addr = - IPv4.toIPv4Address(((InetSocketAddress)(sw.getChannel(). - getRemoteAddress())).getAddress().getAddress()); + if ((SocketAddress.class.isInstance(sw.getInetAddress()))) { + evTopoSwitch.ipv4Addr = IPv4.toIPv4Address( + ((InetSocketAddress)(sw.getInetAddress())) + .getAddress().getAddress()); evTopoSwitch.l4Port = - ((InetSocketAddress)(sw.getChannel(). - getRemoteAddress())).getPort(); + ((InetSocketAddress)(sw.getInetAddress())).getPort(); } else { evTopoSwitch.ipv4Addr = 0; evTopoSwitch.l4Port = 0; diff --git a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java index a4ee23073aa462db36295c529a48ffebee16519d..96c5aa2c05cad6b476d27626393e1614e517084a 100644 --- a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java +++ b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java @@ -1108,8 +1108,7 @@ public class ControllerTest extends FloodlightTestCase int xid = 424242; Controller.OFChannelHandler chdlr = getChannelHandlerForRoleReplyTest(); Channel ch = createMock(Channel.class); - expect(chdlr.sw.getChannel()).andReturn(ch); - expect(ch.close()).andReturn(null); + chdlr.sw.disconnectOutputStream(); OFVendor msg = getRoleReplyMsgForRoleReplyTest(xid, 232323); replay(chdlr.sw, ch); chdlr.processOFMessage(msg); diff --git a/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java b/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java index 0b068824bfb4a8d1a33f14848c4afda4521a6877..b9a93cf472fd846b2932b8ca13a82af014695eeb 100644 --- a/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java +++ b/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java @@ -41,17 +41,15 @@ public class RoleChangerTest { // a switch that doesn't support role requests OFSwitchImpl sw1 = EasyMock.createMock(OFSwitchImpl.class); - Channel channel1 = createMock(Channel.class); - expect(sw1.getChannel()).andReturn(channel1); // No support for NX_ROLE expect(sw1.sendHARoleRequest(Role.SLAVE, 123456)) .andThrow(new HARoleUnsupportedException()).once();; - expect(channel1.close()).andReturn(null); + sw1.disconnectOutputStream(); switches.add(sw1); - replay(sw1, channel1); + replay(sw1); roleChanger.sendRoleRequest(switches, Role.SLAVE, 123456); - verify(sw1, channel1); + verify(sw1); // sendRoleRequest needs to remove the switch from the list since // it closed its connection @@ -93,9 +91,7 @@ public class RoleChangerTest { // No support for NX_ROLE expect(sw1.sendHARoleRequest(Role.MASTER, 123456)) .andThrow(new IOException()).once(); - Channel channel1 = createMock(Channel.class); - expect(sw1.getChannel()).andReturn(channel1); - expect(channel1.close()).andReturn(null); + sw1.disconnectOutputStream(); switches.add(sw1); replay(sw1); diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java index 0d27c488fb2c655252258165bb19e63896421afd..752d485785a5492d41a4de314e7d06f004a98878 100644 --- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java +++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java @@ -100,12 +100,6 @@ public class OFMessageDamperMockSwitch implements IOFSwitch { assertTrue("Unexpected method call", false); } - @Override - public Channel getChannel() { - assertTrue("Unexpected method call", false); - return null; - } - @Override public void setFeaturesReply(OFFeaturesReply featuresReply) { assertTrue("Unexpected method call", false);