use of org.onosproject.store.service.WallClockTimestamp in project onos by opennetworkinglab.
the class FlowRuleIntentInstallerTest method testRuleModifyMissing.
/**
* Test intents with same match rules, should do modify instead of add. However, the flow rules do not exist
* in the FlowRuleService.
*/
@Test
public void testRuleModifyMissing() {
List<Intent> intentsToInstall = createFlowRuleIntents();
List<Intent> intentsToUninstall = createFlowRuleIntentsWithSameMatch();
IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
toInstall = IntentData.compiled(toInstall, intentsToInstall);
IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLED, new WallClockTimestamp());
toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
IntentOperationContext<FlowRuleIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
installer.apply(operationContext);
IntentOperationContext successContext = intentInstallCoordinator.successContext;
assertEquals(successContext, operationContext);
assertEquals(0, flowRuleService.flowRulesRemove.size());
assertEquals(1, flowRuleService.flowRulesAdd.size());
assertEquals(0, flowRuleService.flowRulesModify.size());
FlowRuleIntent installedIntent = (FlowRuleIntent) intentsToInstall.get(0);
assertEquals(flowRuleService.flowRulesAdd.size(), installedIntent.flowRules().size());
assertTrue(flowRuleService.flowRulesAdd.containsAll(installedIntent.flowRules()));
}
use of org.onosproject.store.service.WallClockTimestamp in project onos by opennetworkinglab.
the class FlowRuleIntentInstallerTest method testFailed.
/**
* Test if the flow installation failed.
*/
@Test
public void testFailed() {
installer.flowRuleService = new TestFailedFlowRuleService();
List<Intent> intentsToUninstall = Lists.newArrayList();
List<Intent> intentsToInstall = createFlowRuleIntents();
IntentData toUninstall = null;
IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
toInstall = IntentData.compiled(toInstall, intentsToInstall);
IntentOperationContext<FlowRuleIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
installer.apply(operationContext);
IntentOperationContext failedContext = intentInstallCoordinator.failedContext;
assertEquals(failedContext, operationContext);
}
use of org.onosproject.store.service.WallClockTimestamp in project onos by opennetworkinglab.
the class FlowRuleIntentInstallerTest method testUninstallAndInstallSameMissing.
/**
* Do both install and uninstall Intents with same flow rule Intent. However, the flow rules do not exist
* in the FlowRuleService.
*/
@Test
public void testUninstallAndInstallSameMissing() {
List<Intent> intentsToInstall = createFlowRuleIntents();
List<Intent> intentsToUninstall = intentsToInstall;
IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
toInstall = IntentData.compiled(toInstall, intentsToInstall);
IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLED, new WallClockTimestamp());
toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
IntentOperationContext<FlowRuleIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
installer.apply(operationContext);
IntentOperationContext successContext = intentInstallCoordinator.successContext;
assertEquals(successContext, operationContext);
assertEquals(0, flowRuleService.flowRulesRemove.size());
assertEquals(1, flowRuleService.flowRulesAdd.size());
assertEquals(0, flowRuleService.flowRulesModify.size());
}
use of org.onosproject.store.service.WallClockTimestamp in project onos by opennetworkinglab.
the class DistributedContextEventMapTreeStore method activate.
@Activate
public void activate() {
appId = coreService.registerApplication("org.onosproject.contexteventmapstore");
log.info("appId=" + appId);
KryoNamespace eventMapNamespace = KryoNamespace.newBuilder().register(KryoNamespaces.API).build();
eventMapTree = storageService.<String>documentTreeBuilder().withSerializer(Serializer.using(eventMapNamespace)).withName("context-event-map-store").withOrdering(Ordering.INSERTION).buildDocumentTree();
hintSetPerCxtMap = storageService.<String, Set<String>>eventuallyConsistentMapBuilder().withName("workflow-event-hint-per-cxt").withSerializer(eventMapNamespace).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
log.info("Started");
}
use of org.onosproject.store.service.WallClockTimestamp in project onos by opennetworkinglab.
the class AbstractDistributedP4RuntimeMirror method activate.
@Activate
public void activate() {
final String fullMapName = format(MAP_NAME_TEMPLATE, mapSimpleName());
final KryoNamespace serializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(TimedEntry.class).build();
mirrorMap = storageService.<PiHandle, TimedEntry<E>>eventuallyConsistentMapBuilder().withName(fullMapName).withSerializer(serializer).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
annotationsMap = storageService.<PiHandle, Annotations>eventuallyConsistentMapBuilder().withName(fullMapName + "-annotations").withSerializer(serializer).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
pipeconfWatchdogService.addListener(pipeconfListener);
log.info("Started");
}
Aggregations