Committed by
Thomas Vachuska
Remove all address bindings code from Host subsystem.
This has been superseded by the InterfaceService. Change-Id: I8aae4cfe00752a84e545a1030c199aea8b59da38
Showing
18 changed files
with
26 additions
and
895 deletions
| ... | @@ -21,7 +21,6 @@ import org.onlab.packet.MacAddress; | ... | @@ -21,7 +21,6 @@ import org.onlab.packet.MacAddress; |
| 21 | import org.onlab.packet.VlanId; | 21 | import org.onlab.packet.VlanId; |
| 22 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
| 23 | import org.onosproject.net.host.InterfaceIpAddress; | 23 | import org.onosproject.net.host.InterfaceIpAddress; |
| 24 | -import org.onosproject.net.host.PortAddresses; | ||
| 25 | 24 | ||
| 26 | import java.util.Objects; | 25 | import java.util.Objects; |
| 27 | import java.util.Set; | 26 | import java.util.Set; |
| ... | @@ -55,18 +54,6 @@ public class Interface { | ... | @@ -55,18 +54,6 @@ public class Interface { |
| 55 | } | 54 | } |
| 56 | 55 | ||
| 57 | /** | 56 | /** |
| 58 | - * Creates an Interface based on a PortAddresses object. | ||
| 59 | - * | ||
| 60 | - * @param portAddresses the PortAddresses object to turn into an Interface | ||
| 61 | - */ | ||
| 62 | - public Interface(PortAddresses portAddresses) { | ||
| 63 | - connectPoint = portAddresses.connectPoint(); | ||
| 64 | - ipAddresses = Sets.newHashSet(portAddresses.ipAddresses()); | ||
| 65 | - macAddress = portAddresses.mac(); | ||
| 66 | - vlan = portAddresses.vlan(); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - /** | ||
| 70 | * Retrieves the connection point that this interface maps to. | 57 | * Retrieves the connection point that this interface maps to. |
| 71 | * | 58 | * |
| 72 | * @return the connection point | 59 | * @return the connection point | ... | ... |
apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.routing.config.impl; | ||
| 17 | - | ||
| 18 | -import com.google.common.collect.Sets; | ||
| 19 | -import org.onlab.packet.IpAddress; | ||
| 20 | -import org.onosproject.net.ConnectPoint; | ||
| 21 | -import org.onosproject.net.host.HostService; | ||
| 22 | -import org.onosproject.net.host.InterfaceIpAddress; | ||
| 23 | -import org.onosproject.net.host.PortAddresses; | ||
| 24 | -import org.onosproject.routing.config.Interface; | ||
| 25 | - | ||
| 26 | -import java.util.Set; | ||
| 27 | - | ||
| 28 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 29 | - | ||
| 30 | -/** | ||
| 31 | - * Adapts PortAddresses data from the HostService into Interface data used by | ||
| 32 | - * the routing module. | ||
| 33 | - */ | ||
| 34 | -public class HostToInterfaceAdaptor { | ||
| 35 | - | ||
| 36 | - private final HostService hostService; | ||
| 37 | - | ||
| 38 | - public HostToInterfaceAdaptor(HostService hostService) { | ||
| 39 | - this.hostService = checkNotNull(hostService); | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - public Set<Interface> getInterfaces() { | ||
| 43 | - Set<PortAddresses> addresses = hostService.getAddressBindings(); | ||
| 44 | - Set<Interface> interfaces = Sets.newHashSetWithExpectedSize(addresses.size()); | ||
| 45 | - for (PortAddresses a : addresses) { | ||
| 46 | - interfaces.add(new Interface(a)); | ||
| 47 | - } | ||
| 48 | - return interfaces; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - public Interface getInterface(ConnectPoint connectPoint) { | ||
| 52 | - checkNotNull(connectPoint); | ||
| 53 | - | ||
| 54 | - Set<PortAddresses> portAddresses = | ||
| 55 | - hostService.getAddressBindingsForPort(connectPoint); | ||
| 56 | - | ||
| 57 | - for (PortAddresses addresses : portAddresses) { | ||
| 58 | - if (addresses.connectPoint().equals(connectPoint)) { | ||
| 59 | - return new Interface(addresses); | ||
| 60 | - } | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - return null; | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - public Interface getInterface(IpAddress ip) { | ||
| 67 | - Set<PortAddresses> portAddresses = hostService.getAddressBindings(); | ||
| 68 | - | ||
| 69 | - for (PortAddresses portAddress : portAddresses) { | ||
| 70 | - for (InterfaceIpAddress portIp : portAddress.ipAddresses()) { | ||
| 71 | - if (portIp.ipAddress().equals(ip)) { | ||
| 72 | - return new Interface(portAddress); | ||
| 73 | - } | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - return null; | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - public Interface getMatchingInterface(IpAddress ipAddress) { | ||
| 81 | - checkNotNull(ipAddress); | ||
| 82 | - | ||
| 83 | - for (PortAddresses portAddresses : hostService.getAddressBindings()) { | ||
| 84 | - for (InterfaceIpAddress ia : portAddresses.ipAddresses()) { | ||
| 85 | - if (ia.subnetAddress().contains(ipAddress)) { | ||
| 86 | - return new Interface(portAddresses); | ||
| 87 | - } | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - return null; | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | -} |
| ... | @@ -38,7 +38,6 @@ import org.onosproject.net.config.ConfigFactory; | ... | @@ -38,7 +38,6 @@ import org.onosproject.net.config.ConfigFactory; |
| 38 | import org.onosproject.net.config.NetworkConfigRegistry; | 38 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 39 | import org.onosproject.net.config.NetworkConfigService; | 39 | import org.onosproject.net.config.NetworkConfigService; |
| 40 | import org.onosproject.net.config.basics.SubjectFactories; | 40 | import org.onosproject.net.config.basics.SubjectFactories; |
| 41 | -import org.onosproject.net.host.HostService; | ||
| 42 | import org.onosproject.routing.config.BgpConfig; | 41 | import org.onosproject.routing.config.BgpConfig; |
| 43 | import org.onosproject.routing.config.BgpPeer; | 42 | import org.onosproject.routing.config.BgpPeer; |
| 44 | import org.onosproject.routing.config.BgpSpeaker; | 43 | import org.onosproject.routing.config.BgpSpeaker; |
| ... | @@ -76,9 +75,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { | ... | @@ -76,9 +75,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { |
| 76 | private String configFileName = DEFAULT_CONFIG_FILE; | 75 | private String configFileName = DEFAULT_CONFIG_FILE; |
| 77 | 76 | ||
| 78 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 77 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 79 | - protected HostService hostService; | ||
| 80 | - | ||
| 81 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 82 | protected NetworkConfigRegistry registry; | 78 | protected NetworkConfigRegistry registry; |
| 83 | 79 | ||
| 84 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 80 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| ... | @@ -103,7 +99,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { | ... | @@ -103,7 +99,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { |
| 103 | new DefaultByteArrayNodeFactory()); | 99 | new DefaultByteArrayNodeFactory()); |
| 104 | 100 | ||
| 105 | private MacAddress virtualGatewayMacAddress; | 101 | private MacAddress virtualGatewayMacAddress; |
| 106 | - private HostToInterfaceAdaptor hostAdaptor; | ||
| 107 | 102 | ||
| 108 | private ConfigFactory configFactory = | 103 | private ConfigFactory configFactory = |
| 109 | new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, BgpConfig.class, "bgp") { | 104 | new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, BgpConfig.class, "bgp") { |
| ... | @@ -117,7 +112,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { | ... | @@ -117,7 +112,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { |
| 117 | public void activate() { | 112 | public void activate() { |
| 118 | registry.registerConfigFactory(configFactory); | 113 | registry.registerConfigFactory(configFactory); |
| 119 | readConfiguration(); | 114 | readConfiguration(); |
| 120 | - hostAdaptor = new HostToInterfaceAdaptor(hostService); | ||
| 121 | log.info("Routing configuration service started"); | 115 | log.info("Routing configuration service started"); |
| 122 | } | 116 | } |
| 123 | 117 | ||
| ... | @@ -189,7 +183,7 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { | ... | @@ -189,7 +183,7 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { |
| 189 | 183 | ||
| 190 | @Override | 184 | @Override |
| 191 | public Set<Interface> getInterfaces() { | 185 | public Set<Interface> getInterfaces() { |
| 192 | - return hostAdaptor.getInterfaces(); | 186 | + return Collections.emptySet(); |
| 193 | } | 187 | } |
| 194 | 188 | ||
| 195 | @Override | 189 | @Override |
| ... | @@ -212,17 +206,17 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { | ... | @@ -212,17 +206,17 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { |
| 212 | 206 | ||
| 213 | @Override | 207 | @Override |
| 214 | public Interface getInterface(ConnectPoint connectPoint) { | 208 | public Interface getInterface(ConnectPoint connectPoint) { |
| 215 | - return hostAdaptor.getInterface(connectPoint); | 209 | + return null; |
| 216 | } | 210 | } |
| 217 | 211 | ||
| 218 | @Override | 212 | @Override |
| 219 | public Interface getInterface(IpAddress ip) { | 213 | public Interface getInterface(IpAddress ip) { |
| 220 | - return hostAdaptor.getInterface(ip); | 214 | + return null; |
| 221 | } | 215 | } |
| 222 | 216 | ||
| 223 | @Override | 217 | @Override |
| 224 | public Interface getMatchingInterface(IpAddress ipAddress) { | 218 | public Interface getMatchingInterface(IpAddress ipAddress) { |
| 225 | - return hostAdaptor.getMatchingInterface(ipAddress); | 219 | + return null; |
| 226 | } | 220 | } |
| 227 | 221 | ||
| 228 | @Override | 222 | @Override | ... | ... |
| 1 | -/* | ||
| 2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.routing.config.impl; | ||
| 17 | - | ||
| 18 | -import com.google.common.collect.Maps; | ||
| 19 | -import com.google.common.collect.Sets; | ||
| 20 | -import org.junit.Before; | ||
| 21 | -import org.junit.Test; | ||
| 22 | -import org.onlab.packet.IpAddress; | ||
| 23 | -import org.onlab.packet.IpPrefix; | ||
| 24 | -import org.onlab.packet.MacAddress; | ||
| 25 | -import org.onlab.packet.VlanId; | ||
| 26 | -import org.onosproject.net.ConnectPoint; | ||
| 27 | -import org.onosproject.net.DeviceId; | ||
| 28 | -import org.onosproject.net.PortNumber; | ||
| 29 | -import org.onosproject.net.host.HostService; | ||
| 30 | -import org.onosproject.net.host.InterfaceIpAddress; | ||
| 31 | -import org.onosproject.net.host.PortAddresses; | ||
| 32 | -import org.onosproject.routing.config.Interface; | ||
| 33 | - | ||
| 34 | -import java.util.Collections; | ||
| 35 | -import java.util.Map; | ||
| 36 | -import java.util.Set; | ||
| 37 | - | ||
| 38 | -import static org.easymock.EasyMock.createMock; | ||
| 39 | -import static org.easymock.EasyMock.expect; | ||
| 40 | -import static org.easymock.EasyMock.replay; | ||
| 41 | -import static org.easymock.EasyMock.reset; | ||
| 42 | -import static org.junit.Assert.assertEquals; | ||
| 43 | -import static org.junit.Assert.assertNull; | ||
| 44 | -import static org.junit.Assert.assertTrue; | ||
| 45 | - | ||
| 46 | -/** | ||
| 47 | - * Unit tests for the HostToInterfaceAdaptor class. | ||
| 48 | - */ | ||
| 49 | -public class HostToInterfaceAdaptorTest { | ||
| 50 | - | ||
| 51 | - private HostService hostService; | ||
| 52 | - private HostToInterfaceAdaptor adaptor; | ||
| 53 | - | ||
| 54 | - private Set<PortAddresses> portAddresses; | ||
| 55 | - private Map<ConnectPoint, Interface> interfaces; | ||
| 56 | - | ||
| 57 | - private static final ConnectPoint CP1 = new ConnectPoint( | ||
| 58 | - DeviceId.deviceId("of:1"), PortNumber.portNumber(1)); | ||
| 59 | - private static final ConnectPoint CP2 = new ConnectPoint( | ||
| 60 | - DeviceId.deviceId("of:1"), PortNumber.portNumber(2)); | ||
| 61 | - private static final ConnectPoint CP3 = new ConnectPoint( | ||
| 62 | - DeviceId.deviceId("of:2"), PortNumber.portNumber(1)); | ||
| 63 | - | ||
| 64 | - private static final ConnectPoint NON_EXISTENT_CP = new ConnectPoint( | ||
| 65 | - DeviceId.deviceId("doesnotexist"), PortNumber.portNumber(1)); | ||
| 66 | - | ||
| 67 | - @Before | ||
| 68 | - public void setUp() throws Exception { | ||
| 69 | - hostService = createMock(HostService.class); | ||
| 70 | - | ||
| 71 | - portAddresses = Sets.newHashSet(); | ||
| 72 | - interfaces = Maps.newHashMap(); | ||
| 73 | - | ||
| 74 | - InterfaceIpAddress ia11 = | ||
| 75 | - new InterfaceIpAddress(IpAddress.valueOf("192.168.1.1"), | ||
| 76 | - IpPrefix.valueOf("192.168.1.0/24")); | ||
| 77 | - createPortAddressesAndInterface(CP1, | ||
| 78 | - Sets.newHashSet(ia11), | ||
| 79 | - MacAddress.valueOf("00:00:00:00:00:01"), | ||
| 80 | - VlanId.NONE); | ||
| 81 | - | ||
| 82 | - // Two addresses in the same subnet | ||
| 83 | - InterfaceIpAddress ia21 = | ||
| 84 | - new InterfaceIpAddress(IpAddress.valueOf("192.168.2.1"), | ||
| 85 | - IpPrefix.valueOf("192.168.2.0/24")); | ||
| 86 | - InterfaceIpAddress ia22 = | ||
| 87 | - new InterfaceIpAddress(IpAddress.valueOf("192.168.2.2"), | ||
| 88 | - IpPrefix.valueOf("192.168.2.0/24")); | ||
| 89 | - createPortAddressesAndInterface(CP2, | ||
| 90 | - Sets.newHashSet(ia21, ia22), | ||
| 91 | - MacAddress.valueOf("00:00:00:00:00:02"), | ||
| 92 | - VlanId.vlanId((short) 4)); | ||
| 93 | - | ||
| 94 | - // Two addresses in different subnets | ||
| 95 | - InterfaceIpAddress ia31 = | ||
| 96 | - new InterfaceIpAddress(IpAddress.valueOf("192.168.3.1"), | ||
| 97 | - IpPrefix.valueOf("192.168.3.0/24")); | ||
| 98 | - InterfaceIpAddress ia41 = | ||
| 99 | - new InterfaceIpAddress(IpAddress.valueOf("192.168.4.1"), | ||
| 100 | - IpPrefix.valueOf("192.168.4.0/24")); | ||
| 101 | - createPortAddressesAndInterface(CP3, | ||
| 102 | - Sets.newHashSet(ia31, ia41), | ||
| 103 | - MacAddress.valueOf("00:00:00:00:00:03"), | ||
| 104 | - VlanId.NONE); | ||
| 105 | - | ||
| 106 | - expect(hostService.getAddressBindings()).andReturn(portAddresses).anyTimes(); | ||
| 107 | - | ||
| 108 | - replay(hostService); | ||
| 109 | - | ||
| 110 | - adaptor = new HostToInterfaceAdaptor(hostService); | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - /** | ||
| 114 | - * Creates both a PortAddresses and an Interface for the given inputs and | ||
| 115 | - * places them in the correct global data stores. | ||
| 116 | - * | ||
| 117 | - * @param cp the connect point | ||
| 118 | - * @param ipAddresses the set of interface IP addresses | ||
| 119 | - * @param mac the MAC address | ||
| 120 | - * @param vlan the VLAN ID | ||
| 121 | - */ | ||
| 122 | - private void createPortAddressesAndInterface( | ||
| 123 | - ConnectPoint cp, Set<InterfaceIpAddress> ipAddresses, | ||
| 124 | - MacAddress mac, VlanId vlan) { | ||
| 125 | - PortAddresses pa = new PortAddresses(cp, ipAddresses, mac, vlan); | ||
| 126 | - portAddresses.add(pa); | ||
| 127 | - expect(hostService.getAddressBindingsForPort(cp)).andReturn( | ||
| 128 | - Collections.singleton(pa)).anyTimes(); | ||
| 129 | - | ||
| 130 | - Interface intf = new Interface(cp, ipAddresses, mac, vlan); | ||
| 131 | - interfaces.put(cp, intf); | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - /** | ||
| 135 | - * Tests {@link HostToInterfaceAdaptor#getInterfaces()}. | ||
| 136 | - * Verifies that the set of interfaces returned matches what is expected | ||
| 137 | - * based on the input PortAddresses data. | ||
| 138 | - */ | ||
| 139 | - @Test | ||
| 140 | - public void testGetInterfaces() { | ||
| 141 | - Set<Interface> adaptorIntfs = adaptor.getInterfaces(); | ||
| 142 | - | ||
| 143 | - assertEquals(3, adaptorIntfs.size()); | ||
| 144 | - assertTrue(adaptorIntfs.contains(this.interfaces.get(CP1))); | ||
| 145 | - assertTrue(adaptorIntfs.contains(this.interfaces.get(CP2))); | ||
| 146 | - assertTrue(adaptorIntfs.contains(this.interfaces.get(CP3))); | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - /** | ||
| 150 | - * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)}. | ||
| 151 | - * Verifies that the correct interface is returned for a given connect | ||
| 152 | - * point. | ||
| 153 | - */ | ||
| 154 | - @Test | ||
| 155 | - public void testGetInterface() { | ||
| 156 | - assertEquals(this.interfaces.get(CP1), adaptor.getInterface(CP1)); | ||
| 157 | - assertEquals(this.interfaces.get(CP2), adaptor.getInterface(CP2)); | ||
| 158 | - assertEquals(this.interfaces.get(CP3), adaptor.getInterface(CP3)); | ||
| 159 | - | ||
| 160 | - // Try and get an interface for a connect point with no addresses | ||
| 161 | - reset(hostService); | ||
| 162 | - expect(hostService.getAddressBindingsForPort(NON_EXISTENT_CP)) | ||
| 163 | - .andReturn(Collections.<PortAddresses>emptySet()).anyTimes(); | ||
| 164 | - replay(hostService); | ||
| 165 | - | ||
| 166 | - assertNull(adaptor.getInterface(NON_EXISTENT_CP)); | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - /** | ||
| 170 | - * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)} in the | ||
| 171 | - * case that the input connect point is null. | ||
| 172 | - * Verifies that a NullPointerException is thrown. | ||
| 173 | - */ | ||
| 174 | - @Test(expected = NullPointerException.class) | ||
| 175 | - public void testGetInterfaceNull() { | ||
| 176 | - ConnectPoint c = null; | ||
| 177 | - adaptor.getInterface(c); | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | - /** | ||
| 181 | - * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)}. | ||
| 182 | - * Verifies that the correct interface is returned based on the given IP | ||
| 183 | - * address. | ||
| 184 | - */ | ||
| 185 | - @Test | ||
| 186 | - public void testGetMatchingInterface() { | ||
| 187 | - assertEquals(this.interfaces.get(CP1), | ||
| 188 | - adaptor.getMatchingInterface(IpAddress.valueOf("192.168.1.100"))); | ||
| 189 | - assertEquals(this.interfaces.get(CP2), | ||
| 190 | - adaptor.getMatchingInterface(IpAddress.valueOf("192.168.2.100"))); | ||
| 191 | - assertEquals(this.interfaces.get(CP3), | ||
| 192 | - adaptor.getMatchingInterface(IpAddress.valueOf("192.168.3.100"))); | ||
| 193 | - assertEquals(this.interfaces.get(CP3), | ||
| 194 | - adaptor.getMatchingInterface(IpAddress.valueOf("192.168.4.100"))); | ||
| 195 | - | ||
| 196 | - // Try and match an address we don't have subnet configured for | ||
| 197 | - assertNull(adaptor.getMatchingInterface(IpAddress.valueOf("1.1.1.1"))); | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - /** | ||
| 201 | - * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)} in the | ||
| 202 | - * case that the input IP address is null. | ||
| 203 | - * Verifies that a NullPointerException is thrown. | ||
| 204 | - */ | ||
| 205 | - @Test(expected = NullPointerException.class) | ||
| 206 | - public void testGetMatchingInterfaceNull() { | ||
| 207 | - adaptor.getMatchingInterface(null); | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | -} |
| ... | @@ -25,7 +25,6 @@ import org.onosproject.net.ElementId; | ... | @@ -25,7 +25,6 @@ import org.onosproject.net.ElementId; |
| 25 | import org.onosproject.net.Port; | 25 | import org.onosproject.net.Port; |
| 26 | import org.onosproject.net.flow.FlowRule; | 26 | import org.onosproject.net.flow.FlowRule; |
| 27 | import org.onosproject.net.group.Group; | 27 | import org.onosproject.net.group.Group; |
| 28 | -import org.onosproject.net.host.PortAddresses; | ||
| 29 | import org.onosproject.net.topology.TopologyCluster; | 28 | import org.onosproject.net.topology.TopologyCluster; |
| 30 | 29 | ||
| 31 | import java.util.Comparator; | 30 | import java.util.Comparator; |
| ... | @@ -113,13 +112,6 @@ public final class Comparators { | ... | @@ -113,13 +112,6 @@ public final class Comparators { |
| 113 | } | 112 | } |
| 114 | }; | 113 | }; |
| 115 | 114 | ||
| 116 | - public static final Comparator<PortAddresses> ADDRESSES_COMPARATOR = new Comparator<PortAddresses>() { | ||
| 117 | - @Override | ||
| 118 | - public int compare(PortAddresses arg0, PortAddresses arg1) { | ||
| 119 | - return CONNECT_POINT_COMPARATOR.compare(arg0.connectPoint(), arg1.connectPoint()); | ||
| 120 | - } | ||
| 121 | - }; | ||
| 122 | - | ||
| 123 | public static final Comparator<Interface> INTERFACES_COMPARATOR = (intf1, intf2) -> | 115 | public static final Comparator<Interface> INTERFACES_COMPARATOR = (intf1, intf2) -> |
| 124 | CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint()); | 116 | CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint()); |
| 125 | 117 | ... | ... |
| 1 | -/* | ||
| 2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.cli.net; | ||
| 17 | - | ||
| 18 | -import com.google.common.collect.Lists; | ||
| 19 | -import org.apache.karaf.shell.commands.Command; | ||
| 20 | -import org.onosproject.cli.AbstractShellCommand; | ||
| 21 | -import org.onosproject.cli.Comparators; | ||
| 22 | -import org.onosproject.net.host.HostService; | ||
| 23 | -import org.onosproject.net.host.InterfaceIpAddress; | ||
| 24 | -import org.onosproject.net.host.PortAddresses; | ||
| 25 | - | ||
| 26 | -import java.util.Collections; | ||
| 27 | -import java.util.List; | ||
| 28 | -import java.util.Set; | ||
| 29 | - | ||
| 30 | -/** | ||
| 31 | - * Lists all configured address port bindings. | ||
| 32 | - */ | ||
| 33 | -@Command(scope = "onos", name = "address-bindings", | ||
| 34 | - description = "Lists all configured address port bindings.") | ||
| 35 | -public class AddressBindingsListCommand extends AbstractShellCommand { | ||
| 36 | - | ||
| 37 | - private static final String FORMAT = | ||
| 38 | - "port=%s/%s, ip(s)=%s, mac=%s, vlan=%s"; | ||
| 39 | - | ||
| 40 | - @Override | ||
| 41 | - protected void execute() { | ||
| 42 | - HostService hostService = get(HostService.class); | ||
| 43 | - | ||
| 44 | - List<PortAddresses> addresses = | ||
| 45 | - Lists.newArrayList(hostService.getAddressBindings()); | ||
| 46 | - | ||
| 47 | - Collections.sort(addresses, Comparators.ADDRESSES_COMPARATOR); | ||
| 48 | - | ||
| 49 | - for (PortAddresses pa : addresses) { | ||
| 50 | - print(FORMAT, pa.connectPoint().deviceId(), pa.connectPoint().port(), | ||
| 51 | - printIpAddresses(pa.ipAddresses()), pa.mac(), pa.vlan()); | ||
| 52 | - } | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - private String printIpAddresses(Set<InterfaceIpAddress> addresses) { | ||
| 56 | - StringBuilder output = new StringBuilder("["); | ||
| 57 | - for (InterfaceIpAddress address : addresses) { | ||
| 58 | - output.append(address.ipAddress().toString()); | ||
| 59 | - output.append("/"); | ||
| 60 | - output.append(address.subnetAddress().prefixLength()); | ||
| 61 | - output.append(", "); | ||
| 62 | - } | ||
| 63 | - // Remove the last comma | ||
| 64 | - output.delete(output.length() - 2 , output.length()); | ||
| 65 | - output.append("]"); | ||
| 66 | - return output.toString(); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | -} |
| ... | @@ -331,9 +331,6 @@ | ... | @@ -331,9 +331,6 @@ |
| 331 | </completers> | 331 | </completers> |
| 332 | </command> | 332 | </command> |
| 333 | <command> | 333 | <command> |
| 334 | - <action class="org.onosproject.cli.net.AddressBindingsListCommand"/> | ||
| 335 | - </command> | ||
| 336 | - <command> | ||
| 337 | <action class="org.onosproject.cli.net.InterfacesListCommand"/> | 334 | <action class="org.onosproject.cli.net.InterfacesListCommand"/> |
| 338 | </command> | 335 | </command> |
| 339 | 336 | ... | ... |
| ... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.net.host; | 16 | package org.onosproject.net.host; |
| 17 | 17 | ||
| 18 | -import org.onosproject.net.ConnectPoint; | ||
| 19 | import org.onosproject.net.HostId; | 18 | import org.onosproject.net.HostId; |
| 20 | 19 | ||
| 21 | /** | 20 | /** |
| ... | @@ -30,37 +29,4 @@ public interface HostAdminService extends HostService { | ... | @@ -30,37 +29,4 @@ public interface HostAdminService extends HostService { |
| 30 | */ | 29 | */ |
| 31 | void removeHost(HostId hostId); | 30 | void removeHost(HostId hostId); |
| 32 | 31 | ||
| 33 | - /** | ||
| 34 | - * Binds IP and MAC addresses to the given connection point. | ||
| 35 | - * <p> | ||
| 36 | - * The addresses are added to the set of addresses already bound to the | ||
| 37 | - * connection point. | ||
| 38 | - * | ||
| 39 | - * @param addresses address object containing addresses to add and the port | ||
| 40 | - * to add them to | ||
| 41 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 42 | - */ | ||
| 43 | - @Deprecated | ||
| 44 | - void bindAddressesToPort(PortAddresses addresses); | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * Removes the addresses contained in the given PortAddresses object from | ||
| 48 | - * the set of addresses bound to the port. | ||
| 49 | - * | ||
| 50 | - * @param portAddresses set of addresses to remove and port to remove them | ||
| 51 | - * from | ||
| 52 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 53 | - */ | ||
| 54 | - @Deprecated | ||
| 55 | - void unbindAddressesFromPort(PortAddresses portAddresses); | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | - * Removes all address information for the given connection point. | ||
| 59 | - * | ||
| 60 | - * @param connectPoint the connection point to remove address information | ||
| 61 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 62 | - */ | ||
| 63 | - @Deprecated | ||
| 64 | - void clearAddresses(ConnectPoint connectPoint); | ||
| 65 | - | ||
| 66 | } | 32 | } | ... | ... |
| ... | @@ -123,24 +123,4 @@ public interface HostService | ... | @@ -123,24 +123,4 @@ public interface HostService |
| 123 | */ | 123 | */ |
| 124 | void requestMac(IpAddress ip); | 124 | void requestMac(IpAddress ip); |
| 125 | 125 | ||
| 126 | - /** | ||
| 127 | - * Returns the addresses information for all connection points. | ||
| 128 | - * | ||
| 129 | - * @return the set of address bindings for all connection points | ||
| 130 | - * @deprecated in Drake release: use InterfaceService instead | ||
| 131 | - */ | ||
| 132 | - @Deprecated | ||
| 133 | - Set<PortAddresses> getAddressBindings(); | ||
| 134 | - | ||
| 135 | - /** | ||
| 136 | - * Retrieves the addresses that have been bound to the given connection | ||
| 137 | - * point. | ||
| 138 | - * | ||
| 139 | - * @param connectPoint the connection point to retrieve address bindings for | ||
| 140 | - * @return addresses bound to the port | ||
| 141 | - * @deprecated in Drake release: use InterfaceService instead | ||
| 142 | - */ | ||
| 143 | - @Deprecated | ||
| 144 | - Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint); | ||
| 145 | - | ||
| 146 | } | 126 | } | ... | ... |
| ... | @@ -115,53 +115,4 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> { | ... | @@ -115,53 +115,4 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> { |
| 115 | */ | 115 | */ |
| 116 | Set<Host> getConnectedHosts(DeviceId deviceId); | 116 | Set<Host> getConnectedHosts(DeviceId deviceId); |
| 117 | 117 | ||
| 118 | - /** | ||
| 119 | - * Updates the address information for a given port. The given address | ||
| 120 | - * information is added to any previously held information for the port. | ||
| 121 | - * | ||
| 122 | - * @param addresses the port and address information | ||
| 123 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 124 | - */ | ||
| 125 | - @Deprecated | ||
| 126 | - void updateAddressBindings(PortAddresses addresses); | ||
| 127 | - | ||
| 128 | - /** | ||
| 129 | - * Removes the given addresses from the set of address information held for | ||
| 130 | - * a port. | ||
| 131 | - * | ||
| 132 | - * @param addresses the port and address information | ||
| 133 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 134 | - */ | ||
| 135 | - @Deprecated | ||
| 136 | - void removeAddressBindings(PortAddresses addresses); | ||
| 137 | - | ||
| 138 | - /** | ||
| 139 | - * Removes any previously stored address information for a given connection | ||
| 140 | - * point. | ||
| 141 | - * | ||
| 142 | - * @param connectPoint the connection point | ||
| 143 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 144 | - */ | ||
| 145 | - @Deprecated | ||
| 146 | - void clearAddressBindings(ConnectPoint connectPoint); | ||
| 147 | - | ||
| 148 | - /** | ||
| 149 | - * Returns the address bindings stored for all connection points. | ||
| 150 | - * | ||
| 151 | - * @return the set of address bindings | ||
| 152 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 153 | - */ | ||
| 154 | - @Deprecated | ||
| 155 | - Set<PortAddresses> getAddressBindings(); | ||
| 156 | - | ||
| 157 | - /** | ||
| 158 | - * Returns the address bindings for a particular connection point. | ||
| 159 | - * | ||
| 160 | - * @param connectPoint the connection point to return address information | ||
| 161 | - * for | ||
| 162 | - * @return address information for the connection point | ||
| 163 | - * @deprecated in Drake release: address info now stored in InterfaceService | ||
| 164 | - */ | ||
| 165 | - @Deprecated | ||
| 166 | - Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint); | ||
| 167 | } | 118 | } | ... | ... |
| 1 | -/* | ||
| 2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.net.host; | ||
| 17 | - | ||
| 18 | -import java.util.Collections; | ||
| 19 | -import java.util.HashSet; | ||
| 20 | -import java.util.Objects; | ||
| 21 | -import java.util.Set; | ||
| 22 | - | ||
| 23 | -import org.onlab.packet.MacAddress; | ||
| 24 | -import org.onlab.packet.VlanId; | ||
| 25 | -import org.onosproject.net.ConnectPoint; | ||
| 26 | - | ||
| 27 | -import com.google.common.base.MoreObjects; | ||
| 28 | - | ||
| 29 | -/** | ||
| 30 | - * Represents address information bound to a port. | ||
| 31 | - */ | ||
| 32 | -public final class PortAddresses { | ||
| 33 | - | ||
| 34 | - private final ConnectPoint connectPoint; | ||
| 35 | - private final Set<InterfaceIpAddress> ipAddresses; | ||
| 36 | - private final MacAddress macAddress; | ||
| 37 | - private final VlanId vlan; | ||
| 38 | - | ||
| 39 | - /** | ||
| 40 | - * Constructs a PortAddresses object for the given connection point, with a | ||
| 41 | - * set of IP addresses and a MAC address. Both address parameters are | ||
| 42 | - * optional and can be set to null. | ||
| 43 | - * | ||
| 44 | - * @param connectPoint the connection point these addresses are for | ||
| 45 | - * @param ipAddresses a set of interface IP addresses | ||
| 46 | - * @param mac a MAC address | ||
| 47 | - * @param vlan a VLAN ID | ||
| 48 | - */ | ||
| 49 | - public PortAddresses(ConnectPoint connectPoint, | ||
| 50 | - Set<InterfaceIpAddress> ipAddresses, MacAddress mac, VlanId vlan) { | ||
| 51 | - this.connectPoint = connectPoint; | ||
| 52 | - this.ipAddresses = (ipAddresses == null) ? | ||
| 53 | - Collections.<InterfaceIpAddress>emptySet() | ||
| 54 | - : new HashSet<>(ipAddresses); | ||
| 55 | - this.macAddress = mac; | ||
| 56 | - this.vlan = vlan; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - /** | ||
| 60 | - * Returns the connection point this address information is bound to. | ||
| 61 | - * | ||
| 62 | - * @return the connection point | ||
| 63 | - */ | ||
| 64 | - public ConnectPoint connectPoint() { | ||
| 65 | - return connectPoint; | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - /** | ||
| 69 | - * Returns the set of interface IP addresses. | ||
| 70 | - * | ||
| 71 | - * @return the interface IP addresses | ||
| 72 | - */ | ||
| 73 | - public Set<InterfaceIpAddress> ipAddresses() { | ||
| 74 | - return ipAddresses; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - /** | ||
| 78 | - * Returns the MAC address. | ||
| 79 | - * | ||
| 80 | - * @return the MAC address | ||
| 81 | - */ | ||
| 82 | - public MacAddress mac() { | ||
| 83 | - return macAddress; | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - /** | ||
| 87 | - * Returns the VLAN ID. | ||
| 88 | - * | ||
| 89 | - * @return the VLAN ID | ||
| 90 | - */ | ||
| 91 | - public VlanId vlan() { | ||
| 92 | - return vlan; | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - @Override | ||
| 96 | - public boolean equals(Object other) { | ||
| 97 | - if (this == other) { | ||
| 98 | - return true; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - if (!(other instanceof PortAddresses)) { | ||
| 102 | - return false; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - PortAddresses otherPa = (PortAddresses) other; | ||
| 106 | - | ||
| 107 | - return Objects.equals(this.connectPoint, otherPa.connectPoint) | ||
| 108 | - && Objects.equals(this.ipAddresses, otherPa.ipAddresses) | ||
| 109 | - && Objects.equals(this.macAddress, otherPa.macAddress) | ||
| 110 | - && Objects.equals(this.vlan, otherPa.vlan); | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - @Override | ||
| 114 | - public int hashCode() { | ||
| 115 | - return Objects.hash(connectPoint, ipAddresses, macAddress, vlan); | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - @Override | ||
| 119 | - public String toString() { | ||
| 120 | - return MoreObjects.toStringHelper(getClass()) | ||
| 121 | - .add("connect-point", connectPoint) | ||
| 122 | - .add("ip-addresses", ipAddresses) | ||
| 123 | - .add("mac-address", macAddress) | ||
| 124 | - .add("vlan", vlan) | ||
| 125 | - .toString(); | ||
| 126 | - } | ||
| 127 | -} |
| ... | @@ -15,15 +15,15 @@ | ... | @@ -15,15 +15,15 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.net.host; | 16 | package org.onosproject.net.host; |
| 17 | 17 | ||
| 18 | -import java.util.Set; | 18 | +import org.onlab.packet.IpAddress; |
| 19 | - | 19 | +import org.onlab.packet.MacAddress; |
| 20 | +import org.onlab.packet.VlanId; | ||
| 20 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.Host; | 23 | import org.onosproject.net.Host; |
| 23 | import org.onosproject.net.HostId; | 24 | import org.onosproject.net.HostId; |
| 24 | -import org.onlab.packet.IpAddress; | 25 | + |
| 25 | -import org.onlab.packet.MacAddress; | 26 | +import java.util.Set; |
| 26 | -import org.onlab.packet.VlanId; | ||
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | * Test adapter for host service. | 29 | * Test adapter for host service. |
| ... | @@ -89,14 +89,4 @@ public class HostServiceAdapter implements HostService { | ... | @@ -89,14 +89,4 @@ public class HostServiceAdapter implements HostService { |
| 89 | public void removeListener(HostListener listener) { | 89 | public void removeListener(HostListener listener) { |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | - @Override | ||
| 93 | - public Set<PortAddresses> getAddressBindings() { | ||
| 94 | - return null; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - @Override | ||
| 98 | - public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
| 99 | - return null; | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | } | 92 | } | ... | ... |
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.net.host; | ||
| 17 | - | ||
| 18 | -import java.util.Set; | ||
| 19 | - | ||
| 20 | -import org.junit.Before; | ||
| 21 | -import org.junit.Test; | ||
| 22 | -import org.onlab.packet.IpAddress; | ||
| 23 | -import org.onlab.packet.IpPrefix; | ||
| 24 | -import org.onlab.packet.MacAddress; | ||
| 25 | -import org.onlab.packet.VlanId; | ||
| 26 | -import org.onosproject.net.ConnectPoint; | ||
| 27 | -import org.onosproject.net.NetTestTools; | ||
| 28 | - | ||
| 29 | -import static org.hamcrest.Matchers.is; | ||
| 30 | -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; | ||
| 31 | - | ||
| 32 | -import com.google.common.collect.ImmutableSet; | ||
| 33 | -import com.google.common.testing.EqualsTester; | ||
| 34 | -import static org.hamcrest.MatcherAssert.assertThat; | ||
| 35 | - | ||
| 36 | -/** | ||
| 37 | - * Unit tests for port addresses class. | ||
| 38 | - */ | ||
| 39 | -public class PortAddressesTest { | ||
| 40 | - | ||
| 41 | - PortAddresses addresses1; | ||
| 42 | - PortAddresses sameAsAddresses1; | ||
| 43 | - PortAddresses addresses2; | ||
| 44 | - PortAddresses addresses3; | ||
| 45 | - | ||
| 46 | - private static final ConnectPoint CONNECT_POINT1 = | ||
| 47 | - NetTestTools.connectPoint("cp1", 1); | ||
| 48 | - private static final IpAddress IP_ADDRESS1 = IpAddress.valueOf("1.2.3.4"); | ||
| 49 | - private static final IpPrefix SUBNET_ADDRESS1 = | ||
| 50 | - IpPrefix.valueOf("1.2.0.0/16"); | ||
| 51 | - private static final InterfaceIpAddress INTERFACE_ADDRESS_1 = | ||
| 52 | - new InterfaceIpAddress(IP_ADDRESS1, SUBNET_ADDRESS1); | ||
| 53 | - | ||
| 54 | - private static final ConnectPoint CONNECT_POINT2 = | ||
| 55 | - NetTestTools.connectPoint("cp2", 1); | ||
| 56 | - private static final IpAddress IP_ADDRESS2 = IpAddress.valueOf("1.2.3.5"); | ||
| 57 | - private static final IpPrefix SUBNET_ADDRESS2 = | ||
| 58 | - IpPrefix.valueOf("1.3.0.0/16"); | ||
| 59 | - private static final InterfaceIpAddress INTERFACE_ADDRESS_2 = | ||
| 60 | - new InterfaceIpAddress(IP_ADDRESS2, SUBNET_ADDRESS2); | ||
| 61 | - | ||
| 62 | - Set<InterfaceIpAddress> ipAddresses; | ||
| 63 | - | ||
| 64 | - | ||
| 65 | - /** | ||
| 66 | - * Initializes local data used by all test cases. | ||
| 67 | - */ | ||
| 68 | - @Before | ||
| 69 | - public void setUpAddresses() { | ||
| 70 | - ipAddresses = ImmutableSet.of(INTERFACE_ADDRESS_1, | ||
| 71 | - INTERFACE_ADDRESS_2); | ||
| 72 | - addresses1 = new PortAddresses(CONNECT_POINT1, ipAddresses, | ||
| 73 | - MacAddress.BROADCAST, VlanId.NONE); | ||
| 74 | - sameAsAddresses1 = new PortAddresses(CONNECT_POINT1, ipAddresses, | ||
| 75 | - MacAddress.BROADCAST, VlanId.NONE); | ||
| 76 | - addresses2 = new PortAddresses(CONNECT_POINT2, ipAddresses, | ||
| 77 | - MacAddress.BROADCAST, VlanId.NONE); | ||
| 78 | - addresses3 = new PortAddresses(CONNECT_POINT2, ipAddresses, | ||
| 79 | - MacAddress.ZERO, VlanId.NONE); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - /** | ||
| 83 | - * Checks that the PortAddresses class is immutable. | ||
| 84 | - */ | ||
| 85 | - @Test | ||
| 86 | - public void testImmutability() { | ||
| 87 | - assertThatClassIsImmutable(PortAddresses.class); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - /** | ||
| 91 | - * Checks the operation of the equals(), hash() and toString() | ||
| 92 | - * methods. | ||
| 93 | - */ | ||
| 94 | - @Test | ||
| 95 | - public void testEquals() { | ||
| 96 | - new EqualsTester() | ||
| 97 | - .addEqualityGroup(addresses1, sameAsAddresses1) | ||
| 98 | - .addEqualityGroup(addresses2) | ||
| 99 | - .addEqualityGroup(addresses3) | ||
| 100 | - .testEquals(); | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * Tests that object are created correctly. | ||
| 105 | - */ | ||
| 106 | - @Test | ||
| 107 | - public void testConstruction() { | ||
| 108 | - assertThat(addresses1.mac(), is(MacAddress.BROADCAST)); | ||
| 109 | - assertThat(addresses1.connectPoint(), is(CONNECT_POINT1)); | ||
| 110 | - assertThat(addresses1.ipAddresses(), is(ipAddresses)); | ||
| 111 | - assertThat(addresses1.vlan(), is(VlanId.NONE)); | ||
| 112 | - } | ||
| 113 | -} |
| ... | @@ -15,23 +15,16 @@ | ... | @@ -15,23 +15,16 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.store.trivial; | 16 | package org.onosproject.store.trivial; |
| 17 | 17 | ||
| 18 | -import static org.onosproject.net.DefaultAnnotations.merge; | 18 | +import com.google.common.collect.HashMultimap; |
| 19 | -import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; | 19 | +import com.google.common.collect.ImmutableSet; |
| 20 | -import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED; | 20 | +import com.google.common.collect.Multimap; |
| 21 | -import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; | ||
| 22 | -import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED; | ||
| 23 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 24 | - | ||
| 25 | -import java.util.Collections; | ||
| 26 | -import java.util.HashSet; | ||
| 27 | -import java.util.Map; | ||
| 28 | -import java.util.Set; | ||
| 29 | -import java.util.concurrent.ConcurrentHashMap; | ||
| 30 | - | ||
| 31 | import org.apache.felix.scr.annotations.Activate; | 21 | import org.apache.felix.scr.annotations.Activate; |
| 32 | import org.apache.felix.scr.annotations.Component; | 22 | import org.apache.felix.scr.annotations.Component; |
| 33 | import org.apache.felix.scr.annotations.Deactivate; | 23 | import org.apache.felix.scr.annotations.Deactivate; |
| 34 | import org.apache.felix.scr.annotations.Service; | 24 | import org.apache.felix.scr.annotations.Service; |
| 25 | +import org.onlab.packet.IpAddress; | ||
| 26 | +import org.onlab.packet.MacAddress; | ||
| 27 | +import org.onlab.packet.VlanId; | ||
| 35 | import org.onosproject.net.Annotations; | 28 | import org.onosproject.net.Annotations; |
| 36 | import org.onosproject.net.ConnectPoint; | 29 | import org.onosproject.net.ConnectPoint; |
| 37 | import org.onosproject.net.DefaultAnnotations; | 30 | import org.onosproject.net.DefaultAnnotations; |
| ... | @@ -44,19 +37,21 @@ import org.onosproject.net.host.HostDescription; | ... | @@ -44,19 +37,21 @@ import org.onosproject.net.host.HostDescription; |
| 44 | import org.onosproject.net.host.HostEvent; | 37 | import org.onosproject.net.host.HostEvent; |
| 45 | import org.onosproject.net.host.HostStore; | 38 | import org.onosproject.net.host.HostStore; |
| 46 | import org.onosproject.net.host.HostStoreDelegate; | 39 | import org.onosproject.net.host.HostStoreDelegate; |
| 47 | -import org.onosproject.net.host.PortAddresses; | ||
| 48 | import org.onosproject.net.provider.ProviderId; | 40 | import org.onosproject.net.provider.ProviderId; |
| 49 | import org.onosproject.store.AbstractStore; | 41 | import org.onosproject.store.AbstractStore; |
| 50 | -import org.onlab.packet.IpAddress; | ||
| 51 | -import org.onlab.packet.MacAddress; | ||
| 52 | -import org.onlab.packet.VlanId; | ||
| 53 | import org.slf4j.Logger; | 42 | import org.slf4j.Logger; |
| 54 | 43 | ||
| 55 | -import com.google.common.collect.HashMultimap; | 44 | +import java.util.HashSet; |
| 56 | -import com.google.common.collect.ImmutableSet; | 45 | +import java.util.Map; |
| 57 | -import com.google.common.collect.Multimap; | 46 | +import java.util.Set; |
| 58 | -import com.google.common.collect.Multimaps; | 47 | +import java.util.concurrent.ConcurrentHashMap; |
| 59 | -import com.google.common.collect.SetMultimap; | 48 | + |
| 49 | +import static org.onosproject.net.DefaultAnnotations.merge; | ||
| 50 | +import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; | ||
| 51 | +import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED; | ||
| 52 | +import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; | ||
| 53 | +import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED; | ||
| 54 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 60 | 55 | ||
| 61 | // TODO: multi-provider, annotation not supported. | 56 | // TODO: multi-provider, annotation not supported. |
| 62 | /** | 57 | /** |
| ... | @@ -77,10 +72,6 @@ public class SimpleHostStore | ... | @@ -77,10 +72,6 @@ public class SimpleHostStore |
| 77 | // Hosts tracked by their location | 72 | // Hosts tracked by their location |
| 78 | private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); | 73 | private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); |
| 79 | 74 | ||
| 80 | - private final SetMultimap<ConnectPoint, PortAddresses> portAddresses = | ||
| 81 | - Multimaps.synchronizedSetMultimap( | ||
| 82 | - HashMultimap.<ConnectPoint, PortAddresses>create()); | ||
| 83 | - | ||
| 84 | @Activate | 75 | @Activate |
| 85 | public void activate() { | 76 | public void activate() { |
| 86 | log.info("Started"); | 77 | log.info("Started"); |
| ... | @@ -224,41 +215,6 @@ public class SimpleHostStore | ... | @@ -224,41 +215,6 @@ public class SimpleHostStore |
| 224 | return hostset; | 215 | return hostset; |
| 225 | } | 216 | } |
| 226 | 217 | ||
| 227 | - @Override | ||
| 228 | - public void updateAddressBindings(PortAddresses addresses) { | ||
| 229 | - portAddresses.put(addresses.connectPoint(), addresses); | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - @Override | ||
| 233 | - public void removeAddressBindings(PortAddresses addresses) { | ||
| 234 | - portAddresses.remove(addresses.connectPoint(), addresses); | ||
| 235 | - } | ||
| 236 | - | ||
| 237 | - @Override | ||
| 238 | - public void clearAddressBindings(ConnectPoint connectPoint) { | ||
| 239 | - portAddresses.removeAll(connectPoint); | ||
| 240 | - } | ||
| 241 | - | ||
| 242 | - @Override | ||
| 243 | - public Set<PortAddresses> getAddressBindings() { | ||
| 244 | - synchronized (portAddresses) { | ||
| 245 | - return ImmutableSet.copyOf(portAddresses.values()); | ||
| 246 | - } | ||
| 247 | - } | ||
| 248 | - | ||
| 249 | - @Override | ||
| 250 | - public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
| 251 | - synchronized (portAddresses) { | ||
| 252 | - Set<PortAddresses> addresses = portAddresses.get(connectPoint); | ||
| 253 | - | ||
| 254 | - if (addresses == null) { | ||
| 255 | - return Collections.emptySet(); | ||
| 256 | - } else { | ||
| 257 | - return ImmutableSet.copyOf(addresses); | ||
| 258 | - } | ||
| 259 | - } | ||
| 260 | - } | ||
| 261 | - | ||
| 262 | // Auxiliary extension to allow location to mutate. | 218 | // Auxiliary extension to allow location to mutate. |
| 263 | private static final class StoredHost extends DefaultHost { | 219 | private static final class StoredHost extends DefaultHost { |
| 264 | private HostLocation location; | 220 | private HostLocation location; | ... | ... |
| ... | @@ -46,7 +46,6 @@ import org.onosproject.net.host.HostProviderService; | ... | @@ -46,7 +46,6 @@ import org.onosproject.net.host.HostProviderService; |
| 46 | import org.onosproject.net.host.HostService; | 46 | import org.onosproject.net.host.HostService; |
| 47 | import org.onosproject.net.host.HostStore; | 47 | import org.onosproject.net.host.HostStore; |
| 48 | import org.onosproject.net.host.HostStoreDelegate; | 48 | import org.onosproject.net.host.HostStoreDelegate; |
| 49 | -import org.onosproject.net.host.PortAddresses; | ||
| 50 | import org.onosproject.net.packet.PacketService; | 49 | import org.onosproject.net.packet.PacketService; |
| 51 | import org.onosproject.net.provider.AbstractProviderService; | 50 | import org.onosproject.net.provider.AbstractProviderService; |
| 52 | import org.slf4j.Logger; | 51 | import org.slf4j.Logger; |
| ... | @@ -199,33 +198,6 @@ public class HostManager | ... | @@ -199,33 +198,6 @@ public class HostManager |
| 199 | } | 198 | } |
| 200 | } | 199 | } |
| 201 | 200 | ||
| 202 | - @Override | ||
| 203 | - public void bindAddressesToPort(PortAddresses addresses) { | ||
| 204 | - store.updateAddressBindings(addresses); | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - @Override | ||
| 208 | - public void unbindAddressesFromPort(PortAddresses portAddresses) { | ||
| 209 | - store.removeAddressBindings(portAddresses); | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - @Override | ||
| 213 | - public void clearAddresses(ConnectPoint connectPoint) { | ||
| 214 | - store.clearAddressBindings(connectPoint); | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - @Override | ||
| 218 | - public Set<PortAddresses> getAddressBindings() { | ||
| 219 | - checkPermission(HOST_READ); | ||
| 220 | - return store.getAddressBindings(); | ||
| 221 | - } | ||
| 222 | - | ||
| 223 | - @Override | ||
| 224 | - public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
| 225 | - checkPermission(HOST_READ); | ||
| 226 | - return store.getAddressBindingsForPort(connectPoint); | ||
| 227 | - } | ||
| 228 | - | ||
| 229 | // Personalized host provider service issued to the supplied provider. | 201 | // Personalized host provider service issued to the supplied provider. |
| 230 | private class InternalHostProviderService | 202 | private class InternalHostProviderService |
| 231 | extends AbstractProviderService<HostProvider> | 203 | extends AbstractProviderService<HostProvider> | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -43,7 +43,6 @@ import org.onosproject.net.flow.instructions.Instruction; | ... | @@ -43,7 +43,6 @@ import org.onosproject.net.flow.instructions.Instruction; |
| 43 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; | 43 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; |
| 44 | import org.onosproject.net.host.HostProvider; | 44 | import org.onosproject.net.host.HostProvider; |
| 45 | import org.onosproject.net.host.InterfaceIpAddress; | 45 | import org.onosproject.net.host.InterfaceIpAddress; |
| 46 | -import org.onosproject.net.host.PortAddresses; | ||
| 47 | import org.onosproject.net.packet.OutboundPacket; | 46 | import org.onosproject.net.packet.OutboundPacket; |
| 48 | import org.onosproject.net.packet.PacketServiceAdapter; | 47 | import org.onosproject.net.packet.PacketServiceAdapter; |
| 49 | import org.onosproject.net.provider.ProviderId; | 48 | import org.onosproject.net.provider.ProviderId; |
| ... | @@ -140,8 +139,6 @@ public class HostMonitorTest { | ... | @@ -140,8 +139,6 @@ public class HostMonitorTest { |
| 140 | deviceService.addDevice(device, Collections.singleton(port)); | 139 | deviceService.addDevice(device, Collections.singleton(port)); |
| 141 | 140 | ||
| 142 | ConnectPoint cp = new ConnectPoint(devId, portNum); | 141 | ConnectPoint cp = new ConnectPoint(devId, portNum); |
| 143 | - PortAddresses pa = | ||
| 144 | - new PortAddresses(cp, Collections.singleton(IA1), sourceMac, VlanId.NONE); | ||
| 145 | 142 | ||
| 146 | expect(hostManager.getHostsByIp(TARGET_IP_ADDR)) | 143 | expect(hostManager.getHostsByIp(TARGET_IP_ADDR)) |
| 147 | .andReturn(Collections.emptySet()).anyTimes(); | 144 | .andReturn(Collections.emptySet()).anyTimes(); |
| ... | @@ -211,9 +208,6 @@ public class HostMonitorTest { | ... | @@ -211,9 +208,6 @@ public class HostMonitorTest { |
| 211 | deviceService.addDevice(device, Collections.singleton(port)); | 208 | deviceService.addDevice(device, Collections.singleton(port)); |
| 212 | 209 | ||
| 213 | ConnectPoint cp = new ConnectPoint(devId, portNum); | 210 | ConnectPoint cp = new ConnectPoint(devId, portNum); |
| 214 | - PortAddresses pa = | ||
| 215 | - new PortAddresses(cp, Collections.singleton(IA1), sourceMac, | ||
| 216 | - VlanId.vlanId(vlan)); | ||
| 217 | 211 | ||
| 218 | expect(hostManager.getHostsByIp(TARGET_IP_ADDR)) | 212 | expect(hostManager.getHostsByIp(TARGET_IP_ADDR)) |
| 219 | .andReturn(Collections.emptySet()).anyTimes(); | 213 | .andReturn(Collections.emptySet()).anyTimes(); | ... | ... |
| ... | @@ -25,7 +25,6 @@ import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.RE | ... | @@ -25,7 +25,6 @@ import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.RE |
| 25 | import static org.slf4j.LoggerFactory.getLogger; | 25 | import static org.slf4j.LoggerFactory.getLogger; |
| 26 | 26 | ||
| 27 | import java.util.Collection; | 27 | import java.util.Collection; |
| 28 | -import java.util.Collections; | ||
| 29 | import java.util.Objects; | 28 | import java.util.Objects; |
| 30 | import java.util.Set; | 29 | import java.util.Set; |
| 31 | import java.util.function.Predicate; | 30 | import java.util.function.Predicate; |
| ... | @@ -52,7 +51,6 @@ import org.onosproject.net.host.HostDescription; | ... | @@ -52,7 +51,6 @@ import org.onosproject.net.host.HostDescription; |
| 52 | import org.onosproject.net.host.HostEvent; | 51 | import org.onosproject.net.host.HostEvent; |
| 53 | import org.onosproject.net.host.HostStore; | 52 | import org.onosproject.net.host.HostStore; |
| 54 | import org.onosproject.net.host.HostStoreDelegate; | 53 | import org.onosproject.net.host.HostStoreDelegate; |
| 55 | -import org.onosproject.net.host.PortAddresses; | ||
| 56 | import org.onosproject.net.host.HostEvent.Type; | 54 | import org.onosproject.net.host.HostEvent.Type; |
| 57 | import org.onosproject.net.provider.ProviderId; | 55 | import org.onosproject.net.provider.ProviderId; |
| 58 | import org.onosproject.store.AbstractStore; | 56 | import org.onosproject.store.AbstractStore; |
| ... | @@ -93,10 +91,6 @@ public class ECHostStore | ... | @@ -93,10 +91,6 @@ public class ECHostStore |
| 93 | Multimaps.synchronizedSetMultimap( | 91 | Multimaps.synchronizedSetMultimap( |
| 94 | HashMultimap.<ConnectPoint, Host>create()); | 92 | HashMultimap.<ConnectPoint, Host>create()); |
| 95 | 93 | ||
| 96 | - private final SetMultimap<ConnectPoint, PortAddresses> portAddresses = | ||
| 97 | - Multimaps.synchronizedSetMultimap( | ||
| 98 | - HashMultimap.<ConnectPoint, PortAddresses>create()); | ||
| 99 | - | ||
| 100 | private EventuallyConsistentMap<HostId, DefaultHost> hosts; | 94 | private EventuallyConsistentMap<HostId, DefaultHost> hosts; |
| 101 | 95 | ||
| 102 | private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker = | 96 | private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker = |
| ... | @@ -123,7 +117,6 @@ public class ECHostStore | ... | @@ -123,7 +117,6 @@ public class ECHostStore |
| 123 | hosts.removeListener(hostLocationTracker); | 117 | hosts.removeListener(hostLocationTracker); |
| 124 | hosts.destroy(); | 118 | hosts.destroy(); |
| 125 | locations.clear(); | 119 | locations.clear(); |
| 126 | - portAddresses.clear(); | ||
| 127 | 120 | ||
| 128 | log.info("Stopped"); | 121 | log.info("Stopped"); |
| 129 | } | 122 | } |
| ... | @@ -199,34 +192,6 @@ public class ECHostStore | ... | @@ -199,34 +192,6 @@ public class ECHostStore |
| 199 | .collect(Collectors.toSet()); | 192 | .collect(Collectors.toSet()); |
| 200 | } | 193 | } |
| 201 | 194 | ||
| 202 | - @Override | ||
| 203 | - public void updateAddressBindings(PortAddresses addresses) { | ||
| 204 | - portAddresses.put(addresses.connectPoint(), addresses); | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - @Override | ||
| 208 | - public void removeAddressBindings(PortAddresses addresses) { | ||
| 209 | - portAddresses.remove(addresses.connectPoint(), addresses); | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - @Override | ||
| 213 | - public void clearAddressBindings(ConnectPoint connectPoint) { | ||
| 214 | - portAddresses.removeAll(connectPoint); | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - @Override | ||
| 218 | - public Set<PortAddresses> getAddressBindings() { | ||
| 219 | - return ImmutableSet.copyOf(portAddresses.values()); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - @Override | ||
| 223 | - public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
| 224 | - synchronized (portAddresses) { | ||
| 225 | - Set<PortAddresses> addresses = portAddresses.get(connectPoint); | ||
| 226 | - return addresses == null ? Collections.emptySet() : ImmutableSet.copyOf(addresses); | ||
| 227 | - } | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) { | 195 | private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) { |
| 231 | return collection.stream().filter(predicate).collect(Collectors.toSet()); | 196 | return collection.stream().filter(predicate).collect(Collectors.toSet()); |
| 232 | } | 197 | } | ... | ... |
-
Please register or login to post a comment