Jonathan Hart
Committed by Gerrit Code Review

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

This reverts commit 2451a099.

Change-Id: Iab7afd7c61cc1e25292e093660170101da779cf8
...@@ -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()) {
......
...@@ -8,7 +8,6 @@ TEST_DEPS = [ ...@@ -8,7 +8,6 @@ TEST_DEPS = [
8 '//core/common:onos-core-common', 8 '//core/common:onos-core-common',
9 '//core/store/dist:onos-core-dist', 9 '//core/store/dist:onos-core-dist',
10 '//core/store/dist:onos-core-dist-tests', 10 '//core/store/dist:onos-core-dist-tests',
11 - '//utils/osgi:onlab-osgi-tests',
12 ] 11 ]
13 12
14 osgi_jar_with_tests ( 13 osgi_jar_with_tests (
...@@ -16,4 +15,4 @@ osgi_jar_with_tests ( ...@@ -16,4 +15,4 @@ osgi_jar_with_tests (
16 deps = COMPILE_DEPS, 15 deps = COMPILE_DEPS,
17 test_deps = TEST_DEPS, 16 test_deps = TEST_DEPS,
18 visibility = ['PUBLIC'], 17 visibility = ['PUBLIC'],
19 -) 18 +)
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -110,13 +110,6 @@ ...@@ -110,13 +110,6 @@
110 <groupId>org.apache.felix</groupId> 110 <groupId>org.apache.felix</groupId>
111 <artifactId>org.apache.felix.scr</artifactId> 111 <artifactId>org.apache.felix.scr</artifactId>
112 </dependency> 112 </dependency>
113 - <dependency>
114 - <groupId>org.onosproject</groupId>
115 - <artifactId>onlab-osgi</artifactId>
116 - <version>${project.version}</version>
117 - <classifier>tests</classifier>
118 - <scope>test</scope>
119 - </dependency>
120 </dependencies> 113 </dependencies>
121 114
122 </project> 115 </project>
......
...@@ -18,16 +18,12 @@ package org.onosproject.net.host.impl; ...@@ -18,16 +18,12 @@ package org.onosproject.net.host.impl;
18 import org.apache.felix.scr.annotations.Activate; 18 import org.apache.felix.scr.annotations.Activate;
19 import org.apache.felix.scr.annotations.Component; 19 import org.apache.felix.scr.annotations.Component;
20 import org.apache.felix.scr.annotations.Deactivate; 20 import org.apache.felix.scr.annotations.Deactivate;
21 -import org.apache.felix.scr.annotations.Modified;
22 -import org.apache.felix.scr.annotations.Property;
23 import org.apache.felix.scr.annotations.Reference; 21 import org.apache.felix.scr.annotations.Reference;
24 import org.apache.felix.scr.annotations.ReferenceCardinality; 22 import org.apache.felix.scr.annotations.ReferenceCardinality;
25 import org.apache.felix.scr.annotations.Service; 23 import org.apache.felix.scr.annotations.Service;
26 import org.onlab.packet.IpAddress; 24 import org.onlab.packet.IpAddress;
27 import org.onlab.packet.MacAddress; 25 import org.onlab.packet.MacAddress;
28 import org.onlab.packet.VlanId; 26 import org.onlab.packet.VlanId;
29 -import org.onlab.util.Tools;
30 -import org.onosproject.cfg.ComponentConfigService;
31 import org.onosproject.incubator.net.intf.InterfaceService; 27 import org.onosproject.incubator.net.intf.InterfaceService;
32 import org.onosproject.net.edge.EdgePortService; 28 import org.onosproject.net.edge.EdgePortService;
33 import org.onosproject.net.provider.AbstractListenerProviderRegistry; 29 import org.onosproject.net.provider.AbstractListenerProviderRegistry;
...@@ -52,10 +48,8 @@ import org.onosproject.net.host.HostStore; ...@@ -52,10 +48,8 @@ import org.onosproject.net.host.HostStore;
52 import org.onosproject.net.host.HostStoreDelegate; 48 import org.onosproject.net.host.HostStoreDelegate;
53 import org.onosproject.net.packet.PacketService; 49 import org.onosproject.net.packet.PacketService;
54 import org.onosproject.net.provider.AbstractProviderService; 50 import org.onosproject.net.provider.AbstractProviderService;
55 -import org.osgi.service.component.ComponentContext;
56 import org.slf4j.Logger; 51 import org.slf4j.Logger;
57 52
58 -import java.util.Dictionary;
59 import java.util.Set; 53 import java.util.Set;
60 54
61 import static com.google.common.base.Preconditions.checkNotNull; 55 import static com.google.common.base.Preconditions.checkNotNull;
...@@ -99,29 +93,15 @@ public class HostManager ...@@ -99,29 +93,15 @@ public class HostManager
99 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 93 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
100 protected EdgePortService edgePortService; 94 protected EdgePortService edgePortService;
101 95
102 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
103 - protected ComponentConfigService cfgService;
104 -
105 - @Property(name = "monitorHosts", boolValue = false,
106 - label = "Enable/Disable monitoring of hosts")
107 - private boolean monitorHosts = false;
108 -
109 - @Property(name = "probeRate", longValue = 30000,
110 - label = "Set the probe Rate in milli seconds")
111 - private long probeRate = 30000;
112 -
113 private HostMonitor monitor; 96 private HostMonitor monitor;
114 97
115 @Activate 98 @Activate
116 - public void activate(ComponentContext context) { 99 + public void activate() {
117 store.setDelegate(delegate); 100 store.setDelegate(delegate);
118 eventDispatcher.addSink(HostEvent.class, listenerRegistry); 101 eventDispatcher.addSink(HostEvent.class, listenerRegistry);
119 networkConfigService.addListener(networkConfigListener); 102 networkConfigService.addListener(networkConfigListener);
120 monitor = new HostMonitor(packetService, this, interfaceService, edgePortService); 103 monitor = new HostMonitor(packetService, this, interfaceService, edgePortService);
121 - monitor.setProbeRate(probeRate);
122 monitor.start(); 104 monitor.start();
123 - modified(context);
124 - cfgService.registerProperties(getClass());
125 log.info("Started"); 105 log.info("Started");
126 } 106 }
127 107
...@@ -130,82 +110,9 @@ public class HostManager ...@@ -130,82 +110,9 @@ public class HostManager
130 store.unsetDelegate(delegate); 110 store.unsetDelegate(delegate);
131 eventDispatcher.removeSink(HostEvent.class); 111 eventDispatcher.removeSink(HostEvent.class);
132 networkConfigService.removeListener(networkConfigListener); 112 networkConfigService.removeListener(networkConfigListener);
133 - cfgService.unregisterProperties(getClass(), false);
134 - monitor.shutdown();
135 log.info("Stopped"); 113 log.info("Stopped");
136 } 114 }
137 115
138 - @Modified
139 - public void modified(ComponentContext context) {
140 - boolean oldValue = monitorHosts;
141 - readComponentConfiguration(context);
142 - if (probeRate > 0) {
143 - monitor.setProbeRate(probeRate);
144 - } else {
145 - log.warn("probeRate cannot be lessthan 0");
146 - }
147 - if (oldValue != monitorHosts) {
148 - if (monitorHosts) {
149 - startMonitoring();
150 - } else {
151 - stopMonitoring();
152 - }
153 - }
154 - }
155 -
156 - /**
157 - * Extracts properties from the component configuration context.
158 - *
159 - * @param context the component context
160 - */
161 - private void readComponentConfiguration(ComponentContext context) {
162 - Dictionary<?, ?> properties = context.getProperties();
163 - Boolean flag;
164 -
165 - flag = Tools.isPropertyEnabled(properties, "monitorHosts");
166 - if (flag == null) {
167 - log.info("monitorHosts is not enabled " +
168 - "using current value of {}", monitorHosts);
169 - } else {
170 - monitorHosts = flag;
171 - log.info("Configured. monitorHosts {}",
172 - monitorHosts ? "enabled" : "disabled");
173 - }
174 -
175 - Long longValue = Tools.getLongProperty(properties, "probeRate");
176 - if (longValue == null || longValue == 0) {
177 - log.info("probeRate is not set sing default value of {}", probeRate);
178 - } else {
179 - probeRate = longValue;
180 - log.info("Configured. probeRate {}", probeRate);
181 - }
182 -
183 - }
184 -
185 - /**
186 - * Starts monitoring the hosts by IP Address.
187 - *
188 - */
189 - private void startMonitoring() {
190 - store.getHosts().forEach(host -> {
191 - host.ipAddresses().forEach(ip -> {
192 - monitor.addMonitoringFor(ip);
193 - });
194 - });
195 - }
196 -
197 - /**
198 - * Stops monitoring the hosts by IP Address.
199 - *
200 - */
201 - private void stopMonitoring() {
202 - store.getHosts().forEach(host -> {
203 - host.ipAddresses().forEach(ip -> {
204 - monitor.stopMonitoring(ip);
205 - });
206 - });
207 - }
208 -
209 @Override 116 @Override
210 protected HostProviderService createProviderService(HostProvider provider) { 117 protected HostProviderService createProviderService(HostProvider provider) {
211 monitor.registerHostProvider(provider); 118 monitor.registerHostProvider(provider);
...@@ -304,11 +211,6 @@ public class HostManager ...@@ -304,11 +211,6 @@ public class HostManager
304 hostDescription = validateHost(hostDescription, hostId); 211 hostDescription = validateHost(hostDescription, hostId);
305 store.createOrUpdateHost(provider().id(), hostId, 212 store.createOrUpdateHost(provider().id(), hostId,
306 hostDescription, replaceIps); 213 hostDescription, replaceIps);
307 - if (monitorHosts) {
308 - hostDescription.ipAddress().forEach(ip -> {
309 - monitor.addMonitoringFor(ip);
310 - });
311 - }
312 } 214 }
313 215
314 // returns a HostDescription made from the union of the BasicHostConfig 216 // returns a HostDescription made from the union of the BasicHostConfig
...@@ -324,12 +226,6 @@ public class HostManager ...@@ -324,12 +226,6 @@ public class HostManager
324 public void hostVanished(HostId hostId) { 226 public void hostVanished(HostId hostId) {
325 checkNotNull(hostId, HOST_ID_NULL); 227 checkNotNull(hostId, HOST_ID_NULL);
326 checkValidity(); 228 checkValidity();
327 - Host host = store.getHost(hostId);
328 - if (monitorHosts) {
329 - host.ipAddresses().forEach(ip -> {
330 - monitor.stopMonitoring(ip);
331 - });
332 - }
333 store.removeHost(hostId); 229 store.removeHost(hostId);
334 } 230 }
335 231
...@@ -377,4 +273,3 @@ public class HostManager ...@@ -377,4 +273,3 @@ public class HostManager
377 } 273 }
378 } 274 }
379 } 275 }
380 -
......
...@@ -149,13 +149,6 @@ public class HostMonitor implements TimerTask { ...@@ -149,13 +149,6 @@ public class HostMonitor implements TimerTask {
149 hostProviders.put(provider.id(), provider); 149 hostProviders.put(provider.id(), provider);
150 } 150 }
151 151
152 - /*
153 - * Sets the probe rate.
154 - */
155 - void setProbeRate(long probeRate) {
156 - this.probeRate = probeRate;
157 - }
158 -
159 @Override 152 @Override
160 public void run(Timeout timeout) throws Exception { 153 public void run(Timeout timeout) throws Exception {
161 for (IpAddress ip : monitoredAddresses) { 154 for (IpAddress ip : monitoredAddresses) {
......
...@@ -21,11 +21,9 @@ import org.junit.After; ...@@ -21,11 +21,9 @@ import org.junit.After;
21 import org.junit.Before; 21 import org.junit.Before;
22 import org.junit.Test; 22 import org.junit.Test;
23 import org.onlab.junit.TestTools; 23 import org.onlab.junit.TestTools;
24 -import org.onlab.osgi.ComponentContextAdapter;
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;
28 -import org.onosproject.cfg.ComponentConfigAdapter;
29 import org.onosproject.common.event.impl.TestEventDispatcher; 27 import org.onosproject.common.event.impl.TestEventDispatcher;
30 import org.onosproject.event.Event; 28 import org.onosproject.event.Event;
31 import org.onosproject.net.DeviceId; 29 import org.onosproject.net.DeviceId;
...@@ -45,8 +43,6 @@ import org.onosproject.net.provider.AbstractProvider; ...@@ -45,8 +43,6 @@ import org.onosproject.net.provider.AbstractProvider;
45 import org.onosproject.net.provider.ProviderId; 43 import org.onosproject.net.provider.ProviderId;
46 import org.onosproject.store.trivial.SimpleHostStore; 44 import org.onosproject.store.trivial.SimpleHostStore;
47 45
48 -import java.util.Dictionary;
49 -import java.util.Hashtable;
50 import java.util.List; 46 import java.util.List;
51 import java.util.Set; 47 import java.util.Set;
52 48
...@@ -91,16 +87,6 @@ public class HostManagerTest { ...@@ -91,16 +87,6 @@ public class HostManagerTest {
91 private static final HostLocation LOC1 = new HostLocation(DID1, P1, 123L); 87 private static final HostLocation LOC1 = new HostLocation(DID1, P1, 123L);
92 private static final HostLocation LOC2 = new HostLocation(DID1, P2, 123L); 88 private static final HostLocation LOC2 = new HostLocation(DID1, P2, 123L);
93 89
94 - public static final ComponentContextAdapter CTX_FOR_MONITOR = new ComponentContextAdapter() {
95 - @Override
96 - public Dictionary getProperties() {
97 - Hashtable<String, String> props = new Hashtable<String, String>();
98 - props.put("monitorHosts", "true");
99 - props.put("probeRate", "40000");
100 - return props;
101 - }
102 - };
103 -
104 private HostManager mgr; 90 private HostManager mgr;
105 91
106 protected TestListener listener = new TestListener(); 92 protected TestListener listener = new TestListener();
...@@ -115,27 +101,29 @@ public class HostManagerTest { ...@@ -115,27 +101,29 @@ public class HostManagerTest {
115 injectEventDispatcher(mgr, new TestEventDispatcher()); 101 injectEventDispatcher(mgr, new TestEventDispatcher());
116 registry = mgr; 102 registry = mgr;
117 mgr.networkConfigService = new TestNetworkConfigService(); 103 mgr.networkConfigService = new TestNetworkConfigService();
118 - mgr.cfgService = new ComponentConfigAdapter(); 104 + mgr.activate();
119 - mgr.activate(CTX_FOR_MONITOR);
120 105
121 mgr.addListener(listener); 106 mgr.addListener(listener);
122 107
123 provider = new TestHostProvider(); 108 provider = new TestHostProvider();
124 providerService = registry.register(provider); 109 providerService = registry.register(provider);
125 - assertTrue("provider should be registered", registry.getProviders().contains(provider.id())); 110 + assertTrue("provider should be registered",
111 + registry.getProviders().contains(provider.id()));
126 } 112 }
127 113
128 @After 114 @After
129 public void tearDown() { 115 public void tearDown() {
130 registry.unregister(provider); 116 registry.unregister(provider);
131 - assertFalse("provider should not be registered", registry.getProviders().contains(provider.id())); 117 + assertFalse("provider should not be registered",
118 + registry.getProviders().contains(provider.id()));
132 119
133 mgr.removeListener(listener); 120 mgr.removeListener(listener);
134 mgr.deactivate(); 121 mgr.deactivate();
135 injectEventDispatcher(mgr, null); 122 injectEventDispatcher(mgr, null);
136 } 123 }
137 124
138 - private void detect(HostId hid, MacAddress mac, VlanId vlan, HostLocation loc, IpAddress ip) { 125 + private void detect(HostId hid, MacAddress mac, VlanId vlan,
126 + HostLocation loc, IpAddress ip) {
139 HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ip); 127 HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ip);
140 providerService.hostDetected(hid, descr, false); 128 providerService.hostDetected(hid, descr, false);
141 assertNotNull("host should be found", mgr.getHost(hid)); 129 assertNotNull("host should be found", mgr.getHost(hid));
...@@ -215,7 +203,8 @@ public class HostManagerTest { ...@@ -215,7 +203,8 @@ public class HostManagerTest {
215 assertNull("host should have been removed", mgr.getHost(HID3)); 203 assertNull("host should have been removed", mgr.getHost(HID3));
216 } 204 }
217 205
218 - private void validateHosts(String msg, Iterable<Host> hosts, HostId... ids) { 206 + private void validateHosts(
207 + String msg, Iterable<Host> hosts, HostId... ids) {
219 Set<HostId> hids = Sets.newHashSet(ids); 208 Set<HostId> hids = Sets.newHashSet(ids);
220 for (Host h : hosts) { 209 for (Host h : hosts) {
221 assertTrue(msg, hids.remove(h.id())); 210 assertTrue(msg, hids.remove(h.id()));
...@@ -249,7 +238,8 @@ public class HostManagerTest { ...@@ -249,7 +238,8 @@ public class HostManagerTest {
249 assertTrue("incorrect host location", mgr.getConnectedHosts(DID2).isEmpty()); 238 assertTrue("incorrect host location", mgr.getConnectedHosts(DID2).isEmpty());
250 } 239 }
251 240
252 - private static class TestHostProvider extends AbstractProvider implements HostProvider { 241 + private static class TestHostProvider extends AbstractProvider
242 + implements HostProvider {
253 243
254 protected TestHostProvider() { 244 protected TestHostProvider() {
255 super(PID); 245 super(PID);
...@@ -280,4 +270,3 @@ public class HostManagerTest { ...@@ -280,4 +270,3 @@ public class HostManagerTest {
280 private class TestNetworkConfigService extends NetworkConfigServiceAdapter { 270 private class TestNetworkConfigService extends NetworkConfigServiceAdapter {
281 } 271 }
282 } 272 }
283 -
......
...@@ -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;
...@@ -92,8 +91,7 @@ public class DistributedHostStore ...@@ -92,8 +91,7 @@ public class DistributedHostStore
92 @Activate 91 @Activate
93 public void activate() { 92 public void activate() {
94 KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder() 93 KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
95 - .register(KryoNamespaces.API) 94 + .register(KryoNamespaces.API);
96 - .register(WallClockTimestamp.class);
97 95
98 hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder() 96 hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder()
99 .withName("onos-hosts") 97 .withName("onos-hosts")
...@@ -130,9 +128,7 @@ public class DistributedHostStore ...@@ -130,9 +128,7 @@ public class DistributedHostStore
130 if (!Objects.equals(existingHost.providerId(), providerId) || 128 if (!Objects.equals(existingHost.providerId(), providerId) ||
131 !Objects.equals(existingHost.mac(), hostDescription.hwAddress()) || 129 !Objects.equals(existingHost.mac(), hostDescription.hwAddress()) ||
132 !Objects.equals(existingHost.vlan(), hostDescription.vlan()) || 130 !Objects.equals(existingHost.vlan(), hostDescription.vlan()) ||
133 - !Objects.equals(existingHost.location(), hostDescription.location()) || 131 + !Objects.equals(existingHost.location(), hostDescription.location())) {
134 - hostDescription.timestamp() == null ||
135 - hostDescription.timestamp().isNewerThan(existingHost.timestamp())) {
136 return true; 132 return true;
137 } 133 }
138 134
...@@ -183,13 +179,13 @@ public class DistributedHostStore ...@@ -183,13 +179,13 @@ public class DistributedHostStore
183 } else { 179 } else {
184 annotations = hostDescription.annotations(); 180 annotations = hostDescription.annotations();
185 } 181 }
182 +
186 return new DefaultHost(providerId, 183 return new DefaultHost(providerId,
187 hostId, 184 hostId,
188 hostDescription.hwAddress(), 185 hostDescription.hwAddress(),
189 hostDescription.vlan(), 186 hostDescription.vlan(),
190 location, 187 location,
191 addresses, 188 addresses,
192 - hostDescription.timestamp(),
193 annotations); 189 annotations);
194 }); 190 });
195 return null; 191 return null;
...@@ -311,4 +307,3 @@ public class DistributedHostStore ...@@ -311,4 +307,3 @@ public class DistributedHostStore
311 } 307 }
312 } 308 }
313 } 309 }
314 -
......
...@@ -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
......