Search in sources :

Example 21 with WallClockTimestamp

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

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

the class AbstractDistributedBmv2Mirror method activate.

@Activate
public void activate() {
    mirrorMap = storageService.<H, E>eventuallyConsistentMapBuilder().withName(mapName()).withSerializer(storeSerializer()).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    log.info("Started");
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) Activate(org.osgi.service.component.annotations.Activate)

Example 23 with WallClockTimestamp

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

the class InstallCoordinatorTest method testUninstallAndInstallIntent.

/**
 * Do both uninstall and install test Intents.
 */
@Test
public void testUninstallAndInstallIntent() {
    IntentData toUninstall = new IntentData(createTestIntent(), IntentState.INSTALLED, new WallClockTimestamp());
    IntentData toInstall = new IntentData(createTestIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    List<Intent> intentsToUninstall = Lists.newArrayList();
    List<Intent> intentsToInstall = Lists.newArrayList();
    IntStream.range(0, 10).forEach(val -> {
        intentsToUninstall.add(new TestInstallableIntent(val));
    });
    IntStream.range(10, 20).forEach(val -> {
        intentsToInstall.add(new TestInstallableIntent(val));
    });
    toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    installCoordinator.installIntents(Optional.of(toUninstall), Optional.of(toInstall));
    Intent toInstallIntent = toInstall.intent();
    TestTools.assertAfter(INSTALL_DELAY, INSTALL_DURATION, () -> {
        IntentData newData = intentStore.newData;
        assertEquals(toInstallIntent, newData.intent());
        assertEquals(IntentState.INSTALLED, newData.state());
        assertEquals(intentsToInstall, newData.installables());
    });
}
Also used : TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) Intent(org.onosproject.net.intent.Intent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 24 with WallClockTimestamp

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

the class PiPipeconfWatchdogManager method activate.

@Activate
public void activate() {
    eventDispatcher.addSink(PiPipeconfWatchdogEvent.class, listenerRegistry);
    localStatusMap = Maps.newConcurrentMap();
    // Init distributed status map and configured devices set
    KryoNamespace.Builder serializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(PipelineStatus.class);
    statusMap = storageService.<DeviceId, PipelineStatus>eventuallyConsistentMapBuilder().withName("onos-pipeconf-status-table").withSerializer(serializer).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    statusMap.addListener(new StatusMapListener());
    // Init the set of the configured devices
    configuredDevices = new DefaultDistributedSet<>(storageService.<DeviceId>setBuilder().withName(CONFIGURED_DEVICES).withSerializer(Serializer.using(KryoNamespaces.API)).build(), DistributedPrimitive.DEFAULT_OPERATION_TIMEOUT_MILLIS);
    // Register component configurable properties.
    componentConfigService.registerProperties(getClass());
    // Start periodic watchdog task.
    startProbeTask();
    // Add listeners.
    deviceService.addListener(deviceListener);
    pipeconfService.addListener(pipeconfListener);
    log.info("Started");
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) KryoNamespace(org.onlab.util.KryoNamespace) Activate(org.osgi.service.component.annotations.Activate)

Example 25 with WallClockTimestamp

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

the class AbstractDistributedP4RuntimeMirror method put.

@Override
public void put(H handle, E entry) {
    checkNotNull(handle);
    checkNotNull(entry);
    final PiPipeconfWatchdogService.PipelineStatus status = pipeconfWatchdogService.getStatus(handle.deviceId());
    if (flushOnPipelineUnknown && !status.equals(READY)) {
        // Keep mirror empty if pipeline status is UNKNOWN.
        log.info("Ignoring {} mirror update because pipeline " + "status of {} is {}: {}", entityType, handle.deviceId(), status, entry);
        return;
    }
    final long now = new WallClockTimestamp().unixTimestamp();
    final TimedEntry<E> timedEntry = new TimedEntry<>(now, entry);
    mirrorMap.put(handle, timedEntry);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) PiPipeconfWatchdogService(org.onosproject.net.pi.service.PiPipeconfWatchdogService)

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