Jonathan Hart

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
......@@ -251,7 +251,7 @@ public class IntentManager
executeInstallingPhase(intent);
} catch (Exception e) {
log.warn("Unable to compile intent {} due to: {}", intent.id(), e);
log.warn("Unable to compile intent {} due to:", intent.id(), e);
// If compilation failed, mark the intent as failed.
store.setState(intent, FAILED);
......@@ -304,7 +304,7 @@ public class IntentManager
//eventDispatcher.post(store.setState(intent, INSTALLED));
monitorExecutor.execute(new IntentInstallMonitor(intent, installWork, INSTALLED));
} catch (Exception e) {
log.warn("Unable to install intent {} due to: {}", intent.id(), e);
log.warn("Unable to install intent {} due to:", intent.id(), e);
uninstallIntent(intent, RECOMPILING);
// If compilation failed, kick off the recompiling phase.
......@@ -342,7 +342,7 @@ public class IntentManager
executeInstallingPhase(intent);
}
} catch (Exception e) {
log.warn("Unable to recompile intent {} due to: {}", intent.id(), e);
log.warn("Unable to recompile intent {} due to:", intent.id(), e);
// If compilation failed, mark the intent as failed.
eventDispatcher.post(store.setState(intent, FAILED));
......@@ -385,7 +385,7 @@ public class IntentManager
}
monitorExecutor.execute(new IntentInstallMonitor(intent, uninstallWork, nextState));
} catch (IntentException e) {
log.warn("Unable to uninstall intent {} due to: {}", intent.id(), e);
log.warn("Unable to uninstall intent {} due to:", intent.id(), e);
}
}
......
package org.onlab.onos.store.trivial.impl;
import com.google.common.collect.ImmutableSet;
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.SUBMITTED;
import static org.onlab.onos.net.intent.IntentState.WITHDRAWN;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -15,12 +24,7 @@ import org.onlab.onos.net.intent.IntentStoreDelegate;
import org.onlab.onos.store.AbstractStore;
import org.slf4j.Logger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.onlab.onos.net.intent.IntentState.*;
import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.collect.ImmutableSet;
@Component(immediate = true)
@Service
......@@ -29,9 +33,10 @@ public class SimpleIntentStore
implements IntentStore {
private final Logger log = getLogger(getClass());
private final Map<IntentId, Intent> intents = new HashMap<>();
private final Map<IntentId, IntentState> states = new HashMap<>();
private final Map<IntentId, List<InstallableIntent>> installable = new HashMap<>();
private final Map<IntentId, Intent> intents = new ConcurrentHashMap<>();
private final Map<IntentId, IntentState> states = new ConcurrentHashMap<>();
private final Map<IntentId, List<InstallableIntent>> installable =
new ConcurrentHashMap<>();
@Activate
public void activate() {
......
package org.onlab.onos.provider.of.flow.impl;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -57,20 +68,10 @@ import org.projectfloodlight.openflow.types.OFPort;
import org.projectfloodlight.openflow.types.U32;
import org.slf4j.Logger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
/**
* Provider which uses an OpenFlow controller to detect network
......@@ -159,7 +160,8 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
@Override
public Future<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch) {
final Set<Dpid> sws = new HashSet<Dpid>();
final Set<Dpid> sws =
Collections.newSetFromMap(new ConcurrentHashMap<Dpid, Boolean>());
final Map<Long, FlowRuleBatchEntry> fmXids = new HashMap<Long, FlowRuleBatchEntry>();
OFFlowMod mod = null;
for (FlowRuleBatchEntry fbe : batch.getOperations()) {
......