public <T extends DataObject> Optional<T> read2(LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) throws ReadFailedException { ReadOnlyTransaction tx = broker.newReadOnlyTransaction(); try { CheckedFuture<Optional<T>, ReadFailedException> checkedFuture = tx.read(datastoreType, path); return checkedFuture.checkedGet(); } finally { tx.close(); } }
@Override public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final InstanceIdentifier<?> path) { return delegate.exists(store, path); }
@Override public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(final LogicalDatastoreType store, final InstanceIdentifier<T> path) { return delegate.read(store, path); }
@Override public void close() { delegate.close(); } }
<T extends DataObject> ListenableFuture<Optional<T>> readOperationalData(final InstanceIdentifier<T> id) { try (final ReadOnlyTransaction t = chain.newReadOnlyTransaction()) { return t.read(LogicalDatastoreType.OPERATIONAL, id); } }
/** * Close the MD-SAL DS transaction. */ @Override public void close() { if (localTx != null) { localTx.close(); } } }
private <T extends DataObject> Optional<T> read(LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) { ReadOnlyTransaction tx = broker.newReadOnlyTransaction(); Optional<T> result = Optional.absent(); try { result = tx.read(datastoreType, path).get(); } catch (InterruptedException | ExecutionException e) { LOG.warn("Error reading data from path {} in datastore {}", path, datastoreType, e); } finally { tx.close(); } return result; }
/** * Create read transaction with callback to look up * the Action Definition that the Action Instance * references. */ @Override public void run() { ReadOnlyTransaction rot = dataBroker.newReadOnlyTransaction(); ListenableFuture<Optional<ActionDefinition>> dao = rot.read(LogicalDatastoreType.OPERATIONAL, adIid); Futures.addCallback(dao, this, executor); }
@Override public void onFailure(final Throwable t) { rTx.close(); } };
public static <T extends DataObject> Optional<T> read(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) { ReadOnlyTransaction tx = broker.newReadOnlyTransaction(); Optional<T> result = Optional.absent(); try { result = tx.read(datastoreType, path).get(); } catch (Exception e) { throw new RuntimeException(e); } finally { tx.close(); } return result; }
@Override public <T extends DataObject> Optional<T> read(@Nonnull final InstanceIdentifier<T> currentId) { try (ReadOnlyTransaction tx = contextBindingBrokerDependency.newReadOnlyTransaction()) { try { return tx.read(LogicalDatastoreType.OPERATIONAL, currentId).checkedGet(); } catch (ReadFailedException e) { throw new IllegalStateException("Unable to perform read of " + currentId, e); } } }
/** * Close this datastore transaction. */ @Override public void close() { ReadOnlyTransaction tx = transaction; transaction = null; if (tx != null) { tx.close(); } } }
private <T extends DataObject> Optional<T> read(LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) { ReadOnlyTransaction tx = dataService.newReadOnlyTransaction(); Optional<T> result = Optional.absent(); try { result = tx.read(datastoreType, path).get(); } catch (Exception e) { throw new RuntimeException(e); } tx.close(); return result; } }
private <T extends DataObject> Optional<T> read(LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) { ReadOnlyTransaction tx = broker.newReadOnlyTransaction(); Optional<T> result = Optional.absent(); try { result = tx.read(datastoreType, path).get(); } catch (Exception e) { throw new RuntimeException(e); } return result; }
@Override public void onFailure(final Throwable t) { LOG.error("Can not notify existing nodes", t); tx.close(); }
private Node readNodeInfo(DataBroker dataService, InstanceIdentifier<Node> id) { Node node = null; ReadOnlyTransaction readTx = dataService.newReadOnlyTransaction(); try { Optional<Node> nodeOpt = null; nodeOpt = readTx.read(LogicalDatastoreType.OPERATIONAL, id).get(); if(nodeOpt.isPresent()) { node = (Node) nodeOpt.get(); } } catch(Exception e) { LOG.error("Failed to read node from data store.", e.getMessage()); readTx.close(); } readTx.close(); return node; }
public boolean isActivatable() { ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction(); try { CheckedFuture<Optional<ForwardingConstruct>, ReadFailedException> result = tx.read(LogicalDatastoreType.OPERATIONAL, fcIid); Optional<ForwardingConstruct> fcOptional = result.checkedGet(); return !fcOptional.isPresent(); } catch (ReadFailedException e) { LOG.warn("Error during forwarding construct activation state checking", e); } return false; }
@Override public void onSuccess(@Nullable final Optional<?> result) { rTx.close(); }
public static <T extends DataObject> T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid) { Preconditions.checkNotNull(dataBroker); ReadOnlyTransaction readTransaction = dataBroker.newReadOnlyTransaction(); try { Optional<T> optionalData = readTransaction.read(dataStoreType, iid).get(); if (optionalData.isPresent()) { return (T)optionalData.get(); } } catch (ExecutionException | InterruptedException e) { logger.error("Read transaction for identifier {} failed with error {}", iid, e.getMessage()); readTransaction.close(); } return null; } }
private <T extends DataObject> Optional<T> read(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) { ReadOnlyTransaction tx = broker.newReadOnlyTransaction(); Optional<T> result = Optional.absent(); try { result = tx.read(datastoreType, path).get(); } catch (Exception e) { throw new RuntimeException(e); } return result; }