use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class IntentManager method createInitialPhase.
private IntentProcessPhase createInitialPhase(IntentData data) {
IntentData pending = store.getPendingData(data.key());
if (pending == null || pending.version().isNewerThan(data.version())) {
/*
If the pending map is null, then this intent was compiled by a
previous batch iteration, so we can skip it.
If the pending map has a newer request, it will get compiled as
part of the next batch, so we can skip it.
*/
return Skipped.getPhase();
}
IntentData current = store.getIntentData(data.key());
return newInitialPhase(processor, data, current);
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class IntentManager method submit.
@Override
public void submit(Intent intent) {
checkPermission(INTENT_WRITE);
checkNotNull(intent, INTENT_NULL);
IntentData data = IntentData.submit(intent);
store.addPending(data);
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class IntentManager method purge.
@Override
public void purge(Intent intent) {
checkPermission(INTENT_WRITE);
checkNotNull(intent, INTENT_NULL);
IntentData data = IntentData.purge(intent);
store.addPending(data);
// remove associated group if there is one
if (intent instanceof PointToPointIntent) {
PointToPointIntent pointIntent = (PointToPointIntent) intent;
DeviceId deviceId = pointIntent.filteredIngressPoint().connectPoint().deviceId();
GroupKey groupKey = PointToPointIntentCompiler.makeGroupKey(intent.id());
groupService.removeGroup(deviceId, groupKey, intent.appId());
}
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class InstallCoordinator method finish.
/**
* Completed the installation context and update the Intent store.
*
* @param intentInstallationContext the installation context
*/
private void finish(IntentInstallationContext intentInstallationContext) {
Set<IntentOperationContext> errCtxs = intentInstallationContext.errorContexts();
Optional<IntentData> toUninstall = intentInstallationContext.toUninstall();
Optional<IntentData> toInstall = intentInstallationContext.toInstall();
// Intent install success
if (errCtxs == null || errCtxs.isEmpty()) {
if (toInstall.isPresent()) {
IntentData installData = toInstall.get();
log.debug("Completed installing: {}:{}", installData.key(), installData.intent().id());
installData = IntentData.compiled(installData, installData.installables());
installData.setState(INSTALLED);
intentStore.write(installData);
} else if (toUninstall.isPresent()) {
IntentData uninstallData = toUninstall.get();
uninstallData = IntentData.compiled(uninstallData, Collections.emptyList());
log.debug("Completed withdrawing: {}:{}", uninstallData.key(), uninstallData.intent().id());
switch(uninstallData.request()) {
case INSTALL_REQ:
// INSTALLED intent was damaged & clean up is now complete
uninstallData.setState(FAILED);
break;
case WITHDRAW_REQ:
default:
// TODO "default" case should not happen
uninstallData.setState(WITHDRAWN);
break;
}
// Intent has been withdrawn; we can clear the installables
intentStore.write(uninstallData);
}
} else {
// if toInstall was cause of error, then recompile (manage/increment counter, when exceeded -> CORRUPT)
if (toInstall.isPresent()) {
IntentData installData = toInstall.get();
intentStore.write(IntentData.corrupt(installData));
}
// if toUninstall was cause of error, then CORRUPT (another job will clean this up)
if (toUninstall.isPresent()) {
IntentData uninstallData = toUninstall.get();
intentStore.write(IntentData.corrupt(uninstallData));
}
}
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class SimpleVirtualIntentStore method write.
@Override
public void write(NetworkId networkId, IntentData newData) {
checkNotNull(newData);
synchronized (this) {
// TODO this could be refactored/cleaned up
IntentData currentData = getCurrentMap(networkId).get(newData.key());
IntentData pendingData = getPendingMap(networkId).get(newData.key());
if (IntentData.isUpdateAcceptable(currentData, newData)) {
if (pendingData != null) {
if (pendingData.state() == PURGE_REQ) {
getCurrentMap(networkId).remove(newData.key(), newData);
} else {
getCurrentMap(networkId).put(newData.key(), IntentData.copy(newData));
}
if (pendingData.version().compareTo(newData.version()) <= 0) {
// pendingData version is less than or equal to newData's
// Note: a new update for this key could be pending (it's version will be greater)
getPendingMap(networkId).remove(newData.key());
}
}
IntentEvent.getEvent(newData).ifPresent(e -> notifyDelegate(networkId, e));
}
}
}
Aggregations