Search in sources :

Example 6 with DefaultApplicationId

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));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Test(org.junit.Test)

Example 7 with DefaultApplicationId

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));
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) FilteringObjectiveJsonMatcher.matchesFilteringObjective(org.onosproject.codec.impl.FilteringObjectiveJsonMatcher.matchesFilteringObjective) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Test(org.junit.Test)

Example 8 with DefaultApplicationId

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));
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) NextObjectiveJsonMatcher.matchesNextObjective(org.onosproject.codec.impl.NextObjectiveJsonMatcher.matchesNextObjective) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Test(org.junit.Test)

Example 9 with DefaultApplicationId

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);
        });
    });
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Example 10 with DefaultApplicationId

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()));
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) SimpleGroupStore(org.onosproject.store.trivial.SimpleGroupStore) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DriverRegistryManager(org.onosproject.net.driver.impl.DriverRegistryManager) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Before(org.junit.Before)

Aggregations

DefaultApplicationId (org.onosproject.core.DefaultApplicationId)28 ApplicationId (org.onosproject.core.ApplicationId)19 Test (org.junit.Test)12 IntentMonitorAndRerouteService (org.onosproject.imr.IntentMonitorAndRerouteService)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 WebTarget (javax.ws.rs.client.WebTarget)3 Response (javax.ws.rs.core.Response)3 Before (org.junit.Before)3 TunnelService (org.onosproject.incubator.net.tunnel.TunnelService)3 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 FlowRule (org.onosproject.net.flow.FlowRule)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 EqualsTester (com.google.common.testing.EqualsTester)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 DefaultOpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint)2