mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-22 21:01:00 +02:00
ONOS-1057 - Remove references to deprecated applyBatch() method
Change-Id: I9215fde6be2acaa2becea58d8b6e5b171ff16817
This commit is contained in:
parent
90a02c2539
commit
da36c40e9d
@ -18,8 +18,6 @@ package org.onosproject.net.flow;
|
|||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.net.DeviceId;
|
import org.onosproject.net.DeviceId;
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for injecting flow rules into the environment and for obtaining
|
* Service for injecting flow rules into the environment and for obtaining
|
||||||
* information about flow rules already in the environment. This implements
|
* information about flow rules already in the environment. This implements
|
||||||
@ -97,16 +95,6 @@ public interface FlowRuleService {
|
|||||||
*/
|
*/
|
||||||
Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId);
|
Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a batch operation of FlowRules.
|
|
||||||
*
|
|
||||||
* @param batch batch operation to apply
|
|
||||||
* @return future indicating the state of the batch operation, due to the
|
|
||||||
* deprecation of this api the future will immediately return
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a batch operation of FlowRules.
|
* Applies a batch operation of FlowRules.
|
||||||
*
|
*
|
||||||
|
@ -19,8 +19,6 @@ package org.onosproject.net.flow;
|
|||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.net.DeviceId;
|
import org.onosproject.net.DeviceId;
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test adapter for flow rule service.
|
* Test adapter for flow rule service.
|
||||||
*/
|
*/
|
||||||
@ -60,11 +58,6 @@ public class FlowRuleServiceAdapter implements FlowRuleService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(FlowRuleOperations ops) {
|
public void apply(FlowRuleOperations ops) {
|
||||||
|
|
||||||
|
@ -15,13 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.flow.impl;
|
package org.onosproject.net.flow.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import java.util.Collections;
|
||||||
import com.google.common.collect.Iterables;
|
import java.util.List;
|
||||||
import com.google.common.collect.Lists;
|
import java.util.Map;
|
||||||
import com.google.common.collect.Maps;
|
import java.util.Set;
|
||||||
import com.google.common.collect.Multimap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import com.google.common.collect.Sets;
|
import java.util.concurrent.ExecutorService;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.apache.felix.scr.annotations.Activate;
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
import org.apache.felix.scr.annotations.Component;
|
import org.apache.felix.scr.annotations.Component;
|
||||||
import org.apache.felix.scr.annotations.Deactivate;
|
import org.apache.felix.scr.annotations.Deactivate;
|
||||||
@ -58,15 +60,12 @@ import org.onosproject.net.provider.AbstractProviderRegistry;
|
|||||||
import org.onosproject.net.provider.AbstractProviderService;
|
import org.onosproject.net.provider.AbstractProviderService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.Collections;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import java.util.List;
|
import com.google.common.collect.Iterables;
|
||||||
import java.util.Map;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.Set;
|
import com.google.common.collect.Maps;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import com.google.common.collect.Multimap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.onlab.util.Tools.namedThreads;
|
import static org.onlab.util.Tools.namedThreads;
|
||||||
@ -194,36 +193,6 @@ public class FlowRuleManager
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch) {
|
|
||||||
|
|
||||||
|
|
||||||
FlowRuleOperations.Builder fopsBuilder = FlowRuleOperations.builder();
|
|
||||||
batch.getOperations().stream().forEach(op -> {
|
|
||||||
switch (op.operator()) {
|
|
||||||
case ADD:
|
|
||||||
fopsBuilder.add(op.target());
|
|
||||||
break;
|
|
||||||
case REMOVE:
|
|
||||||
fopsBuilder.remove(op.target());
|
|
||||||
break;
|
|
||||||
case MODIFY:
|
|
||||||
fopsBuilder.modify(op.target());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log.warn("Unknown flow operation operator: {}", op.operator());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
apply(fopsBuilder.build());
|
|
||||||
return Futures.immediateFuture(
|
|
||||||
new CompletedBatchOperation(true,
|
|
||||||
Collections.emptySet(), null));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(FlowRuleOperations ops) {
|
public void apply(FlowRuleOperations ops) {
|
||||||
operationsService.submit(new FlowOperationsProcessor(ops));
|
operationsService.submit(new FlowOperationsProcessor(ops));
|
||||||
|
@ -15,12 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.flow.impl;
|
package org.onosproject.net.flow.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import java.util.ArrayList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import java.util.Arrays;
|
||||||
import com.google.common.collect.Lists;
|
import java.util.Collections;
|
||||||
import com.google.common.collect.Sets;
|
import java.util.HashMap;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import java.util.List;
|
||||||
import com.google.common.util.concurrent.MoreExecutors;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -45,7 +52,6 @@ import org.onosproject.net.flow.DefaultFlowRule;
|
|||||||
import org.onosproject.net.flow.FlowEntry;
|
import org.onosproject.net.flow.FlowEntry;
|
||||||
import org.onosproject.net.flow.FlowEntry.FlowEntryState;
|
import org.onosproject.net.flow.FlowEntry.FlowEntryState;
|
||||||
import org.onosproject.net.flow.FlowRule;
|
import org.onosproject.net.flow.FlowRule;
|
||||||
import org.onosproject.net.flow.FlowRuleBatchEntry;
|
|
||||||
import org.onosproject.net.flow.FlowRuleBatchOperation;
|
import org.onosproject.net.flow.FlowRuleBatchOperation;
|
||||||
import org.onosproject.net.flow.FlowRuleEvent;
|
import org.onosproject.net.flow.FlowRuleEvent;
|
||||||
import org.onosproject.net.flow.FlowRuleListener;
|
import org.onosproject.net.flow.FlowRuleListener;
|
||||||
@ -62,22 +68,22 @@ import org.onosproject.net.provider.AbstractProvider;
|
|||||||
import org.onosproject.net.provider.ProviderId;
|
import org.onosproject.net.provider.ProviderId;
|
||||||
import org.onosproject.store.trivial.impl.SimpleFlowRuleStore;
|
import org.onosproject.store.trivial.impl.SimpleFlowRuleStore;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.Arrays;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import java.util.Collections;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.HashMap;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.List;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import java.util.Map;
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.onosproject.net.flow.FlowRuleEvent.Type.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_ADDED;
|
||||||
|
import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_ADD_REQUESTED;
|
||||||
|
import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_REMOVED;
|
||||||
|
import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_REMOVE_REQUESTED;
|
||||||
|
import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_UPDATED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test codifying the flow rule service & flow rule provider service contracts.
|
* Test codifying the flow rule service & flow rule provider service contracts.
|
||||||
@ -387,42 +393,6 @@ public class FlowRuleManagerTest {
|
|||||||
f2, FlowEntryState.PENDING_REMOVE));
|
f2, FlowEntryState.PENDING_REMOVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void applyBatch() {
|
|
||||||
FlowRule f1 = flowRule(1, 1);
|
|
||||||
FlowRule f2 = flowRule(2, 2);
|
|
||||||
|
|
||||||
|
|
||||||
mgr.applyFlowRules(f1);
|
|
||||||
|
|
||||||
FlowEntry fe1 = new DefaultFlowEntry(f1);
|
|
||||||
providerService.pushFlowMetrics(DID, Collections.<FlowEntry>singletonList(fe1));
|
|
||||||
|
|
||||||
FlowRuleBatchEntry fbe1 = new FlowRuleBatchEntry(
|
|
||||||
FlowRuleBatchEntry.FlowRuleOperation.REMOVE, f1);
|
|
||||||
|
|
||||||
FlowRuleBatchEntry fbe2 = new FlowRuleBatchEntry(
|
|
||||||
FlowRuleBatchEntry.FlowRuleOperation.ADD, f2);
|
|
||||||
|
|
||||||
FlowRuleBatchOperation fbo = new FlowRuleBatchOperation(
|
|
||||||
Lists.newArrayList(fbe1, fbe2), null, 0);
|
|
||||||
Future<CompletedBatchOperation> future = mgr.applyBatch(fbo);
|
|
||||||
assertTrue("Entries in wrong state",
|
|
||||||
validateState(ImmutableMap.of(
|
|
||||||
f1, FlowEntryState.PENDING_REMOVE,
|
|
||||||
f2, FlowEntryState.PENDING_ADD)));
|
|
||||||
CompletedBatchOperation completed = null;
|
|
||||||
try {
|
|
||||||
completed = future.get();
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
fail("Unexpected exception: " + e);
|
|
||||||
}
|
|
||||||
if (!completed.isSuccess()) {
|
|
||||||
fail("Installation should be a success");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TestListener implements FlowRuleListener {
|
private static class TestListener implements FlowRuleListener {
|
||||||
final List<FlowRuleEvent> events = new ArrayList<>();
|
final List<FlowRuleEvent> events = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -15,21 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.intent.impl;
|
package org.onosproject.net.intent.impl;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.net.DeviceId;
|
import org.onosproject.net.DeviceId;
|
||||||
import org.onosproject.net.flow.CompletedBatchOperation;
|
|
||||||
import org.onosproject.net.flow.DefaultFlowEntry;
|
import org.onosproject.net.flow.DefaultFlowEntry;
|
||||||
import org.onosproject.net.flow.FlowEntry;
|
import org.onosproject.net.flow.FlowEntry;
|
||||||
import org.onosproject.net.flow.FlowRule;
|
import org.onosproject.net.flow.FlowRule;
|
||||||
import org.onosproject.net.flow.FlowRuleBatchOperation;
|
|
||||||
import org.onosproject.net.flow.FlowRuleListener;
|
import org.onosproject.net.flow.FlowRuleListener;
|
||||||
import org.onosproject.net.flow.FlowRuleOperations;
|
import org.onosproject.net.flow.FlowRuleOperations;
|
||||||
import org.onosproject.net.flow.FlowRuleService;
|
import org.onosproject.net.flow.FlowRuleService;
|
||||||
|
|
||||||
import java.util.Set;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
public class MockFlowRuleService implements FlowRuleService {
|
public class MockFlowRuleService implements FlowRuleService {
|
||||||
@ -41,11 +39,6 @@ public class MockFlowRuleService implements FlowRuleService {
|
|||||||
this.success = success;
|
this.success = success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch) {
|
|
||||||
throw new UnsupportedOperationException("deprecated");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(FlowRuleOperations ops) {
|
public void apply(FlowRuleOperations ops) {
|
||||||
ops.stages().forEach(stage -> stage.forEach(flow -> {
|
ops.stages().forEach(stage -> stage.forEach(flow -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user