Search in sources :

Example 16 with WallClockTimestamp

use of org.onosproject.store.service.WallClockTimestamp in project onos by opennetworkinglab.

the class ProtectionEndpointIntentInstallerTest method testInstallIntents.

/**
 * Installs protection endpoint Intents.
 * framework.
 */
@Test
public void testInstallIntents() {
    List<Intent> intentsToUninstall = Lists.newArrayList();
    List<Intent> intentsToInstall = createProtectionIntents(CP2);
    IntentData toUninstall = null;
    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 17 with WallClockTimestamp

use of org.onosproject.store.service.WallClockTimestamp 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 18 with WallClockTimestamp

use of org.onosproject.store.service.WallClockTimestamp in project onos by opennetworkinglab.

the class ProtectionEndpointIntentInstallerTest method testInstallFailed.

/**
 * Test if installation failed.
 * framework.
 */
@Test
public void testInstallFailed() {
    networkConfigService = new TestFailedNetworkConfigService();
    installer.networkConfigService = networkConfigService;
    List<Intent> intentsToUninstall = Lists.newArrayList();
    List<Intent> intentsToInstall = createProtectionIntents(CP2);
    IntentData toUninstall = null;
    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.failedContext, 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 19 with WallClockTimestamp

use of org.onosproject.store.service.WallClockTimestamp 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 20 with WallClockTimestamp

use of org.onosproject.store.service.WallClockTimestamp 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)

Aggregations

WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)48 IntentData (org.onosproject.net.intent.IntentData)34 Intent (org.onosproject.net.intent.Intent)33 Test (org.junit.Test)28 IntentInstallationContext (org.onosproject.net.intent.IntentInstallationContext)26 IntentOperationContext (org.onosproject.net.intent.IntentOperationContext)26 Activate (org.osgi.service.component.annotations.Activate)15 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)13 PathIntent (org.onosproject.net.intent.PathIntent)13 Collection (java.util.Collection)8 KryoNamespace (org.onlab.util.KryoNamespace)8 ImmutableList (com.google.common.collect.ImmutableList)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)5 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)5 FlowRule (org.onosproject.net.flow.FlowRule)5 IntentState (org.onosproject.net.intent.IntentState)5 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)4 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)4