private DataObject read(final InstanceIdentifier<?> id) { try { return this.t.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet().get(); } catch (ReadFailedException | IllegalStateException e) { throw new IllegalStateException("Failed to read data.", e); } }
private static <T extends DataObject> T read(final ReadTransaction t, final InstanceIdentifier<T> id) { final Optional<T> o; try { o = t.read(LogicalDatastoreType.OPERATIONAL, id).get(); } catch (InterruptedException | ExecutionException e) { LOG.warn("Failed to read {}, assuming non-existent", id, e); return null; } return o.orNull(); }
public static <T extends DataObject> Optional<T> readFromDs(InstanceIdentifier<T> path, ReadTransaction rTx) { CheckedFuture<Optional<T>, ReadFailedException> resultFuture = rTx.read(logicalDatastoreType, path); try { return resultFuture.checkedGet(); } catch (ReadFailedException e) { LOG.warn("Read failed from DS.", e); return Optional.absent(); } }
private static <T extends DataObject> T getDataObject(final ReadTransaction readOnlyTransaction, final InstanceIdentifier<T> identifier) { Optional<T> optionalData = null; try { optionalData = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, identifier).get(); if (optionalData.isPresent()) { return optionalData.get(); } } catch (ExecutionException | InterruptedException e) { LOG.error("Read transaction for identifier {} failed.", identifier, e); } return null; }
public static <T extends DataObject> Optional<T> syncReadOper(ReadTransaction rt, InstanceIdentifier<T> path) { Optional<T> opt; try { opt = rt.read(LogicalDatastoreType.OPERATIONAL, path).get(); } catch (InterruptedException | ExecutionException e) { LOG.error("unexcepte exception", e); opt = Optional.absent(); } return opt; }
private static <T extends DataObject> T getDataObject(final ReadTransaction readOnlyTransaction, final InstanceIdentifier<T> identifier) { Optional<T> optionalData = null; try { optionalData = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, identifier).get(); if (optionalData.isPresent()) { return optionalData.get(); } } catch (ExecutionException | InterruptedException e) { LOG.error("Read transaction for identifier {} failed.", identifier, e); } return null; }
public static <T extends DataObject> T getDataObject(ReadTransaction readOnlyTransaction, InstanceIdentifier<T> identifier) { Optional<T> optionalData = null; try { optionalData = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, identifier).get(); if (optionalData.isPresent()) { return optionalData.get(); } } catch (ExecutionException | InterruptedException e) { LOG.error("Read transaction for identifier {} failed.", identifier, e); } return null; }
private <T extends DataObject> T readMd(InstanceIdentifier<T> path, ReadTransaction tx) { Preconditions.checkNotNull(tx); T result = null; final CheckedFuture<Optional<T>, ReadFailedException> future = tx.read(LogicalDatastoreType.CONFIGURATION, path); if (future != null) { Optional<T> optional; try { optional = future.checkedGet(); if (optional.isPresent()) { result = optional.get(); } } catch (final ReadFailedException e) { LOGGER.warn("Failed to read {}", path, e); } } return result; }
/** * Read data from the given MD-SAL datastore at the given path. * * @param rtx A read transaction. * @param store A {@link LogicalDatastoreType} which specifies the type * of logical datastore. * @param path An {@link InstanceIdentifier} instance which specifies * data to be read. * @param <T> Type of data to be read. * @return An {@link Optional} instance that contains the result. * @throws VTNException Failed to read data. */ public static <T extends DataObject> Optional<T> read( ReadTransaction rtx, LogicalDatastoreType store, InstanceIdentifier<T> path) throws VTNException { return read(rtx.read(store, path)); }
/** * Read data from the given MD-SAL data store at the given path. * * @param rtx A read transaction. * @param store A {@link LogicalDatastoreType} which specifies the type * of logical datastore. * @param path An {@link InstanceIdentifier} instance which specifies * data to be read. * @param <T> Type of data to be read. * @return An {@link Optional} instance that contains the result. * {@code null} if no data is present. * @throws IllegalStateException * Failed to read data. */ public static <T extends DataObject> Optional<T> read( ReadTransaction rtx, LogicalDatastoreType store, InstanceIdentifier<T> path) { return read(rtx.read(store, path)); }
public static <T extends DataObject> Optional<T> read(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) throws ExecutionException, InterruptedException, TimeoutException { ReadTransaction tx = broker.newReadOnlyTransaction(); CheckedFuture<?,?> result = tx.read(datastoreType, path); try { return (Optional<T>) result.get(); } catch (Exception e) { LOG.error("DataStore read exception {} ", e); } return Optional.absent(); }
public static IrdInstance readInstance(ResourceId instanceId, ReadTransaction rx) throws InterruptedException, ExecutionException { InstanceIdentifier<IrdInstance> iid = getInstanceIID(instanceId); Optional<IrdInstance> instance = rx.read(LogicalDatastoreType.OPERATIONAL, iid).get(); if (instance.isPresent()) { return instance.get(); } return null; }
/** * Executes read as a blocking transaction. * * @param rtx Readable transaction for MD-SAL datastore. * @param store {@link LogicalDatastoreType} to read * @param path {@link InstanceIdentifier} for path to read * @param <D> The data object type * @return An {@link Optional} instance that contains the result. * @throws ReadFailedException * Datastore read failed. * @throws TimeoutException * Read operation timed out. */ private static <D extends DataObject> Optional<D> readImpl( final ReadTransaction rtx, final LogicalDatastoreType store, final InstanceIdentifier<D> path) throws ReadFailedException, TimeoutException { CheckedFuture<Optional<D>, ReadFailedException> future = rtx.read(store, path); return future.checkedGet(READ_TIMEOUT, TimeUnit.SECONDS); }
public static <T extends DataObject> Optional<T> syncReadOper(DataBroker db, InstanceIdentifier<T> path) { Optional<T> opt; try { ReadTransaction rt = db.newReadOnlyTransaction(); opt = rt.read(LogicalDatastoreType.OPERATIONAL, path).get(); } catch (InterruptedException | ExecutionException e) { LOG.error("unexcepte exception", e); opt = Optional.absent(); } return opt; } }
public static boolean contextExists(ContextKey key, ReadTransaction rx) throws InterruptedException, ExecutionException { Optional<Context> context; context = rx.read(LogicalDatastoreType.OPERATIONAL, getContextIID(key)).get(); return (context.isPresent()); }
public static boolean resourceExists(Uuid cid, ResourceId rid, ReadTransaction rx) throws InterruptedException, ExecutionException { InstanceIdentifier<Resource> iid = getResourceIID(cid, rid); Optional<Resource> resource; resource = rx.read(LogicalDatastoreType.OPERATIONAL, iid).get(); return (resource.isPresent()); }
/** * Start read operation, and add a new callback for the operation. * * @param path Path to the flow index. */ private IndexCallback(InstanceIdentifier<T> path) { ReadTransaction rtx = getTxContext().getTransaction(); LogicalDatastoreType oper = LogicalDatastoreType.OPERATIONAL; Futures.addCallback(rtx.read(oper, path), this); }
private boolean isFlowTopologyExist(final DataBroker dataBroker, final InstanceIdentifier<Topology> path) { final ReadTransaction tx = dataBroker.newReadOnlyTransaction(); try { Optional<Topology> ofTopology = tx.read(LogicalDatastoreType.OPERATIONAL, path).checkedGet(); LOG.debug("OpenFlow topology exist in the operational data store at {}",path); if(ofTopology.isPresent()){ return true; } } catch (ReadFailedException e) { LOG.warn("OpenFlow topology read operation failed!", e); } return false; } }
private List<DeviceTypeInfo> readDeviceTypeInfoFromMdsalDataStore() { ReadTransaction readTx = dataBroker.newReadOnlyTransaction(); try { Optional<DeviceTypes> data = readTx.read(LogicalDatastoreType.CONFIGURATION, DEVICE_TYPES_IID).get(); if (data.isPresent()) { DeviceTypes devTypes = data.get(); return devTypes.getDeviceTypeInfo(); } } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to read Device Info from data store", e); } return new ArrayList<>(0); }
public static <T extends DataObject> Optional<T> readData(final LogicalDatastoreType storeType, final InstanceIdentifier<T> path) { final ReadTransaction tx = FabMgrDatastoreDependency.getDataProvider().newReadOnlyTransaction(); CheckedFuture<Optional<T>, ReadFailedException> resultFuture = tx.read(storeType, path); try { return resultFuture.checkedGet(); } catch (ReadFailedException e) { LOG.error("FABMGR: ERROR: Read failed from DS.", e); return Optional.absent(); } }