Search in sources :

Example 21 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.MonitorId in project genius by opendaylight.

the class AlivenessMonitorUtils method createOrUpdateMonitorIdInterfaceMap.

private static void createOrUpdateMonitorIdInterfaceMap(ReadWriteTransaction tx, String infName, long monitorId) throws ReadFailedException {
    MonitorIdInterface monitorIdInterfaceInstance;
    String existinginterfaceName;
    MonitorIdInterfaceBuilder monitorIdInterfaceBuilder = new MonitorIdInterfaceBuilder();
    InstanceIdentifier<MonitorIdInterface> id = InstanceIdentifier.builder(MonitorIdInterfaceMap.class).child(MonitorIdInterface.class, new MonitorIdInterfaceKey(monitorId)).build();
    Optional<MonitorIdInterface> monitorIdInterfaceMap = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
    if (monitorIdInterfaceMap.isPresent()) {
        monitorIdInterfaceInstance = monitorIdInterfaceMap.get();
        existinginterfaceName = monitorIdInterfaceInstance.getInterfaceName();
        if (!existinginterfaceName.equals(infName)) {
            monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
        }
    } else {
        monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setMonitorId(monitorId).setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
        tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
    }
}
Also used : MonitorIdInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceBuilder) MonitorIdInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterface) MonitorIdInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceKey)

Aggregations

Optional (com.google.common.base.Optional)10 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 EtherTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes)7 MonitorProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 ArrayList (java.util.ArrayList)5 ExecutionException (java.util.concurrent.ExecutionException)5 MonitorStartInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInput)5 MonitorStartOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartOutput)5 MonitorStopInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInput)5 FutureCallback (com.google.common.util.concurrent.FutureCallback)4 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 List (java.util.List)4 Future (java.util.concurrent.Future)4 Nonnull (javax.annotation.Nonnull)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4