Search in sources :

Example 26 with WallClockTimestamp

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

the class DistributedTunnelStore method activate.

@Activate
public void activate() {
    KryoNamespace.Builder serializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(MultiValuedTimestamp.class);
    tunnelIdAsKeyStore = storageService.<TunnelId, Tunnel>eventuallyConsistentMapBuilder().withName("all_tunnel").withSerializer(serializer).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    orderRelationship = storageService.<ApplicationId, Set<TunnelSubscription>>eventuallyConsistentMapBuilder().withName("type_tunnel").withSerializer(serializer).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    idGenerator = coreService.getIdGenerator(tunnelOpTopic);
    tunnelIdAsKeyStore.addListener(tunnelUpdateListener);
    log.info("Started");
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) KryoNamespace(org.onlab.util.KryoNamespace) TunnelSubscription(org.onosproject.incubator.net.tunnel.TunnelSubscription) Activate(org.osgi.service.component.annotations.Activate)

Example 27 with WallClockTimestamp

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

the class GossipIntentStore method getIntentData.

@Override
public Iterable<IntentData> getIntentData(boolean localOnly, long olderThan) {
    if (localOnly || olderThan > 0) {
        long now = System.currentTimeMillis();
        final WallClockTimestamp time = new WallClockTimestamp(now - olderThan);
        return currentMap.values().stream().filter(data -> data.version().isOlderThan(time) && (!localOnly || isMaster(data.key()))).collect(Collectors.toList());
    }
    return currentMap.values();
}
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 28 with WallClockTimestamp

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

the class AbstractDistributedPiTranslationStore method activate.

@Activate
public void activate() {
    final String fullMapName = format(MAP_NAME_TEMPLATE, mapSimpleName());
    translatedEntities = storageService.<PiHandle, PiTranslatedEntity<T, E>>eventuallyConsistentMapBuilder().withName(fullMapName).withSerializer(KryoNamespaces.API).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
    translatedEntities.addListener(entityMapListener);
    log.info("Started");
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) Activate(org.osgi.service.component.annotations.Activate)

Example 29 with WallClockTimestamp

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

the class DistributedVplsStore method writeVplsToNetConfig.

/**
 * Writes all VPLS data to the network configuration store.
 *
 * @param vplsDataCollection the VPLSs data
 */
public void writeVplsToNetConfig(Collection<VplsData> vplsDataCollection) {
    VplsAppConfig config = networkConfigService.addConfig(appId, VplsAppConfig.class);
    if (config == null) {
        log.debug("VPLS config is not available now");
        return;
    }
    config.clearVplsConfig();
    // Setup update time for this VPLS application configuration
    WallClockTimestamp ts = new WallClockTimestamp();
    config.updateTime(ts.unixTimestamp());
    vplsDataCollection.forEach(vplsData -> {
        Set<String> interfaceNames = vplsData.interfaces().stream().map(Interface::name).collect(Collectors.toSet());
        VplsConfig vplsConfig = new VplsConfig(vplsData.name(), interfaceNames, vplsData.encapsulationType());
        config.addVpls(vplsConfig);
    });
    networkConfigService.applyConfig(appId, VplsAppConfig.class, config.node());
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) VplsAppConfig(org.onosproject.vpls.config.VplsAppConfig) VplsConfig(org.onosproject.vpls.config.VplsConfig)

Example 30 with WallClockTimestamp

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

the class InstallCoordinatorTest method testInstallFailed.

/**
 * Test Intent install failed.
 */
@Test
public void testInstallFailed() {
    installerRegistry.unregisterInstaller(TestInstallableIntent.class);
    installerRegistry.registerInstaller(TestInstallableIntent.class, new TestFailedIntentInstaller());
    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 toUninstallIntent = toUninstall.intent();
    TestTools.assertAfter(INSTALL_DELAY, INSTALL_DURATION, () -> {
        IntentData newData = intentStore.newData;
        assertEquals(toUninstallIntent, newData.intent());
        assertEquals(IntentState.CORRUPT, newData.state());
        assertEquals(intentsToUninstall, 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)

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