Search in sources :

Example 1 with Mapping

use of org.onosproject.mapping.Mapping in project onos by opennetworkinglab.

the class DistributedMappingStore method activate.

@Activate
public void activate() {
    Serializer serializer = Serializer.using(KryoNamespaces.API, Mapping.class, DefaultMapping.class, MappingId.class, MappingEvent.Type.class, MappingKey.class, MappingValue.class, MappingAddress.class, MappingAddress.Type.class, MappingAction.class, MappingAction.Type.class, MappingTreatment.class, MappingInstruction.class, MappingInstruction.Type.class);
    database = storageService.<MappingId, Mapping>consistentMapBuilder().withName("onos-mapping-database").withSerializer(serializer).build();
    cache = storageService.<MappingId, Mapping>consistentMapBuilder().withName("onos-mapping-cache").withSerializer(serializer).build();
    database.addListener(listener);
    cache.addListener(listener);
    databaseMap = database.asJavaMap();
    cacheMap = cache.asJavaMap();
    log.info("Started");
}
Also used : MappingId(org.onosproject.mapping.MappingId) MappingEvent(org.onosproject.mapping.MappingEvent) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) MappingAction(org.onosproject.mapping.actions.MappingAction) DefaultMapping(org.onosproject.mapping.DefaultMapping) Mapping(org.onosproject.mapping.Mapping) MappingInstruction(org.onosproject.mapping.instructions.MappingInstruction) Serializer(org.onosproject.store.service.Serializer) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with Mapping

use of org.onosproject.mapping.Mapping in project onos by opennetworkinglab.

the class MappingEntryCodecTest method testMappingEntryEncode.

/**
 * Tests encoding of a mapping entry object.
 */
@Test
public void testMappingEntryEncode() {
    MappingAddress address = MappingAddresses.ipv4MappingAddress(IPV4_PREFIX);
    MappingInstruction unicastWeight = MappingInstructions.unicastWeight(UNICAST_WEIGHT);
    MappingInstruction unicastPriority = MappingInstructions.unicastPriority(UNICAST_PRIORITY);
    MappingInstruction multicastWeight = MappingInstructions.multicastWeight(MULTICAST_WEIGHT);
    MappingInstruction multicastPriority = MappingInstructions.multicastPriority(MULTICAST_PRIORITY);
    MappingKey key = DefaultMappingKey.builder().withAddress(address).build();
    MappingTreatment treatment = DefaultMappingTreatment.builder().add(unicastWeight).add(unicastPriority).add(multicastWeight).add(multicastPriority).withAddress(address).build();
    MappingAction action = MappingActions.noAction();
    MappingValue value = DefaultMappingValue.builder().add(treatment).withAction(action).build();
    Mapping mapping = DefaultMapping.builder().withId(ID).forDevice(DEVICE_ID).withKey(key).withValue(value).build();
    MappingEntry entry = new DefaultMappingEntry(mapping, STATE);
    ObjectNode entryJson = entryCodec.encode(entry, context);
    assertThat(entryJson, MappingEntryJsonMatcher.matchesMappingEntry(entry));
}
Also used : MappingEntry(org.onosproject.mapping.MappingEntry) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MappingAction(org.onosproject.mapping.actions.MappingAction) DefaultMapping(org.onosproject.mapping.DefaultMapping) Mapping(org.onosproject.mapping.Mapping) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) DefaultMappingKey(org.onosproject.mapping.DefaultMappingKey) MappingKey(org.onosproject.mapping.MappingKey) MappingTreatment(org.onosproject.mapping.MappingTreatment) DefaultMappingTreatment(org.onosproject.mapping.DefaultMappingTreatment) DefaultMappingValue(org.onosproject.mapping.DefaultMappingValue) MappingValue(org.onosproject.mapping.MappingValue) MappingInstruction(org.onosproject.mapping.instructions.MappingInstruction) Test(org.junit.Test)

Example 3 with Mapping

use of org.onosproject.mapping.Mapping in project onos by opennetworkinglab.

the class DistributedMappingStoreTest method setUp.

/**
 * Sets up the storage service test harness.
 */
@Before
public void setUp() {
    mappingStore = new DistributedMappingStore();
    mappingStore.storageService = new TestStorageService();
    mappingStore.deviceService = new InternalDeviceServiceAdapter();
    mappingStore.setDelegate(event -> {
    });
    IpPrefix ipPrefix = IpPrefix.valueOf(IP_ADDRESS);
    MappingAddress address = MappingAddresses.ipv4MappingAddress(ipPrefix);
    MappingKey key = DefaultMappingKey.builder().withAddress(address).build();
    MappingAction action = MappingActions.noAction();
    MappingTreatment treatment = DefaultMappingTreatment.builder().withAddress(address).setUnicastPriority(10).setUnicastWeight(10).build();
    MappingValue value = DefaultMappingValue.builder().withAction(action).add(treatment).build();
    device1 = new MockDevice(ProviderId.NONE, DEVICE_ID_1, Device.Type.OTHER, "foo.inc", "0", "0", "0", null, DefaultAnnotations.builder().build());
    device2 = new MockDevice(ProviderId.NONE, DEVICE_ID_2, Device.Type.OTHER, "foo.inc", "0", "0", "0", null, DefaultAnnotations.builder().build());
    Mapping originalMapping1 = DefaultMapping.builder().forDevice(DEVICE_ID_1).withId(1000L).withKey(key).withValue(value).build();
    Mapping originalMapping2 = DefaultMapping.builder().forDevice(DEVICE_ID_2).withId(2000L).withKey(key).withValue(value).build();
    mapping1 = new DefaultMappingEntry(originalMapping1);
    mapping2 = new DefaultMappingEntry(originalMapping2);
    mappingStore.activate();
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) MappingAction(org.onosproject.mapping.actions.MappingAction) TestStorageService(org.onosproject.store.service.TestStorageService) DefaultMapping(org.onosproject.mapping.DefaultMapping) Mapping(org.onosproject.mapping.Mapping) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) DefaultMappingKey(org.onosproject.mapping.DefaultMappingKey) MappingKey(org.onosproject.mapping.MappingKey) MappingTreatment(org.onosproject.mapping.MappingTreatment) DefaultMappingTreatment(org.onosproject.mapping.DefaultMappingTreatment) DefaultMappingValue(org.onosproject.mapping.DefaultMappingValue) MappingValue(org.onosproject.mapping.MappingValue) Before(org.junit.Before)

Example 4 with Mapping

use of org.onosproject.mapping.Mapping in project onos by opennetworkinglab.

the class MappingManagerTest method removeMappingEntries.

/**
 * Tests removing mapping entries method.
 */
@Test
public void removeMappingEntries() {
    Mapping m1 = addMapping(MAP_DATABASE, 1);
    Mapping m2 = addMapping(MAP_DATABASE, 2);
    addMapping(MAP_DATABASE, 3);
    assertEquals("3 mappings should exist", 3, mappingCount(MAP_DATABASE));
    MappingEntry me1 = new DefaultMappingEntry(m1);
    MappingEntry me2 = new DefaultMappingEntry(m2);
    adminService.removeMappingEntries(MAP_DATABASE, me1, me2);
    assertEquals("1 mappings should exist", 1, mappingCount(MAP_DATABASE));
}
Also used : MappingEntry(org.onosproject.mapping.MappingEntry) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) DefaultMapping(org.onosproject.mapping.DefaultMapping) Mapping(org.onosproject.mapping.Mapping) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) Test(org.junit.Test)

Example 5 with Mapping

use of org.onosproject.mapping.Mapping in project onos by opennetworkinglab.

the class MappingManagerTest method storeMappingEntry.

/**
 * Tests storing mapping entry method.
 */
@Test
public void storeMappingEntry() {
    Mapping m1 = mapping(1, 1);
    Mapping m2 = mapping(2, 2);
    Mapping m3 = mapping(3, 3);
    MappingEntry me1 = new DefaultMappingEntry(m1);
    MappingEntry me2 = new DefaultMappingEntry(m2);
    MappingEntry me3 = new DefaultMappingEntry(m3);
    assertTrue("store should be empty", Sets.newHashSet(service.getMappingEntries(MAP_DATABASE, LISP_DID)).isEmpty());
    adminService.storeMappingEntry(MAP_DATABASE, me1);
    adminService.storeMappingEntry(MAP_DATABASE, me2);
    adminService.storeMappingEntry(MAP_DATABASE, me3);
    assertEquals("3 mappings should exist", 3, mappingCount(MAP_DATABASE));
}
Also used : MappingEntry(org.onosproject.mapping.MappingEntry) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) DefaultMapping(org.onosproject.mapping.DefaultMapping) Mapping(org.onosproject.mapping.Mapping) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) Test(org.junit.Test)

Aggregations

DefaultMapping (org.onosproject.mapping.DefaultMapping)6 Mapping (org.onosproject.mapping.Mapping)6 DefaultMappingEntry (org.onosproject.mapping.DefaultMappingEntry)5 MappingEntry (org.onosproject.mapping.MappingEntry)4 Test (org.junit.Test)3 MappingAction (org.onosproject.mapping.actions.MappingAction)3 MappingAddress (org.onosproject.mapping.addresses.MappingAddress)3 DefaultMappingKey (org.onosproject.mapping.DefaultMappingKey)2 DefaultMappingTreatment (org.onosproject.mapping.DefaultMappingTreatment)2 DefaultMappingValue (org.onosproject.mapping.DefaultMappingValue)2 MappingKey (org.onosproject.mapping.MappingKey)2 MappingTreatment (org.onosproject.mapping.MappingTreatment)2 MappingValue (org.onosproject.mapping.MappingValue)2 MappingInstruction (org.onosproject.mapping.instructions.MappingInstruction)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Before (org.junit.Before)1 IpPrefix (org.onlab.packet.IpPrefix)1 MappingEvent (org.onosproject.mapping.MappingEvent)1 MappingId (org.onosproject.mapping.MappingId)1 Serializer (org.onosproject.store.service.Serializer)1