WriteTransaction beginTransaction() { return chain.newWriteOnlyTransaction(); }
private WriteTransaction getTransactionSafely() { if (wTx == null && !TransactionChainManagerStatus.SHUTTING_DOWN.equals(transactionChainManagerStatus)) { synchronized (txLock) { if (wTx == null) { wTx = txChainFactory.newWriteOnlyTransaction(); } } } return wTx; }
private <U extends org.opendaylight.yangtools.yang.binding.DataObject> void writePutTransaction( InstanceIdentifier<U> addIID, U data, LogicalDatastoreType logicalDatastoreType, String errMsg) { WriteTransaction writeTx = txChain.newWriteOnlyTransaction(); writeTx.put(logicalDatastoreType, addIID, data, true); Futures.addCallback(writeTx.submit(), new FutureCallback<Void>() { public void onSuccess(Void result) { } public void onFailure(Throwable throwable) { LOG.error("Transaction failed:", throwable); } }); }
private <U extends org.opendaylight.yangtools.yang.binding.DataObject> void deleteTransaction( InstanceIdentifier<U> deleteIID, LogicalDatastoreType logicalDatastoreType, String errMsg) { WriteTransaction writeTx = txChain.newWriteOnlyTransaction(); writeTx.delete(logicalDatastoreType, deleteIID); Futures.addCallback(writeTx.submit(), new FutureCallback<Void>() { public void onSuccess(Void result) { } public void onFailure(Throwable throwable) { LOG.error("Transaction failed:", throwable); } }); }
@Override public void update(@Nonnull final NodeId id, @Nonnull final Node operationalDataNode) { // merge final WriteTransaction wTx = transactionChain.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, TopologyUtil.createTopologyNodeListPath(new NodeKey(id), topologyId), operationalDataNode); commitTransaction(wTx, id, "update"); }
@Override public void init(@Nonnull final NodeId id, @Nonnull final Node operationalDataNode) { // put into Datastore final WriteTransaction wTx = transactionChain.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, TopologyUtil.createTopologyNodeListPath(new NodeKey(id), topologyId), operationalDataNode); commitTransaction(wTx, id, "init"); }
public ListenableFuture<Void> deleteLocationForVppEndpoint(VppEndpoint vppEndpoint) { ProviderAddressEndpointLocationKey provAddrEpLocKey = createProviderAddressEndpointLocationKey(vppEndpoint); WriteTransaction wTx = txChain.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.CONFIGURATION, IidFactory.providerAddressEndpointLocationIid(VPP_ENDPOINT_LOCATION_PROVIDER, provAddrEpLocKey)); LOG.debug("Deleting location for {}", provAddrEpLocKey); return Futures.transform(wTx.submit(), new Function<Void, Void>() { @Override public Void apply(Void input) { LOG.debug("{} removed location: {}", VPP_ENDPOINT_LOCATION_PROVIDER.getValue(), provAddrEpLocKey); return null; } }); }
@Override public void delete(@Nonnull final NodeId id) { // delete final WriteTransaction wTx = transactionChain.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.OPERATIONAL, TopologyUtil.createTopologyNodeListPath(new NodeKey(id), topologyId)); commitTransaction(wTx, id, "delete"); }
@Override public void close() throws Exception { WriteTransaction wTx = txChain.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.CONFIGURATION, IidFactory.locationProviderIid(VPP_ENDPOINT_LOCATION_PROVIDER)); wTx.submit(); } }
@Override public void close() { this.rpcRegistration.close(); final WriteTransaction dTx = this.txChain.newWriteOnlyTransaction(); dTx.delete(LogicalDatastoreType.CONFIGURATION, this.iid); try { dTx.submit().checkedGet(); } catch (final TransactionCommitFailedException e) { LOG.warn("Failed to clean-up BGP Application RIB.", e); } this.txChain.close(); LOG.info("BGP Application Peer Benchmark Application closed."); }
private void writeConfiguration(final Identifier key, final T openConfig) { final WriteTransaction wTx = txChain.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.CONFIGURATION, getInstanceIdentifier(key), openConfig); wTx.submit(); }
private void removeConfiguration(final Identifier key) { final WriteTransaction wTx = txChain.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.CONFIGURATION, getInstanceIdentifier(key)); wTx.submit(); }
public void updateDeviceData(boolean up, NetconfDeviceCapabilities capabilities) { final Node data = buildDataForNetconfNode(up, capabilities); final WriteTransaction writeTx = txChain.newWriteOnlyTransaction(); logger.trace("{}: Update device state transaction {} merging operational data started.", id, writeTx.getIdentifier()); writeTx.put(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath(), data); logger.trace("{}: Update device state transaction {} merging operational data ended.", id, writeTx.getIdentifier()); commitTransaction(writeTx, "update"); }
private void removeDeviceConfigAndState() { final WriteTransaction transaction = txChain.newWriteOnlyTransaction(); logger.trace("{}: Close device state transaction {} removing all data started.", id, transaction.getIdentifier()); transaction.delete(LogicalDatastoreType.CONFIGURATION, id.getBindingPath()); transaction.delete(LogicalDatastoreType.OPERATIONAL, id.getBindingPath()); logger.trace("{}: Close device state transaction {} removing all data ended.", id, transaction.getIdentifier()); try { transaction.submit().get(); } catch (InterruptedException | ExecutionException e) { logger.error("{}: Transaction(close) {} FAILED!", id, transaction.getIdentifier(), e); throw new IllegalStateException(id + " Transaction(close) not committed correctly", e); } }
public void removeDeviceConfiguration() { final WriteTransaction writeTx = txChain.newWriteOnlyTransaction(); logger.trace("{}: Close device state transaction {} removing all data started.", id, writeTx.getIdentifier()); writeTx.delete(LogicalDatastoreType.CONFIGURATION, id.getTopologyBindingPath()); writeTx.delete(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath()); logger.trace("{}: Close device state transaction {} removing all data ended.", id, writeTx.getIdentifier()); try { writeTx.submit().get(); } catch (InterruptedException | ExecutionException e) { logger.error("{}: Transaction(close) {} FAILED!", id, writeTx.getIdentifier(), e); throw new IllegalStateException(id + " Transaction(close) not committed correctly", e); } }
/** * Destroy the current operational topology data. Note a valid transaction must be provided * @throws TransactionCommitFailedException */ private synchronized void destroyOperationalTopology() { Preconditions.checkNotNull(this.chain, "A valid transaction chain must be provided."); final WriteTransaction trans = this.chain.newWriteOnlyTransaction(); trans.delete(LogicalDatastoreType.OPERATIONAL, getInstanceIdentifier()); try { trans.submit().checkedGet(); } catch (final TransactionCommitFailedException e) { LOG.error("Unable to reset operational topology {} (transaction {})", this.topology, trans.getIdentifier(), e); } clearTopology(); }
@Override public void close() throws Exception { final WriteTransaction wTx = txChain.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.CONFIGURATION, BGP_IID); wTx.submit().checkedGet(); txChain.close(); }
private void initDeviceData() { final WriteTransaction transaction = txChain.newWriteOnlyTransaction(); createNodesListIfNotPresent(transaction); final InstanceIdentifier<Node> path = id.getBindingPath(); final Node nodeWithId = getNodeWithId(id); logger.trace("{}: Init device state transaction {} putting if absent operational data started.", id, transaction.getIdentifier()); transaction.put(LogicalDatastoreType.OPERATIONAL, path, nodeWithId); logger.trace("{}: Init device state transaction {} putting operational data ended.", id, transaction.getIdentifier()); logger.trace("{}: Init device state transaction {} putting if absent config data started.", id, transaction.getIdentifier()); transaction.put(LogicalDatastoreType.CONFIGURATION, path, nodeWithId); logger.trace("{}: Init device state transaction {} putting config data ended.", id, transaction.getIdentifier()); commitTransaction(transaction, "init"); }
public void setDeviceAsFailed(Throwable throwable) { String reason = (throwable != null && throwable.getMessage() != null) ? throwable.getMessage() : UNKNOWN_REASON; final NetconfNode netconfNode = new NetconfNodeBuilder().setConnectionStatus(ConnectionStatus.UnableToConnect).setConnectedMessage(reason).build(); final Node data = getNodeIdBuilder(id).addAugmentation(NetconfNode.class, netconfNode).build(); final WriteTransaction writeTx = txChain.newWriteOnlyTransaction(); logger.trace("{}: Setting device state as failed {} putting operational data started.", id, writeTx.getIdentifier()); writeTx.put(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath(), data); logger.trace("{}: Setting device state as failed {} putting operational data ended.", id, writeTx.getIdentifier()); commitTransaction(writeTx, "update-failed-device"); }
private void putCount(final long count) { final WriteTransaction wTx = this.chain.newWriteOnlyTransaction(); Counter counter = new CounterBuilder().setId(this.counterId).setCount(count).build(); wTx.put(LogicalDatastoreType.OPERATIONAL, this.counterInstanceId, counter); wTx.submit(); }