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);
}
});
}
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());
}
}
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;
}
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);
}
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();
}
Aggregations