Brian O'Connor
Committed by Gerrit Code Review

Refactored intent framework to deal with batches.

There is still work to be done, but for now, submit, withdraw and reroute are working.

Change-Id: Ib94cf8c4be03786cc070f402d1f296f5dfa6588b
Showing 27 changed files with 380 additions and 55 deletions
......@@ -29,6 +29,7 @@ import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.IntentEvent;
import org.onlab.onos.net.intent.IntentEvent.Type;
import org.onlab.onos.net.intent.IntentListener;
import org.onlab.onos.net.intent.IntentOperations;
import org.onlab.onos.net.intent.IntentService;
import org.onlab.onos.net.intent.PointToPointIntent;
import org.onlab.packet.Ethernet;
......@@ -63,9 +64,6 @@ public class IntentPushTestCommand extends AbstractShellCommand
required = true, multiValued = false)
String countString = null;
private static long id = 0x7870001;
private IntentService service;
private CountDownLatch latch;
private long start, end;
......@@ -91,15 +89,18 @@ public class IntentPushTestCommand extends AbstractShellCommand
service.addListener(this);
latch = new CountDownLatch(count);
start = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
IntentOperations.Builder ops = IntentOperations.builder();
for (int i = 1; i <= count; i++) {
TrafficSelector s = selector
.matchEthSrc(MacAddress.valueOf(i))
.build();
Intent intent = new PointToPointIntent(appId(), s, treatment,
ingress, egress);
service.submit(intent);
ops.addSubmitOperation(intent);
}
IntentOperations operations = ops.build();
start = System.currentTimeMillis();
service.execute(operations);
try {
if (latch.await(10, TimeUnit.SECONDS)) {
printResults(count);
......
......@@ -15,13 +15,13 @@
*/
package org.onlab.onos.net.flow;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* A list of BatchOperationEntry.
*
......@@ -88,6 +88,16 @@ public abstract class BatchOperation<T extends BatchOperationEntry<?, ?>> {
return ops.add(entry) ? this : null;
}
/**
* Add all operations from another batch to this batch.
*
* @param another another batch
* @return true if success
*/
public boolean addAll(BatchOperation<T> another) {
return ops.addAll(another.getOperations());
}
@Override
public boolean equals(Object o) {
if (this == o) {
......
......@@ -19,12 +19,20 @@ import java.util.Set;
import com.google.common.collect.ImmutableSet;
/**
* Representation of a completed flow rule batch operation.
*/
public class CompletedBatchOperation implements BatchOperationResult<FlowRule> {
private final boolean success;
private final Set<FlowRule> failures;
/**
* Creates a new batch completion result.
*
* @param success indicates whether the completion is successful.
* @param failures set of any failures encountered
*/
public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures) {
this.success = success;
this.failures = ImmutableSet.copyOf(failures);
......@@ -40,5 +48,4 @@ public class CompletedBatchOperation implements BatchOperationResult<FlowRule> {
return failures;
}
}
......
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onlab.onos.net.intent;
/**
* Facade for receiving notifications from the intent batch service.
*/
public interface IntentBatchDelegate {
/**
* Submits the specified batch of intent operations for processing.
*
* @param operations batch of operations
*/
void execute(IntentOperations operations);
/**
* Cancesl the specified batch of intent operations.
*
* @param operations batch of operations to be cancelled
*/
void cancel(IntentOperations operations);
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onlab.onos.net.intent;
import java.util.Set;
/**
* Service for tracking and delegating batches of intent operations.
*/
public interface IntentBatchService {
/**
* Submits a batch of intent operations.
*
* @param operations batch of operations
*/
void addIntentOperations(IntentOperations operations);
/**
* Removes the specified batch of intent operations after completion.
*
* @param operations batch of operations
*/
void removeIntentOperations(IntentOperations operations);
/**
* Returns the set of intent batches currently being tracked.
* @return set of batches
*/
Set<IntentOperations> getIntentOperations();
/**
* Sets the batch service delegate.
*
* @param delegate delegate to apply
*/
void setDelegate(IntentBatchDelegate delegate);
/**
* Unsets the batch service delegate.
*
* @param delegate delegate to unset
*/
void unsetDelegate(IntentBatchDelegate delegate);
}
......@@ -15,7 +15,10 @@
*/
package org.onlab.onos.net.intent;
import org.onlab.onos.net.resource.LinkResourceAllocations;
import java.util.List;
import java.util.Set;
/**
* Abstraction of a compiler which is capable of taking an intent
......@@ -27,9 +30,13 @@ public interface IntentCompiler<T extends Intent> {
/**
* Compiles the specified intent into other intents.
*
* @param intent intent to be compiled
* @param intent intent to be compiled
* @param installable previously compilation result; optional
* @param resources previously allocated resources; optional
* @return list of resulting intents
* @throws IntentException if issues are encountered while compiling the intent
*/
List<Intent> compile(T intent);
List<Intent> compile(T intent, List<Intent> installable,
Set<LinkResourceAllocations> resources);
}
......
......@@ -15,10 +15,10 @@
*/
package org.onlab.onos.net.intent;
import java.util.List;
import org.onlab.onos.net.flow.FlowRuleBatchOperation;
import java.util.List;
/**
* Abstraction of entity capable of installing intents to the environment.
*/
......@@ -26,8 +26,8 @@ public interface IntentInstaller<T extends Intent> {
/**
* Installs the specified intent to the environment.
*
* @param intent intent to be installed
* @return FlowRule operations to install
* @param intent intent to be installed
* @return flow rule operations to complete install
* @throws IntentException if issues are encountered while installing the intent
*/
List<FlowRuleBatchOperation> install(T intent);
......@@ -35,9 +35,20 @@ public interface IntentInstaller<T extends Intent> {
/**
* Uninstalls the specified intent from the environment.
*
* @param intent intent to be uninstalled
* @return FlowRule operations to uninstall
* @param intent intent to be uninstalled
* @return flow rule operations to complete uninstall
* @throws IntentException if issues are encountered while uninstalling the intent
*/
List<FlowRuleBatchOperation> uninstall(T intent);
/**
* Replaces the specified intent with a new one in the environment.
*
* @param oldIntent intent to be removed
* @param newIntent intent to be installed
* @return flow rule operations to complete the replace
* @throws IntentException if issues are encountered while uninstalling the intent
*/
List<FlowRuleBatchOperation> replace(T oldIntent, T newIntent);
}
......
......@@ -15,6 +15,11 @@
*/
package org.onlab.onos.net.intent;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Abstraction of an intent-related operation, e.g. add, remove, replace.
*/
......@@ -27,7 +32,7 @@ public class IntentOperation {
/**
* Operation type.
*/
enum Type {
public enum Type {
/**
* Indicates that an intent should be added.
*/
......@@ -41,15 +46,20 @@ public class IntentOperation {
/**
* Indicates that an intent should be replaced with another.
*/
REPLACE
REPLACE,
/**
* Indicates that an intent should be updated (i.e. recompiled/reinstalled).
*/
UPDATE,
}
/**
* Creates an intent operation.
*
* @param type operation type
* @param type operation type
* @param intentId identifier of the intent subject to the operation
* @param intent intent subject
* @param intent intent subject
*/
IntentOperation(Type type, IntentId intentId, Intent intent) {
this.type = type;
......@@ -85,4 +95,32 @@ public class IntentOperation {
return intent;
}
@Override
public int hashCode() {
return Objects.hash(type, intentId, intent);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final IntentOperation other = (IntentOperation) obj;
return Objects.equals(this.type, other.type) &&
Objects.equals(this.intentId, other.intentId) &&
Objects.equals(this.intent, other.intent);
}
@Override
public String toString() {
return toStringHelper(this)
.add("type", type)
.add("intentId", intentId)
.add("intent", intent)
.toString();
}
}
......
......@@ -18,11 +18,11 @@ package org.onlab.onos.net.intent;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.onos.net.intent.IntentOperation.Type.REPLACE;
import static org.onlab.onos.net.intent.IntentOperation.Type.SUBMIT;
import static org.onlab.onos.net.intent.IntentOperation.Type.WITHDRAW;
import static org.onlab.onos.net.intent.IntentOperation.Type.*;
/**
* Batch of intent submit/withdraw/replace operations.
......@@ -58,6 +58,31 @@ public final class IntentOperations {
return new Builder();
}
@Override
public int hashCode() {
return Objects.hash(operations);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final IntentOperations other = (IntentOperations) obj;
return Objects.equals(this.operations, other.operations);
}
@Override
public String toString() {
return toStringHelper(this)
.add("operations", operations)
.toString();
}
/**
* Builder for batches of intent operations.
*/
......@@ -108,6 +133,18 @@ public final class IntentOperations {
}
/**
* Adds an intent update operation.
*
* @param intentId identifier of the intent to be updated
* @return self
*/
public Builder addUpdateOperation(IntentId intentId) {
checkNotNull(intentId, "Intent ID cannot be null");
builder.add(new IntentOperation(UPDATE, intentId, null));
return this;
}
/**
* Builds a batch of intent operations.
*
* @return immutable batch of intent operations
......
......@@ -17,7 +17,6 @@ package org.onlab.onos.net.intent;
import java.util.List;
import java.util.concurrent.Future;
/**
* Service for application submitting or withdrawing their intents.
......@@ -59,9 +58,8 @@ public interface IntentService {
* affected at later time.
* </p>
* @param operations batch of intent operations
* @return Future to get execution result
*/
Future<IntentOperations> execute(IntentOperations operations);
void execute(IntentOperations operations);
/**
* Returns an iterable of intents currently in the system.
......
......@@ -24,7 +24,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
* Fake implementation of the intent service to assist in developing tests of
......@@ -104,7 +103,7 @@ public class FakeIntentManager implements TestableIntentService {
try {
// For the fake, we compile using a single level pass
List<Intent> installable = new ArrayList<>();
for (Intent compiled : getCompiler(intent).compile(intent)) {
for (Intent compiled : getCompiler(intent).compile(intent, null, null)) {
installable.add((Intent) compiled);
}
executeInstallingPhase(intent, installable);
......@@ -192,9 +191,8 @@ public class FakeIntentManager implements TestableIntentService {
}
@Override
public Future<IntentOperations> execute(IntentOperations operations) {
public void execute(IntentOperations operations) {
// TODO: implement later
return null;
}
@Override
......
......@@ -29,11 +29,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.onos.net.flow.FlowRuleBatchOperation;
import org.onlab.onos.net.resource.LinkResourceAllocations;
/**
* Suite of tests for the intent service contract.
......@@ -294,7 +296,8 @@ public class IntentServiceTest {
}
@Override
public List<Intent> compile(TestIntent intent) {
public List<Intent> compile(TestIntent intent, List<Intent> installable,
Set<LinkResourceAllocations> resources) {
if (fail) {
throw new IntentException("compile failed by design");
}
......@@ -326,6 +329,12 @@ public class IntentServiceTest {
}
return null;
}
@Override
public List<FlowRuleBatchOperation> replace(TestInstallableIntent intent,
TestInstallableIntent newIntent) {
return null;
}
}
}
......
......@@ -509,13 +509,8 @@ public class FlowRuleManager
boolean success = true;
Set<FlowRule> failed = Sets.newHashSet();
CompletedBatchOperation completed;
long start = System.nanoTime();
long end = start + unit.toNanos(timeout);
for (Future<CompletedBatchOperation> future : futures) {
long now = System.nanoTime();
long thisTimeout = end - now;
completed = future.get(thisTimeout, TimeUnit.NANOSECONDS);
completed = future.get(timeout, unit);
success = validateBatchOperation(failed, completed);
}
return finalizeBatchOperation(success, failed);
......
......@@ -27,9 +27,11 @@ import org.onlab.onos.net.host.HostService;
import org.onlab.onos.net.intent.HostToHostIntent;
import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.PathIntent;
import org.onlab.onos.net.resource.LinkResourceAllocations;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import static org.onlab.onos.net.flow.DefaultTrafficSelector.builder;
......@@ -54,7 +56,8 @@ public class HostToHostIntentCompiler
}
@Override
public List<Intent> compile(HostToHostIntent intent) {
public List<Intent> compile(HostToHostIntent intent, List<Intent> installable,
Set<LinkResourceAllocations> resources) {
Path pathOne = getPath(intent, intent.one(), intent.two());
Path pathTwo = getPath(intent, intent.two(), intent.one());
......
......@@ -111,6 +111,13 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
return Lists.newArrayList(new FlowRuleBatchOperation(rules));
}
@Override
public List<FlowRuleBatchOperation> replace(LinkCollectionIntent intent,
LinkCollectionIntent newIntent) {
// FIXME: implement
return null;
}
/**
* Creates a FlowRuleBatchEntry based on the provided parameters.
*
......
......@@ -29,6 +29,7 @@ import org.onlab.onos.net.intent.IntentExtensionService;
import org.onlab.onos.net.intent.LinkCollectionIntent;
import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
import org.onlab.onos.net.intent.PointToPointIntent;
import org.onlab.onos.net.resource.LinkResourceAllocations;
import org.onlab.onos.net.topology.PathService;
import java.util.Arrays;
......@@ -61,7 +62,8 @@ public class MultiPointToSinglePointIntentCompiler
}
@Override
public List<Intent> compile(MultiPointToSinglePointIntent intent) {
public List<Intent> compile(MultiPointToSinglePointIntent intent, List<Intent> installable,
Set<LinkResourceAllocations> resources) {
Set<Link> links = new HashSet<>();
for (ConnectPoint ingressPoint : intent.ingressPoints()) {
......
......@@ -29,6 +29,7 @@ import org.onlab.onos.net.intent.IntentCompiler;
import org.onlab.onos.net.intent.IntentExtensionService;
import org.onlab.onos.net.intent.OpticalConnectivityIntent;
import org.onlab.onos.net.intent.OpticalPathIntent;
import org.onlab.onos.net.resource.LinkResourceAllocations;
import org.onlab.onos.net.topology.LinkWeight;
import org.onlab.onos.net.topology.Topology;
import org.onlab.onos.net.topology.TopologyEdge;
......@@ -60,7 +61,9 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
}
@Override
public List<Intent> compile(OpticalConnectivityIntent intent) {
public List<Intent> compile(OpticalConnectivityIntent intent,
List<Intent> installable,
Set<LinkResourceAllocations> resources) {
// TODO: compute multiple paths using the K-shortest path algorithm
Path path = calculateOpticalPath(intent.getSrcConnectPoint(), intent.getDst());
Intent newIntent = new OpticalPathIntent(intent.appId(),
......
......@@ -104,6 +104,13 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
return generateRules(intent, allocations, FlowRuleOperation.REMOVE);
}
@Override
public List<FlowRuleBatchOperation> replace(OpticalPathIntent intent,
OpticalPathIntent newIntent) {
// FIXME: implement this
return null;
}
private LinkResourceAllocations assignWavelength(OpticalPathIntent intent) {
LinkResourceRequest.Builder request = DefaultLinkResourceRequest.builder(intent.id(),
intent.path().links())
......
......@@ -131,6 +131,15 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
return Lists.newArrayList(new FlowRuleBatchOperation(rules));
}
@Override
public List<FlowRuleBatchOperation> replace(PathIntent oldIntent, PathIntent newIntent) {
// FIXME: implement this
List<FlowRuleBatchOperation> batches = Lists.newArrayList();
batches.addAll(uninstall(oldIntent));
batches.addAll(install(newIntent));
return batches;
}
/**
* Allocate resources required for an intent.
*
......@@ -147,7 +156,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
return request.resources().isEmpty() ? null : resourceService.requestResources(request);
}
// TODO refactor below this line... ----------------------------
// FIXME refactor below this line... ----------------------------
/**
* Generates the series of MatchActionOperations from the
......
......@@ -28,9 +28,11 @@ import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.PathIntent;
import org.onlab.onos.net.intent.PointToPointIntent;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.net.resource.LinkResourceAllocations;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static java.util.Arrays.asList;
import static org.onlab.onos.net.Link.Type.DIRECT;
......@@ -57,7 +59,9 @@ public class PointToPointIntentCompiler
}
@Override
public List<Intent> compile(PointToPointIntent intent) {
public List<Intent> compile(PointToPointIntent intent, List<Intent> installable,
Set<LinkResourceAllocations> resources) {
ConnectPoint ingressPoint = intent.ingressPoint();
ConnectPoint egressPoint = intent.egressPoint();
......
......@@ -87,7 +87,7 @@ public class PathConstraintCalculationTest {
constraints);
final PointToPointIntentCompiler compiler = makeCompiler(resourceService);
return compiler.compile(intent);
return compiler.compile(intent, null, null);
}
/**
......
......@@ -121,7 +121,7 @@ public class TestHostToHostIntentCompiler {
HostToHostIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(2));
Intent forwardResultIntent = result.get(0);
......
......@@ -137,7 +137,7 @@ public class TestMultiPointToSinglePointIntentCompiler {
MultiPointToSinglePointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
......@@ -172,7 +172,7 @@ public class TestMultiPointToSinglePointIntentCompiler {
MultiPointToSinglePointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
......@@ -205,7 +205,7 @@ public class TestMultiPointToSinglePointIntentCompiler {
MultiPointToSinglePointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
......
......@@ -93,7 +93,7 @@ public class TestPointToPointIntentCompiler {
PointToPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent forwardResultIntent = result.get(0);
......@@ -126,7 +126,7 @@ public class TestPointToPointIntentCompiler {
PointToPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent reverseResultIntent = result.get(0);
......@@ -157,7 +157,7 @@ public class TestPointToPointIntentCompiler {
String[] hops = {"1"};
PointToPointIntentCompiler sut = makeCompiler(hops);
List<Intent> compiled = sut.compile(intent);
List<Intent> compiled = sut.compile(intent, null, null);
assertThat(compiled, hasSize(1));
assertThat(compiled.get(0), is(instanceOf(PathIntent.class)));
......
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onlab.onos.store.trivial.impl;
import com.google.common.collect.ImmutableSet;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.net.intent.IntentBatchDelegate;
import org.onlab.onos.net.intent.IntentBatchService;
import org.onlab.onos.net.intent.IntentOperations;
import org.slf4j.Logger;
import java.util.HashSet;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = true)
@Service
public class SimpleIntentBatchQueue implements IntentBatchService {
private final Logger log = getLogger(getClass());
private final Set<IntentOperations> pendingBatches = new HashSet<>();
private IntentBatchDelegate delegate;
@Activate
public void activate() {
log.info("Started");
}
@Deactivate
public void deactivate() {
log.info("Stopped");
}
@Override
public void addIntentOperations(IntentOperations operations) {
checkState(delegate != null, "No delegate set");
pendingBatches.add(operations);
delegate.execute(operations);
}
@Override
public void removeIntentOperations(IntentOperations operations) {
pendingBatches.remove(operations);
}
@Override
public Set<IntentOperations> getIntentOperations() {
return ImmutableSet.copyOf(pendingBatches);
}
@Override
public void setDelegate(IntentBatchDelegate delegate) {
this.delegate = checkNotNull(delegate, "Delegate cannot be null");
}
@Override
public void unsetDelegate(IntentBatchDelegate delegate) {
if (this.delegate != null && this.delegate.equals(delegate)) {
this.delegate = null;
}
}
}
......@@ -33,7 +33,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static org.onlab.onos.net.intent.IntentState.*;
import static org.onlab.onos.net.intent.IntentState.WITHDRAWN;
import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = true)
......@@ -45,8 +45,8 @@ public class SimpleIntentStore
private final Logger log = getLogger(getClass());
private final Map<IntentId, Intent> intents = new ConcurrentHashMap<>();
private final Map<IntentId, IntentState> states = new ConcurrentHashMap<>();
private final Map<IntentId, List<Intent>> installable =
new ConcurrentHashMap<>();
private final Map<IntentId, List<Intent>> installable = new ConcurrentHashMap<>();
@Activate
public void activate() {
......@@ -60,6 +60,9 @@ public class SimpleIntentStore
@Override
public IntentEvent createIntent(Intent intent) {
if (intents.containsKey(intent.id())) {
return null;
}
intents.put(intent.id(), intent);
return this.setState(intent, IntentState.SUBMITTED);
}
......