Changed some non concurrent structures to ConcurrentHashMaps in
SimpleIntentStore and OpenFlowRuleProvider. Also improved logging in IntentManager so exception stack traces are logged. Change-Id: I72f5e20893bda633dc36ea271a0f56c0ddb7fb5a
Showing
3 changed files
with
40 additions
and
33 deletions
... | @@ -251,7 +251,7 @@ public class IntentManager | ... | @@ -251,7 +251,7 @@ public class IntentManager |
251 | executeInstallingPhase(intent); | 251 | executeInstallingPhase(intent); |
252 | 252 | ||
253 | } catch (Exception e) { | 253 | } catch (Exception e) { |
254 | - log.warn("Unable to compile intent {} due to: {}", intent.id(), e); | 254 | + log.warn("Unable to compile intent {} due to:", intent.id(), e); |
255 | 255 | ||
256 | // If compilation failed, mark the intent as failed. | 256 | // If compilation failed, mark the intent as failed. |
257 | store.setState(intent, FAILED); | 257 | store.setState(intent, FAILED); |
... | @@ -304,7 +304,7 @@ public class IntentManager | ... | @@ -304,7 +304,7 @@ public class IntentManager |
304 | //eventDispatcher.post(store.setState(intent, INSTALLED)); | 304 | //eventDispatcher.post(store.setState(intent, INSTALLED)); |
305 | monitorExecutor.execute(new IntentInstallMonitor(intent, installWork, INSTALLED)); | 305 | monitorExecutor.execute(new IntentInstallMonitor(intent, installWork, INSTALLED)); |
306 | } catch (Exception e) { | 306 | } catch (Exception e) { |
307 | - log.warn("Unable to install intent {} due to: {}", intent.id(), e); | 307 | + log.warn("Unable to install intent {} due to:", intent.id(), e); |
308 | uninstallIntent(intent, RECOMPILING); | 308 | uninstallIntent(intent, RECOMPILING); |
309 | 309 | ||
310 | // If compilation failed, kick off the recompiling phase. | 310 | // If compilation failed, kick off the recompiling phase. |
... | @@ -342,7 +342,7 @@ public class IntentManager | ... | @@ -342,7 +342,7 @@ public class IntentManager |
342 | executeInstallingPhase(intent); | 342 | executeInstallingPhase(intent); |
343 | } | 343 | } |
344 | } catch (Exception e) { | 344 | } catch (Exception e) { |
345 | - log.warn("Unable to recompile intent {} due to: {}", intent.id(), e); | 345 | + log.warn("Unable to recompile intent {} due to:", intent.id(), e); |
346 | 346 | ||
347 | // If compilation failed, mark the intent as failed. | 347 | // If compilation failed, mark the intent as failed. |
348 | eventDispatcher.post(store.setState(intent, FAILED)); | 348 | eventDispatcher.post(store.setState(intent, FAILED)); |
... | @@ -385,7 +385,7 @@ public class IntentManager | ... | @@ -385,7 +385,7 @@ public class IntentManager |
385 | } | 385 | } |
386 | monitorExecutor.execute(new IntentInstallMonitor(intent, uninstallWork, nextState)); | 386 | monitorExecutor.execute(new IntentInstallMonitor(intent, uninstallWork, nextState)); |
387 | } catch (IntentException e) { | 387 | } catch (IntentException e) { |
388 | - log.warn("Unable to uninstall intent {} due to: {}", intent.id(), e); | 388 | + log.warn("Unable to uninstall intent {} due to:", intent.id(), e); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ... | ... |
1 | package org.onlab.onos.store.trivial.impl; | 1 | package org.onlab.onos.store.trivial.impl; |
2 | 2 | ||
3 | -import com.google.common.collect.ImmutableSet; | 3 | +import static org.onlab.onos.net.intent.IntentState.FAILED; |
4 | +import static org.onlab.onos.net.intent.IntentState.INSTALLED; | ||
5 | +import static org.onlab.onos.net.intent.IntentState.SUBMITTED; | ||
6 | +import static org.onlab.onos.net.intent.IntentState.WITHDRAWN; | ||
7 | +import static org.slf4j.LoggerFactory.getLogger; | ||
8 | + | ||
9 | +import java.util.List; | ||
10 | +import java.util.Map; | ||
11 | +import java.util.concurrent.ConcurrentHashMap; | ||
12 | + | ||
4 | import org.apache.felix.scr.annotations.Activate; | 13 | import org.apache.felix.scr.annotations.Activate; |
5 | import org.apache.felix.scr.annotations.Component; | 14 | import org.apache.felix.scr.annotations.Component; |
6 | import org.apache.felix.scr.annotations.Deactivate; | 15 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -15,12 +24,7 @@ import org.onlab.onos.net.intent.IntentStoreDelegate; | ... | @@ -15,12 +24,7 @@ import org.onlab.onos.net.intent.IntentStoreDelegate; |
15 | import org.onlab.onos.store.AbstractStore; | 24 | import org.onlab.onos.store.AbstractStore; |
16 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
17 | 26 | ||
18 | -import java.util.HashMap; | 27 | +import com.google.common.collect.ImmutableSet; |
19 | -import java.util.List; | ||
20 | -import java.util.Map; | ||
21 | - | ||
22 | -import static org.onlab.onos.net.intent.IntentState.*; | ||
23 | -import static org.slf4j.LoggerFactory.getLogger; | ||
24 | 28 | ||
25 | @Component(immediate = true) | 29 | @Component(immediate = true) |
26 | @Service | 30 | @Service |
... | @@ -29,9 +33,10 @@ public class SimpleIntentStore | ... | @@ -29,9 +33,10 @@ public class SimpleIntentStore |
29 | implements IntentStore { | 33 | implements IntentStore { |
30 | 34 | ||
31 | private final Logger log = getLogger(getClass()); | 35 | private final Logger log = getLogger(getClass()); |
32 | - private final Map<IntentId, Intent> intents = new HashMap<>(); | 36 | + private final Map<IntentId, Intent> intents = new ConcurrentHashMap<>(); |
33 | - private final Map<IntentId, IntentState> states = new HashMap<>(); | 37 | + private final Map<IntentId, IntentState> states = new ConcurrentHashMap<>(); |
34 | - private final Map<IntentId, List<InstallableIntent>> installable = new HashMap<>(); | 38 | + private final Map<IntentId, List<InstallableIntent>> installable = |
39 | + new ConcurrentHashMap<>(); | ||
35 | 40 | ||
36 | @Activate | 41 | @Activate |
37 | public void activate() { | 42 | public void activate() { | ... | ... |
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
1 | package org.onlab.onos.provider.of.flow.impl; | 1 | package org.onlab.onos.provider.of.flow.impl; |
2 | 2 | ||
3 | -import com.google.common.collect.ArrayListMultimap; | 3 | +import static org.slf4j.LoggerFactory.getLogger; |
4 | -import com.google.common.collect.Lists; | 4 | + |
5 | -import com.google.common.collect.Maps; | 5 | +import java.util.Collections; |
6 | -import com.google.common.collect.Multimap; | 6 | +import java.util.HashMap; |
7 | +import java.util.List; | ||
8 | +import java.util.Map; | ||
9 | +import java.util.Set; | ||
10 | +import java.util.concurrent.ConcurrentHashMap; | ||
11 | +import java.util.concurrent.CountDownLatch; | ||
12 | +import java.util.concurrent.ExecutionException; | ||
13 | +import java.util.concurrent.Future; | ||
14 | +import java.util.concurrent.TimeUnit; | ||
15 | +import java.util.concurrent.TimeoutException; | ||
16 | +import java.util.concurrent.atomic.AtomicBoolean; | ||
17 | + | ||
7 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
8 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
9 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -57,20 +68,10 @@ import org.projectfloodlight.openflow.types.OFPort; | ... | @@ -57,20 +68,10 @@ import org.projectfloodlight.openflow.types.OFPort; |
57 | import org.projectfloodlight.openflow.types.U32; | 68 | import org.projectfloodlight.openflow.types.U32; |
58 | import org.slf4j.Logger; | 69 | import org.slf4j.Logger; |
59 | 70 | ||
60 | -import java.util.HashMap; | 71 | +import com.google.common.collect.ArrayListMultimap; |
61 | -import java.util.HashSet; | 72 | +import com.google.common.collect.Lists; |
62 | -import java.util.List; | 73 | +import com.google.common.collect.Maps; |
63 | -import java.util.Map; | 74 | +import com.google.common.collect.Multimap; |
64 | -import java.util.Set; | ||
65 | -import java.util.concurrent.ConcurrentHashMap; | ||
66 | -import java.util.concurrent.CountDownLatch; | ||
67 | -import java.util.concurrent.ExecutionException; | ||
68 | -import java.util.concurrent.Future; | ||
69 | -import java.util.concurrent.TimeUnit; | ||
70 | -import java.util.concurrent.TimeoutException; | ||
71 | -import java.util.concurrent.atomic.AtomicBoolean; | ||
72 | - | ||
73 | -import static org.slf4j.LoggerFactory.getLogger; | ||
74 | 75 | ||
75 | /** | 76 | /** |
76 | * Provider which uses an OpenFlow controller to detect network | 77 | * Provider which uses an OpenFlow controller to detect network |
... | @@ -159,7 +160,8 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -159,7 +160,8 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
159 | 160 | ||
160 | @Override | 161 | @Override |
161 | public Future<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch) { | 162 | public Future<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch) { |
162 | - final Set<Dpid> sws = new HashSet<Dpid>(); | 163 | + final Set<Dpid> sws = |
164 | + Collections.newSetFromMap(new ConcurrentHashMap<Dpid, Boolean>()); | ||
163 | final Map<Long, FlowRuleBatchEntry> fmXids = new HashMap<Long, FlowRuleBatchEntry>(); | 165 | final Map<Long, FlowRuleBatchEntry> fmXids = new HashMap<Long, FlowRuleBatchEntry>(); |
164 | OFFlowMod mod = null; | 166 | OFFlowMod mod = null; |
165 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { | 167 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { | ... | ... |
-
Please register or login to post a comment