Jonathan Hart
Committed by Gerrit Code Review

Revert "Fix for ONOS-5032 and ONOS-5034"

This reverts commit 50ad0806.

Change-Id: Id2f9924a28c18686b4be30200244dbd0c975e90a
...@@ -24,7 +24,6 @@ import org.onosproject.cli.AbstractShellCommand; ...@@ -24,7 +24,6 @@ import org.onosproject.cli.AbstractShellCommand;
24 import org.onosproject.net.Host; 24 import org.onosproject.net.Host;
25 import org.onosproject.net.host.HostService; 25 import org.onosproject.net.host.HostService;
26 import org.onosproject.utils.Comparators; 26 import org.onosproject.utils.Comparators;
27 -import org.onlab.util.Tools;
28 27
29 import java.util.Collections; 28 import java.util.Collections;
30 import java.util.List; 29 import java.util.List;
...@@ -39,7 +38,7 @@ import static com.google.common.collect.Lists.newArrayList; ...@@ -39,7 +38,7 @@ import static com.google.common.collect.Lists.newArrayList;
39 public class HostsListCommand extends AbstractShellCommand { 38 public class HostsListCommand extends AbstractShellCommand {
40 39
41 private static final String FMT = 40 private static final String FMT =
42 - "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s%s, last seen time=%s"; 41 + "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s%s";
43 42
44 private static final String FMT_SHORT = 43 private static final String FMT_SHORT =
45 "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s"; 44 "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s";
...@@ -94,9 +93,7 @@ public class HostsListCommand extends AbstractShellCommand { ...@@ -94,9 +93,7 @@ public class HostsListCommand extends AbstractShellCommand {
94 } else { 93 } else {
95 print(FMT, host.id(), host.mac(), 94 print(FMT, host.id(), host.mac(),
96 host.location().deviceId(), host.location().port(), 95 host.location().deviceId(), host.location().port(),
97 - host.vlan(), host.ipAddresses(), annotations(host.annotations()), 96 + host.vlan(), host.ipAddresses(), annotations(host.annotations()));
98 - Tools.timeAgo(host.timestamp().unixTimestamp()));
99 } 97 }
100 } 98 }
101 } 99 }
102 -
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 package org.onosproject.net; 16 package org.onosproject.net;
17 17
18 import org.onosproject.net.provider.ProviderId; 18 import org.onosproject.net.provider.ProviderId;
19 -import org.onosproject.store.service.WallClockTimestamp;
20 import org.onlab.packet.IpAddress; 19 import org.onlab.packet.IpAddress;
21 import org.onlab.packet.MacAddress; 20 import org.onlab.packet.MacAddress;
22 import org.onlab.packet.VlanId; 21 import org.onlab.packet.VlanId;
...@@ -37,7 +36,6 @@ public class DefaultHost extends AbstractElement implements Host { ...@@ -37,7 +36,6 @@ public class DefaultHost extends AbstractElement implements Host {
37 private final VlanId vlan; 36 private final VlanId vlan;
38 private final HostLocation location; 37 private final HostLocation location;
39 private final Set<IpAddress> ips; 38 private final Set<IpAddress> ips;
40 - private final WallClockTimestamp timestamp;
41 39
42 /** 40 /**
43 * Creates an end-station host using the supplied information. 41 * Creates an end-station host using the supplied information.
...@@ -53,29 +51,10 @@ public class DefaultHost extends AbstractElement implements Host { ...@@ -53,29 +51,10 @@ public class DefaultHost extends AbstractElement implements Host {
53 public DefaultHost(ProviderId providerId, HostId id, MacAddress mac, 51 public DefaultHost(ProviderId providerId, HostId id, MacAddress mac,
54 VlanId vlan, HostLocation location, Set<IpAddress> ips, 52 VlanId vlan, HostLocation location, Set<IpAddress> ips,
55 Annotations... annotations) { 53 Annotations... annotations) {
56 - this(providerId, id, mac, vlan, location, ips, new WallClockTimestamp(), annotations);
57 - }
58 -
59 - /**
60 - * Creates an end-station host using the supplied information.
61 - *
62 - * @param providerId provider identity
63 - * @param id host identifier
64 - * @param mac host MAC address
65 - * @param vlan host VLAN identifier
66 - * @param location host location
67 - * @param ips host IP addresses
68 - * @param timestamp last host updated time
69 - * @param annotations optional key/value annotations
70 - */
71 - public DefaultHost(ProviderId providerId, HostId id, MacAddress mac,
72 - VlanId vlan, HostLocation location, Set<IpAddress> ips,
73 - WallClockTimestamp timestamp, Annotations... annotations) {
74 super(providerId, id, annotations); 54 super(providerId, id, annotations);
75 this.mac = mac; 55 this.mac = mac;
76 this.vlan = vlan; 56 this.vlan = vlan;
77 this.location = location; 57 this.location = location;
78 - this.timestamp = timestamp;
79 this.ips = new HashSet<>(ips); 58 this.ips = new HashSet<>(ips);
80 } 59 }
81 60
...@@ -105,11 +84,6 @@ public class DefaultHost extends AbstractElement implements Host { ...@@ -105,11 +84,6 @@ public class DefaultHost extends AbstractElement implements Host {
105 } 84 }
106 85
107 @Override 86 @Override
108 - public WallClockTimestamp timestamp() {
109 - return timestamp;
110 - }
111 -
112 - @Override
113 public int hashCode() { 87 public int hashCode() {
114 return Objects.hash(id, mac, vlan, location); 88 return Objects.hash(id, mac, vlan, location);
115 } 89 }
...@@ -140,7 +114,6 @@ public class DefaultHost extends AbstractElement implements Host { ...@@ -140,7 +114,6 @@ public class DefaultHost extends AbstractElement implements Host {
140 .add("location", location()) 114 .add("location", location())
141 .add("ipAddresses", ipAddresses()) 115 .add("ipAddresses", ipAddresses())
142 .add("annotations", annotations()) 116 .add("annotations", annotations())
143 - .add("timestamp", timestamp())
144 .toString(); 117 .toString();
145 } 118 }
146 119
......
...@@ -18,7 +18,6 @@ package org.onosproject.net; ...@@ -18,7 +18,6 @@ package org.onosproject.net;
18 import org.onlab.packet.IpAddress; 18 import org.onlab.packet.IpAddress;
19 import org.onlab.packet.MacAddress; 19 import org.onlab.packet.MacAddress;
20 import org.onlab.packet.VlanId; 20 import org.onlab.packet.VlanId;
21 -import org.onosproject.store.service.WallClockTimestamp;
22 21
23 import java.util.Set; 22 import java.util.Set;
24 23
...@@ -64,14 +63,6 @@ public interface Host extends Element { ...@@ -64,14 +63,6 @@ public interface Host extends Element {
64 */ 63 */
65 HostLocation location(); 64 HostLocation location();
66 65
67 - /**
68 - * Returns the host recent time.
69 - * @return host last updated time
70 - */
71 - default WallClockTimestamp timestamp() {
72 - return null;
73 - }
74 // TODO: explore capturing list of recent locations to aid in mobility 66 // TODO: explore capturing list of recent locations to aid in mobility
75 67
76 } 68 }
77 -
......
...@@ -21,7 +21,6 @@ import java.util.Set; ...@@ -21,7 +21,6 @@ import java.util.Set;
21 import org.onosproject.net.AbstractDescription; 21 import org.onosproject.net.AbstractDescription;
22 import org.onosproject.net.HostLocation; 22 import org.onosproject.net.HostLocation;
23 import org.onosproject.net.SparseAnnotations; 23 import org.onosproject.net.SparseAnnotations;
24 -import org.onosproject.store.service.WallClockTimestamp;
25 import org.onlab.packet.IpAddress; 24 import org.onlab.packet.IpAddress;
26 import org.onlab.packet.MacAddress; 25 import org.onlab.packet.MacAddress;
27 import org.onlab.packet.VlanId; 26 import org.onlab.packet.VlanId;
...@@ -41,7 +40,6 @@ public class DefaultHostDescription extends AbstractDescription ...@@ -41,7 +40,6 @@ public class DefaultHostDescription extends AbstractDescription
41 private final VlanId vlan; 40 private final VlanId vlan;
42 private final HostLocation location; 41 private final HostLocation location;
43 private final Set<IpAddress> ip; 42 private final Set<IpAddress> ip;
44 - private final WallClockTimestamp timestamp;
45 43
46 /** 44 /**
47 * Creates a host description using the supplied information. 45 * Creates a host description using the supplied information.
...@@ -85,28 +83,11 @@ public class DefaultHostDescription extends AbstractDescription ...@@ -85,28 +83,11 @@ public class DefaultHostDescription extends AbstractDescription
85 public DefaultHostDescription(MacAddress mac, VlanId vlan, 83 public DefaultHostDescription(MacAddress mac, VlanId vlan,
86 HostLocation location, Set<IpAddress> ip, 84 HostLocation location, Set<IpAddress> ip,
87 SparseAnnotations... annotations) { 85 SparseAnnotations... annotations) {
88 - this(mac, vlan, location, ip, new WallClockTimestamp(), annotations);
89 - }
90 -
91 - /**
92 - * Creates a host description using the supplied information.
93 - *
94 - * @param mac host MAC address
95 - * @param vlan host VLAN identifier
96 - * @param location host location
97 - * @param ip host IP addresses
98 - * @param timestamp host recent updated time
99 - * @param annotations optional key/value annotations map
100 - */
101 - public DefaultHostDescription(MacAddress mac, VlanId vlan,
102 - HostLocation location, Set<IpAddress> ip,
103 - WallClockTimestamp timestamp, SparseAnnotations... annotations) {
104 super(annotations); 86 super(annotations);
105 this.mac = mac; 87 this.mac = mac;
106 this.vlan = vlan; 88 this.vlan = vlan;
107 this.location = location; 89 this.location = location;
108 this.ip = ImmutableSet.copyOf(ip); 90 this.ip = ImmutableSet.copyOf(ip);
109 - this.timestamp = timestamp;
110 } 91 }
111 92
112 @Override 93 @Override
...@@ -130,18 +111,12 @@ public class DefaultHostDescription extends AbstractDescription ...@@ -130,18 +111,12 @@ public class DefaultHostDescription extends AbstractDescription
130 } 111 }
131 112
132 @Override 113 @Override
133 - public WallClockTimestamp timestamp() {
134 - return timestamp;
135 - }
136 -
137 - @Override
138 public String toString() { 114 public String toString() {
139 return toStringHelper(this) 115 return toStringHelper(this)
140 .add("mac", mac) 116 .add("mac", mac)
141 .add("vlan", vlan) 117 .add("vlan", vlan)
142 .add("location", location) 118 .add("location", location)
143 .add("ipAddress", ip) 119 .add("ipAddress", ip)
144 - .add("timestamp", timestamp)
145 .toString(); 120 .toString();
146 } 121 }
147 122
...@@ -164,4 +139,5 @@ public class DefaultHostDescription extends AbstractDescription ...@@ -164,4 +139,5 @@ public class DefaultHostDescription extends AbstractDescription
164 } 139 }
165 return false; 140 return false;
166 } 141 }
142 +
167 } 143 }
......
...@@ -22,7 +22,6 @@ import org.onosproject.net.HostLocation; ...@@ -22,7 +22,6 @@ import org.onosproject.net.HostLocation;
22 import org.onlab.packet.IpAddress; 22 import org.onlab.packet.IpAddress;
23 import org.onlab.packet.MacAddress; 23 import org.onlab.packet.MacAddress;
24 import org.onlab.packet.VlanId; 24 import org.onlab.packet.VlanId;
25 -import org.onosproject.store.service.WallClockTimestamp;
26 25
27 /** 26 /**
28 * Information describing host and its location. 27 * Information describing host and its location.
...@@ -56,12 +55,4 @@ public interface HostDescription extends Description { ...@@ -56,12 +55,4 @@ public interface HostDescription extends Description {
56 * @return host IP address 55 * @return host IP address
57 */ 56 */
58 Set<IpAddress> ipAddress(); 57 Set<IpAddress> ipAddress();
59 -
60 - /**
61 - * Returns the host recent updated Time.
62 - * @return host last updated time.
63 - */
64 - default WallClockTimestamp timestamp() {
65 - return null;
66 - }
67 } 58 }
......
...@@ -39,8 +39,7 @@ public final class HostCodec extends AnnotatedCodec<Host> { ...@@ -39,8 +39,7 @@ public final class HostCodec extends AnnotatedCodec<Host> {
39 final ObjectNode result = context.mapper().createObjectNode() 39 final ObjectNode result = context.mapper().createObjectNode()
40 .put("id", host.id().toString()) 40 .put("id", host.id().toString())
41 .put("mac", host.mac().toString()) 41 .put("mac", host.mac().toString())
42 - .put("vlan", host.vlan().toString()) 42 + .put("vlan", host.vlan().toString());
43 - .put("timestamp", host.timestamp().unixTimestamp());
44 43
45 final ArrayNode jsonIpAddresses = result.putArray("ipAddresses"); 44 final ArrayNode jsonIpAddresses = result.putArray("ipAddresses");
46 for (final IpAddress ipAddress : host.ipAddresses()) { 45 for (final IpAddress ipAddress : host.ipAddresses()) {
......
...@@ -12,7 +12,6 @@ TEST_DEPS = [ ...@@ -12,7 +12,6 @@ TEST_DEPS = [
12 '//core/common:onos-core-common', 12 '//core/common:onos-core-common',
13 '//core/store/dist:onos-core-dist', 13 '//core/store/dist:onos-core-dist',
14 '//core/store/dist:onos-core-dist-tests', 14 '//core/store/dist:onos-core-dist-tests',
15 - '//utils/osgi:onlab-osgi-tests',
16 ] 15 ]
17 16
18 osgi_jar_with_tests ( 17 osgi_jar_with_tests (
......
...@@ -125,13 +125,6 @@ ...@@ -125,13 +125,6 @@
125 <groupId>org.onosproject</groupId> 125 <groupId>org.onosproject</groupId>
126 <artifactId>onos-incubator-net</artifactId> 126 <artifactId>onos-incubator-net</artifactId>
127 </dependency> 127 </dependency>
128 - <dependency>
129 - <groupId>org.onosproject</groupId>
130 - <artifactId>onlab-osgi</artifactId>
131 - <version>${project.version}</version>
132 - <classifier>tests</classifier>
133 - <scope>test</scope>
134 - </dependency>
135 </dependencies> 128 </dependencies>
136 129
137 </project> 130 </project>
......
...@@ -106,15 +106,6 @@ public class HostManager ...@@ -106,15 +106,6 @@ public class HostManager
106 label = "Enable removal of duplicate ip address") 106 label = "Enable removal of duplicate ip address")
107 107
108 private boolean allowDuplicateIps = true; 108 private boolean allowDuplicateIps = true;
109 -
110 - @Property(name = "monitorHosts", boolValue = false,
111 - label = "Enable/Disable monitoring of hosts")
112 - private boolean monitorHosts = false;
113 -
114 - @Property(name = "probeRate", longValue = 30000,
115 - label = "Set the probe Rate in milli seconds")
116 - private long probeRate = 30000;
117 -
118 private HostMonitor monitor; 109 private HostMonitor monitor;
119 110
120 111
...@@ -123,71 +114,17 @@ public class HostManager ...@@ -123,71 +114,17 @@ public class HostManager
123 store.setDelegate(delegate); 114 store.setDelegate(delegate);
124 eventDispatcher.addSink(HostEvent.class, listenerRegistry); 115 eventDispatcher.addSink(HostEvent.class, listenerRegistry);
125 cfgService.registerProperties(getClass()); 116 cfgService.registerProperties(getClass());
117 + modified(context);
126 networkConfigService.addListener(networkConfigListener); 118 networkConfigService.addListener(networkConfigListener);
127 monitor = new HostMonitor(packetService, this, interfaceService, edgePortService); 119 monitor = new HostMonitor(packetService, this, interfaceService, edgePortService);
128 - monitor.setProbeRate(probeRate);
129 monitor.start(); 120 monitor.start();
130 - modified(context);
131 - cfgService.registerProperties(getClass());
132 log.info("Started"); 121 log.info("Started");
133 } 122 }
134 123
135 - @Deactivate
136 - public void deactivate() {
137 - store.unsetDelegate(delegate);
138 - eventDispatcher.removeSink(HostEvent.class);
139 - networkConfigService.removeListener(networkConfigListener);
140 - cfgService.unregisterProperties(getClass(), false);
141 - monitor.shutdown();
142 - log.info("Stopped");
143 - }
144 -
145 @Modified 124 @Modified
146 public void modified(ComponentContext context) { 125 public void modified(ComponentContext context) {
147 - boolean oldValue = monitorHosts;
148 - readComponentConfiguration(context);
149 - if (probeRate > 0) {
150 - monitor.setProbeRate(probeRate);
151 - } else {
152 - log.warn("probeRate cannot be lessthan 0");
153 - }
154 -
155 - if (oldValue != monitorHosts) {
156 - if (monitorHosts) {
157 - startMonitoring();
158 - } else {
159 - stopMonitoring();
160 - }
161 - }
162 - }
163 -
164 - /**
165 - * Extracts properties from the component configuration context.
166 - *
167 - * @param context the component context
168 - */
169 - private void readComponentConfiguration(ComponentContext context) {
170 Dictionary<?, ?> properties = context.getProperties(); 126 Dictionary<?, ?> properties = context.getProperties();
171 Boolean flag; 127 Boolean flag;
172 -
173 - flag = Tools.isPropertyEnabled(properties, "monitorHosts");
174 - if (flag == null) {
175 - log.info("monitorHosts is not enabled " +
176 - "using current value of {}", monitorHosts);
177 - } else {
178 - monitorHosts = flag;
179 - log.info("Configured. monitorHosts {}",
180 - monitorHosts ? "enabled" : "disabled");
181 - }
182 -
183 - Long longValue = Tools.getLongProperty(properties, "probeRate");
184 - if (longValue == null || longValue == 0) {
185 - log.info("probeRate is not set sing default value of {}", probeRate);
186 - } else {
187 - probeRate = longValue;
188 - log.info("Configured. probeRate {}", probeRate);
189 - }
190 -
191 flag = Tools.isPropertyEnabled(properties, "allowDuplicateIps"); 128 flag = Tools.isPropertyEnabled(properties, "allowDuplicateIps");
192 if (flag == null) { 129 if (flag == null) {
193 log.info("Removal of duplicate ip address is not configured"); 130 log.info("Removal of duplicate ip address is not configured");
...@@ -196,32 +133,14 @@ public class HostManager ...@@ -196,32 +133,14 @@ public class HostManager
196 log.info("Removal of duplicate ip address is {}", 133 log.info("Removal of duplicate ip address is {}",
197 allowDuplicateIps ? "disabled" : "enabled"); 134 allowDuplicateIps ? "disabled" : "enabled");
198 } 135 }
199 -
200 -
201 } 136 }
202 137
203 - /** 138 + @Deactivate
204 - * Starts monitoring the hosts by IP Address. 139 + public void deactivate() {
205 - * 140 + store.unsetDelegate(delegate);
206 - */ 141 + eventDispatcher.removeSink(HostEvent.class);
207 - private void startMonitoring() { 142 + networkConfigService.removeListener(networkConfigListener);
208 - store.getHosts().forEach(host -> { 143 + log.info("Stopped");
209 - host.ipAddresses().forEach(ip -> {
210 - monitor.addMonitoringFor(ip);
211 - });
212 - });
213 - }
214 -
215 - /**
216 - * Stops monitoring the hosts by IP Address.
217 - *
218 - */
219 - private void stopMonitoring() {
220 - store.getHosts().forEach(host -> {
221 - host.ipAddresses().forEach(ip -> {
222 - monitor.stopMonitoring(ip);
223 - });
224 - });
225 } 144 }
226 145
227 @Override 146 @Override
...@@ -325,15 +244,8 @@ public class HostManager ...@@ -325,15 +244,8 @@ public class HostManager
325 } 244 }
326 store.createOrUpdateHost(provider().id(), hostId, 245 store.createOrUpdateHost(provider().id(), hostId,
327 hostDescription, replaceIps); 246 hostDescription, replaceIps);
328 -
329 - if (monitorHosts) {
330 - hostDescription.ipAddress().forEach(ip -> {
331 - monitor.addMonitoringFor(ip);
332 - });
333 - }
334 } 247 }
335 248
336 -
337 // When a new IP is detected, remove that IP on other hosts if it exists 249 // When a new IP is detected, remove that IP on other hosts if it exists
338 public void removeDuplicates(HostId hostId, HostDescription desc) { 250 public void removeDuplicates(HostId hostId, HostDescription desc) {
339 desc.ipAddress().forEach(ip -> { 251 desc.ipAddress().forEach(ip -> {
...@@ -346,7 +258,9 @@ public class HostManager ...@@ -346,7 +258,9 @@ public class HostManager
346 } 258 }
347 }); 259 });
348 }); 260 });
349 - } 261 + }
262 +
263 +
350 264
351 265
352 // returns a HostDescription made from the union of the BasicHostConfig 266 // returns a HostDescription made from the union of the BasicHostConfig
...@@ -362,12 +276,6 @@ public class HostManager ...@@ -362,12 +276,6 @@ public class HostManager
362 public void hostVanished(HostId hostId) { 276 public void hostVanished(HostId hostId) {
363 checkNotNull(hostId, HOST_ID_NULL); 277 checkNotNull(hostId, HOST_ID_NULL);
364 checkValidity(); 278 checkValidity();
365 - Host host = store.getHost(hostId);
366 - if (monitorHosts) {
367 - host.ipAddresses().forEach(ip -> {
368 - monitor.stopMonitoring(ip);
369 - });
370 - }
371 store.removeHost(hostId); 279 store.removeHost(hostId);
372 } 280 }
373 281
...@@ -415,4 +323,3 @@ public class HostManager ...@@ -415,4 +323,3 @@ public class HostManager
415 } 323 }
416 } 324 }
417 } 325 }
418 -
......
...@@ -150,13 +150,6 @@ public class HostMonitor implements TimerTask { ...@@ -150,13 +150,6 @@ public class HostMonitor implements TimerTask {
150 hostProviders.put(provider.id(), provider); 150 hostProviders.put(provider.id(), provider);
151 } 151 }
152 152
153 - /*
154 - * Sets the probe rate.
155 - */
156 - void setProbeRate(long probeRate) {
157 - this.probeRate = probeRate;
158 - }
159 -
160 @Override 153 @Override
161 public void run(Timeout timeout) throws Exception { 154 public void run(Timeout timeout) throws Exception {
162 monitoredAddresses.forEach(this::probe); 155 monitoredAddresses.forEach(this::probe);
......
...@@ -98,14 +98,12 @@ public class HostManagerTest { ...@@ -98,14 +98,12 @@ public class HostManagerTest {
98 protected TestHostProvider provider; 98 protected TestHostProvider provider;
99 protected HostProviderService providerService; 99 protected HostProviderService providerService;
100 100
101 - private static final ComponentContextAdapter REMOVE_DUPS_MONITOR = 101 + private static final ComponentContextAdapter REMOVE_DUPS =
102 new ComponentContextAdapter() { 102 new ComponentContextAdapter() {
103 @Override 103 @Override
104 public Dictionary getProperties() { 104 public Dictionary getProperties() {
105 Hashtable<String, String> props = new Hashtable<>(); 105 Hashtable<String, String> props = new Hashtable<>();
106 props.put("allowDuplicateIps", "true"); 106 props.put("allowDuplicateIps", "true");
107 - props.put("monitorHosts", "true");
108 - props.put("probeRate", "40000");
109 return props; 107 return props;
110 } 108 }
111 }; 109 };
...@@ -118,27 +116,28 @@ public class HostManagerTest { ...@@ -118,27 +116,28 @@ public class HostManagerTest {
118 registry = mgr; 116 registry = mgr;
119 mgr.networkConfigService = new TestNetworkConfigService(); 117 mgr.networkConfigService = new TestNetworkConfigService();
120 mgr.cfgService = new ComponentConfigAdapter(); 118 mgr.cfgService = new ComponentConfigAdapter();
121 - 119 + mgr.activate(REMOVE_DUPS);
122 - mgr.activate(REMOVE_DUPS_MONITOR);
123 -
124 mgr.addListener(listener); 120 mgr.addListener(listener);
125 121
126 provider = new TestHostProvider(); 122 provider = new TestHostProvider();
127 providerService = registry.register(provider); 123 providerService = registry.register(provider);
128 - assertTrue("provider should be registered", registry.getProviders().contains(provider.id())); 124 + assertTrue("provider should be registered",
125 + registry.getProviders().contains(provider.id()));
129 } 126 }
130 127
131 @After 128 @After
132 public void tearDown() { 129 public void tearDown() {
133 registry.unregister(provider); 130 registry.unregister(provider);
134 - assertFalse("provider should not be registered", registry.getProviders().contains(provider.id())); 131 + assertFalse("provider should not be registered",
132 + registry.getProviders().contains(provider.id()));
135 133
136 mgr.removeListener(listener); 134 mgr.removeListener(listener);
137 mgr.deactivate(); 135 mgr.deactivate();
138 injectEventDispatcher(mgr, null); 136 injectEventDispatcher(mgr, null);
139 } 137 }
140 138
141 - private void detect(HostId hid, MacAddress mac, VlanId vlan, HostLocation loc, IpAddress ip) { 139 + private void detect(HostId hid, MacAddress mac, VlanId vlan,
140 + HostLocation loc, IpAddress ip) {
142 HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ip); 141 HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ip);
143 providerService.hostDetected(hid, descr, false); 142 providerService.hostDetected(hid, descr, false);
144 assertNotNull("host should be found", mgr.getHost(hid)); 143 assertNotNull("host should be found", mgr.getHost(hid));
...@@ -218,7 +217,8 @@ public class HostManagerTest { ...@@ -218,7 +217,8 @@ public class HostManagerTest {
218 assertNull("host should have been removed", mgr.getHost(HID3)); 217 assertNull("host should have been removed", mgr.getHost(HID3));
219 } 218 }
220 219
221 - private void validateHosts(String msg, Iterable<Host> hosts, HostId... ids) { 220 + private void validateHosts(
221 + String msg, Iterable<Host> hosts, HostId... ids) {
222 Set<HostId> hids = Sets.newHashSet(ids); 222 Set<HostId> hids = Sets.newHashSet(ids);
223 for (Host h : hosts) { 223 for (Host h : hosts) {
224 assertTrue(msg, hids.remove(h.id())); 224 assertTrue(msg, hids.remove(h.id()));
...@@ -252,7 +252,8 @@ public class HostManagerTest { ...@@ -252,7 +252,8 @@ public class HostManagerTest {
252 assertTrue("incorrect host location", mgr.getConnectedHosts(DID2).isEmpty()); 252 assertTrue("incorrect host location", mgr.getConnectedHosts(DID2).isEmpty());
253 } 253 }
254 254
255 - private static class TestHostProvider extends AbstractProvider implements HostProvider { 255 + private static class TestHostProvider extends AbstractProvider
256 + implements HostProvider {
256 257
257 protected TestHostProvider() { 258 protected TestHostProvider() {
258 super(PID); 259 super(PID);
...@@ -283,4 +284,3 @@ public class HostManagerTest { ...@@ -283,4 +284,3 @@ public class HostManagerTest {
283 private class TestNetworkConfigService extends NetworkConfigServiceAdapter { 284 private class TestNetworkConfigService extends NetworkConfigServiceAdapter {
284 } 285 }
285 } 286 }
286 -
......
...@@ -48,7 +48,6 @@ import org.onosproject.store.service.MapEvent; ...@@ -48,7 +48,6 @@ import org.onosproject.store.service.MapEvent;
48 import org.onosproject.store.service.MapEventListener; 48 import org.onosproject.store.service.MapEventListener;
49 import org.onosproject.store.service.Serializer; 49 import org.onosproject.store.service.Serializer;
50 import org.onosproject.store.service.StorageService; 50 import org.onosproject.store.service.StorageService;
51 -import org.onosproject.store.service.WallClockTimestamp;
52 import org.slf4j.Logger; 51 import org.slf4j.Logger;
53 52
54 import java.util.Collection; 53 import java.util.Collection;
...@@ -88,8 +87,7 @@ public class DistributedHostStore ...@@ -88,8 +87,7 @@ public class DistributedHostStore
88 @Activate 87 @Activate
89 public void activate() { 88 public void activate() {
90 KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder() 89 KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
91 - .register(KryoNamespaces.API) 90 + .register(KryoNamespaces.API);
92 - .register(WallClockTimestamp.class);
93 91
94 hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder() 92 hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder()
95 .withName("onos-hosts") 93 .withName("onos-hosts")
...@@ -124,9 +122,7 @@ public class DistributedHostStore ...@@ -124,9 +122,7 @@ public class DistributedHostStore
124 if (!Objects.equals(existingHost.providerId(), providerId) || 122 if (!Objects.equals(existingHost.providerId(), providerId) ||
125 !Objects.equals(existingHost.mac(), hostDescription.hwAddress()) || 123 !Objects.equals(existingHost.mac(), hostDescription.hwAddress()) ||
126 !Objects.equals(existingHost.vlan(), hostDescription.vlan()) || 124 !Objects.equals(existingHost.vlan(), hostDescription.vlan()) ||
127 - !Objects.equals(existingHost.location(), hostDescription.location()) || 125 + !Objects.equals(existingHost.location(), hostDescription.location())) {
128 - hostDescription.timestamp() == null ||
129 - hostDescription.timestamp().isNewerThan(existingHost.timestamp())) {
130 return true; 126 return true;
131 } 127 }
132 128
...@@ -177,13 +173,13 @@ public class DistributedHostStore ...@@ -177,13 +173,13 @@ public class DistributedHostStore
177 } else { 173 } else {
178 annotations = hostDescription.annotations(); 174 annotations = hostDescription.annotations();
179 } 175 }
176 +
180 return new DefaultHost(providerId, 177 return new DefaultHost(providerId,
181 hostId, 178 hostId,
182 hostDescription.hwAddress(), 179 hostDescription.hwAddress(),
183 hostDescription.vlan(), 180 hostDescription.vlan(),
184 location, 181 location,
185 addresses, 182 addresses,
186 - hostDescription.timestamp(),
187 annotations); 183 annotations);
188 }); 184 });
189 return null; 185 return null;
...@@ -306,4 +302,3 @@ public class DistributedHostStore ...@@ -306,4 +302,3 @@ public class DistributedHostStore
306 } 302 }
307 } 303 }
308 } 304 }
309 -
......
...@@ -44,22 +44,17 @@ import org.onosproject.net.Device; ...@@ -44,22 +44,17 @@ import org.onosproject.net.Device;
44 import org.onosproject.net.Host; 44 import org.onosproject.net.Host;
45 import org.onosproject.net.HostId; 45 import org.onosproject.net.HostId;
46 import org.onosproject.net.HostLocation; 46 import org.onosproject.net.HostLocation;
47 -import org.onosproject.net.MastershipRole;
48 import org.onosproject.net.device.DeviceEvent; 47 import org.onosproject.net.device.DeviceEvent;
49 import org.onosproject.net.device.DeviceListener; 48 import org.onosproject.net.device.DeviceListener;
50 import org.onosproject.net.device.DeviceService; 49 import org.onosproject.net.device.DeviceService;
51 import org.onosproject.net.flow.DefaultTrafficSelector; 50 import org.onosproject.net.flow.DefaultTrafficSelector;
52 -import org.onosproject.net.flow.DefaultTrafficTreatment;
53 import org.onosproject.net.flow.TrafficSelector; 51 import org.onosproject.net.flow.TrafficSelector;
54 -import org.onosproject.net.flow.TrafficTreatment;
55 import org.onosproject.net.host.DefaultHostDescription; 52 import org.onosproject.net.host.DefaultHostDescription;
56 import org.onosproject.net.host.HostDescription; 53 import org.onosproject.net.host.HostDescription;
57 import org.onosproject.net.host.HostProvider; 54 import org.onosproject.net.host.HostProvider;
58 import org.onosproject.net.host.HostProviderRegistry; 55 import org.onosproject.net.host.HostProviderRegistry;
59 import org.onosproject.net.host.HostProviderService; 56 import org.onosproject.net.host.HostProviderService;
60 import org.onosproject.net.host.HostService; 57 import org.onosproject.net.host.HostService;
61 -import org.onosproject.net.packet.DefaultOutboundPacket;
62 -import org.onosproject.net.packet.OutboundPacket;
63 import org.onosproject.net.packet.PacketContext; 58 import org.onosproject.net.packet.PacketContext;
64 import org.onosproject.net.packet.PacketPriority; 59 import org.onosproject.net.packet.PacketPriority;
65 import org.onosproject.net.packet.PacketProcessor; 60 import org.onosproject.net.packet.PacketProcessor;
...@@ -71,7 +66,6 @@ import org.onosproject.net.topology.TopologyService; ...@@ -71,7 +66,6 @@ import org.onosproject.net.topology.TopologyService;
71 import org.osgi.service.component.ComponentContext; 66 import org.osgi.service.component.ComponentContext;
72 import org.slf4j.Logger; 67 import org.slf4j.Logger;
73 68
74 -import java.nio.ByteBuffer;
75 import java.util.Dictionary; 69 import java.util.Dictionary;
76 import java.util.Set; 70 import java.util.Set;
77 import java.util.concurrent.ExecutorService; 71 import java.util.concurrent.ExecutorService;
...@@ -132,8 +126,6 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -132,8 +126,6 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
132 126
133 protected ExecutorService eventHandler; 127 protected ExecutorService eventHandler;
134 128
135 - private static final byte[] SENDER_ADDRESS = IpAddress.valueOf("0.0.0.0").toOctets();
136 -
137 /** 129 /**
138 * Creates an OpenFlow host provider. 130 * Creates an OpenFlow host provider.
139 */ 131 */
...@@ -269,60 +261,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -269,60 +261,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
269 261
270 @Override 262 @Override
271 public void triggerProbe(Host host) { 263 public void triggerProbe(Host host) {
272 - log.info("Triggering probe on device {} ", host); 264 + log.info("Triggering probe on device {}", host);
273 - MastershipRole role = deviceService.getRole(host.location().deviceId());
274 - if (role.equals(MastershipRole.MASTER)) {
275 - host.ipAddresses().forEach(ip -> {
276 - sendProbe(host, ip);
277 - });
278 - } else {
279 - log.info("not the master, master will probe {}");
280 - }
281 - }
282 -
283 - private void sendProbe(Host host, IpAddress targetIp) {
284 - Ethernet probePacket = null;
285 - if (targetIp.isIp4()) {
286 - // IPv4: Use ARP
287 - probePacket = buildArpRequest(targetIp, host);
288 - } else {
289 - // IPv6: Use Neighbor Discovery
290 - //FIX ME need to implement ndp probe
291 - log.info("Triggering probe on device {} ", host);
292 - }
293 -
294 - TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(host.location().port()).build();
295 -
296 - OutboundPacket outboundPacket = new DefaultOutboundPacket(host.location().deviceId(), treatment,
297 - ByteBuffer.wrap(probePacket.serialize()));
298 -
299 - packetService.emit(outboundPacket);
300 - }
301 -
302 - /*
303 - * This method is using source ip as 0.0.0.0 , to receive the reply even from the sub net hosts.
304 - */
305 - private Ethernet buildArpRequest(IpAddress targetIp, Host host) {
306 -
307 - ARP arp = new ARP();
308 - arp.setHardwareType(ARP.HW_TYPE_ETHERNET)
309 - .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
310 - .setProtocolType(ARP.PROTO_TYPE_IP)
311 - .setProtocolAddressLength((byte) IpAddress.INET_BYTE_LENGTH)
312 - .setOpCode(ARP.OP_REQUEST);
313 -
314 - arp.setSenderHardwareAddress(MacAddress.BROADCAST.toBytes())
315 - .setSenderProtocolAddress(SENDER_ADDRESS)
316 - .setTargetHardwareAddress(MacAddress.BROADCAST.toBytes())
317 - .setTargetProtocolAddress(targetIp.toOctets());
318 -
319 - Ethernet ethernet = new Ethernet();
320 - ethernet.setEtherType(Ethernet.TYPE_ARP)
321 - .setDestinationMACAddress(MacAddress.BROADCAST)
322 - .setSourceMACAddress(MacAddress.BROADCAST).setPayload(arp);
323 -
324 - ethernet.setPad(true);
325 - return ethernet;
326 } 265 }
327 266
328 private class InternalHostProvider implements PacketProcessor { 267 private class InternalHostProvider implements PacketProcessor {
...@@ -510,4 +449,3 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -510,4 +449,3 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
510 } 449 }
511 450
512 } 451 }
513 -
......
...@@ -348,26 +348,6 @@ public abstract class Tools { ...@@ -348,26 +348,6 @@ public abstract class Tools {
348 } 348 }
349 349
350 /** 350 /**
351 - * Get Long property from the propertyName
352 - * Return null if propertyName is not found.
353 - *
354 - * @param properties properties to be looked up
355 - * @param propertyName the name of the property to look up
356 - * @return value when the propertyName is defined or return null
357 - */
358 - public static Long getLongProperty(Dictionary<?, ?> properties,
359 - String propertyName) {
360 - Long value;
361 - try {
362 - String s = get(properties, propertyName);
363 - value = Strings.isNullOrEmpty(s) ? null : Long.valueOf(s);
364 - } catch (NumberFormatException | ClassCastException e) {
365 - value = null;
366 - }
367 - return value;
368 - }
369 -
370 - /**
371 * Suspends the current thread for a specified number of millis. 351 * Suspends the current thread for a specified number of millis.
372 * 352 *
373 * @param ms number of millis 353 * @param ms number of millis
......
...@@ -198,7 +198,7 @@ public class HostResourceTest extends ResourceTest { ...@@ -198,7 +198,7 @@ public class HostResourceTest extends ResourceTest {
198 @Override 198 @Override
199 public boolean matchesSafely(JsonArray json) { 199 public boolean matchesSafely(JsonArray json) {
200 boolean hostFound = false; 200 boolean hostFound = false;
201 - final int expectedAttributes = 6; 201 + final int expectedAttributes = 5;
202 for (int jsonHostIndex = 0; jsonHostIndex < json.size(); 202 for (int jsonHostIndex = 0; jsonHostIndex < json.size();
203 jsonHostIndex++) { 203 jsonHostIndex++) {
204 204
......