use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class ApplicationIdCodecTest method testApplicationIdEncode.
/**
* Tests encoding of an application id object.
*/
@Test
public void testApplicationIdEncode() {
int id = 1;
String name = "org.onosproject.foo";
ApplicationId appId = new DefaultApplicationId(id, name);
ObjectNode applicationIdJson = applicationIdCodec.encode(appId, context);
assertThat(applicationIdJson, ApplicationIdJsonMatcher.matchesApplicationId(appId));
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class FilteringObjectiveCodecTest method testFilteringObjectiveDecode.
/**
* Test decoding of a FilteringObjective object.
*/
@Test
public void testFilteringObjectiveDecode() throws IOException {
ApplicationId appId = new DefaultApplicationId(0, SAMPLE_APP_ID);
expect(mockCoreService.registerApplication(SAMPLE_APP_ID)).andReturn(appId).anyTimes();
replay(mockCoreService);
FilteringObjective filteringObjective = getFilteringObjective("FilteringObjective.json");
assertThat(filteringObjective.type(), is(FilteringObjective.Type.PERMIT));
assertThat(filteringObjective.priority(), is(60));
assertThat(filteringObjective.timeout(), is(1));
assertThat(filteringObjective.op(), is(FilteringObjective.Operation.ADD));
assertThat(filteringObjective.permanent(), is(false));
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class NextObjectiveCodecTest method testNextObjectiveDecode.
/**
* Test decoding of a NextObjective object.
*/
@Test
public void testNextObjectiveDecode() throws IOException {
ApplicationId appId = new DefaultApplicationId(0, SAMPLE_APP_ID);
expect(mockCoreService.registerApplication(SAMPLE_APP_ID)).andReturn(appId).anyTimes();
replay(mockCoreService);
NextObjective nextObjective = getNextObjective("NextObjective.json");
assertThat(nextObjective.type(), is(NextObjective.Type.FAILOVER));
assertThat(nextObjective.op(), is(NextObjective.Operation.ADD));
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class FlowRuleIntentInstaller method prepareReallocation.
/**
* This method prepares the {@link FlowRule} required for every reallocation stage.
* <p>Stage 1: the FlowRules of the new path are installed,
* with a lower priority only on the devices shared with the old path;</p>
* <p>Stage 2: the FlowRules of the old path are removed from the ingress to the egress points,
* only in the shared devices;</p>
* <p>Stage 3: the FlowRules with a lower priority are restored to the original one;</p>
* <p>Stage 4: the remaining FlowRules of the old path are deleted.</p>
*
* @param uninstallIntents the previous FlowRuleIntent
* @param installIntents the new FlowRuleIntent to be installed
* @param firstStageBuilder the first stage operation builder
* @param secondStageFlowRules the second stage FlowRules
* @param thirdStageBuilder the third stage operation builder
* @param finalStageBuilder the last stage operation builder
*/
private void prepareReallocation(List<FlowRuleIntent> uninstallIntents, List<FlowRuleIntent> installIntents, FlowRuleOperations.Builder firstStageBuilder, List<FlowRule> secondStageFlowRules, FlowRuleOperations.Builder thirdStageBuilder, FlowRuleOperations.Builder finalStageBuilder) {
// Filter out same intents and intents with same flow rules
installIntents.forEach(installIntent -> {
uninstallIntents.forEach(uninstallIntent -> {
List<FlowRule> uninstallFlowRules = Lists.newArrayList(uninstallIntent.flowRules());
List<FlowRule> installFlowRules = Lists.newArrayList(installIntent.flowRules());
List<FlowRule> secondStageRules = Lists.newArrayList();
List<FlowRule> thirdStageRules = Lists.newArrayList();
List<DeviceId> orderedDeviceList = createIngressToEgressDeviceList(installIntent.resources());
uninstallIntent.flowRules().forEach(flowRuleToUnistall -> {
installIntent.flowRules().forEach(flowRuleToInstall -> {
if (flowRuleToInstall.exactMatch(flowRuleToUnistall)) {
// The FlowRules are in common (i.e., we are sharing the path)
uninstallFlowRules.remove(flowRuleToInstall);
installFlowRules.remove(flowRuleToInstall);
} else if (flowRuleToInstall.deviceId().equals(flowRuleToUnistall.deviceId())) {
// FlowRules that have a device in common but
// different treatment/selector (i.e., overlapping path)
FlowRule flowRuleWithLowerPriority = DefaultFlowRule.builder().withPriority(flowRuleToInstall.priority() - 1).withSelector(flowRuleToInstall.selector()).forDevice(flowRuleToInstall.deviceId()).makePermanent().withTreatment(flowRuleToInstall.treatment()).fromApp(new DefaultApplicationId(flowRuleToInstall.appId(), "org.onosproject.net.intent")).build();
// Update the FlowRule to be installed with one with a lower priority
installFlowRules.remove(flowRuleToInstall);
installFlowRules.add(flowRuleWithLowerPriority);
// Add the FlowRule to be uninstalled to the second stage of non-disruptive update
secondStageRules.add(flowRuleToUnistall);
uninstallFlowRules.remove(flowRuleToUnistall);
thirdStageRules.add(flowRuleToInstall);
uninstallFlowRules.add(flowRuleWithLowerPriority);
}
});
});
firstStageBuilder.newStage();
installFlowRules.forEach(firstStageBuilder::add);
Collections.sort(secondStageRules, new SecondStageComparator(orderedDeviceList));
secondStageFlowRules.addAll(secondStageRules);
thirdStageBuilder.newStage();
thirdStageRules.forEach(thirdStageBuilder::add);
finalStageBuilder.newStage();
uninstallFlowRules.forEach(finalStageBuilder::remove);
});
});
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class GroupManagerTest method setUp.
@Before
public void setUp() {
mgr = new GroupManager();
groupService = mgr;
// mgr.deviceService = new DeviceManager();
mgr.deviceService = new TestDeviceService();
mgr.cfgService = new ComponentConfigAdapter();
mgr.store = new SimpleGroupStore();
mgr.mastershipService = new TestMastershipService();
injectEventDispatcher(mgr, new TestEventDispatcher());
providerRegistry = mgr;
mgr.activate(null);
mgr.addListener(listener);
DriverRegistryManager driverRegistry = new DriverRegistryManager();
driverService = new TestDriverManager(driverRegistry);
driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(GroupProgrammable.class, TestGroupProgrammable.class), ImmutableMap.of()));
internalProvider = new TestGroupProvider(PID);
provider = internalProvider;
providerService = providerRegistry.register(provider);
appId = new DefaultApplicationId(2, "org.groupmanager.test");
assertTrue("provider should be registered", providerRegistry.getProviders().contains(provider.id()));
}
Aggregations