Thomas Vachuska

Adding configurability for registration of flow-based intent compilers.

Added configurability of the intent manager number of workers.

Change-Id: Id5e221e077ef3246a7f274bad2e40166313899f5
...@@ -85,19 +85,23 @@ public class IntentManager ...@@ -85,19 +85,23 @@ public class IntentManager
85 public static final String INTENT_NULL = "Intent cannot be null"; 85 public static final String INTENT_NULL = "Intent cannot be null";
86 public static final String INTENT_ID_NULL = "Intent key cannot be null"; 86 public static final String INTENT_ID_NULL = "Intent key cannot be null";
87 87
88 - private static final int NUM_THREADS = 12;
89 -
90 private static final EnumSet<IntentState> RECOMPILE 88 private static final EnumSet<IntentState> RECOMPILE
91 = EnumSet.of(INSTALL_REQ, FAILED, WITHDRAW_REQ); 89 = EnumSet.of(INSTALL_REQ, FAILED, WITHDRAW_REQ);
92 private static final EnumSet<IntentState> WITHDRAW 90 private static final EnumSet<IntentState> WITHDRAW
93 = EnumSet.of(WITHDRAW_REQ, WITHDRAWING, WITHDRAWN); 91 = EnumSet.of(WITHDRAW_REQ, WITHDRAWING, WITHDRAWN);
94 - private static final boolean DEFAULT_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL = false;
95 92
93 + private static final boolean DEFAULT_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL = false;
96 @Property(name = "skipReleaseResourcesOnWithdrawal", 94 @Property(name = "skipReleaseResourcesOnWithdrawal",
97 boolValue = DEFAULT_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL, 95 boolValue = DEFAULT_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL,
98 label = "Indicates whether skipping resource releases on withdrawal is enabled or not") 96 label = "Indicates whether skipping resource releases on withdrawal is enabled or not")
99 private boolean skipReleaseResourcesOnWithdrawal = DEFAULT_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL; 97 private boolean skipReleaseResourcesOnWithdrawal = DEFAULT_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL;
100 98
99 + private static final int DEFAULT_NUM_THREADS = 12;
100 + @Property(name = "numThreads",
101 + intValue = DEFAULT_NUM_THREADS,
102 + label = "Number of worker threads")
103 + private int numThreads = DEFAULT_NUM_THREADS;
104 +
101 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 105 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
102 protected CoreService coreService; 106 protected CoreService coreService;
103 107
...@@ -119,7 +123,6 @@ public class IntentManager ...@@ -119,7 +123,6 @@ public class IntentManager
119 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 123 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
120 protected ComponentConfigService configService; 124 protected ComponentConfigService configService;
121 125
122 -
123 private ExecutorService batchExecutor; 126 private ExecutorService batchExecutor;
124 private ExecutorService workerExecutor; 127 private ExecutorService workerExecutor;
125 128
...@@ -147,7 +150,7 @@ public class IntentManager ...@@ -147,7 +150,7 @@ public class IntentManager
147 trackerService.setDelegate(topoDelegate); 150 trackerService.setDelegate(topoDelegate);
148 eventDispatcher.addSink(IntentEvent.class, listenerRegistry); 151 eventDispatcher.addSink(IntentEvent.class, listenerRegistry);
149 batchExecutor = newSingleThreadExecutor(groupedThreads("onos/intent", "batch")); 152 batchExecutor = newSingleThreadExecutor(groupedThreads("onos/intent", "batch"));
150 - workerExecutor = newFixedThreadPool(NUM_THREADS, groupedThreads("onos/intent", "worker-%d")); 153 + workerExecutor = newFixedThreadPool(numThreads, groupedThreads("onos/intent", "worker-%d"));
151 idGenerator = coreService.getIdGenerator("intent-ids"); 154 idGenerator = coreService.getIdGenerator("intent-ids");
152 Intent.bindIdGenerator(idGenerator); 155 Intent.bindIdGenerator(idGenerator);
153 log.info("Started"); 156 log.info("Started");
...@@ -183,11 +186,25 @@ public class IntentManager ...@@ -183,11 +186,25 @@ public class IntentManager
183 if (skipReleaseResourcesOnWithdrawal && !newTestEnabled) { 186 if (skipReleaseResourcesOnWithdrawal && !newTestEnabled) {
184 store.unsetDelegate(testOnlyDelegate); 187 store.unsetDelegate(testOnlyDelegate);
185 store.setDelegate(delegate); 188 store.setDelegate(delegate);
186 - logConfig("Reconfigured"); 189 + skipReleaseResourcesOnWithdrawal = false;
190 + logConfig("Reconfigured skip release resources on withdrawal");
187 } else if (!skipReleaseResourcesOnWithdrawal && newTestEnabled) { 191 } else if (!skipReleaseResourcesOnWithdrawal && newTestEnabled) {
188 store.unsetDelegate(delegate); 192 store.unsetDelegate(delegate);
189 store.setDelegate(testOnlyDelegate); 193 store.setDelegate(testOnlyDelegate);
190 - logConfig("Reconfigured"); 194 + skipReleaseResourcesOnWithdrawal = true;
195 + logConfig("Reconfigured skip release resources on withdrawal");
196 + }
197 +
198 + s = Tools.get(context.getProperties(), "numThreads");
199 + int newNumThreads = isNullOrEmpty(s) ? numThreads : Integer.parseInt(s);
200 + if (newNumThreads != numThreads) {
201 + numThreads = newNumThreads;
202 + ExecutorService oldWorkerExecutor = workerExecutor;
203 + workerExecutor = newFixedThreadPool(numThreads, groupedThreads("onos/intent", "worker-%d"));
204 + if (oldWorkerExecutor != null) {
205 + oldWorkerExecutor.shutdown();
206 + }
207 + logConfig("Reconfigured number of worker threads");
191 } 208 }
192 } 209 }
193 210
...@@ -281,7 +298,6 @@ public class IntentManager ...@@ -281,7 +298,6 @@ public class IntentManager
281 @Override 298 @Override
282 public Iterable<Intent> getPending() { 299 public Iterable<Intent> getPending() {
283 checkPermission(INTENT_READ); 300 checkPermission(INTENT_READ);
284 -
285 return store.getPending(); 301 return store.getPending();
286 } 302 }
287 303
......
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.net.intent.impl.compiler;
18 +
19 +import com.google.common.collect.Maps;
20 +import org.apache.felix.scr.annotations.Activate;
21 +import org.apache.felix.scr.annotations.Component;
22 +import org.apache.felix.scr.annotations.Deactivate;
23 +import org.apache.felix.scr.annotations.Modified;
24 +import org.apache.felix.scr.annotations.Property;
25 +import org.apache.felix.scr.annotations.Reference;
26 +import org.apache.felix.scr.annotations.ReferenceCardinality;
27 +import org.apache.felix.scr.annotations.Service;
28 +import org.onlab.util.Tools;
29 +import org.onosproject.cfg.ComponentConfigService;
30 +import org.onosproject.net.intent.Intent;
31 +import org.onosproject.net.intent.IntentCompiler;
32 +import org.onosproject.net.intent.IntentExtensionService;
33 +import org.osgi.service.component.ComponentContext;
34 +import org.slf4j.Logger;
35 +
36 +import java.util.Map;
37 +
38 +import static com.google.common.base.Strings.isNullOrEmpty;
39 +import static org.slf4j.LoggerFactory.getLogger;
40 +
41 +/**
42 + * Auxiliary utility to register either flow-rule compilers or flow-objective
43 + * compilers.
44 + */
45 +@Component
46 +@Service(value = IntentConfigurableRegistrator.class)
47 +public class IntentConfigurableRegistrator {
48 +
49 + private final Logger log = getLogger(getClass());
50 +
51 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
52 + protected IntentExtensionService extensionService;
53 +
54 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
55 + protected ComponentConfigService cfgService;
56 +
57 + private static final boolean DEFAULT_FLOW_OBJECTIVES = false;
58 + @Property(name = "useFlowObjectives",
59 + boolValue = DEFAULT_FLOW_OBJECTIVES,
60 + label = "Indicates whether to use flow objective-based compilers")
61 + private boolean useFlowObjectives = DEFAULT_FLOW_OBJECTIVES;
62 +
63 + private final Map<Class<Intent>, IntentCompiler<Intent>> flowRuleBased = Maps.newConcurrentMap();
64 + private final Map<Class<Intent>, IntentCompiler<Intent>> flowObjectiveBased = Maps.newConcurrentMap();
65 +
66 + @Activate
67 + public void activate() {
68 + cfgService.registerProperties(getClass());
69 + log.info("Started");
70 + }
71 +
72 + @Deactivate
73 + public void deactivate() {
74 + cfgService.unregisterProperties(getClass(), false);
75 + log.info("Stopped");
76 + }
77 +
78 + @Modified
79 + public void modified(ComponentContext context) {
80 + if (context == null) {
81 + log.info("Default config");
82 + return;
83 + }
84 +
85 + boolean newFlowObjectives;
86 + try {
87 + String s = Tools.get(context.getProperties(), "useFlowObjectives");
88 + newFlowObjectives = isNullOrEmpty(s) ? useFlowObjectives : Boolean.parseBoolean(s.trim());
89 + } catch (ClassCastException e) {
90 + newFlowObjectives = useFlowObjectives;
91 + }
92 +
93 + if (useFlowObjectives != newFlowObjectives) {
94 + useFlowObjectives = newFlowObjectives;
95 + changeCompilers();
96 + log.info("Reconfigured use of flow objectives");
97 + }
98 + }
99 +
100 + /**
101 + * Registers the specified compiler for the given intent class.
102 + *
103 + * @param cls intent class
104 + * @param compiler intent compiler
105 + * @param flowBased true if the compiler is flow based
106 + * @param <T> the type of intent
107 + */
108 + @SuppressWarnings("unchecked")
109 + <T extends Intent> void registerCompiler(Class<T> cls, IntentCompiler<T> compiler,
110 + boolean flowBased) {
111 + if (flowBased) {
112 + flowObjectiveBased.put((Class<Intent>) cls, (IntentCompiler<Intent>) compiler);
113 + } else {
114 + flowRuleBased.put((Class<Intent>) cls, (IntentCompiler<Intent>) compiler);
115 + }
116 + if (flowBased == useFlowObjectives) {
117 + extensionService.registerCompiler(cls, compiler);
118 + }
119 + }
120 +
121 + /**
122 + * Unregisters the compiler for the specified intent class.
123 + *
124 + * @param cls intent class
125 + * @param flowBased true if the compiler is flow based
126 + * @param <T> the type of intent
127 + */
128 + @SuppressWarnings("unchecked")
129 + <T extends Intent> void unregisterCompiler(Class<T> cls, boolean flowBased) {
130 + if (flowBased) {
131 + flowObjectiveBased.remove(cls);
132 + } else {
133 + flowRuleBased.remove(cls);
134 + }
135 + if (flowBased == useFlowObjectives) {
136 + extensionService.unregisterCompiler(cls);
137 + }
138 + }
139 +
140 + private void changeCompilers() {
141 + if (useFlowObjectives) {
142 + flowRuleBased.forEach((cls, compiler) -> extensionService.unregisterCompiler(cls));
143 + flowObjectiveBased.forEach((cls, compiler) -> extensionService.registerCompiler(cls, compiler));
144 + } else {
145 + flowObjectiveBased.forEach((cls, compiler) -> extensionService.unregisterCompiler(cls));
146 + flowRuleBased.forEach((cls, compiler) -> extensionService.registerCompiler(cls, compiler));
147 + }
148 + }
149 +
150 +}
...@@ -37,7 +37,6 @@ import org.onosproject.net.flow.TrafficTreatment; ...@@ -37,7 +37,6 @@ import org.onosproject.net.flow.TrafficTreatment;
37 import org.onosproject.net.intent.FlowRuleIntent; 37 import org.onosproject.net.intent.FlowRuleIntent;
38 import org.onosproject.net.intent.Intent; 38 import org.onosproject.net.intent.Intent;
39 import org.onosproject.net.intent.IntentCompiler; 39 import org.onosproject.net.intent.IntentCompiler;
40 -import org.onosproject.net.intent.IntentExtensionService;
41 import org.onosproject.net.intent.LinkCollectionIntent; 40 import org.onosproject.net.intent.LinkCollectionIntent;
42 import org.onosproject.net.resource.link.LinkResourceAllocations; 41 import org.onosproject.net.resource.link.LinkResourceAllocations;
43 42
...@@ -51,7 +50,7 @@ import java.util.stream.Collectors; ...@@ -51,7 +50,7 @@ import java.util.stream.Collectors;
51 public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollectionIntent> { 50 public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollectionIntent> {
52 51
53 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 52 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
54 - protected IntentExtensionService intentManager; 53 + protected IntentConfigurableRegistrator registrator;
55 54
56 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 55 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
57 protected CoreService coreService; 56 protected CoreService coreService;
...@@ -61,12 +60,12 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti ...@@ -61,12 +60,12 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti
61 @Activate 60 @Activate
62 public void activate() { 61 public void activate() {
63 appId = coreService.registerApplication("org.onosproject.net.intent"); 62 appId = coreService.registerApplication("org.onosproject.net.intent");
64 - intentManager.registerCompiler(LinkCollectionIntent.class, this); 63 + registrator.registerCompiler(LinkCollectionIntent.class, this, false);
65 } 64 }
66 65
67 @Deactivate 66 @Deactivate
68 public void deactivate() { 67 public void deactivate() {
69 - intentManager.unregisterCompiler(LinkCollectionIntent.class); 68 + registrator.unregisterCompiler(LinkCollectionIntent.class, false);
70 } 69 }
71 70
72 @Override 71 @Override
......
...@@ -15,12 +15,8 @@ ...@@ -15,12 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.intent.impl.compiler; 16 package org.onosproject.net.intent.impl.compiler;
17 17
18 -import java.util.ArrayList; 18 +import com.google.common.collect.HashMultimap;
19 -import java.util.Collections; 19 +import com.google.common.collect.SetMultimap;
20 -import java.util.List;
21 -import java.util.Set;
22 -import java.util.stream.Collectors;
23 -
24 import org.apache.felix.scr.annotations.Activate; 20 import org.apache.felix.scr.annotations.Activate;
25 import org.apache.felix.scr.annotations.Component; 21 import org.apache.felix.scr.annotations.Component;
26 import org.apache.felix.scr.annotations.Deactivate; 22 import org.apache.felix.scr.annotations.Deactivate;
...@@ -42,12 +38,14 @@ import org.onosproject.net.flowobjective.Objective; ...@@ -42,12 +38,14 @@ import org.onosproject.net.flowobjective.Objective;
42 import org.onosproject.net.intent.FlowObjectiveIntent; 38 import org.onosproject.net.intent.FlowObjectiveIntent;
43 import org.onosproject.net.intent.Intent; 39 import org.onosproject.net.intent.Intent;
44 import org.onosproject.net.intent.IntentCompiler; 40 import org.onosproject.net.intent.IntentCompiler;
45 -import org.onosproject.net.intent.IntentExtensionService;
46 import org.onosproject.net.intent.LinkCollectionIntent; 41 import org.onosproject.net.intent.LinkCollectionIntent;
47 import org.onosproject.net.resource.link.LinkResourceAllocations; 42 import org.onosproject.net.resource.link.LinkResourceAllocations;
48 43
49 -import com.google.common.collect.HashMultimap; 44 +import java.util.ArrayList;
50 -import com.google.common.collect.SetMultimap; 45 +import java.util.Collections;
46 +import java.util.List;
47 +import java.util.Set;
48 +import java.util.stream.Collectors;
51 49
52 /** 50 /**
53 * Compiler to produce flow objectives from link collections. 51 * Compiler to produce flow objectives from link collections.
...@@ -56,7 +54,7 @@ import com.google.common.collect.SetMultimap; ...@@ -56,7 +54,7 @@ import com.google.common.collect.SetMultimap;
56 public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompiler<LinkCollectionIntent> { 54 public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompiler<LinkCollectionIntent> {
57 55
58 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 56 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
59 - protected IntentExtensionService intentManager; 57 + protected IntentConfigurableRegistrator registrator;
60 58
61 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 59 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
62 protected CoreService coreService; 60 protected CoreService coreService;
...@@ -66,12 +64,12 @@ public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompile ...@@ -66,12 +64,12 @@ public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompile
66 @Activate 64 @Activate
67 public void activate() { 65 public void activate() {
68 appId = coreService.registerApplication("org.onosproject.net.intent"); 66 appId = coreService.registerApplication("org.onosproject.net.intent");
69 - //intentManager.registerCompiler(LinkCollectionIntent.class, this); 67 + registrator.registerCompiler(LinkCollectionIntent.class, this, true);
70 } 68 }
71 69
72 @Deactivate 70 @Deactivate
73 public void deactivate() { 71 public void deactivate() {
74 - //intentManager.unregisterCompiler(LinkCollectionIntent.class); 72 + registrator.unregisterCompiler(LinkCollectionIntent.class, true);
75 } 73 }
76 74
77 @Override 75 @Override
......
...@@ -37,7 +37,6 @@ import org.onosproject.net.flow.TrafficTreatment; ...@@ -37,7 +37,6 @@ import org.onosproject.net.flow.TrafficTreatment;
37 import org.onosproject.net.intent.FlowRuleIntent; 37 import org.onosproject.net.intent.FlowRuleIntent;
38 import org.onosproject.net.intent.Intent; 38 import org.onosproject.net.intent.Intent;
39 import org.onosproject.net.intent.IntentCompiler; 39 import org.onosproject.net.intent.IntentCompiler;
40 -import org.onosproject.net.intent.IntentExtensionService;
41 import org.onosproject.net.intent.PathIntent; 40 import org.onosproject.net.intent.PathIntent;
42 import org.onosproject.net.newresource.ResourceService; 41 import org.onosproject.net.newresource.ResourceService;
43 import org.onosproject.net.resource.link.LinkResourceAllocations; 42 import org.onosproject.net.resource.link.LinkResourceAllocations;
...@@ -59,7 +58,7 @@ public class PathIntentCompiler ...@@ -59,7 +58,7 @@ public class PathIntentCompiler
59 protected CoreService coreService; 58 protected CoreService coreService;
60 59
61 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 60 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
62 - protected IntentExtensionService intentManager; 61 + protected IntentConfigurableRegistrator registrator;
63 62
64 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 63 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
65 protected ResourceService resourceService; 64 protected ResourceService resourceService;
...@@ -69,12 +68,12 @@ public class PathIntentCompiler ...@@ -69,12 +68,12 @@ public class PathIntentCompiler
69 @Activate 68 @Activate
70 public void activate() { 69 public void activate() {
71 appId = coreService.registerApplication("org.onosproject.net.intent"); 70 appId = coreService.registerApplication("org.onosproject.net.intent");
72 - intentManager.registerCompiler(PathIntent.class, this); 71 + registrator.registerCompiler(PathIntent.class, this, false);
73 } 72 }
74 73
75 @Deactivate 74 @Deactivate
76 public void deactivate() { 75 public void deactivate() {
77 - intentManager.unregisterCompiler(PathIntent.class); 76 + registrator.unregisterCompiler(PathIntent.class, false);
78 } 77 }
79 78
80 @Override 79 @Override
......
...@@ -38,7 +38,6 @@ import org.onosproject.net.flowobjective.Objective; ...@@ -38,7 +38,6 @@ import org.onosproject.net.flowobjective.Objective;
38 import org.onosproject.net.intent.FlowObjectiveIntent; 38 import org.onosproject.net.intent.FlowObjectiveIntent;
39 import org.onosproject.net.intent.Intent; 39 import org.onosproject.net.intent.Intent;
40 import org.onosproject.net.intent.IntentCompiler; 40 import org.onosproject.net.intent.IntentCompiler;
41 -import org.onosproject.net.intent.IntentExtensionService;
42 import org.onosproject.net.intent.PathIntent; 41 import org.onosproject.net.intent.PathIntent;
43 import org.onosproject.net.newresource.ResourceService; 42 import org.onosproject.net.newresource.ResourceService;
44 import org.onosproject.net.resource.link.LinkResourceAllocations; 43 import org.onosproject.net.resource.link.LinkResourceAllocations;
...@@ -60,7 +59,7 @@ public class PathIntentFlowObjectiveCompiler ...@@ -60,7 +59,7 @@ public class PathIntentFlowObjectiveCompiler
60 protected CoreService coreService; 59 protected CoreService coreService;
61 60
62 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 61 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
63 - protected IntentExtensionService intentManager; 62 + protected IntentConfigurableRegistrator registrator;
64 63
65 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 64 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
66 protected ResourceService resourceService; 65 protected ResourceService resourceService;
...@@ -70,12 +69,12 @@ public class PathIntentFlowObjectiveCompiler ...@@ -70,12 +69,12 @@ public class PathIntentFlowObjectiveCompiler
70 @Activate 69 @Activate
71 public void activate() { 70 public void activate() {
72 appId = coreService.registerApplication("org.onosproject.net.intent"); 71 appId = coreService.registerApplication("org.onosproject.net.intent");
73 - //intentManager.registerCompiler(PathIntent.class, this); 72 + registrator.registerCompiler(PathIntent.class, this, true);
74 } 73 }
75 74
76 @Deactivate 75 @Deactivate
77 public void deactivate() { 76 public void deactivate() {
78 - //intentManager.unregisterCompiler(PathIntent.class); 77 + registrator.unregisterCompiler(PathIntent.class, true);
79 } 78 }
80 79
81 @Override 80 @Override
......
...@@ -20,6 +20,7 @@ import org.junit.After; ...@@ -20,6 +20,7 @@ import org.junit.After;
20 import org.junit.Before; 20 import org.junit.Before;
21 import org.junit.Test; 21 import org.junit.Test;
22 import org.onosproject.TestApplicationId; 22 import org.onosproject.TestApplicationId;
23 +import org.onosproject.cfg.ComponentConfigAdapter;
23 import org.onosproject.core.ApplicationId; 24 import org.onosproject.core.ApplicationId;
24 import org.onosproject.core.CoreService; 25 import org.onosproject.core.CoreService;
25 import org.onosproject.core.IdGenerator; 26 import org.onosproject.core.IdGenerator;
...@@ -74,6 +75,7 @@ public class LinkCollectionIntentCompilerTest { ...@@ -74,6 +75,7 @@ public class LinkCollectionIntentCompilerTest {
74 75
75 private CoreService coreService; 76 private CoreService coreService;
76 private IntentExtensionService intentExtensionService; 77 private IntentExtensionService intentExtensionService;
78 + private IntentConfigurableRegistrator registrator;
77 private IdGenerator idGenerator = new MockIdGenerator(); 79 private IdGenerator idGenerator = new MockIdGenerator();
78 80
79 private LinkCollectionIntent intent; 81 private LinkCollectionIntent intent;
...@@ -101,7 +103,13 @@ public class LinkCollectionIntentCompilerTest { ...@@ -101,7 +103,13 @@ public class LinkCollectionIntentCompilerTest {
101 intentExtensionService = createMock(IntentExtensionService.class); 103 intentExtensionService = createMock(IntentExtensionService.class);
102 intentExtensionService.registerCompiler(LinkCollectionIntent.class, sut); 104 intentExtensionService.registerCompiler(LinkCollectionIntent.class, sut);
103 intentExtensionService.unregisterCompiler(LinkCollectionIntent.class); 105 intentExtensionService.unregisterCompiler(LinkCollectionIntent.class);
104 - sut.intentManager = intentExtensionService; 106 +
107 + registrator = new IntentConfigurableRegistrator();
108 + registrator.extensionService = intentExtensionService;
109 + registrator.cfgService = new ComponentConfigAdapter();
110 + registrator.activate();
111 +
112 + sut.registrator = registrator;
105 113
106 replay(coreService, intentExtensionService); 114 replay(coreService, intentExtensionService);
107 } 115 }
......
...@@ -21,6 +21,7 @@ import org.junit.Before; ...@@ -21,6 +21,7 @@ import org.junit.Before;
21 import org.junit.Test; 21 import org.junit.Test;
22 import org.onlab.packet.VlanId; 22 import org.onlab.packet.VlanId;
23 import org.onosproject.TestApplicationId; 23 import org.onosproject.TestApplicationId;
24 +import org.onosproject.cfg.ComponentConfigAdapter;
24 import org.onosproject.core.ApplicationId; 25 import org.onosproject.core.ApplicationId;
25 import org.onosproject.core.CoreService; 26 import org.onosproject.core.CoreService;
26 import org.onosproject.core.IdGenerator; 27 import org.onosproject.core.IdGenerator;
...@@ -67,6 +68,7 @@ public class PathIntentCompilerTest { ...@@ -67,6 +68,7 @@ public class PathIntentCompilerTest {
67 68
68 private CoreService coreService; 69 private CoreService coreService;
69 private IntentExtensionService intentExtensionService; 70 private IntentExtensionService intentExtensionService;
71 + private IntentConfigurableRegistrator registrator;
70 private IdGenerator idGenerator = new MockIdGenerator(); 72 private IdGenerator idGenerator = new MockIdGenerator();
71 private PathIntentCompiler sut; 73 private PathIntentCompiler sut;
72 74
...@@ -142,7 +144,13 @@ public class PathIntentCompilerTest { ...@@ -142,7 +144,13 @@ public class PathIntentCompilerTest {
142 intentExtensionService = createMock(IntentExtensionService.class); 144 intentExtensionService = createMock(IntentExtensionService.class);
143 intentExtensionService.registerCompiler(PathIntent.class, sut); 145 intentExtensionService.registerCompiler(PathIntent.class, sut);
144 intentExtensionService.unregisterCompiler(PathIntent.class); 146 intentExtensionService.unregisterCompiler(PathIntent.class);
145 - sut.intentManager = intentExtensionService; 147 +
148 + registrator = new IntentConfigurableRegistrator();
149 + registrator.extensionService = intentExtensionService;
150 + registrator.cfgService = new ComponentConfigAdapter();
151 + registrator.activate();
152 +
153 + sut.registrator = registrator;
146 154
147 replay(coreService, intentExtensionService); 155 replay(coreService, intentExtensionService);
148 } 156 }
......