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