private static ListenableFuture<Optional<Node>> readNodeData( final LogicalDatastoreType store, final ReadWriteTransaction transaction, final InstanceIdentifier<Node> path) { return transaction.read(store, path); }
@Override public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(final LogicalDatastoreType store, final InstanceIdentifier<T> path) { return delegate.read(store, path); }
private ListenableFuture<Void> deleteTableIfExists(final ReadWriteTransaction rwTx, final InstanceIdentifier<Table> tablePath) { return Futures.transform(rwTx.read(LogicalDatastoreType.CONFIGURATION, tablePath), new Function<Optional<Table>, Void>() { @Override public Void apply(Optional<Table> optTable) { if (optTable.isPresent()) { rwTx.delete(LogicalDatastoreType.CONFIGURATION, tablePath); } return null; } }); }
@Override public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) { try { return delegate.read(LogicalDatastoreType.OPERATIONAL, path).get().orNull(); } catch (InterruptedException | ExecutionException e) { LOG.error("Read of {} failed.", path,e); return null; } }
private Optional<Node> readNode(final ReadWriteTransaction transaction, final InstanceIdentifier<Node> nodePath) { Optional<Node> node = Optional.absent(); try { node = transaction.read( LogicalDatastoreType.OPERATIONAL, nodePath) .checkedGet(); } catch (final ReadFailedException e) { LOG.warn("Read Operational/DS for Node fail! {}", nodePath, e); } return node; }
@Override public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) { try { return delegate.read(LogicalDatastoreType.CONFIGURATION, path).get().orNull(); } catch (InterruptedException | ExecutionException e) { LOG.error("Read of {} failed.", path,e); return null; } }
public static <D extends org.opendaylight.yangtools.yang.binding.DataObject> Optional<D> readNode( ReadWriteTransaction transaction, final InstanceIdentifier<D> connectionIid) { Optional<D> node = Optional.absent(); try { node = transaction.read(LogicalDatastoreType.OPERATIONAL, connectionIid).checkedGet(); } catch (final ReadFailedException e) { LOG.warn("Read Operational/DS for Node failed! {}", connectionIid, e); } return node; }
@Override public <T extends DataObject> Optional<T> read(@Nonnull final InstanceIdentifier<T> currentId) { try { return readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, currentId).checkedGet(); } catch (ReadFailedException e) { throw new IllegalStateException("Unable to perform read", e); } }
static void removeAffectedLinks(final NodeId id, final ReadWriteTransaction transaction, InstanceIdentifier<Topology> topology) { Optional<Topology> topologyOptional = Optional.absent(); try { topologyOptional = transaction.read(LogicalDatastoreType.OPERATIONAL, topology).checkedGet(); } catch (ReadFailedException e) { LOG.warn("Error reading topology data for topology {}: {}", topology, e.getMessage()); LOG.debug("Error reading topology data for topology.. ", e); } if (topologyOptional.isPresent()) { removeAffectedLinks(id, topologyOptional, transaction, topology); } }
static void removeAffectedLinks(final TpId id, final ReadWriteTransaction transaction, final InstanceIdentifier<Topology> topology) { Optional<Topology> topologyOptional = Optional.absent(); try { topologyOptional = transaction.read(LogicalDatastoreType.OPERATIONAL, topology).checkedGet(); } catch (ReadFailedException e) { LOG.warn("Error reading topology data for topology {}: {}", topology, e.getMessage()); LOG.debug("Error reading topology data for topology..", e); } if (topologyOptional.isPresent()) { removeAffectedLinks(id, topologyOptional, transaction, topology); } }
private Optional<TerminationPoint> readTp() throws Exception { if (lportIid != null) { ReadWriteTransaction trans = databroker.newReadWriteTransaction(); return trans.read(LogicalDatastoreType.OPERATIONAL, lportIid).get(); } else { return Optional.absent(); } } }
private Optional<TerminationPoint> readTp() throws Exception { if (lportIid != null) { ReadWriteTransaction trans = databroker.newReadWriteTransaction(); return trans.read(LogicalDatastoreType.OPERATIONAL, lportIid).get(); } else { return Optional.absent(); } }
@Override public void applyOperation(final ReadWriteTransaction transaction) { Optional<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> nodeOptional = Optional.absent(); try { nodeOptional = transaction.read(LogicalDatastoreType.OPERATIONAL, node).checkedGet(); } catch (ReadFailedException e) { LOG.warn("Error occured when trying to read NodeConnector: {}", e.getMessage()); LOG.debug("Error occured when trying to read NodeConnector.. ", e); } if (nodeOptional.isPresent()) { TopologyManagerUtil.removeAffectedLinks(terminationPointId, transaction, II_TO_TOPOLOGY); transaction.delete(LogicalDatastoreType.OPERATIONAL, iiToTopologyTerminationPoint); } } });
private void unlock(final String lockName, final InstanceIdentifier<Lock> lockInstanceIdentifier) { ReadWriteTransaction tx = broker.newReadWriteTransaction(); Optional<Lock> result = Optional.absent(); try { result = tx.read(LogicalDatastoreType.OPERATIONAL, lockInstanceIdentifier).get(); if (!result.isPresent()) { LOG.info("{} is already unlocked", lockName); return; } tx.delete(LogicalDatastoreType.OPERATIONAL, lockInstanceIdentifier); CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit(); futures.get(); } catch (Exception e) { LOG.error("In unlock unable to unlock due to {}", e.getMessage()); } }
@Override public void applyOperation(final ReadWriteTransaction transaction) { Optional<Link> linkOptional = Optional.absent(); try { // read that checks if link exists (if we do not do this we might get an exception on delete) linkOptional = transaction.read(LogicalDatastoreType.OPERATIONAL, TopologyManagerUtil.linkPath(toTopologyLink(notification), iiToTopology)).checkedGet(); } catch (ReadFailedException e) { LOG.warn("Error occured when trying to read Link: {}", e.getMessage()); LOG.debug("Error occured when trying to read Link.. ", e); } if (linkOptional.isPresent()) { transaction.delete(LogicalDatastoreType.OPERATIONAL, TopologyManagerUtil.linkPath(toTopologyLink(notification), iiToTopology)); } }
/** * Method invoked when the open flow switch is Added. * * @param transaction Read-write transaction for MD-SAL datastore. * @param type The type of the logical datastore. */ private void initializeTopology(ReadWriteTransaction transaction, LogicalDatastoreType type) { InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type, path); try { if (!topology.get().isPresent()) { NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type, path, ntb.build()); } } catch (Exception e) { LOG.error("Error initializing ovsdb topology {}", e); } } }
private void initializeTopology(LogicalDatastoreType type) { ReadWriteTransaction transaction = db.newReadWriteTransaction(); InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path); try { if (!topology.get().isPresent()) { NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type,path,ntb.build()); transaction.submit(); } else { transaction.cancel(); } } catch (InterruptedException | ExecutionException e) { LOG.error("Error initializing ovsdb topology", e); } }
private Link findGWLink(ReadWriteTransaction trans, FabricId fabricid, TpId tpid, NodeId routerid) { InstanceIdentifier<Link> linkIId = InstanceIdentifier.create(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(fabricid))) .child(Link.class, new LinkKey(this.createGatewayLink(routerid, tpid))); CheckedFuture<Optional<Link>,ReadFailedException> readFuture = trans.read(LogicalDatastoreType.OPERATIONAL, linkIId); try { Optional<Link> optional = readFuture.get(); if (optional.isPresent()) { return optional.get(); } else { return null; } } catch (InterruptedException | ExecutionException e) { LOG.error("", e); } return null; }
private void initializeTZNode(DataBroker db) { ReadWriteTransaction transaction = db.newReadWriteTransaction(); InstanceIdentifier<TransportZones> path = InstanceIdentifier.create(TransportZones.class); CheckedFuture<Optional<TransportZones>, ReadFailedException> tzones = transaction.read(LogicalDatastoreType.CONFIGURATION,path); try { if (!tzones.get().isPresent()) { TransportZonesBuilder tzb = new TransportZonesBuilder(); transaction.put(LogicalDatastoreType.CONFIGURATION,path,tzb.build()); transaction.submit(); } else { transaction.cancel(); } } catch (Exception e) { LOG.error("Error initializing TransportZones {}",e); } }
private void initializeTopology(final LogicalDatastoreType type) { final ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); final InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); final CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path); try { if (!topology.get().isPresent()) { final NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type,path,ntb.build()); transaction.submit().get(); } else { transaction.cancel(); } } catch (final Exception e) { LOG.error("Error initializing unimgr topology {}", e); } }