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; }
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; }
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 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(); } }
Optional<Service> readConfigService(final ServiceKey serviceKey, final ReadTransaction rTx) throws ReadFailedException { Preconditions.checkNotNull(serviceKey.getType(), "Supplied serviceKey Type may not be null"); return rTx.read(LogicalDatastoreType.CONFIGURATION, SERVICES_IID.child(Service.class, serviceKey)).checkedGet(); }
private Map<Name, Endpoint> readEpsWithOfOverlayAugByPortName(ReadTransaction rTx) { Optional<Endpoints> potentialEps = Futures.getUnchecked(rTx.read(LogicalDatastoreType.OPERATIONAL, endpointsIid)); if (!potentialEps.isPresent() || potentialEps.get().getEndpoint() == null) { return Collections.emptyMap(); } Map<Name, Endpoint> epsByPortName = new HashMap<>(); for (Endpoint ep : potentialEps.get().getEndpoint()) { OfOverlayContext ofOverlayEp = ep.getAugmentation(OfOverlayContext.class); if (ofOverlayEp != null && ofOverlayEp.getPortName() != null) { epsByPortName.put(ofOverlayEp.getPortName(), ep); } } return epsByPortName; }
private CheckedFuture<Optional<ServiceFunctionForwarders>, ReadFailedException> readServiceFunctionForwarders() { ReadTransaction rTx = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<ServiceFunctionForwarders> sffIid = InstanceIdentifier.builder( ServiceFunctionForwarders.class).build(); return rTx.read(LogicalDatastoreType.CONFIGURATION, sffIid); }
Optional<Module> readModuleConfiguration(final ModuleKey moduleKey, final ReadTransaction rTx) throws ReadFailedException { checkModuleKey(moduleKey); return rTx.read(LogicalDatastoreType.CONFIGURATION, MODULES_IID.child(Module.class, moduleKey)).checkedGet(); }
public static Optional<Node> sourceNode(final ReadTransaction t, final InstanceIdentifier<Topology> topology, final Link link) throws ReadFailedException { return t.read(LogicalDatastoreType.OPERATIONAL, topology.child(Node.class, new NodeKey(link.getSource().getSourceNode()))).checkedGet(); } }