Optimize drop-test memory usage 40/7140/2
authorRobert Varga <robert.varga@pantheon.sk>
Sat, 17 May 2014 20:12:17 +0000 (22:12 +0200)
committerRobert Varga <robert.varga@pantheon.sk>
Sun, 18 May 2014 09:53:52 +0000 (11:53 +0200)
This patch makes sure drop-test uses the Collections.singletonList(),
so as to not waste memory on ArrayList, since we are only forwarding a
single entry.

Change-Id: Iaf4e7e408ed147177a40355b3c0ab2d4e18d133c
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
drop-test/src/main/java/org/opendaylight/openflowplugin/droptest/DropTestRpcSender.java

index 180c6fc63886f2066fd02e57b1dc272e284b43e9..7da88c688f214a0648a3b7626eff4faba92e0be7 100644 (file)
@@ -39,7 +39,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.math.BigInteger;
-import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.Arrays;
 
 @SuppressWarnings("all")
@@ -122,8 +123,7 @@ public class DropTestRpcSender implements PacketProcessingListener {
                        ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
 
                        // Add our drop action to a list
-                       final ArrayList<Action> actionList = new ArrayList<Action>();
-                       actionList.add(ab.build());
+                       final List<Action> actionList = Collections.singletonList(ab.build());
 
                        // Create an Apply Action
                        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
@@ -135,8 +135,7 @@ public class DropTestRpcSender implements PacketProcessingListener {
 
                        // Put our Instruction in a list of Instructions
                        final InstructionsBuilder isb = new InstructionsBuilder();;
-                       final ArrayList<Instruction> instructions = new ArrayList<Instruction>();
-                       instructions.add(ib.build());
+                       final List<Instruction> instructions = Collections.singletonList(ib.build());
                        isb.setInstruction(instructions);
 
                        // Finally build our flow