tom

Eliminating some performance bottlenecks; more to be done.

......@@ -170,7 +170,9 @@ public class ReactiveForwarding {
// We don't yet support bufferids in the flowservice so packet out first.
packetOut(context, portNumber);
if (true) {
return;
}
// Install the flow rule to handle this type of message from now on.
Ethernet inPkt = context.inPacket().parsed();
......
......@@ -19,17 +19,16 @@ import org.onlab.onos.net.intent.IntentState;
description = "Wipes-out the entire network information base, i.e. devices, links, hosts")
public class WipeOutCommand extends ClustersListCommand {
private static final String DISCLAIMER = "Delete everything please.";
private static final String PLEASE = "please";
@Argument(index = 0, name = "disclaimer", description = "Device ID",
@Argument(index = 0, name = "please", description = "Confirmation phrase",
required = false, multiValued = false)
String disclaimer = null;
String please = null;
@Override
protected void execute() {
if (disclaimer == null || !disclaimer.equals(DISCLAIMER)) {
print("I'm afraid I can't do that!\nPlease acknowledge with phrase: '%s'",
DISCLAIMER);
if (please == null || !please.equals(PLEASE)) {
print("I'm afraid I can't do that!\nSay: %s", PLEASE);
return;
}
......
......@@ -9,10 +9,12 @@ import java.util.Objects;
public abstract class ElementId {
private final URI uri;
private final String str;
// Default constructor for serialization
protected ElementId() {
this.uri = null;
this.str = null;
}
/**
......@@ -22,6 +24,7 @@ public abstract class ElementId {
*/
protected ElementId(URI uri) {
this.uri = uri;
this.str = uri.toString();
}
/**
......@@ -35,7 +38,7 @@ public abstract class ElementId {
@Override
public int hashCode() {
return Objects.hash(uri);
return Objects.hash(str);
}
@Override
......@@ -46,14 +49,14 @@ public abstract class ElementId {
if (obj instanceof ElementId) {
final ElementId that = (ElementId) obj;
return this.getClass() == that.getClass() &&
Objects.equals(this.uri, that.uri);
Objects.equals(this.str, that.str);
}
return false;
}
@Override
public String toString() {
return uri.toString();
return str;
}
}
......
package org.onlab.onos.net.flow;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.instructions.Instruction;
import org.onlab.onos.net.flow.instructions.Instructions;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
/**
* Default traffic treatment implementation.
......@@ -58,7 +55,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
}
if (obj instanceof DefaultTrafficTreatment) {
DefaultTrafficTreatment that = (DefaultTrafficTreatment) obj;
return Objects.equals(instructions, that.instructions);
return Objects.equals(instructions, that.instructions);
}
return false;
......@@ -70,8 +67,6 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
*/
public static final class Builder implements TrafficTreatment.Builder {
private final Logger log = getLogger(getClass());
boolean drop = false;
List<Instruction> outputs = new LinkedList<>();
......@@ -107,7 +102,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
groups.add(instruction);
break;
default:
log.warn("Unknown instruction type {}", instruction.type());
throw new IllegalArgumentException("Unknown instruction type: " +
instruction.type());
}
return this;
}
......
package org.onlab.onos.openflow.controller;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
import org.onlab.packet.Ethernet;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut;
......@@ -13,11 +8,11 @@ import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
import org.slf4j.Logger;
public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext {
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
private final Logger log = getLogger(getClass());
public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext {
private final AtomicBoolean free = new AtomicBoolean(true);
private final AtomicBoolean isBuilt = new AtomicBoolean(false);
......@@ -82,7 +77,7 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
}
public static OpenFlowPacketContext packetContextFromPacketIn(OpenFlowSwitch s,
OFPacketIn pkt) {
OFPacketIn pkt) {
return new DefaultOpenFlowPacketContext(s, pkt);
}
......
......@@ -157,9 +157,7 @@ public class Controller {
}
log.debug("OpenFlow port set to {}", this.openFlowPort);
String threads = configParams.get("workerthreads");
if (threads != null) {
this.workerThreads = Integer.parseInt(threads);
}
this.workerThreads = threads != null ? Integer.parseInt(threads) : 16;
log.debug("Number of worker threads set to {}", this.workerThreads);
}
......
......@@ -44,7 +44,6 @@ public class OpenFlowControllerImpl implements OpenFlowController {
private final ExecutorService executor = Executors.newFixedThreadPool(16,
namedThreads("of-event-%d"));
protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches =
new ConcurrentHashMap<Dpid, OpenFlowSwitch>();
protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches =
......
package org.onlab.onos.provider.of.packet.impl;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.List;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.instructions.Instruction;
import org.onlab.onos.net.flow.instructions.Instruction.Type;
......@@ -14,16 +10,16 @@ import org.onlab.onos.net.packet.OutboundPacket;
import org.onlab.onos.openflow.controller.OpenFlowPacketContext;
import org.onlab.packet.Ethernet;
import org.projectfloodlight.openflow.types.OFPort;
import org.slf4j.Logger;
public class OpenFlowCorePacketContext extends DefaultPacketContext {
import java.util.List;
private final Logger log = getLogger(getClass());
public class OpenFlowCorePacketContext extends DefaultPacketContext {
private final OpenFlowPacketContext ofPktCtx;
protected OpenFlowCorePacketContext(long time, InboundPacket inPkt,
OutboundPacket outPkt, boolean block, OpenFlowPacketContext ofPktCtx) {
OutboundPacket outPkt, boolean block,
OpenFlowPacketContext ofPktCtx) {
super(time, inPkt, outPkt, block);
this.ofPktCtx = ofPktCtx;
}
......@@ -36,9 +32,8 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
} else {
Ethernet eth = new Ethernet();
eth.deserialize(outPacket().data().array(), 0,
outPacket().data().array().length);
outPacket().data().array().length);
sendPacket(eth);
}
}
......@@ -61,6 +56,7 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
}
ofPktCtx.send();
}
private OFPort buildPort(PortNumber port) {
return OFPort.of((int) port.toLong());
}
......