Search in sources :

Example 76 with ReadFailedException

use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.

the class HwvtepNodeBaseListener method onDataTreeChanged.

@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
    HAJobScheduler.getInstance().submitJob(() -> {
        ReadWriteTransaction tx = getTx();
        try {
            processConnectedNodes(changes, tx);
            processUpdatedNodes(changes, tx);
            processDisconnectedNodes(changes, tx);
            tx.submit().get();
        } catch (InterruptedException | ExecutionException | ReadFailedException e) {
            LOG.error("Error processing data-tree changes", e);
        }
    });
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Example 77 with ReadFailedException

use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.

the class VpnInstanceListener method remove.

@Override
protected void remove(InstanceIdentifier<VpnInstance> identifier, VpnInstance del) {
    LOG.trace("{} remove: VPN event key: {}, value: {}", LOGGING_PREFIX_DELETE, identifier, del);
    final String vpnName = del.getVpnInstanceName();
    Optional<VpnInstanceOpDataEntry> vpnOpValue;
    String primaryRd = VpnUtil.getPrimaryRd(del);
    // TODO(vpnteam): Entire code would need refactoring to listen only on the parent object - VPNInstance
    try {
        vpnOpValue = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd));
    } catch (ReadFailedException e) {
        LOG.error("{} remove: Exception when attempting to retrieve VpnInstanceOpDataEntry for VPN {}. ", LOGGING_PREFIX_DELETE, vpnName, e);
        return;
    }
    if (!vpnOpValue.isPresent()) {
        LOG.error("{} remove: Unable to retrieve VpnInstanceOpDataEntry for VPN {}. ", LOGGING_PREFIX_DELETE, vpnName);
        return;
    } else {
        jobCoordinator.enqueueJob("VPN-" + vpnName, () -> {
            VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder().setVrfId(primaryRd).setVpnState(VpnInstanceOpDataEntry.VpnState.PendingDelete);
            InstanceIdentifier<VpnInstanceOpDataEntry> id = VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd);
            WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
            writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build());
            LOG.info("{} call: Operational status set to PENDING_DELETE for vpn {} with rd {}", LOGGING_PREFIX_DELETE, vpnName, primaryRd);
            return Collections.singletonList(writeTxn.submit());
        }, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder)

Example 78 with ReadFailedException

use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.

the class L2GwValidateCli method doExecute.

@Override
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public Object doExecute() throws Exception {
    try {
        pw = new PrintWriter(new FileOutputStream(new File("l2gw.validation.txt")));
        readNodes();
        verifyHANodes();
        verifyConfigVsOperationalDiff();
        verifyL2GatewayConnections();
        pw.close();
    } catch (ReadFailedException e) {
        session.getConsole().println("Failed with error " + e.getMessage());
        LOG.error("Failed with error ", e);
    }
    return null;
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) FileOutputStream(java.io.FileOutputStream) File(java.io.File) PrintWriter(java.io.PrintWriter) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 79 with ReadFailedException

use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.

the class EvpnUtils method getExternalTunnelList.

public Optional<ExternalTunnelList> getExternalTunnelList() {
    InstanceIdentifier<ExternalTunnelList> externalTunnelListId = getExternaTunnelListIdentifier();
    ExternalTunnelList externalTunnelList = null;
    try {
        externalTunnelList = elanUtils.read2(LogicalDatastoreType.CONFIGURATION, externalTunnelListId).orNull();
    } catch (ReadFailedException e) {
        LOG.error("getExternalTunnelList: unable to read ExternalTunnelList, exception ", e);
    }
    return Optional.fromNullable(externalTunnelList);
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)

Example 80 with ReadFailedException

use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.

the class StatisticsImpl method getElementCountersByHandler.

@Override
public Future<RpcResult<GetElementCountersByHandlerOutput>> getElementCountersByHandler(GetElementCountersByHandlerInput input) {
    InstanceIdentifier<CounterRequests> ingressPath = InstanceIdentifier.builder(IngressElementCountersRequestConfig.class).child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
    InstanceIdentifier<CounterRequests> egressPath = InstanceIdentifier.builder(EgressElementCountersRequestConfig.class).child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
    ReadOnlyTransaction tx = db.newReadOnlyTransaction();
    CheckedFuture<Optional<CounterRequests>, ReadFailedException> ingressRequestData = tx.read(LogicalDatastoreType.CONFIGURATION, ingressPath);
    CheckedFuture<Optional<CounterRequests>, ReadFailedException> egressRequestData = tx.read(LogicalDatastoreType.CONFIGURATION, egressPath);
    List<CounterResult> counters = new ArrayList<>();
    try {
        if (!ingressRequestData.get().isPresent() && !egressRequestData.get().isPresent()) {
            LOG.warn("Handler does not exists");
            return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "Handler does not exists").buildFuture();
        }
        if (ingressRequestData.get().isPresent()) {
            CounterRequests ingressCounterRequest = ingressRequestData.get().get();
            CounterResultDataStructure ingressCounterResultDS = createElementCountersResult(ingressCounterRequest);
            if (ingressCounterResultDS == null) {
                LOG.warn("Unable to get counter results");
                StatisticsPluginImplCounters.failed_getting_counter_results.inc();
                return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "Unable to get counter results").buildFuture();
            }
            createCounterResults(counters, ingressCounterResultDS, CountersServiceUtils.INGRESS_COUNTER_RESULT_ID);
        }
        if (egressRequestData.get().isPresent()) {
            CounterRequests egressCounterRequest = egressRequestData.get().get();
            CounterResultDataStructure egressCounterResultDS = createElementCountersResult(egressCounterRequest);
            if (egressCounterResultDS == null) {
                LOG.warn("Unable to get counter results");
                StatisticsPluginImplCounters.failed_getting_counter_results.inc();
                return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "Unable to get counter results").buildFuture();
            }
            createCounterResults(counters, egressCounterResultDS, CountersServiceUtils.EGRESS_COUNTER_RESULT_ID);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("failed to get counter request data from DB");
        return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
    }
    GetElementCountersByHandlerOutputBuilder gecbhob = new GetElementCountersByHandlerOutputBuilder();
    gecbhob.setCounterResult(counters);
    return RpcResultBuilder.success(gecbhob.build()).buildFuture();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) GetElementCountersByHandlerOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetElementCountersByHandlerOutput) GetElementCountersByHandlerOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetElementCountersByHandlerOutputBuilder) Optional(com.google.common.base.Optional) CounterRequestsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequestsKey) ArrayList(java.util.ArrayList) CounterRequests(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequests) CounterResult(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)129 Optional (com.google.common.base.Optional)44 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)30 ArrayList (java.util.ArrayList)25 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)23 ExecutionException (java.util.concurrent.ExecutionException)17 Test (org.junit.Test)16 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)10 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)10 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)9 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)9 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)8 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)8 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)7 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)6 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)6