Committed by
Gerrit Code Review
[ONOS-4385] Handle flow removed message type in all cases
- Do not handle packet in messages inside ControllerImpl class Change-Id: Idcb26b277b790125bd6b3ba8f10bb4c60e2a3c58
Showing
2 changed files
with
7 additions
and
52 deletions
| ... | @@ -48,8 +48,6 @@ import org.projectfloodlight.openflow.protocol.OFExperimenter; | ... | @@ -48,8 +48,6 @@ import org.projectfloodlight.openflow.protocol.OFExperimenter; |
| 48 | import org.projectfloodlight.openflow.protocol.OFFactories; | 48 | import org.projectfloodlight.openflow.protocol.OFFactories; |
| 49 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | 49 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 50 | import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; | 50 | import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; |
| 51 | -import org.projectfloodlight.openflow.protocol.OFTableStatsEntry; | ||
| 52 | -import org.projectfloodlight.openflow.protocol.OFTableStatsReply; | ||
| 53 | import org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry; | 51 | import org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry; |
| 54 | import org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply; | 52 | import org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply; |
| 55 | import org.projectfloodlight.openflow.protocol.OFGroupStatsEntry; | 53 | import org.projectfloodlight.openflow.protocol.OFGroupStatsEntry; |
| ... | @@ -62,6 +60,8 @@ import org.projectfloodlight.openflow.protocol.OFPortStatsReply; | ... | @@ -62,6 +60,8 @@ import org.projectfloodlight.openflow.protocol.OFPortStatsReply; |
| 62 | import org.projectfloodlight.openflow.protocol.OFPortStatus; | 60 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
| 63 | import org.projectfloodlight.openflow.protocol.OFStatsReply; | 61 | import org.projectfloodlight.openflow.protocol.OFStatsReply; |
| 64 | import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags; | 62 | import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags; |
| 63 | +import org.projectfloodlight.openflow.protocol.OFTableStatsEntry; | ||
| 64 | +import org.projectfloodlight.openflow.protocol.OFTableStatsReply; | ||
| 65 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; | 65 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
| 66 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | 66 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
| 67 | import org.slf4j.Logger; | 67 | import org.slf4j.Logger; |
| ... | @@ -79,6 +79,7 @@ import java.util.concurrent.ExecutorService; | ... | @@ -79,6 +79,7 @@ import java.util.concurrent.ExecutorService; |
| 79 | import java.util.concurrent.Executors; | 79 | import java.util.concurrent.Executors; |
| 80 | import java.util.concurrent.locks.Lock; | 80 | import java.util.concurrent.locks.Lock; |
| 81 | import java.util.concurrent.locks.ReentrantLock; | 81 | import java.util.concurrent.locks.ReentrantLock; |
| 82 | + | ||
| 82 | import static org.onlab.util.Tools.groupedThreads; | 83 | import static org.onlab.util.Tools.groupedThreads; |
| 83 | 84 | ||
| 84 | @Component(immediate = true) | 85 | @Component(immediate = true) |
| ... | @@ -115,12 +116,6 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -115,12 +116,6 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
| 115 | protected ExecutorService executorMsgs = | 116 | protected ExecutorService executorMsgs = |
| 116 | Executors.newFixedThreadPool(32, groupedThreads("onos/of", "event-stats-%d", log)); | 117 | Executors.newFixedThreadPool(32, groupedThreads("onos/of", "event-stats-%d", log)); |
| 117 | 118 | ||
| 118 | - protected ExecutorService executorPacketIn = | ||
| 119 | - Executors.newCachedThreadPool(groupedThreads("onos/of", "event-pkt-in-stats-%d", log)); | ||
| 120 | - | ||
| 121 | - protected ExecutorService executorFlowRemoved = | ||
| 122 | - Executors.newCachedThreadPool(groupedThreads("onos/of", "event-flow-removed-stats-%d", log)); | ||
| 123 | - | ||
| 124 | private final ExecutorService executorBarrier = | 119 | private final ExecutorService executorBarrier = |
| 125 | Executors.newFixedThreadPool(4, groupedThreads("onos/of", "event-barrier-%d", log)); | 120 | Executors.newFixedThreadPool(4, groupedThreads("onos/of", "event-barrier-%d", log)); |
| 126 | 121 | ||
| ... | @@ -286,19 +281,11 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -286,19 +281,11 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
| 286 | for (PacketListener p : ofPacketListener.values()) { | 281 | for (PacketListener p : ofPacketListener.values()) { |
| 287 | p.handlePacket(pktCtx); | 282 | p.handlePacket(pktCtx); |
| 288 | } | 283 | } |
| 289 | - if (monitorAllEvents) { | ||
| 290 | - executorPacketIn.execute(new OFMessageHandler(dpid, msg)); | ||
| 291 | - } | ||
| 292 | break; | 284 | break; |
| 293 | // TODO: Consider using separate threadpool for sensitive messages. | 285 | // TODO: Consider using separate threadpool for sensitive messages. |
| 294 | // ie. Back to back error could cause us to starve. | 286 | // ie. Back to back error could cause us to starve. |
| 295 | case FLOW_REMOVED: | 287 | case FLOW_REMOVED: |
| 296 | - if (monitorAllEvents) { | ||
| 297 | - executorFlowRemoved.execute(new OFMessageHandler(dpid, msg)); | ||
| 298 | - } | ||
| 299 | - break; | ||
| 300 | case ERROR: | 288 | case ERROR: |
| 301 | - log.debug("Received error message from {}: {}", dpid, msg); | ||
| 302 | executorMsgs.execute(new OFMessageHandler(dpid, msg)); | 289 | executorMsgs.execute(new OFMessageHandler(dpid, msg)); |
| 303 | break; | 290 | break; |
| 304 | case STATS_REPLY: | 291 | case STATS_REPLY: |
| ... | @@ -648,7 +635,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -648,7 +635,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
| 648 | } | 635 | } |
| 649 | 636 | ||
| 650 | /** | 637 | /** |
| 651 | - * OpenFlow message handler for incoming control messages. | 638 | + * OpenFlow message handler. |
| 652 | */ | 639 | */ |
| 653 | protected final class OFMessageHandler implements Runnable { | 640 | protected final class OFMessageHandler implements Runnable { |
| 654 | 641 | ... | ... |
| ... | @@ -19,7 +19,6 @@ import org.junit.Before; | ... | @@ -19,7 +19,6 @@ import org.junit.Before; |
| 19 | import org.junit.Test; | 19 | import org.junit.Test; |
| 20 | import org.onosproject.openflow.ExecutorServiceAdapter; | 20 | import org.onosproject.openflow.ExecutorServiceAdapter; |
| 21 | import org.onosproject.openflow.MockOfFeaturesReply; | 21 | import org.onosproject.openflow.MockOfFeaturesReply; |
| 22 | -import org.onosproject.openflow.MockOfPacketIn; | ||
| 23 | import org.onosproject.openflow.MockOfPortStatus; | 22 | import org.onosproject.openflow.MockOfPortStatus; |
| 24 | import org.onosproject.openflow.OfMessageAdapter; | 23 | import org.onosproject.openflow.OfMessageAdapter; |
| 25 | import org.onosproject.openflow.OpenFlowSwitchListenerAdapter; | 24 | import org.onosproject.openflow.OpenFlowSwitchListenerAdapter; |
| ... | @@ -38,7 +37,9 @@ import java.util.List; | ... | @@ -38,7 +37,9 @@ import java.util.List; |
| 38 | 37 | ||
| 39 | import static junit.framework.TestCase.fail; | 38 | import static junit.framework.TestCase.fail; |
| 40 | import static org.hamcrest.MatcherAssert.assertThat; | 39 | import static org.hamcrest.MatcherAssert.assertThat; |
| 41 | -import static org.hamcrest.Matchers.*; | 40 | +import static org.hamcrest.Matchers.equalTo; |
| 41 | +import static org.hamcrest.Matchers.hasSize; | ||
| 42 | +import static org.hamcrest.Matchers.is; | ||
| 42 | 43 | ||
| 43 | /** | 44 | /** |
| 44 | * Tests for packet processing in the open flow controller impl class. | 45 | * Tests for packet processing in the open flow controller impl class. |
| ... | @@ -51,8 +52,6 @@ public class OpenFlowControllerImplPacketsTest { | ... | @@ -51,8 +52,6 @@ public class OpenFlowControllerImplPacketsTest { |
| 51 | OpenFlowSwitchListenerAdapter switchListener; | 52 | OpenFlowSwitchListenerAdapter switchListener; |
| 52 | TestPacketListener packetListener; | 53 | TestPacketListener packetListener; |
| 53 | TestExecutorService statsExecutorService; | 54 | TestExecutorService statsExecutorService; |
| 54 | - TestExecutorService pktInExecutorService; | ||
| 55 | - TestExecutorService flowRmvExecutorService; | ||
| 56 | 55 | ||
| 57 | /** | 56 | /** |
| 58 | * Mock packet listener that accumulates packets. | 57 | * Mock packet listener that accumulates packets. |
| ... | @@ -70,7 +69,6 @@ public class OpenFlowControllerImplPacketsTest { | ... | @@ -70,7 +69,6 @@ public class OpenFlowControllerImplPacketsTest { |
| 70 | } | 69 | } |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | - | ||
| 74 | /** | 72 | /** |
| 75 | * Mock executor service that tracks submits. | 73 | * Mock executor service that tracks submits. |
| 76 | */ | 74 | */ |
| ... | @@ -112,13 +110,8 @@ public class OpenFlowControllerImplPacketsTest { | ... | @@ -112,13 +110,8 @@ public class OpenFlowControllerImplPacketsTest { |
| 112 | controller.addPacketListener(100, packetListener); | 110 | controller.addPacketListener(100, packetListener); |
| 113 | 111 | ||
| 114 | statsExecutorService = new TestExecutorService(); | 112 | statsExecutorService = new TestExecutorService(); |
| 115 | - pktInExecutorService = new TestExecutorService(); | ||
| 116 | - flowRmvExecutorService = new TestExecutorService(); | ||
| 117 | 113 | ||
| 118 | controller.executorMsgs = statsExecutorService; | 114 | controller.executorMsgs = statsExecutorService; |
| 119 | - controller.executorPacketIn = pktInExecutorService; | ||
| 120 | - controller.executorFlowRemoved = flowRmvExecutorService; | ||
| 121 | - | ||
| 122 | } | 115 | } |
| 123 | 116 | ||
| 124 | /** | 117 | /** |
| ... | @@ -148,19 +141,6 @@ public class OpenFlowControllerImplPacketsTest { | ... | @@ -148,19 +141,6 @@ public class OpenFlowControllerImplPacketsTest { |
| 148 | } | 141 | } |
| 149 | 142 | ||
| 150 | /** | 143 | /** |
| 151 | - * Tests a packet in listen operation. | ||
| 152 | - */ | ||
| 153 | - @Test | ||
| 154 | - public void testPacketInListen() { | ||
| 155 | - agent.addConnectedSwitch(dpid1, switch1); | ||
| 156 | - OFMessage packetInPacket = new MockOfPacketIn(); | ||
| 157 | - controller.processPacket(dpid1, packetInPacket); | ||
| 158 | - assertThat(packetListener.contexts(), hasSize(1)); | ||
| 159 | - assertThat(pktInExecutorService.submittedMessages(), hasSize(1)); | ||
| 160 | - assertThat(pktInExecutorService.submittedMessages().get(0), is(packetInPacket)); | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - /** | ||
| 164 | * Tests an error operation. | 144 | * Tests an error operation. |
| 165 | */ | 145 | */ |
| 166 | @Test | 146 | @Test |
| ... | @@ -171,16 +151,4 @@ public class OpenFlowControllerImplPacketsTest { | ... | @@ -171,16 +151,4 @@ public class OpenFlowControllerImplPacketsTest { |
| 171 | assertThat(statsExecutorService.submittedMessages(), hasSize(1)); | 151 | assertThat(statsExecutorService.submittedMessages(), hasSize(1)); |
| 172 | assertThat(statsExecutorService.submittedMessages().get(0), is(errorPacket)); | 152 | assertThat(statsExecutorService.submittedMessages().get(0), is(errorPacket)); |
| 173 | } | 153 | } |
| 174 | - | ||
| 175 | - /** | ||
| 176 | - * Tests a packet in operation. | ||
| 177 | - */ | ||
| 178 | - @Test | ||
| 179 | - public void testFlowRemoved() { | ||
| 180 | - agent.addConnectedSwitch(dpid1, switch1); | ||
| 181 | - OFMessage flowRemovedPacket = new MockOfFlowRemoved(); | ||
| 182 | - controller.processPacket(dpid1, flowRemovedPacket); | ||
| 183 | - assertThat(flowRmvExecutorService.submittedMessages(), hasSize(1)); | ||
| 184 | - assertThat(flowRmvExecutorService.submittedMessages().get(0), is(flowRemovedPacket)); | ||
| 185 | - } | ||
| 186 | } | 154 | } | ... | ... |
-
Please register or login to post a comment