Removed deprecated null provider sub-modules.
Change-Id: I154bdbc5eb27ce79ae5428ec6dc01b1dc09be8b0
Showing
16 changed files
with
1 additions
and
1104 deletions
providers/null/device/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2014 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-null-providers</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-null-provider-device</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>ONOS Null protocol device provider</description> | ||
33 | - | ||
34 | - <dependencies> | ||
35 | - <dependency> | ||
36 | - <groupId>org.osgi</groupId> | ||
37 | - <artifactId>org.osgi.compendium</artifactId> | ||
38 | - </dependency> | ||
39 | - </dependencies> | ||
40 | - | ||
41 | -</project> |
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.provider.nil.device.impl; | ||
17 | - | ||
18 | -import com.google.common.collect.Lists; | ||
19 | -import com.google.common.collect.Maps; | ||
20 | -import org.apache.felix.scr.annotations.Activate; | ||
21 | -import org.apache.felix.scr.annotations.Component; | ||
22 | -import org.apache.felix.scr.annotations.Deactivate; | ||
23 | -import org.apache.felix.scr.annotations.Modified; | ||
24 | -import org.apache.felix.scr.annotations.Property; | ||
25 | -import org.apache.felix.scr.annotations.Reference; | ||
26 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
27 | -import org.onlab.packet.ChassisId; | ||
28 | -import org.onosproject.cfg.ComponentConfigService; | ||
29 | -import org.onosproject.cluster.ClusterService; | ||
30 | -import org.onosproject.cluster.NodeId; | ||
31 | -import org.onosproject.net.Device; | ||
32 | -import org.onosproject.net.DeviceId; | ||
33 | -import org.onosproject.net.MastershipRole; | ||
34 | -import org.onosproject.net.Port; | ||
35 | -import org.onosproject.net.PortNumber; | ||
36 | -import org.onosproject.net.device.DefaultDeviceDescription; | ||
37 | -import org.onosproject.net.device.DefaultPortDescription; | ||
38 | -import org.onosproject.net.device.DeviceDescription; | ||
39 | -import org.onosproject.net.device.DeviceProvider; | ||
40 | -import org.onosproject.net.device.DeviceProviderRegistry; | ||
41 | -import org.onosproject.net.device.DeviceProviderService; | ||
42 | -import org.onosproject.net.device.PortDescription; | ||
43 | -import org.onosproject.net.provider.AbstractProvider; | ||
44 | -import org.onosproject.net.provider.ProviderId; | ||
45 | -import org.osgi.service.component.ComponentContext; | ||
46 | -import org.slf4j.Logger; | ||
47 | - | ||
48 | -import java.net.URI; | ||
49 | -import java.net.URISyntaxException; | ||
50 | -import java.util.Dictionary; | ||
51 | -import java.util.List; | ||
52 | -import java.util.Map; | ||
53 | -import java.util.concurrent.ExecutorService; | ||
54 | -import java.util.concurrent.Executors; | ||
55 | -import java.util.concurrent.TimeUnit; | ||
56 | - | ||
57 | -import static com.google.common.base.Strings.isNullOrEmpty; | ||
58 | -import static org.onlab.util.Tools.*; | ||
59 | -import static org.slf4j.LoggerFactory.getLogger; | ||
60 | - | ||
61 | -/** | ||
62 | - * Provider which advertises fake/nonexistant devices to the core. | ||
63 | - * nodeID is passed as part of the fake device id so that multiple nodes can run simultaneously. | ||
64 | - * To be used for benchmarking only. | ||
65 | - */ | ||
66 | -@Component(immediate = true) | ||
67 | -public class NullDeviceProvider extends AbstractProvider implements DeviceProvider { | ||
68 | - | ||
69 | - private static final Logger log = getLogger(NullDeviceProvider.class); | ||
70 | - | ||
71 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
72 | - protected ClusterService clusterService; | ||
73 | - | ||
74 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
75 | - protected DeviceProviderRegistry providerRegistry; | ||
76 | - | ||
77 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
78 | - protected ComponentConfigService cfgService; | ||
79 | - | ||
80 | - private DeviceProviderService providerService; | ||
81 | - | ||
82 | - private ExecutorService deviceBuilder = | ||
83 | - Executors.newFixedThreadPool(1, groupedThreads("onos/null", "device-creator")); | ||
84 | - | ||
85 | - private static final String SCHEME = "null"; | ||
86 | - private static final int DEF_NUMDEVICES = 10; | ||
87 | - private static final int DEF_NUMPORTS = 10; | ||
88 | - | ||
89 | - //Delay between events in ms. | ||
90 | - private static final int EVENTINTERVAL = 5; | ||
91 | - | ||
92 | - private final Map<Integer, DeviceDescription> descriptions = Maps.newHashMap(); | ||
93 | - | ||
94 | - @Property(name = "devConfigs", value = "", label = "Instance-specific configurations") | ||
95 | - private String devConfigs = null; | ||
96 | - | ||
97 | - private int numDevices = DEF_NUMDEVICES; | ||
98 | - | ||
99 | - @Property(name = "numPorts", intValue = 10, label = "Number of ports per devices") | ||
100 | - private int numPorts = DEF_NUMPORTS; | ||
101 | - | ||
102 | - private DeviceCreator creator; | ||
103 | - | ||
104 | - /** | ||
105 | - * | ||
106 | - * Creates a provider with the supplier identifier. | ||
107 | - * | ||
108 | - */ | ||
109 | - public NullDeviceProvider() { | ||
110 | - super(new ProviderId("null", "org.onosproject.provider.nil")); | ||
111 | - } | ||
112 | - | ||
113 | - @Activate | ||
114 | - public void activate(ComponentContext context) { | ||
115 | - cfgService.registerProperties(getClass()); | ||
116 | - providerService = providerRegistry.register(this); | ||
117 | - if (!modified(context)) { | ||
118 | - deviceBuilder.submit(new DeviceCreator(true)); | ||
119 | - } | ||
120 | - log.info("Started"); | ||
121 | - | ||
122 | - } | ||
123 | - | ||
124 | - @Deactivate | ||
125 | - public void deactivate(ComponentContext context) { | ||
126 | - cfgService.unregisterProperties(getClass(), false); | ||
127 | - deviceBuilder.submit(new DeviceCreator(false)); | ||
128 | - try { | ||
129 | - deviceBuilder.awaitTermination(1000, TimeUnit.MILLISECONDS); | ||
130 | - } catch (InterruptedException e) { | ||
131 | - log.error("Device builder did not terminate"); | ||
132 | - } | ||
133 | - deviceBuilder.shutdownNow(); | ||
134 | - providerRegistry.unregister(this); | ||
135 | - providerService = null; | ||
136 | - | ||
137 | - log.info("Stopped"); | ||
138 | - } | ||
139 | - | ||
140 | - @Modified | ||
141 | - public boolean modified(ComponentContext context) { | ||
142 | - if (context == null) { | ||
143 | - log.info("No configuration file, using defaults: numDevices={}, numPorts={}", | ||
144 | - numDevices, numPorts); | ||
145 | - return false; | ||
146 | - } | ||
147 | - | ||
148 | - Dictionary<?, ?> properties = context.getProperties(); | ||
149 | - | ||
150 | - int newDevNum = DEF_NUMDEVICES; | ||
151 | - int newPortNum = DEF_NUMPORTS; | ||
152 | - try { | ||
153 | - String s = get(properties, "devConfigs"); | ||
154 | - if (!isNullOrEmpty(s)) { | ||
155 | - newDevNum = getDevicesConfig(s); | ||
156 | - } | ||
157 | - s = get(properties, "numPorts"); | ||
158 | - newPortNum = isNullOrEmpty(s) ? DEF_NUMPORTS : Integer.parseInt(s.trim()); | ||
159 | - } catch (NumberFormatException e) { | ||
160 | - log.warn(e.getMessage()); | ||
161 | - newDevNum = numDevices; | ||
162 | - newPortNum = numPorts; | ||
163 | - } | ||
164 | - | ||
165 | - boolean chgd = false; | ||
166 | - if (newDevNum != numDevices) { | ||
167 | - numDevices = newDevNum; | ||
168 | - chgd |= true; | ||
169 | - } | ||
170 | - if (newPortNum != numPorts) { | ||
171 | - numPorts = newPortNum; | ||
172 | - chgd |= true; | ||
173 | - } | ||
174 | - log.info("Using settings numDevices={}, numPorts={}", numDevices, numPorts); | ||
175 | - if (chgd) { | ||
176 | - deviceBuilder.submit(new DeviceCreator(true)); | ||
177 | - } | ||
178 | - return chgd; | ||
179 | - } | ||
180 | - | ||
181 | - private int getDevicesConfig(String config) { | ||
182 | - for (String sub : config.split(",")) { | ||
183 | - String[] params = sub.split(":"); | ||
184 | - if (params.length == 2) { | ||
185 | - NodeId that = new NodeId(params[0].trim()); | ||
186 | - String nd = params[1]; | ||
187 | - if (clusterService.getLocalNode().id().equals(that)) { | ||
188 | - return Integer.parseInt(nd.trim()); | ||
189 | - } | ||
190 | - continue; | ||
191 | - } | ||
192 | - } | ||
193 | - return DEF_NUMDEVICES; | ||
194 | - } | ||
195 | - | ||
196 | - @Override | ||
197 | - public void triggerProbe(DeviceId deviceId) {} | ||
198 | - | ||
199 | - @Override | ||
200 | - public void roleChanged(DeviceId deviceId, MastershipRole newRole) {} | ||
201 | - | ||
202 | - @Override | ||
203 | - public boolean isReachable(DeviceId deviceId) { | ||
204 | - return descriptions.values().stream() | ||
205 | - .anyMatch(desc -> desc.deviceURI().equals(deviceId.uri())); | ||
206 | - } | ||
207 | - | ||
208 | - | ||
209 | - private class DeviceCreator implements Runnable { | ||
210 | - | ||
211 | - private boolean setup; | ||
212 | - | ||
213 | - public DeviceCreator(boolean setup) { | ||
214 | - this.setup = setup; | ||
215 | - } | ||
216 | - | ||
217 | - @Override | ||
218 | - public void run() { | ||
219 | - if (setup) { | ||
220 | - try { | ||
221 | - advertiseDevices(); | ||
222 | - } catch (URISyntaxException e) { | ||
223 | - log.warn("URI creation failed during device adverts {}", e.getMessage()); | ||
224 | - } | ||
225 | - } else { | ||
226 | - removeDevices(); | ||
227 | - } | ||
228 | - } | ||
229 | - | ||
230 | - private void removeDevices() { | ||
231 | - for (DeviceDescription desc : descriptions.values()) { | ||
232 | - providerService.deviceDisconnected( | ||
233 | - DeviceId.deviceId(desc.deviceURI())); | ||
234 | - delay(EVENTINTERVAL); | ||
235 | - } | ||
236 | - descriptions.clear(); | ||
237 | - } | ||
238 | - | ||
239 | - private void advertiseDevices() throws URISyntaxException { | ||
240 | - DeviceId did; | ||
241 | - ChassisId cid; | ||
242 | - | ||
243 | - // nodeIdHash takes into account for nodeID to avoid collisions when running multi-node providers. | ||
244 | - long nodeIdHash = clusterService.getLocalNode().id().hashCode() << 16; | ||
245 | - | ||
246 | - for (int i = 0; i < numDevices; i++) { | ||
247 | - long id = nodeIdHash | i; | ||
248 | - | ||
249 | - did = DeviceId.deviceId(new URI(SCHEME, toHex(id), null)); | ||
250 | - cid = new ChassisId(i); | ||
251 | - DeviceDescription desc = | ||
252 | - new DefaultDeviceDescription(did.uri(), Device.Type.SWITCH, | ||
253 | - "ON.Lab", "0.0.1", "0.0.1", "1234", | ||
254 | - cid); | ||
255 | - descriptions.put(i, desc); | ||
256 | - providerService.deviceConnected(did, desc); | ||
257 | - providerService.updatePorts(did, buildPorts()); | ||
258 | - delay(EVENTINTERVAL); | ||
259 | - } | ||
260 | - } | ||
261 | - | ||
262 | - private List<PortDescription> buildPorts() { | ||
263 | - List<PortDescription> ports = Lists.newArrayList(); | ||
264 | - for (int i = 0; i < numPorts; i++) { | ||
265 | - ports.add(new DefaultPortDescription(PortNumber.portNumber(i), true, | ||
266 | - Port.Type.COPPER, | ||
267 | - 0)); | ||
268 | - } | ||
269 | - return ports; | ||
270 | - } | ||
271 | - } | ||
272 | -} |
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 | - | ||
17 | -/** | ||
18 | - * Provider that advertises fake devices. | ||
19 | - */ | ||
20 | -package org.onosproject.provider.nil.device.impl; |
providers/null/flow/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2014 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-null-providers</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-null-provider-flow</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>ONOS Null protocol flow provider</description> | ||
33 | - | ||
34 | -</project> |
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.provider.nil.flow.impl; | ||
17 | - | ||
18 | -import com.google.common.collect.Sets; | ||
19 | -import org.apache.felix.scr.annotations.Activate; | ||
20 | -import org.apache.felix.scr.annotations.Component; | ||
21 | -import org.apache.felix.scr.annotations.Deactivate; | ||
22 | -import org.apache.felix.scr.annotations.Reference; | ||
23 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
24 | -import org.jboss.netty.util.HashedWheelTimer; | ||
25 | -import org.jboss.netty.util.Timeout; | ||
26 | -import org.jboss.netty.util.TimerTask; | ||
27 | -import org.onlab.util.Timer; | ||
28 | -import org.onosproject.core.ApplicationId; | ||
29 | -import org.onosproject.net.DeviceId; | ||
30 | -import org.onosproject.net.flow.CompletedBatchOperation; | ||
31 | -import org.onosproject.net.flow.DefaultFlowEntry; | ||
32 | -import org.onosproject.net.flow.FlowEntry; | ||
33 | -import org.onosproject.net.flow.FlowRule; | ||
34 | -import org.onosproject.net.flow.FlowRuleBatchEntry; | ||
35 | -import org.onosproject.net.flow.FlowRuleBatchOperation; | ||
36 | -import org.onosproject.net.flow.FlowRuleProvider; | ||
37 | -import org.onosproject.net.flow.FlowRuleProviderRegistry; | ||
38 | -import org.onosproject.net.flow.FlowRuleProviderService; | ||
39 | -import org.onosproject.net.provider.AbstractProvider; | ||
40 | -import org.onosproject.net.provider.ProviderId; | ||
41 | -import org.slf4j.Logger; | ||
42 | - | ||
43 | -import java.util.Collections; | ||
44 | -import java.util.Set; | ||
45 | -import java.util.concurrent.ConcurrentHashMap; | ||
46 | -import java.util.concurrent.ConcurrentMap; | ||
47 | -import java.util.concurrent.TimeUnit; | ||
48 | - | ||
49 | -import static org.slf4j.LoggerFactory.getLogger; | ||
50 | - | ||
51 | -/** | ||
52 | - * Null provider to accept any flow and report them. | ||
53 | - */ | ||
54 | -@Component(immediate = true) | ||
55 | -public class NullFlowRuleProvider extends AbstractProvider implements FlowRuleProvider { | ||
56 | - | ||
57 | - private final Logger log = getLogger(getClass()); | ||
58 | - | ||
59 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
60 | - protected FlowRuleProviderRegistry providerRegistry; | ||
61 | - | ||
62 | - private ConcurrentMap<DeviceId, Set<FlowEntry>> flowTable = new ConcurrentHashMap<>(); | ||
63 | - | ||
64 | - private FlowRuleProviderService providerService; | ||
65 | - | ||
66 | - private HashedWheelTimer timer = Timer.getTimer(); | ||
67 | - private Timeout timeout; | ||
68 | - | ||
69 | - public NullFlowRuleProvider() { | ||
70 | - super(new ProviderId("null", "org.onosproject.provider.nil")); | ||
71 | - } | ||
72 | - | ||
73 | - @Activate | ||
74 | - public void activate() { | ||
75 | - providerService = providerRegistry.register(this); | ||
76 | - timeout = timer.newTimeout(new StatisticTask(), 5, TimeUnit.SECONDS); | ||
77 | - | ||
78 | - log.info("Started"); | ||
79 | - } | ||
80 | - | ||
81 | - @Deactivate | ||
82 | - public void deactivate() { | ||
83 | - providerRegistry.unregister(this); | ||
84 | - providerService = null; | ||
85 | - timeout.cancel(); | ||
86 | - | ||
87 | - log.info("Stopped"); | ||
88 | - } | ||
89 | - | ||
90 | - @Override | ||
91 | - public void applyFlowRule(FlowRule... flowRules) {} | ||
92 | - | ||
93 | - @Override | ||
94 | - public void removeFlowRule(FlowRule... flowRules) {} | ||
95 | - | ||
96 | - @Override | ||
97 | - public void removeRulesById(ApplicationId id, FlowRule... flowRules) { | ||
98 | - log.info("removal by app id not supported in null provider"); | ||
99 | - } | ||
100 | - | ||
101 | - @Override | ||
102 | - public void executeBatch( | ||
103 | - FlowRuleBatchOperation batch) { | ||
104 | - Set<FlowEntry> flowRules = flowTable.getOrDefault(batch.deviceId(), Sets.newConcurrentHashSet()); | ||
105 | - for (FlowRuleBatchEntry fbe : batch.getOperations()) { | ||
106 | - switch (fbe.operator()) { | ||
107 | - case ADD: | ||
108 | - flowRules.add(new DefaultFlowEntry(fbe.target())); | ||
109 | - break; | ||
110 | - case REMOVE: | ||
111 | - flowRules.remove(new DefaultFlowEntry(fbe.target())); | ||
112 | - break; | ||
113 | - case MODIFY: | ||
114 | - FlowEntry entry = new DefaultFlowEntry(fbe.target()); | ||
115 | - flowRules.remove(entry); | ||
116 | - flowRules.add(entry); | ||
117 | - break; | ||
118 | - default: | ||
119 | - log.error("Unknown flow operation: {}", fbe); | ||
120 | - } | ||
121 | - } | ||
122 | - flowTable.put(batch.deviceId(), flowRules); | ||
123 | - providerService.batchOperationCompleted(batch.id(), | ||
124 | - new CompletedBatchOperation( | ||
125 | - true, | ||
126 | - Collections.emptySet(), | ||
127 | - batch.deviceId())); | ||
128 | - } | ||
129 | - | ||
130 | - private class StatisticTask implements TimerTask { | ||
131 | - | ||
132 | - @Override | ||
133 | - public void run(Timeout to) throws Exception { | ||
134 | - for (DeviceId devId : flowTable.keySet()) { | ||
135 | - providerService.pushFlowMetrics(devId, | ||
136 | - flowTable.getOrDefault(devId, Collections.emptySet())); | ||
137 | - } | ||
138 | - timeout = timer.newTimeout(to.getTask(), 5, TimeUnit.SECONDS); | ||
139 | - | ||
140 | - } | ||
141 | - } | ||
142 | -} |
providers/null/flow/src/main/java/org/onosproject/provider/nil/flow/impl/package-info.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 | - | ||
17 | -/** | ||
18 | - * Provider that will accept any flow rules. | ||
19 | - */ | ||
20 | -package org.onosproject.provider.nil.flow.impl; |
providers/null/host/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2014 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-null-providers</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-null-provider-host</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>ONOS Null host provider</description> | ||
33 | - | ||
34 | -</project> |
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.provider.nil.host.impl; | ||
17 | - | ||
18 | -import org.apache.felix.scr.annotations.Activate; | ||
19 | -import org.apache.felix.scr.annotations.Component; | ||
20 | -import org.apache.felix.scr.annotations.Deactivate; | ||
21 | -import org.apache.felix.scr.annotations.Reference; | ||
22 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
23 | -import org.onlab.packet.MacAddress; | ||
24 | -import org.onlab.packet.VlanId; | ||
25 | -import org.onosproject.cluster.ClusterService; | ||
26 | -import org.onosproject.mastership.MastershipService; | ||
27 | -import org.onosproject.net.Device; | ||
28 | -import org.onosproject.net.Host; | ||
29 | -import org.onosproject.net.HostId; | ||
30 | -import org.onosproject.net.HostLocation; | ||
31 | -import org.onosproject.net.MastershipRole; | ||
32 | -import org.onosproject.net.PortNumber; | ||
33 | -import org.onosproject.net.device.DeviceEvent; | ||
34 | -import org.onosproject.net.device.DeviceListener; | ||
35 | -import org.onosproject.net.device.DeviceService; | ||
36 | -import org.onosproject.net.host.DefaultHostDescription; | ||
37 | -import org.onosproject.net.host.HostDescription; | ||
38 | -import org.onosproject.net.host.HostProvider; | ||
39 | -import org.onosproject.net.host.HostProviderRegistry; | ||
40 | -import org.onosproject.net.host.HostProviderService; | ||
41 | -import org.onosproject.net.provider.AbstractProvider; | ||
42 | -import org.onosproject.net.provider.ProviderId; | ||
43 | -import org.slf4j.Logger; | ||
44 | - | ||
45 | -import static org.onlab.util.Tools.toHex; | ||
46 | -import static org.slf4j.LoggerFactory.getLogger; | ||
47 | - | ||
48 | -/** | ||
49 | - * Null provider to advertise fake hosts. | ||
50 | - */ | ||
51 | -@Component(immediate = true) | ||
52 | -public class NullHostProvider extends AbstractProvider implements HostProvider { | ||
53 | - | ||
54 | - private final Logger log = getLogger(getClass()); | ||
55 | - | ||
56 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
57 | - protected DeviceService deviceService; | ||
58 | - | ||
59 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
60 | - protected MastershipService roleService; | ||
61 | - | ||
62 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
63 | - protected ClusterService nodeService; | ||
64 | - | ||
65 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
66 | - protected HostProviderRegistry providerRegistry; | ||
67 | - | ||
68 | - private HostProviderService providerService; | ||
69 | - | ||
70 | - //make sure the device has enough ports to accomodate all of them. | ||
71 | - private static final int HOSTSPERDEVICE = 5; | ||
72 | - | ||
73 | - private final InternalHostProvider hostProvider = new InternalHostProvider(); | ||
74 | - | ||
75 | - /** | ||
76 | - * Creates an OpenFlow host provider. | ||
77 | - */ | ||
78 | - public NullHostProvider() { | ||
79 | - super(new ProviderId("null", "org.onosproject.provider.nil")); | ||
80 | - } | ||
81 | - | ||
82 | - /** | ||
83 | - * Creates a provider with the supplier identifier. | ||
84 | - * | ||
85 | - * @param id provider id | ||
86 | - */ | ||
87 | - protected NullHostProvider(ProviderId id) { | ||
88 | - super(id); | ||
89 | - } | ||
90 | - | ||
91 | - @Activate | ||
92 | - public void activate() { | ||
93 | - providerService = providerRegistry.register(this); | ||
94 | - for (Device dev : deviceService.getDevices()) { | ||
95 | - addHosts(dev); | ||
96 | - } | ||
97 | - deviceService.addListener(hostProvider); | ||
98 | - | ||
99 | - log.info("Started"); | ||
100 | - } | ||
101 | - | ||
102 | - @Deactivate | ||
103 | - public void deactivate() { | ||
104 | - providerRegistry.unregister(this); | ||
105 | - deviceService.removeListener(hostProvider); | ||
106 | - providerService = null; | ||
107 | - log.info("Stopped"); | ||
108 | - } | ||
109 | - | ||
110 | - @Override | ||
111 | - public void triggerProbe(Host host) {} | ||
112 | - | ||
113 | - private void addHosts(Device device) { | ||
114 | - String nhash = toHex(nodeService.getLocalNode().id().hashCode()); | ||
115 | - String dhash = device.id().toString(); | ||
116 | - // make sure this instance owns the device. | ||
117 | - if (!nhash.substring(nhash.length() - 3) | ||
118 | - .equals(dhash.substring(14, 17))) { | ||
119 | - log.warn("Device {} is not mine. Can't add hosts.", device.id()); | ||
120 | - return; | ||
121 | - } | ||
122 | - for (int i = 0; i < HOSTSPERDEVICE; i++) { | ||
123 | - providerService.hostDetected( | ||
124 | - HostId.hostId(MacAddress.valueOf(i + device.hashCode()), | ||
125 | - VlanId.vlanId((short) -1)), | ||
126 | - buildHostDescription(device, i)); | ||
127 | - } | ||
128 | - } | ||
129 | - | ||
130 | - private void removeHosts(Device device) { | ||
131 | - for (int i = 0; i < HOSTSPERDEVICE; i++) { | ||
132 | - providerService.hostVanished( | ||
133 | - HostId.hostId(MacAddress.valueOf(i + device.hashCode()), | ||
134 | - VlanId.vlanId((short) -1))); | ||
135 | - } | ||
136 | - } | ||
137 | - | ||
138 | - private HostDescription buildHostDescription(Device device, int port) { | ||
139 | - MacAddress mac = MacAddress.valueOf(device.hashCode() + port); | ||
140 | - HostLocation location = new HostLocation(device.id(), | ||
141 | - PortNumber.portNumber(port), 0L); | ||
142 | - return new DefaultHostDescription(mac, VlanId.vlanId((short) -1), location); | ||
143 | - } | ||
144 | - | ||
145 | - private class InternalHostProvider implements DeviceListener { | ||
146 | - @Override | ||
147 | - public void event(DeviceEvent event) { | ||
148 | - Device dev = event.subject(); | ||
149 | - if (!deviceService.getRole(event.subject().id()).equals( | ||
150 | - MastershipRole.MASTER)) { | ||
151 | - log.info("Local node is not master for device {}", event | ||
152 | - .subject().id()); | ||
153 | - return; | ||
154 | - } | ||
155 | - switch (event.type()) { | ||
156 | - | ||
157 | - case DEVICE_ADDED: | ||
158 | - addHosts(dev); | ||
159 | - break; | ||
160 | - case DEVICE_UPDATED: | ||
161 | - break; | ||
162 | - case DEVICE_REMOVED: | ||
163 | - removeHosts(dev); | ||
164 | - break; | ||
165 | - case DEVICE_SUSPENDED: | ||
166 | - break; | ||
167 | - case DEVICE_AVAILABILITY_CHANGED: | ||
168 | - break; | ||
169 | - case PORT_ADDED: | ||
170 | - break; | ||
171 | - case PORT_UPDATED: | ||
172 | - break; | ||
173 | - case PORT_REMOVED: | ||
174 | - break; | ||
175 | - default: | ||
176 | - break; | ||
177 | - } | ||
178 | - } | ||
179 | - | ||
180 | - } | ||
181 | - | ||
182 | -} |
providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/package-info.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 | - | ||
17 | -/** | ||
18 | - * Provider that advertises fake hosts. | ||
19 | - */ | ||
20 | -package org.onosproject.provider.nil.host.impl; |
providers/null/link/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2014 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-null-providers</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-null-provider-link</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>ONOS Null link provider</description> | ||
33 | - | ||
34 | - <dependencies> | ||
35 | - <dependency> | ||
36 | - <groupId>org.osgi</groupId> | ||
37 | - <artifactId>org.osgi.compendium</artifactId> | ||
38 | - </dependency> | ||
39 | - </dependencies> | ||
40 | - | ||
41 | -</project> |
This diff is collapsed. Click to expand it.
providers/null/link/src/main/java/org/onosproject/provider/nil/link/impl/package-info.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 | - | ||
17 | -/** | ||
18 | - * Provider that advertises fake links. | ||
19 | - */ | ||
20 | -package org.onosproject.provider.nil.link.impl; |
providers/null/packet/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2014 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-null-providers</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-null-provider-packet</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>ONOS Null packet provider</description> | ||
33 | - | ||
34 | - <dependencies> | ||
35 | - <dependency> | ||
36 | - <groupId>org.osgi</groupId> | ||
37 | - <artifactId>org.osgi.compendium</artifactId> | ||
38 | - </dependency> | ||
39 | - </dependencies> | ||
40 | - | ||
41 | -</project> |
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.provider.nil.packet.impl; | ||
17 | - | ||
18 | -import org.apache.felix.scr.annotations.Activate; | ||
19 | -import org.apache.felix.scr.annotations.Component; | ||
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; | ||
24 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
25 | -import org.onlab.packet.Ethernet; | ||
26 | -import org.onlab.packet.ICMP; | ||
27 | -import org.onosproject.cfg.ComponentConfigService; | ||
28 | -import org.onosproject.net.ConnectPoint; | ||
29 | -import org.onosproject.net.Device; | ||
30 | -import org.onosproject.net.PortNumber; | ||
31 | -import org.onosproject.net.device.DeviceService; | ||
32 | -import org.onosproject.net.packet.DefaultInboundPacket; | ||
33 | -import org.onosproject.net.packet.DefaultPacketContext; | ||
34 | -import org.onosproject.net.packet.InboundPacket; | ||
35 | -import org.onosproject.net.packet.OutboundPacket; | ||
36 | -import org.onosproject.net.packet.PacketContext; | ||
37 | -import org.onosproject.net.packet.PacketProvider; | ||
38 | -import org.onosproject.net.packet.PacketProviderRegistry; | ||
39 | -import org.onosproject.net.packet.PacketProviderService; | ||
40 | -import org.onosproject.net.provider.AbstractProvider; | ||
41 | -import org.onosproject.net.provider.ProviderId; | ||
42 | -import org.osgi.service.component.ComponentContext; | ||
43 | -import org.slf4j.Logger; | ||
44 | - | ||
45 | -import java.nio.ByteBuffer; | ||
46 | -import java.util.Dictionary; | ||
47 | -import java.util.concurrent.ExecutorService; | ||
48 | -import java.util.concurrent.Executors; | ||
49 | -import java.util.concurrent.TimeUnit; | ||
50 | - | ||
51 | -import static com.google.common.base.Strings.isNullOrEmpty; | ||
52 | -import static org.onlab.util.Tools.delay; | ||
53 | -import static org.onlab.util.Tools.groupedThreads; | ||
54 | -import static org.slf4j.LoggerFactory.getLogger; | ||
55 | - | ||
56 | -/** | ||
57 | - * Provider which 1) intercepts network-bound messages from the core, and 2) | ||
58 | - * generates PacketEvents at some tunable rate. To be used for benchmarking | ||
59 | - * only. | ||
60 | - */ | ||
61 | -@Component(immediate = true) | ||
62 | -public class NullPacketProvider extends AbstractProvider implements | ||
63 | - PacketProvider { | ||
64 | - | ||
65 | - private final Logger log = getLogger(getClass()); | ||
66 | - | ||
67 | - // Default packetEvent generation rate (in packets/sec) | ||
68 | - // If 0, we are just a sink for network-bound packets | ||
69 | - private static final int DEFAULT_RATE = 5; | ||
70 | - // arbitrary host "destination" | ||
71 | - private static final int DESTHOST = 5; | ||
72 | - | ||
73 | - private PacketProviderService providerService; | ||
74 | - | ||
75 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
76 | - protected PacketProviderRegistry providerRegistry; | ||
77 | - | ||
78 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
79 | - protected DeviceService deviceService; | ||
80 | - | ||
81 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
82 | - protected ComponentConfigService cfgService; | ||
83 | - | ||
84 | - // Rate to generate PacketEvents, per second | ||
85 | - @Property(name = "pktRate", intValue = DEFAULT_RATE, | ||
86 | - label = "Rate of PacketEvent generation") | ||
87 | - private int pktRate = DEFAULT_RATE; | ||
88 | - | ||
89 | - private ExecutorService packetDriver = | ||
90 | - Executors.newFixedThreadPool(1, groupedThreads("onos/null", "packet-driver")); | ||
91 | - | ||
92 | - public NullPacketProvider() { | ||
93 | - super(new ProviderId("null", "org.onosproject.provider.nil")); | ||
94 | - } | ||
95 | - | ||
96 | - @Activate | ||
97 | - public void activate(ComponentContext context) { | ||
98 | - cfgService.registerProperties(getClass()); | ||
99 | - providerService = providerRegistry.register(this); | ||
100 | - if (!modified(context)) { | ||
101 | - packetDriver.submit(new PacketDriver()); | ||
102 | - } | ||
103 | - log.info("started"); | ||
104 | - } | ||
105 | - | ||
106 | - @Deactivate | ||
107 | - public void deactivate(ComponentContext context) { | ||
108 | - cfgService.unregisterProperties(getClass(), false); | ||
109 | - try { | ||
110 | - packetDriver.awaitTermination(1000, TimeUnit.MILLISECONDS); | ||
111 | - } catch (InterruptedException e) { | ||
112 | - log.error("PacketDriver did not terminate"); | ||
113 | - } | ||
114 | - packetDriver.shutdownNow(); | ||
115 | - providerRegistry.unregister(this); | ||
116 | - log.info("stopped"); | ||
117 | - } | ||
118 | - | ||
119 | - @Modified | ||
120 | - public boolean modified(ComponentContext context) { | ||
121 | - if (context == null) { | ||
122 | - log.info("No configuration change, using defaults: pktRate={}", | ||
123 | - DEFAULT_RATE); | ||
124 | - return false; | ||
125 | - } | ||
126 | - Dictionary<?, ?> properties = context.getProperties(); | ||
127 | - | ||
128 | - int newRate; | ||
129 | - try { | ||
130 | - String s = String.valueOf(properties.get("pktRate")); | ||
131 | - newRate = isNullOrEmpty(s) ? pktRate : Integer.parseInt(s.trim()); | ||
132 | - } catch (NumberFormatException | ClassCastException e) { | ||
133 | - log.warn(e.getMessage()); | ||
134 | - newRate = pktRate; | ||
135 | - } | ||
136 | - | ||
137 | - if (newRate != pktRate) { | ||
138 | - pktRate = newRate; | ||
139 | - packetDriver.submit(new PacketDriver()); | ||
140 | - log.info("Using new settings: pktRate={}", pktRate); | ||
141 | - return true; | ||
142 | - } | ||
143 | - return false; | ||
144 | - } | ||
145 | - | ||
146 | - @Override | ||
147 | - public void emit(OutboundPacket packet) { | ||
148 | - // We don't have a network to emit to. Keep a counter here, maybe? | ||
149 | - } | ||
150 | - | ||
151 | - /** | ||
152 | - * Generates packet events at a given rate. | ||
153 | - */ | ||
154 | - private class PacketDriver implements Runnable { | ||
155 | - | ||
156 | - // time between event firing, in milliseconds | ||
157 | - int pktInterval; | ||
158 | - // filler echo request | ||
159 | - ICMP icmp; | ||
160 | - Ethernet eth; | ||
161 | - | ||
162 | - public PacketDriver() { | ||
163 | - pktInterval = 1000 / pktRate; | ||
164 | - icmp = new ICMP(); | ||
165 | - icmp.setIcmpType((byte) 8).setIcmpCode((byte) 0) | ||
166 | - .setChecksum((short) 0); | ||
167 | - eth = new Ethernet(); | ||
168 | - eth.setEtherType(Ethernet.TYPE_IPV4); | ||
169 | - eth.setPayload(icmp); | ||
170 | - } | ||
171 | - | ||
172 | - @Override | ||
173 | - public void run() { | ||
174 | - log.info("PacketDriver started"); | ||
175 | - while (!packetDriver.isShutdown()) { | ||
176 | - for (Device dev : deviceService.getDevices()) { | ||
177 | - sendEvents(dev); | ||
178 | - } | ||
179 | - } | ||
180 | - } | ||
181 | - | ||
182 | - private void sendEvents(Device dev) { | ||
183 | - // make it look like things came from ports attached to hosts | ||
184 | - for (int i = 0; i < 4; i++) { | ||
185 | - eth.setSourceMACAddress("00:00:10:00:00:0" + i) | ||
186 | - .setDestinationMACAddress("00:00:10:00:00:0" + DESTHOST); | ||
187 | - InboundPacket inPkt = new DefaultInboundPacket( | ||
188 | - new ConnectPoint(dev.id(), PortNumber.portNumber(i)), | ||
189 | - eth, ByteBuffer.wrap(eth.serialize())); | ||
190 | - PacketContext pctx = new NullPacketContext( | ||
191 | - System.currentTimeMillis(), inPkt, null, false); | ||
192 | - providerService.processPacket(pctx); | ||
193 | - delay(pktInterval); | ||
194 | - } | ||
195 | - } | ||
196 | - | ||
197 | - } | ||
198 | - | ||
199 | - /** | ||
200 | - * Minimal PacketContext to make core + applications happy. | ||
201 | - */ | ||
202 | - private class NullPacketContext extends DefaultPacketContext { | ||
203 | - | ||
204 | - public NullPacketContext(long time, InboundPacket inPkt, | ||
205 | - OutboundPacket outPkt, boolean block) { | ||
206 | - super(time, inPkt, outPkt, block); | ||
207 | - } | ||
208 | - | ||
209 | - @Override | ||
210 | - public void send() { | ||
211 | - // We don't send anything out. | ||
212 | - } | ||
213 | - | ||
214 | - } | ||
215 | - | ||
216 | -} |
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 | - | ||
17 | -/** | ||
18 | - * Provider that sends and brings packets to & from oblivion. | ||
19 | - */ | ||
20 | -package org.onosproject.provider.nil.packet.impl; |
... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
29 | <artifactId>onos-null-provider</artifactId> | 29 | <artifactId>onos-null-provider</artifactId> |
30 | <packaging>bundle</packaging> | 30 | <packaging>bundle</packaging> |
31 | 31 | ||
32 | - <description>ONOS null protocol adapters</description> | 32 | + <description>Null southbound providers application</description> |
33 | 33 | ||
34 | <dependencies> | 34 | <dependencies> |
35 | <dependency> | 35 | <dependency> | ... | ... |
-
Please register or login to post a comment