tom

Merge remote-tracking branch 'origin/master'

1 +package org.onlab.onos.net.host.impl;
2 +
3 +import org.onlab.onos.net.ConnectPoint;
4 +import org.onlab.onos.net.host.PortAddresses;
5 +import org.onlab.packet.IpAddress;
6 +import org.onlab.packet.MacAddress;
7 +
8 +public class DefaultPortAddresses implements PortAddresses {
9 +
10 + private final ConnectPoint connectPoint;
11 + private final IpAddress ipAddress;
12 + private final MacAddress macAddress;
13 +
14 + public DefaultPortAddresses(ConnectPoint connectPoint,
15 + IpAddress ip, MacAddress mac) {
16 + this.connectPoint = connectPoint;
17 + this.ipAddress = ip;
18 + this.macAddress = mac;
19 + }
20 +
21 + @Override
22 + public ConnectPoint connectPoint() {
23 + return connectPoint;
24 + }
25 +
26 + @Override
27 + public IpAddress ip() {
28 + return ipAddress;
29 + }
30 +
31 + @Override
32 + public MacAddress mac() {
33 + return macAddress;
34 + }
35 +
36 +}
...@@ -157,26 +157,22 @@ public class HostManager ...@@ -157,26 +157,22 @@ public class HostManager
157 @Override 157 @Override
158 public void bindAddressesToPort(IpAddress ip, MacAddress mac, 158 public void bindAddressesToPort(IpAddress ip, MacAddress mac,
159 ConnectPoint connectPoint) { 159 ConnectPoint connectPoint) {
160 - // TODO Auto-generated method stub 160 + store.updateAddressBindings(new DefaultPortAddresses(connectPoint, ip, mac));
161 -
162 } 161 }
163 162
164 @Override 163 @Override
165 public void unbindAddressesFromPort(ConnectPoint connectPoint) { 164 public void unbindAddressesFromPort(ConnectPoint connectPoint) {
166 - // TODO Auto-generated method stub 165 + store.removeAddressBindings(connectPoint);
167 -
168 } 166 }
169 167
170 @Override 168 @Override
171 public Set<PortAddresses> getAddressBindings() { 169 public Set<PortAddresses> getAddressBindings() {
172 - // TODO Auto-generated method stub 170 + return store.getAddressBindings();
173 - return null;
174 } 171 }
175 172
176 @Override 173 @Override
177 public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) { 174 public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) {
178 - // TODO Auto-generated method stub 175 + return store.getAddressBindingsForPort(connectPoint);
179 - return null;
180 } 176 }
181 177
182 // Personalized host provider service issued to the supplied provider. 178 // Personalized host provider service issued to the supplied provider.
......
...@@ -51,6 +51,9 @@ public class SimpleHostStore implements HostStore { ...@@ -51,6 +51,9 @@ public class SimpleHostStore implements HostStore {
51 // Hosts tracked by their location 51 // Hosts tracked by their location
52 private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); 52 private final Multimap<ConnectPoint, Host> locations = HashMultimap.create();
53 53
54 + private final Map<ConnectPoint, PortAddresses> portAddresses =
55 + new ConcurrentHashMap<>();
56 +
54 @Activate 57 @Activate
55 public void activate() { 58 public void activate() {
56 log.info("Started"); 59 log.info("Started");
...@@ -195,26 +198,22 @@ public class SimpleHostStore implements HostStore { ...@@ -195,26 +198,22 @@ public class SimpleHostStore implements HostStore {
195 198
196 @Override 199 @Override
197 public void updateAddressBindings(PortAddresses addresses) { 200 public void updateAddressBindings(PortAddresses addresses) {
198 - // TODO Auto-generated method stub 201 + portAddresses.put(addresses.connectPoint(), addresses);
199 -
200 } 202 }
201 203
202 @Override 204 @Override
203 public void removeAddressBindings(ConnectPoint connectPoint) { 205 public void removeAddressBindings(ConnectPoint connectPoint) {
204 - // TODO Auto-generated method stub 206 + portAddresses.remove(connectPoint);
205 -
206 } 207 }
207 208
208 @Override 209 @Override
209 public Set<PortAddresses> getAddressBindings() { 210 public Set<PortAddresses> getAddressBindings() {
210 - // TODO Auto-generated method stub 211 + return new HashSet<>(portAddresses.values());
211 - return null;
212 } 212 }
213 213
214 @Override 214 @Override
215 public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) { 215 public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) {
216 - // TODO Auto-generated method stub 216 + return portAddresses.get(connectPoint);
217 - return null;
218 } 217 }
219 218
220 } 219 }
......