use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class ProtectionEndpointIntentInstallerTest method testUninstallAndInstallIntents.
/**
* Test both uninstall and install protection endpoint Intents.
* framework.
*/
@Test
public void testUninstallAndInstallIntents() {
List<Intent> intentsToUninstall = createProtectionIntents(CP2);
List<Intent> intentsToInstall = createProtectionIntents(CP3);
IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLED, new WallClockTimestamp());
toUninstall = IntentData.compiled(toUninstall, intentsToInstall);
IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
toInstall = IntentData.compiled(toInstall, intentsToInstall);
IntentOperationContext<ProtectionEndpointIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
installer.apply(operationContext);
assertEquals(intentInstallCoordinator.successContext, operationContext);
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class ProtectionEndpointIntentInstallerTest method testUninstallIntents.
/**
* Uninstalls protection endpoint Intents.
* framework.
*/
@Test
public void testUninstallIntents() {
List<Intent> intentsToUninstall = createProtectionIntents(CP2);
List<Intent> intentsToInstall = Lists.newArrayList();
IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
IntentData toInstall = null;
IntentOperationContext<ProtectionEndpointIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
installer.apply(operationContext);
assertEquals(intentInstallCoordinator.successContext, operationContext);
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class GossipIntentStore method getPendingData.
@Override
public Iterable<IntentData> getPendingData(boolean localOnly, long olderThan) {
long now = System.currentTimeMillis();
final WallClockTimestamp time = new WallClockTimestamp(now - olderThan);
return pendingMap.values().stream().filter(data -> data.version().isOlderThan(time) && (!localOnly || isMaster(data.key()))).collect(Collectors.toList());
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class GossipIntentStore method activate.
@Activate
public void activate(ComponentContext context) {
configService.registerProperties(getClass());
modified(context);
// TODO persistent intents must be reevaluated and the appropriate
// processing done here, current implementation is not functional
// and is for performance evaluation only
initiallyPersistent = persistenceEnabled;
KryoNamespace.Builder intentSerializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(IntentData.class).register(MultiValuedTimestamp.class);
EventuallyConsistentMapBuilder currentECMapBuilder = storageService.<Key, IntentData>eventuallyConsistentMapBuilder().withName("intent-current").withSerializer(intentSerializer).withTimestampProvider(this::currentTimestampProvider).withPeerUpdateFunction((key, intentData) -> getPeerNodes(key, intentData));
EventuallyConsistentMapBuilder pendingECMapBuilder = storageService.<Key, IntentData>eventuallyConsistentMapBuilder().withName("intent-pending").withSerializer(intentSerializer).withTimestampProvider((key, intentData) -> new MultiValuedTimestamp<>(new WallClockTimestamp(), System.nanoTime())).withPeerUpdateFunction((key, intentData) -> getPeerNodes(key, intentData));
if (initiallyPersistent) {
currentECMapBuilder = currentECMapBuilder.withPersistence();
pendingECMapBuilder = pendingECMapBuilder.withPersistence();
}
currentMap = currentECMapBuilder.build();
pendingMap = pendingECMapBuilder.build();
currentMap.addListener(mapCurrentListener);
pendingMap.addListener(mapPendingListener);
log.info("Started");
}
use of org.onosproject.net.intent.IntentData in project onos by opennetworkinglab.
the class DomainIntentInstallerTest method testUninstall.
/**
* Uninstall domain Intents.
*/
@Test
public void testUninstall() {
List<Intent> intentsToUninstall = createDomainIntents();
List<Intent> intentsToInstall = Lists.newArrayList();
IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.WITHDRAWING, new WallClockTimestamp());
IntentData toInstall = null;
toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
IntentOperationContext<DomainIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
installer.apply(operationContext);
assertEquals(intentInstallCoordinator.successContext, operationContext);
}
Aggregations