Search in sources :

Example 1 with PiPreEntryHandle

use of org.onosproject.net.pi.runtime.PiPreEntryHandle in project onos by opennetworkinglab.

the class P4RuntimeReplicationGroupProgrammable method processGroupOp.

private void processGroupOp(Group pdGroup, GroupOperation.Type opType) {
    final PiPreEntry preEntry;
    try {
        preEntry = translator.translate(pdGroup, pipeconf);
    } catch (PiTranslationException e) {
        log.warn("Unable to translate replication group, aborting {} operation: {} [{}]", opType, e.getMessage(), pdGroup);
        return;
    }
    final PiPreEntryHandle handle = (PiPreEntryHandle) preEntry.handle(deviceId);
    final PiPreEntry entryOnDevice = mirror.get(handle) == null ? null : mirror.get(handle).entry();
    final Lock lock = STRIPED_LOCKS.get(handle);
    lock.lock();
    try {
        processPreEntry(handle, preEntry, entryOnDevice, pdGroup, opType);
    } finally {
        lock.unlock();
    }
}
Also used : PiPreEntryHandle(org.onosproject.net.pi.runtime.PiPreEntryHandle) PiPreEntry(org.onosproject.net.pi.runtime.PiPreEntry) PiTranslationException(org.onosproject.net.pi.service.PiTranslationException) Lock(java.util.concurrent.locks.Lock)

Example 2 with PiPreEntryHandle

use of org.onosproject.net.pi.runtime.PiPreEntryHandle in project onos by opennetworkinglab.

the class P4RuntimeReplicationGroupProgrammable method forgeGroupEntry.

private Group forgeGroupEntry(PiPreEntry preEntry) {
    final PiPreEntryHandle handle = (PiPreEntryHandle) preEntry.handle(deviceId);
    final Optional<PiTranslatedEntity<Group, PiPreEntry>> translatedEntity = translator.lookup(handle);
    final TimedEntry<PiPreEntry> timedEntry = mirror.get(handle);
    // Is entry consistent with our state?
    if (!translatedEntity.isPresent()) {
        log.warn("PRE entry handle not found in translation store: {}", handle);
        return null;
    }
    if (timedEntry == null) {
        log.warn("PRE entry handle not found in device mirror: {}", handle);
        return null;
    }
    return addedGroup(translatedEntity.get().original(), timedEntry.lifeSec());
}
Also used : PiTranslatedEntity(org.onosproject.net.pi.service.PiTranslatedEntity) PiPreEntryHandle(org.onosproject.net.pi.runtime.PiPreEntryHandle) PiPreEntry(org.onosproject.net.pi.runtime.PiPreEntry)

Aggregations

PiPreEntry (org.onosproject.net.pi.runtime.PiPreEntry)2 PiPreEntryHandle (org.onosproject.net.pi.runtime.PiPreEntryHandle)2 Lock (java.util.concurrent.locks.Lock)1 PiTranslatedEntity (org.onosproject.net.pi.service.PiTranslatedEntity)1 PiTranslationException (org.onosproject.net.pi.service.PiTranslationException)1