Brian O'Connor

Bug fixes for Intent Manager

ONOS-343

Change-Id: I164c52b41080392c4b27a3969f270171558599a6
......@@ -294,7 +294,7 @@ public class IntentManager
// intents with the top-level intent and proceed to install.
update.setInstallables(installables);
} catch (PathNotFoundException e) {
log.debug("Path not found for intent {}", intent.id());
log.debug("Path not found for intent {}", intent);
} catch (IntentException e) {
log.warn("Unable to compile intent {} due to:", intent.id(), e);
......@@ -606,6 +606,9 @@ public class IntentManager
oldInstallables = store.getInstallableIntents(oldIntent.id());
} else {
oldInstallables = null;
if (newIntent == null) {
log.info("Ignoring {} for Intent {}", op.type(), op.intentId());
}
}
}
......@@ -853,8 +856,8 @@ public class IntentManager
*/
private void processFutures() {
if (future == null) {
log.warn("I have no Future.");
return; //FIXME look at this
// we are done if the future is null
return;
}
try {
CompletedBatchOperation completed = future.get(100, TimeUnit.NANOSECONDS);
......
......@@ -77,7 +77,7 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LinkResourceService resourceManager;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
protected IntentService intentService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
......@@ -108,6 +108,18 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
log.info("Stopped");
}
protected void bindIntentService(IntentService service) {
if (intentService == null) {
intentService = service;
}
}
protected void unbindIntentService(IntentService service) {
if (intentService == service) {
intentService = null;
}
}
@Override
public void setDelegate(TopologyChangeDelegate delegate) {
checkNotNull(delegate, "Delegate cannot be null");
......@@ -235,6 +247,10 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
//TODO consider adding flow rule event tracking
private void updateTrackedResources(ApplicationId appId, boolean track) {
if (intentService == null) {
log.debug("Intent service is not bound yet");
return;
}
intentService.getIntents().forEach(intent -> {
if (intent.appId().equals(appId)) {
IntentId id = intent.id();
......
......@@ -63,7 +63,7 @@ import com.google.common.collect.ImmutableList;
* Strongly consistent and durable state management service based on
* Copycat implementation of Raft consensus protocol.
*/
@Component(immediate = true)
@Component(immediate = false)
@Service
public class DatabaseManager implements DatabaseService, DatabaseAdminService {
......
......@@ -33,7 +33,7 @@ import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimaps;
@Component(immediate = true)
@Component(immediate = false)
@Service
public class DistributedLockManager implements LockService {
......