IrdInstance getInstance(ResourceId rid) { ReadTransaction rx = m_dataBroker.newReadOnlyTransaction(); try { return SimpleIrdUtils.readInstance(rid, rx); } catch (Exception e) { return null; } }
/** * {@inheritDoc} */ @Override public ReadTransaction getTransaction() { ReadOnlyTransaction tx = transaction; if (tx == null) { tx = vtnProvider.getDataBroker().newReadOnlyTransaction(); transaction = tx; } return tx; }
@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); } } }
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; }
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; }
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; }
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); } return result; }
@VisibleForTesting L3Context readL3ContextInstance(TenantId tenantId, L3ContextId l3cId) { ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); InstanceIdentifier<L3Context> iid = IidFactory.l3ContextIid(tenantId, l3cId); Optional<L3Context> l2Op = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, iid, rTx); if (!l2Op.isPresent()) { LOG.error("Couldn't find L3 Context Domain {} which belongs to Tenant {}", l3cId, tenantId); rTx.close(); return null; } return l2Op.get(); }
public static TenantLogicalNetwork readTenantsLogicalNetworksFromDs() { ReadTransaction t = UlnMapperDatastoreDependency.getDataProvider().newReadOnlyTransaction(); Optional<TenantLogicalNetwork> potentialSubnet = readFromDs(UlnIidFactory.tenantsLogicalNetworksIid(), t); if (!potentialSubnet.isPresent()) { LOG.debug("No Tenants Logical Networks exist in Datastore."); return null; } return potentialSubnet.get(); }
public Subnet readSubnet(SubnetId subnetId, TenantId tenantId) { ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); InstanceIdentifier<Subnet> iid = IidFactory.subnetIid(tenantId, subnetId); Optional<Subnet> subnetOp = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, iid, rTx); if (!subnetOp.isPresent()) { LOG.warn("Couldn't find Subnet {} which belongs to Tenant {}", subnetId, tenantId); rTx.close(); return null; } return subnetOp.get(); }
private Optional<OfOverlayConfig> readConfig() { final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); Optional<OfOverlayConfig> config = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, configIid, rTx); rTx.close(); return config; }
protected <T extends DataObject> T readMd(InstanceIdentifier<T> path) { try (ReadOnlyTransaction tx = getDataBroker().newReadOnlyTransaction()) { return readMd(path, tx); } }
@Override public List<S> getAll() { try (ReadOnlyTransaction tx = getDataBroker().newReadOnlyTransaction()) { return getAll(tx); } }
public static TenantLogicalNetwork readTenantLogicalNetworkFromDs(Uuid tenantId) { ReadTransaction t = UlnMapperDatastoreDependency.getDataProvider().newReadOnlyTransaction(); Optional<TenantLogicalNetwork> potentialSubnet = readFromDs(UlnIidFactory.tenantLogicalNetworkIid(tenantId), t); if (!potentialSubnet.isPresent()) { LOG.debug("Tenant {} Logical Network does not exist.", tenantId.getValue()); return null; } return potentialSubnet.get(); }
private List<Node> getNodes() { ReadOnlyTransaction readOnlyTransaction = dataProviderService .newReadOnlyTransaction(); InstanceIdentifier<Nodes> nodesID = InstanceIdentifier.create(Nodes.class); Nodes nodes = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodesID); if (nodes == null) { throw new RuntimeException("nodes are not found, pls add the node."); } return nodes.getNode(); }
public static Port readPortFromDs(Uuid tenantId, Uuid portId) { ReadTransaction t = UlnMapperDatastoreDependency.getDataProvider().newReadOnlyTransaction(); Optional<Port> potentialPort = readFromDs(UlnIidFactory.portIid(tenantId, portId), t); if (!potentialPort.isPresent()) { LOG.debug("Logical Port {} does not exist in tenant {}.", portId.getValue(), tenantId.getValue()); return null; } return potentialPort.get(); }
public static EndpointLocation readEndpointLocationFromDs(Uuid tenantId, Uuid endpointLocationId) { ReadTransaction t = UlnMapperDatastoreDependency.getDataProvider().newReadOnlyTransaction(); Optional<EndpointLocation> potentialEndpointLocation = readFromDs( UlnIidFactory.endpointLocationIid(tenantId, endpointLocationId), t); if (!potentialEndpointLocation.isPresent()) { LOG.debug("Logical EndpointLocation {} does not exist in tenant {}.", endpointLocationId.getValue(), tenantId.getValue()); return null; } return potentialEndpointLocation.get(); }
public static LogicalRouter readLogicalRouterFromDs(Uuid tenantId, Uuid routerId) { ReadTransaction t = UlnMapperDatastoreDependency.getDataProvider().newReadOnlyTransaction(); Optional<LogicalRouter> potentialRouter = readFromDs(UlnIidFactory.logicalRouterIid(tenantId, routerId), t); if (!potentialRouter.isPresent()) { LOG.debug("Logical Router {} does not exist in tenant {}.", routerId.getValue(), tenantId.getValue()); return null; } return potentialRouter.get(); }
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(); } }
public void onNeighborModified(final Neighbor modifiedNeighbor) { final ModuleKey moduleKey = this.neighborState.getModuleKey(modifiedNeighbor.getKey()); final ReadOnlyTransaction rTx = this.dataBroker.newReadOnlyTransaction(); final List<AdvertizedTable> advertizedTables = getAdvertizedTables(modifiedNeighbor, rTx); final List<AddPath> addPathCapabilities = getAddPathCapabilities(modifiedNeighbor, rTx); if (moduleKey != null) { updateExistingPeerConfiguration(moduleKey, modifiedNeighbor, advertizedTables, rTx, addPathCapabilities); } else { createNewPeerConfiguration(moduleKey, modifiedNeighbor, advertizedTables, rTx, addPathCapabilities); } }