Search in sources :

Example 21 with IntentData

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);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 22 with IntentData

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);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 23 with IntentData

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());
}
Also used : IntentState(org.onosproject.net.intent.IntentState) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Backtrace(org.onlab.util.Backtrace) RandomUtils(org.apache.commons.lang.math.RandomUtils) StorageService(org.onosproject.store.service.StorageService) PURGE_REQ(org.onosproject.net.intent.IntentState.PURGE_REQ) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) NodeId(org.onosproject.cluster.NodeId) Tools.get(org.onlab.util.Tools.get) EventuallyConsistentMapEvent(org.onosproject.store.service.EventuallyConsistentMapEvent) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) GIS_PERSISTENCE_ENABLED_DEFAULT(org.onosproject.store.OsgiPropertyConstants.GIS_PERSISTENCE_ENABLED_DEFAULT) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) GIS_PERSISTENCE_ENABLED(org.onosproject.store.OsgiPropertyConstants.GIS_PERSISTENCE_ENABLED) Dictionary(java.util.Dictionary) IntentEvent(org.onosproject.net.intent.IntentEvent) ComponentContext(org.osgi.service.component.ComponentContext) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) KryoNamespace(org.onlab.util.KryoNamespace) IntentData(org.onosproject.net.intent.IntentData) ControllerNode(org.onosproject.cluster.ControllerNode) Component(org.osgi.service.component.annotations.Component) ImmutableList(com.google.common.collect.ImmutableList) Intent(org.onosproject.net.intent.Intent) Timestamp(org.onosproject.store.Timestamp) Activate(org.osgi.service.component.annotations.Activate) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) EventuallyConsistentMapListener(org.onosproject.store.service.EventuallyConsistentMapListener) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Logger(org.slf4j.Logger) Properties(java.util.Properties) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) AtomicLong(java.util.concurrent.atomic.AtomicLong) IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) MultiValuedTimestamp(org.onosproject.store.service.MultiValuedTimestamp) IntentStore(org.onosproject.net.intent.IntentStore) AbstractStore(org.onosproject.store.AbstractStore) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Reference(org.osgi.service.component.annotations.Reference) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp)

Example 24 with IntentData

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");
}
Also used : IntentState(org.onosproject.net.intent.IntentState) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Backtrace(org.onlab.util.Backtrace) RandomUtils(org.apache.commons.lang.math.RandomUtils) StorageService(org.onosproject.store.service.StorageService) PURGE_REQ(org.onosproject.net.intent.IntentState.PURGE_REQ) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) NodeId(org.onosproject.cluster.NodeId) Tools.get(org.onlab.util.Tools.get) EventuallyConsistentMapEvent(org.onosproject.store.service.EventuallyConsistentMapEvent) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) GIS_PERSISTENCE_ENABLED_DEFAULT(org.onosproject.store.OsgiPropertyConstants.GIS_PERSISTENCE_ENABLED_DEFAULT) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) GIS_PERSISTENCE_ENABLED(org.onosproject.store.OsgiPropertyConstants.GIS_PERSISTENCE_ENABLED) Dictionary(java.util.Dictionary) IntentEvent(org.onosproject.net.intent.IntentEvent) ComponentContext(org.osgi.service.component.ComponentContext) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) KryoNamespace(org.onlab.util.KryoNamespace) IntentData(org.onosproject.net.intent.IntentData) ControllerNode(org.onosproject.cluster.ControllerNode) Component(org.osgi.service.component.annotations.Component) ImmutableList(com.google.common.collect.ImmutableList) Intent(org.onosproject.net.intent.Intent) Timestamp(org.onosproject.store.Timestamp) Activate(org.osgi.service.component.annotations.Activate) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) EventuallyConsistentMapListener(org.onosproject.store.service.EventuallyConsistentMapListener) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Logger(org.slf4j.Logger) Properties(java.util.Properties) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) AtomicLong(java.util.concurrent.atomic.AtomicLong) IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) MultiValuedTimestamp(org.onosproject.store.service.MultiValuedTimestamp) IntentStore(org.onosproject.net.intent.IntentStore) AbstractStore(org.onosproject.store.AbstractStore) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Reference(org.osgi.service.component.annotations.Reference) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) KryoNamespace(org.onlab.util.KryoNamespace) MultiValuedTimestamp(org.onosproject.store.service.MultiValuedTimestamp) Key(org.onosproject.net.intent.Key) Activate(org.osgi.service.component.annotations.Activate)

Example 25 with IntentData

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);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainIntent(org.onosproject.net.domain.DomainIntent) Intent(org.onosproject.net.intent.Intent) DomainIntent(org.onosproject.net.domain.DomainIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Aggregations

IntentData (org.onosproject.net.intent.IntentData)79 Test (org.junit.Test)49 Intent (org.onosproject.net.intent.Intent)49 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)34 IntentOperationContext (org.onosproject.net.intent.IntentOperationContext)33 IntentInstallationContext (org.onosproject.net.intent.IntentInstallationContext)30 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)21 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)16 IntentEvent (org.onosproject.net.intent.IntentEvent)15 IntentStoreDelegate (org.onosproject.net.intent.IntentStoreDelegate)15 PathIntent (org.onosproject.net.intent.PathIntent)13 MockIntent (org.onosproject.net.intent.IntentTestsMocks.MockIntent)12 Timestamp (org.onosproject.store.Timestamp)11 Collection (java.util.Collection)10 List (java.util.List)8 Collectors (java.util.stream.Collectors)7 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)7 FlowRule (org.onosproject.net.flow.FlowRule)7 Set (java.util.Set)6 DeviceId (org.onosproject.net.DeviceId)6