Madan Jampani

Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next

......@@ -115,7 +115,7 @@ public class DefaultFlowRule implements FlowRule {
}
public int hash() {
return Objects.hash(deviceId, selector, id);
return Objects.hash(deviceId, selector, treatment);
}
@Override
......@@ -132,7 +132,7 @@ public class DefaultFlowRule implements FlowRule {
if (obj instanceof DefaultFlowRule) {
DefaultFlowRule that = (DefaultFlowRule) obj;
return Objects.equals(deviceId, that.deviceId) &&
//Objects.equals(id, that.id) &&
Objects.equals(id, that.id) &&
Objects.equals(priority, that.priority) &&
Objects.equals(selector, that.selector);
......@@ -143,7 +143,7 @@ public class DefaultFlowRule implements FlowRule {
@Override
public String toString() {
return toStringHelper(this)
.add("id", id)
.add("id", Long.toHexString(id.value()))
.add("deviceId", deviceId)
.add("priority", priority)
.add("selector", selector.criteria())
......@@ -154,7 +154,7 @@ public class DefaultFlowRule implements FlowRule {
@Override
public int timeout() {
return timeout > MAX_TIMEOUT ? MAX_TIMEOUT : this.timeout;
return timeout;
}
}
......
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;
......@@ -8,12 +15,6 @@ 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 static org.slf4j.LoggerFactory.getLogger;
/**
* Default traffic treatment implementation.
*/
......@@ -44,6 +45,25 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
return new Builder();
}
//FIXME: Order of instructions may affect hashcode
@Override
public int hashCode() {
return Objects.hash(instructions);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof DefaultTrafficTreatment) {
DefaultTrafficTreatment that = (DefaultTrafficTreatment) obj;
return Objects.equals(instructions, that.instructions);
}
return false;
}
/**
* Builds a list of treatments following the following order.
* Modifications -> Group -> Output (including drop)
......@@ -66,6 +86,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
private Builder() {
}
@Override
public Builder add(Instruction instruction) {
if (drop) {
return this;
......
......@@ -66,6 +66,8 @@ public interface FlowRuleService {
*/
Iterable<FlowRule> getFlowRulesById(ApplicationId id);
//Future<CompletedBatchOperation> applyBatch(BatchOperation<FlowRuleBatchEntry>)
/**
* Adds the specified flow rule listener.
*
......
......@@ -3,6 +3,8 @@ package org.onlab.onos.net.flow.instructions;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.L2SubType;
import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
......@@ -117,6 +119,24 @@ public final class Instructions {
return toStringHelper(type()).toString();
}
@Override
public int hashCode() {
return Objects.hash(type());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof DropInstruction) {
DropInstruction that = (DropInstruction) obj;
return Objects.equals(type(), that.type());
}
return false;
}
}
......@@ -140,6 +160,26 @@ public final class Instructions {
return toStringHelper(type().toString())
.add("port", port).toString();
}
@Override
public int hashCode() {
return Objects.hash(port, type());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof OutputInstruction) {
OutputInstruction that = (OutputInstruction) obj;
Objects.equals(port, that.port);
}
return false;
}
}
}
......
......@@ -2,6 +2,8 @@ package org.onlab.onos.net.flow.instructions;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Objects;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -74,6 +76,25 @@ public abstract class L2ModificationInstruction implements Instruction {
.add("mac", mac).toString();
}
@Override
public int hashCode() {
return Objects.hash(mac, subtype);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ModEtherInstruction) {
ModEtherInstruction that = (ModEtherInstruction) obj;
return Objects.equals(mac, that.mac) &&
Objects.equals(subtype, that.subtype);
}
return false;
}
}
......@@ -103,6 +124,25 @@ public abstract class L2ModificationInstruction implements Instruction {
.add("id", vlanId).toString();
}
@Override
public int hashCode() {
return Objects.hash(vlanId, subtype());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ModVlanIdInstruction) {
ModVlanIdInstruction that = (ModVlanIdInstruction) obj;
return Objects.equals(vlanId, that.vlanId);
}
return false;
}
}
/**
......@@ -131,6 +171,24 @@ public abstract class L2ModificationInstruction implements Instruction {
.add("pcp", Long.toHexString(vlanPcp)).toString();
}
@Override
public int hashCode() {
return Objects.hash(vlanPcp, subtype());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ModVlanPcpInstruction) {
ModVlanPcpInstruction that = (ModVlanPcpInstruction) obj;
return Objects.equals(vlanPcp, that.vlanPcp);
}
return false;
}
}
......
......@@ -2,6 +2,8 @@ package org.onlab.onos.net.flow.instructions;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Objects;
import org.onlab.packet.IpPrefix;
/**
......@@ -66,5 +68,23 @@ public abstract class L3ModificationInstruction implements Instruction {
.add("ip", ip).toString();
}
@Override
public int hashCode() {
return Objects.hash(ip, subtype());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ModIPInstruction) {
ModIPInstruction that = (ModIPInstruction) obj;
return Objects.equals(ip, that.ip);
}
return false;
}
}
}
......
package org.onlab.onos.net.intent.impl;
import com.google.common.collect.ImmutableMap;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.onlab.onos.net.intent.IntentState.COMPILING;
import static org.onlab.onos.net.intent.IntentState.FAILED;
import static org.onlab.onos.net.intent.IntentState.INSTALLED;
import static org.onlab.onos.net.intent.IntentState.INSTALLING;
import static org.onlab.onos.net.intent.IntentState.RECOMPILING;
import static org.onlab.onos.net.intent.IntentState.WITHDRAWING;
import static org.onlab.onos.net.intent.IntentState.WITHDRAWN;
import static org.onlab.util.Tools.namedThreads;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -25,20 +44,7 @@ import org.onlab.onos.net.intent.IntentStore;
import org.onlab.onos.net.intent.IntentStoreDelegate;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.onlab.onos.net.intent.IntentState.*;
import static org.onlab.util.Tools.delay;
import static org.onlab.util.Tools.namedThreads;
import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.collect.ImmutableMap;
/**
* An implementation of Intent Manager.
......@@ -61,7 +67,7 @@ public class IntentManager
private final AbstractListenerRegistry<IntentEvent, IntentListener>
listenerRegistry = new AbstractListenerRegistry<>();
private ExecutorService executor = newSingleThreadExecutor(namedThreads("onos-intents"));
private final ExecutorService executor = newSingleThreadExecutor(namedThreads("onos-intents"));
private final IntentStoreDelegate delegate = new InternalStoreDelegate();
private final TopologyChangeDelegate topoDelegate = new InternalTopoChangeDelegate();
......@@ -417,7 +423,7 @@ public class IntentManager
for (IntentId intentId : intentIds) {
Intent intent = getIntent(intentId);
uninstallIntent(intent);
delay(1000);
executeRecompilingPhase(intent);
}
......
package org.onlab.onos.net.intent.impl;
import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Iterator;
......@@ -21,6 +22,7 @@ import org.onlab.onos.net.flow.TrafficTreatment;
import org.onlab.onos.net.intent.IntentExtensionService;
import org.onlab.onos.net.intent.IntentInstaller;
import org.onlab.onos.net.intent.PathIntent;
import org.slf4j.Logger;
/**
* Installer for {@link PathIntent path connectivity intents}.
......@@ -28,6 +30,8 @@ import org.onlab.onos.net.intent.PathIntent;
@Component(immediate = true)
public class PathIntentInstaller implements IntentInstaller<PathIntent> {
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected IntentExtensionService intentManager;
......@@ -82,6 +86,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
FlowRule rule = new DefaultFlowRule(link.src().deviceId(),
builder.build(), treatment,
123, appId, 600);
flowRuleService.removeFlowRules(rule);
prev = link.dst();
}
......
......@@ -103,6 +103,7 @@ public class SimpleFlowRuleStore
public synchronized void deleteFlowRule(FlowRule rule) {
FlowEntry entry = getFlowEntry(rule);
if (entry == null) {
//log.warn("Cannot find rule {}", rule);
return;
}
entry.setState(FlowEntryState.PENDING_REMOVE);
......@@ -125,7 +126,7 @@ public class SimpleFlowRuleStore
return new FlowRuleEvent(Type.RULE_UPDATED, rule);
}
flowEntries.put(did, rule);
//flowEntries.put(did, rule);
return null;
}
......