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");
}
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();
}
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");
}
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());
}
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());
});
}
Aggregations