outstanding = total;
}
- static BatchedExistenceCheck start(final DOMDataTreeReadOperations tx,
- final LogicalDatastoreType datastore, final YangInstanceIdentifier parentPath,
- final Collection<? extends NormalizedNode> children) {
- final BatchedExistenceCheck ret = new BatchedExistenceCheck(children.size());
- for (NormalizedNode child : children) {
- final YangInstanceIdentifier path = parentPath.node(child.name());
+ static BatchedExistenceCheck start(final DOMDataTreeReadOperations tx, final LogicalDatastoreType datastore,
+ final YangInstanceIdentifier parentPath, final Collection<? extends NormalizedNode> children) {
+ final var ret = new BatchedExistenceCheck(children.size());
+ for (var child : children) {
+ final var path = parentPath.node(child.name());
tx.exists(datastore, path).addCallback(new FutureCallback<Boolean>() {
@Override
public void onSuccess(final Boolean result) {
}
@Override
- public RestconfTransaction prepareWriteExecution() {
+ RestconfTransaction prepareWriteExecution() {
return new MdsalRestconfTransaction(dataBroker);
}
@Override
- protected void delete(final SettableRestconfFuture<Empty> future, final YangInstanceIdentifier path) {
+ void delete(final SettableRestconfFuture<Empty> future, final YangInstanceIdentifier path) {
final var tx = dataBroker.newReadWriteTransaction();
tx.exists(CONFIGURATION, path).addCallback(new FutureCallback<>() {
@Override
}
@Override
- public ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
+ ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
try (var tx = dataBroker.newReadOnlyTransaction()) {
return tx.read(store, path);
}
@Override
- public ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path, final List<YangInstanceIdentifier> fields) {
+ ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final List<YangInstanceIdentifier> fields) {
return Futures.immediateFailedFuture(new UnsupportedOperationException(
"Reading of selected subtrees is currently not supported in: " + MdsalRestconfStrategy.class));
}
}
@Override
- protected void delete(final SettableRestconfFuture<Empty> future, final YangInstanceIdentifier path) {
+ void delete(final SettableRestconfFuture<Empty> future, final YangInstanceIdentifier path) {
final var tx = prepareWriteExecution();
tx.delete(path);
Futures.addCallback(tx.commit(), new FutureCallback<CommitInfo>() {
}
@Override
- public RestconfTransaction prepareWriteExecution() {
+ RestconfTransaction prepareWriteExecution() {
return new NetconfRestconfTransaction(netconfService);
}
@Override
- public ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
+ ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
return switch (store) {
case CONFIGURATION -> netconfService.getConfig(path);
}
@Override
- public ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
+ ListenableFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path, final List<YangInstanceIdentifier> fields) {
return switch (store) {
case CONFIGURATION -> netconfService.getConfig(path, fields);
}
@Override
- public void cancel() {
+ void cancel() {
resultsFutures.clear();
executeWithLogging(netconfService::discardChanges);
executeWithLogging(netconfService::unlock);
}
@Override
- public ListenableFuture<? extends @NonNull CommitInfo> commit() {
+ ListenableFuture<? extends @NonNull CommitInfo> commit() {
final SettableFuture<CommitInfo> commitResult = SettableFuture.create();
// First complete all resultsFutures and merge them ...
* @return A {@link RestconfTransaction}. This transaction needs to be either committed or canceled before doing
* anything else.
*/
- public abstract RestconfTransaction prepareWriteExecution();
+ abstract RestconfTransaction prepareWriteExecution();
/**
* Read data from the datastore.
* @param path the data object path
* @return a ListenableFuture containing the result of the read
*/
- public abstract ListenableFuture<Optional<NormalizedNode>> read(LogicalDatastoreType store,
+ abstract ListenableFuture<Optional<NormalizedNode>> read(LogicalDatastoreType store,
YangInstanceIdentifier path);
/**
* @param fields paths to selected fields relative to parent path
* @return a ListenableFuture containing the result of the read
*/
- public abstract ListenableFuture<Optional<NormalizedNode>> read(LogicalDatastoreType store,
+ abstract ListenableFuture<Optional<NormalizedNode>> read(LogicalDatastoreType store,
YangInstanceIdentifier path, List<YangInstanceIdentifier> fields);
/**
return ret;
}
- protected abstract void delete(@NonNull SettableRestconfFuture<Empty> future, @NonNull YangInstanceIdentifier path);
+ abstract void delete(@NonNull SettableRestconfFuture<Empty> future, @NonNull YangInstanceIdentifier path);
/**
* Merge data into the configuration datastore, as outlined in
};
}
+ private @Nullable NormalizedNode readDataViaTransaction(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
+ return TransactionUtil.syncAccess(read(store, path), path).orElse(null);
+ }
+
+ /**
+ * Read specific type of data {@link LogicalDatastoreType} via transaction in {@link RestconfStrategy} with
+ * specified subtrees that should only be read.
+ *
+ * @param store datastore type
+ * @param path parent path to selected fields
+ * @param closeTransactionChain if it is set to {@code true}, after transaction it will close transactionChain
+ * in {@link RestconfStrategy} if any
+ * @param fields paths to selected subtrees which should be read, relative to to the parent path
+ * @return {@link NormalizedNode}
+ */
+ private @Nullable NormalizedNode readDataViaTransaction(final @NonNull LogicalDatastoreType store,
+ final @NonNull YangInstanceIdentifier path, final @NonNull List<YangInstanceIdentifier> fields) {
+ return TransactionUtil.syncAccess(read(store, path, fields), path).orElse(null);
+ }
+
private static NormalizedNode prepareDataByParamWithDef(final NormalizedNode readData,
final YangInstanceIdentifier path, final WithDefaultsMode defaultsMode, final EffectiveModelContext ctx) {
final boolean trim = switch (defaultsMode) {
return childCtx;
}
- private @Nullable NormalizedNode readDataViaTransaction(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return TransactionUtil.syncAccess(read(store, path), path).orElse(null);
- }
-
- /**
- * Read specific type of data {@link LogicalDatastoreType} via transaction in {@link RestconfStrategy} with
- * specified subtrees that should only be read.
- *
- * @param store datastore type
- * @param path parent path to selected fields
- * @param closeTransactionChain if it is set to {@code true}, after transaction it will close transactionChain
- * in {@link RestconfStrategy} if any
- * @param fields paths to selected subtrees which should be read, relative to to the parent path
- * @return {@link NormalizedNode}
- */
- private @Nullable NormalizedNode readDataViaTransaction(final @NonNull LogicalDatastoreType store,
- final @NonNull YangInstanceIdentifier path, final @NonNull List<YangInstanceIdentifier> fields) {
- return TransactionUtil.syncAccess(read(store, path, fields), path).orElse(null);
- }
-
private static NormalizedNode mergeConfigAndSTateDataIfNeeded(final NormalizedNode stateDataNode,
final NormalizedNode configDataNode) {
// if no data exists
import static java.util.Objects.requireNonNull;
-import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Optional;
*/
// FIXME: it seems the first two operations deal with lifecycle of a transaction, while others invoke various
// operations. This should be handled through proper allocation indirection.
-@Beta
-public abstract class RestconfTransaction {
+abstract class RestconfTransaction {
private static final Logger LOG = LoggerFactory.getLogger(RestconfTransaction.class);
RestconfTransaction() {
* Rollback changes and unlock the datastore.
*/
// FIXME: this looks synchronous, but it should not be
- public abstract void cancel();
+ abstract void cancel();
/**
* Confirm previous operations.
*
* @return a FluentFuture containing the result of the commit information
*/
- public abstract ListenableFuture<? extends @NonNull CommitInfo> commit();
+ abstract ListenableFuture<? extends @NonNull CommitInfo> commit();
/**
* Delete data from the datastore.
*
* @param path the data object path
*/
- public final void delete(final YangInstanceIdentifier path) {
+ final void delete(final YangInstanceIdentifier path) {
LOG.trace("Delete {}", path);
deleteImpl(requireNonNull(path));
}
*
* @param path the data object path
*/
- public final void remove(final YangInstanceIdentifier path) {
+ final void remove(final YangInstanceIdentifier path) {
LOG.trace("Remove {}", path);
removeImpl(requireNonNull(path));
}
* @param path the data object path
* @param data the data object to be merged to the specified path
*/
- public final void merge(final YangInstanceIdentifier path, final NormalizedNode data) {
+ final void merge(final YangInstanceIdentifier path, final NormalizedNode data) {
LOG.trace("Merge {}", path);
LOG.trace(Markers.confidential(), "Merge with {}", data.prettyTree());
mergeImpl(requireNonNull(path), data);
* @param data the data object to be merged to the specified path
* @param context static view of compiled yang files
*/
- public final void create(final YangInstanceIdentifier path, final NormalizedNode data,
+ final void create(final YangInstanceIdentifier path, final NormalizedNode data,
final EffectiveModelContext context) {
LOG.trace("Create {}", path);
LOG.trace(Markers.confidential(), "Create as {}", data.prettyTree());
* @param data the data object to be merged to the specified path
* @param context static view of compiled yang files
*/
- public final void replace(final YangInstanceIdentifier path, final NormalizedNode data,
+ final void replace(final YangInstanceIdentifier path, final NormalizedNode data,
final EffectiveModelContext context) {
LOG.trace("Replace {}", path);
LOG.trace(Markers.confidential(), "Replace with {}", data.prettyTree());
merge(rootNormalizedPath,
ImmutableNodes.fromInstanceId(context, YangInstanceIdentifier.of(normalizedPathWithoutChildArgs)));
}
-
}