Committed by
Gerrit Code Review
Moving Openflow executors from submit to execute
Change-Id: I446747c7b28d2562ff14afe7e898cab8a83a14b7
Showing
4 changed files
with
31 additions
and
36 deletions
... | @@ -95,7 +95,7 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour | ... | @@ -95,7 +95,7 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour |
95 | protected Set<OpenFlowEventListener> ofOutgoingMsgListener = new CopyOnWriteArraySet<>(); | 95 | protected Set<OpenFlowEventListener> ofOutgoingMsgListener = new CopyOnWriteArraySet<>(); |
96 | 96 | ||
97 | protected ExecutorService executorMsgs = | 97 | protected ExecutorService executorMsgs = |
98 | - Executors.newCachedThreadPool(groupedThreads("onos/of", "event-outgoing-msg-stats-%d")); | 98 | + Executors.newCachedThreadPool(groupedThreads("onos/of", "event-outgoing-msg-stats-%d", log)); |
99 | 99 | ||
100 | // messagesPendingMastership is used as synchronization variable for | 100 | // messagesPendingMastership is used as synchronization variable for |
101 | // all mastership related changes. In this block, mastership (including | 101 | // all mastership related changes. In this block, mastership (including |
... | @@ -173,7 +173,7 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour | ... | @@ -173,7 +173,7 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour |
173 | if (m.getType() == OFType.PACKET_OUT || | 173 | if (m.getType() == OFType.PACKET_OUT || |
174 | m.getType() == OFType.FLOW_MOD || | 174 | m.getType() == OFType.FLOW_MOD || |
175 | m.getType() == OFType.STATS_REQUEST) { | 175 | m.getType() == OFType.STATS_REQUEST) { |
176 | - executorMsgs.submit(new OFMessageHandler(dpid, m)); | 176 | + executorMsgs.execute(new OFMessageHandler(dpid, m)); |
177 | } | 177 | } |
178 | }); | 178 | }); |
179 | } | 179 | } | ... | ... |
... | @@ -15,15 +15,15 @@ | ... | @@ -15,15 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.openflow.controller.driver; | 16 | package org.onosproject.openflow.controller.driver; |
17 | 17 | ||
18 | +import org.jboss.netty.channel.Channel; | ||
18 | import org.junit.Before; | 19 | import org.junit.Before; |
19 | import org.junit.Test; | 20 | import org.junit.Test; |
20 | import org.onosproject.openflow.controller.Dpid; | 21 | import org.onosproject.openflow.controller.Dpid; |
21 | import org.onosproject.openflow.controller.OpenFlowEventListener; | 22 | import org.onosproject.openflow.controller.OpenFlowEventListener; |
22 | import org.projectfloodlight.openflow.protocol.OFMessage; | 23 | import org.projectfloodlight.openflow.protocol.OFMessage; |
23 | -import org.jboss.netty.channel.Channel; | 24 | + |
24 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
25 | import java.util.List; | 26 | import java.util.List; |
26 | -import java.util.concurrent.Future; | ||
27 | 27 | ||
28 | import static org.hamcrest.MatcherAssert.assertThat; | 28 | import static org.hamcrest.MatcherAssert.assertThat; |
29 | import static org.hamcrest.Matchers.hasSize; | 29 | import static org.hamcrest.Matchers.hasSize; |
... | @@ -48,11 +48,10 @@ public class AbstractOpenFlowSwitchTest { | ... | @@ -48,11 +48,10 @@ public class AbstractOpenFlowSwitchTest { |
48 | } | 48 | } |
49 | 49 | ||
50 | @Override | 50 | @Override |
51 | - public Future<?> submit(Runnable task) { | 51 | + public void execute(Runnable task) { |
52 | AbstractOpenFlowSwitch.OFMessageHandler handler = | 52 | AbstractOpenFlowSwitch.OFMessageHandler handler = |
53 | (AbstractOpenFlowSwitch.OFMessageHandler) task; | 53 | (AbstractOpenFlowSwitch.OFMessageHandler) task; |
54 | submittedMessages.add(handler.msg); | 54 | submittedMessages.add(handler.msg); |
55 | - return null; | ||
56 | } | 55 | } |
57 | } | 56 | } |
58 | 57 | ... | ... |
... | @@ -113,16 +113,16 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -113,16 +113,16 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
113 | private int workerThreads = DEFAULT_WORKER_THREADS; | 113 | private int workerThreads = DEFAULT_WORKER_THREADS; |
114 | 114 | ||
115 | protected ExecutorService executorMsgs = | 115 | protected ExecutorService executorMsgs = |
116 | - Executors.newFixedThreadPool(32, groupedThreads("onos/of", "event-stats-%d")); | 116 | + Executors.newFixedThreadPool(32, groupedThreads("onos/of", "event-stats-%d", log)); |
117 | 117 | ||
118 | protected ExecutorService executorPacketIn = | 118 | protected ExecutorService executorPacketIn = |
119 | - Executors.newCachedThreadPool(groupedThreads("onos/of", "event-pkt-in-stats-%d")); | 119 | + Executors.newCachedThreadPool(groupedThreads("onos/of", "event-pkt-in-stats-%d", log)); |
120 | 120 | ||
121 | protected ExecutorService executorFlowRemoved = | 121 | protected ExecutorService executorFlowRemoved = |
122 | - Executors.newCachedThreadPool(groupedThreads("onos/of", "event-flow-removed-stats-%d")); | 122 | + Executors.newCachedThreadPool(groupedThreads("onos/of", "event-flow-removed-stats-%d", log)); |
123 | 123 | ||
124 | private final ExecutorService executorBarrier = | 124 | private final ExecutorService executorBarrier = |
125 | - Executors.newFixedThreadPool(4, groupedThreads("onos/of", "event-barrier-%d")); | 125 | + Executors.newFixedThreadPool(4, groupedThreads("onos/of", "event-barrier-%d", log)); |
126 | 126 | ||
127 | protected ConcurrentMap<Dpid, OpenFlowSwitch> connectedSwitches = | 127 | protected ConcurrentMap<Dpid, OpenFlowSwitch> connectedSwitches = |
128 | new ConcurrentHashMap<>(); | 128 | new ConcurrentHashMap<>(); |
... | @@ -286,19 +286,19 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -286,19 +286,19 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
286 | p.handlePacket(pktCtx); | 286 | p.handlePacket(pktCtx); |
287 | } | 287 | } |
288 | if (monitorAllEvents) { | 288 | if (monitorAllEvents) { |
289 | - executorPacketIn.submit(new OFMessageHandler(dpid, msg)); | 289 | + executorPacketIn.execute(new OFMessageHandler(dpid, msg)); |
290 | } | 290 | } |
291 | break; | 291 | break; |
292 | // TODO: Consider using separate threadpool for sensitive messages. | 292 | // TODO: Consider using separate threadpool for sensitive messages. |
293 | // ie. Back to back error could cause us to starve. | 293 | // ie. Back to back error could cause us to starve. |
294 | case FLOW_REMOVED: | 294 | case FLOW_REMOVED: |
295 | if (monitorAllEvents) { | 295 | if (monitorAllEvents) { |
296 | - executorFlowRemoved.submit(new OFMessageHandler(dpid, msg)); | 296 | + executorFlowRemoved.execute(new OFMessageHandler(dpid, msg)); |
297 | break; | 297 | break; |
298 | } | 298 | } |
299 | case ERROR: | 299 | case ERROR: |
300 | log.debug("Received error message from {}: {}", dpid, msg); | 300 | log.debug("Received error message from {}: {}", dpid, msg); |
301 | - executorMsgs.submit(new OFMessageHandler(dpid, msg)); | 301 | + executorMsgs.execute(new OFMessageHandler(dpid, msg)); |
302 | break; | 302 | break; |
303 | case STATS_REPLY: | 303 | case STATS_REPLY: |
304 | OFStatsReply reply = (OFStatsReply) msg; | 304 | OFStatsReply reply = (OFStatsReply) msg; |
... | @@ -315,7 +315,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -315,7 +315,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
315 | OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply(); | 315 | OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply(); |
316 | rep.setEntries(Lists.newLinkedList(flowStats)); | 316 | rep.setEntries(Lists.newLinkedList(flowStats)); |
317 | rep.setXid(reply.getXid()); | 317 | rep.setXid(reply.getXid()); |
318 | - executorMsgs.submit(new OFMessageHandler(dpid, rep.build())); | 318 | + executorMsgs.execute(new OFMessageHandler(dpid, rep.build())); |
319 | } | 319 | } |
320 | break; | 320 | break; |
321 | case TABLE: | 321 | case TABLE: |
... | @@ -324,7 +324,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -324,7 +324,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
324 | OFTableStatsReply.Builder rep = | 324 | OFTableStatsReply.Builder rep = |
325 | OFFactories.getFactory(msg.getVersion()).buildTableStatsReply(); | 325 | OFFactories.getFactory(msg.getVersion()).buildTableStatsReply(); |
326 | rep.setEntries(Lists.newLinkedList(tableStats)); | 326 | rep.setEntries(Lists.newLinkedList(tableStats)); |
327 | - executorMsgs.submit(new OFMessageHandler(dpid, rep.build())); | 327 | + executorMsgs.execute(new OFMessageHandler(dpid, rep.build())); |
328 | } | 328 | } |
329 | break; | 329 | break; |
330 | case GROUP: | 330 | case GROUP: |
... | @@ -334,7 +334,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -334,7 +334,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
334 | OFFactories.getFactory(msg.getVersion()).buildGroupStatsReply(); | 334 | OFFactories.getFactory(msg.getVersion()).buildGroupStatsReply(); |
335 | rep.setEntries(Lists.newLinkedList(groupStats)); | 335 | rep.setEntries(Lists.newLinkedList(groupStats)); |
336 | rep.setXid(reply.getXid()); | 336 | rep.setXid(reply.getXid()); |
337 | - executorMsgs.submit(new OFMessageHandler(dpid, rep.build())); | 337 | + executorMsgs.execute(new OFMessageHandler(dpid, rep.build())); |
338 | } | 338 | } |
339 | break; | 339 | break; |
340 | case GROUP_DESC: | 340 | case GROUP_DESC: |
... | @@ -345,14 +345,14 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -345,14 +345,14 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
345 | OFFactories.getFactory(msg.getVersion()).buildGroupDescStatsReply(); | 345 | OFFactories.getFactory(msg.getVersion()).buildGroupDescStatsReply(); |
346 | rep.setEntries(Lists.newLinkedList(groupDescStats)); | 346 | rep.setEntries(Lists.newLinkedList(groupDescStats)); |
347 | rep.setXid(reply.getXid()); | 347 | rep.setXid(reply.getXid()); |
348 | - executorMsgs.submit(new OFMessageHandler(dpid, rep.build())); | 348 | + executorMsgs.execute(new OFMessageHandler(dpid, rep.build())); |
349 | } | 349 | } |
350 | break; | 350 | break; |
351 | case PORT: | 351 | case PORT: |
352 | - executorMsgs.submit(new OFMessageHandler(dpid, reply)); | 352 | + executorMsgs.execute(new OFMessageHandler(dpid, reply)); |
353 | break; | 353 | break; |
354 | case METER: | 354 | case METER: |
355 | - executorMsgs.submit(new OFMessageHandler(dpid, reply)); | 355 | + executorMsgs.execute(new OFMessageHandler(dpid, reply)); |
356 | break; | 356 | break; |
357 | case EXPERIMENTER: | 357 | case EXPERIMENTER: |
358 | if (reply instanceof OFCalientFlowStatsReply) { | 358 | if (reply instanceof OFCalientFlowStatsReply) { |
... | @@ -394,10 +394,10 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -394,10 +394,10 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
394 | OFFlowStatsReply.Builder rep = | 394 | OFFlowStatsReply.Builder rep = |
395 | OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply(); | 395 | OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply(); |
396 | rep.setEntries(Lists.newLinkedList(flowStats)); | 396 | rep.setEntries(Lists.newLinkedList(flowStats)); |
397 | - executorMsgs.submit(new OFMessageHandler(dpid, rep.build())); | 397 | + executorMsgs.execute(new OFMessageHandler(dpid, rep.build())); |
398 | } | 398 | } |
399 | } else { | 399 | } else { |
400 | - executorMsgs.submit(new OFMessageHandler(dpid, reply)); | 400 | + executorMsgs.execute(new OFMessageHandler(dpid, reply)); |
401 | } | 401 | } |
402 | break; | 402 | break; |
403 | default: | 403 | default: |
... | @@ -406,7 +406,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -406,7 +406,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
406 | } | 406 | } |
407 | break; | 407 | break; |
408 | case BARRIER_REPLY: | 408 | case BARRIER_REPLY: |
409 | - executorBarrier.submit(new OFMessageHandler(dpid, msg)); | 409 | + executorBarrier.execute(new OFMessageHandler(dpid, msg)); |
410 | break; | 410 | break; |
411 | case EXPERIMENTER: | 411 | case EXPERIMENTER: |
412 | long experimenter = ((OFExperimenter) msg).getExperimenter(); | 412 | long experimenter = ((OFExperimenter) msg).getExperimenter(); | ... | ... |
... | @@ -15,21 +15,15 @@ | ... | @@ -15,21 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.openflow.controller.impl; | 16 | package org.onosproject.openflow.controller.impl; |
17 | 17 | ||
18 | -import java.net.URI; | ||
19 | -import java.net.URISyntaxException; | ||
20 | -import java.util.ArrayList; | ||
21 | -import java.util.List; | ||
22 | -import java.util.concurrent.Future; | ||
23 | - | ||
24 | import org.junit.Before; | 18 | import org.junit.Before; |
25 | import org.junit.Test; | 19 | import org.junit.Test; |
26 | import org.onosproject.openflow.ExecutorServiceAdapter; | 20 | import org.onosproject.openflow.ExecutorServiceAdapter; |
27 | -import org.onosproject.openflow.MockOfPortStatus; | ||
28 | -import org.onosproject.openflow.OpenFlowSwitchListenerAdapter; | ||
29 | -import org.onosproject.openflow.OpenflowSwitchDriverAdapter; | ||
30 | import org.onosproject.openflow.MockOfFeaturesReply; | 21 | import org.onosproject.openflow.MockOfFeaturesReply; |
31 | import org.onosproject.openflow.MockOfPacketIn; | 22 | import org.onosproject.openflow.MockOfPacketIn; |
23 | +import org.onosproject.openflow.MockOfPortStatus; | ||
32 | import org.onosproject.openflow.OfMessageAdapter; | 24 | import org.onosproject.openflow.OfMessageAdapter; |
25 | +import org.onosproject.openflow.OpenFlowSwitchListenerAdapter; | ||
26 | +import org.onosproject.openflow.OpenflowSwitchDriverAdapter; | ||
33 | import org.onosproject.openflow.controller.Dpid; | 27 | import org.onosproject.openflow.controller.Dpid; |
34 | import org.onosproject.openflow.controller.OpenFlowPacketContext; | 28 | import org.onosproject.openflow.controller.OpenFlowPacketContext; |
35 | import org.onosproject.openflow.controller.OpenFlowSwitch; | 29 | import org.onosproject.openflow.controller.OpenFlowSwitch; |
... | @@ -37,11 +31,14 @@ import org.onosproject.openflow.controller.PacketListener; | ... | @@ -37,11 +31,14 @@ import org.onosproject.openflow.controller.PacketListener; |
37 | import org.projectfloodlight.openflow.protocol.OFMessage; | 31 | import org.projectfloodlight.openflow.protocol.OFMessage; |
38 | import org.projectfloodlight.openflow.protocol.OFType; | 32 | import org.projectfloodlight.openflow.protocol.OFType; |
39 | 33 | ||
34 | +import java.net.URI; | ||
35 | +import java.net.URISyntaxException; | ||
36 | +import java.util.ArrayList; | ||
37 | +import java.util.List; | ||
38 | + | ||
40 | import static junit.framework.TestCase.fail; | 39 | import static junit.framework.TestCase.fail; |
41 | import static org.hamcrest.MatcherAssert.assertThat; | 40 | import static org.hamcrest.MatcherAssert.assertThat; |
42 | -import static org.hamcrest.Matchers.equalTo; | 41 | +import static org.hamcrest.Matchers.*; |
43 | -import static org.hamcrest.Matchers.hasSize; | ||
44 | -import static org.hamcrest.Matchers.is; | ||
45 | 42 | ||
46 | /** | 43 | /** |
47 | * Tests for packet processing in the open flow controller impl class. | 44 | * Tests for packet processing in the open flow controller impl class. |
... | @@ -85,11 +82,10 @@ public class OpenFlowControllerImplPacketsTest { | ... | @@ -85,11 +82,10 @@ public class OpenFlowControllerImplPacketsTest { |
85 | } | 82 | } |
86 | 83 | ||
87 | @Override | 84 | @Override |
88 | - public Future<?> submit(Runnable task) { | 85 | + public void execute(Runnable task) { |
89 | OpenFlowControllerImpl.OFMessageHandler handler = | 86 | OpenFlowControllerImpl.OFMessageHandler handler = |
90 | (OpenFlowControllerImpl.OFMessageHandler) task; | 87 | (OpenFlowControllerImpl.OFMessageHandler) task; |
91 | submittedMessages.add(handler.msg); | 88 | submittedMessages.add(handler.msg); |
92 | - return null; | ||
93 | } | 89 | } |
94 | } | 90 | } |
95 | 91 | ... | ... |
-
Please register or login to post a comment