package org.opendaylight.netconf.callhome.mount;
import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.IOException;
import java.security.GeneralSecurityException;
}
private Optional<Device> readDevice(final NodeId nodeId) {
- ReadTransaction opTx = dataBroker.newReadOnlyTransaction();
-
- InstanceIdentifier<Device> deviceIID = buildDeviceInstanceIdentifier(nodeId);
- ListenableFuture<Optional<Device>> devFuture = opTx.read(LogicalDatastoreType.OPERATIONAL, deviceIID);
- try {
- return devFuture.get();
+ try (ReadTransaction opTx = dataBroker.newReadOnlyTransaction()) {
+ InstanceIdentifier<Device> deviceIID = buildDeviceInstanceIdentifier(nodeId);
+ return opTx.read(LogicalDatastoreType.OPERATIONAL, deviceIID).get();
} catch (InterruptedException | ExecutionException e) {
return Optional.empty();
}
}
private AllowedDevices getDevices() {
- ReadTransaction rxTransaction = dataBroker.newReadOnlyTransaction();
- ListenableFuture<Optional<AllowedDevices>> devicesFuture =
- rxTransaction.read(LogicalDatastoreType.OPERATIONAL, IetfZeroTouchCallHomeServerProvider.ALL_DEVICES);
- try {
- return devicesFuture.get().orElse(null);
+ try (ReadTransaction rxTransaction = dataBroker.newReadOnlyTransaction()) {
+ return rxTransaction.read(LogicalDatastoreType.OPERATIONAL, IetfZeroTouchCallHomeServerProvider.ALL_DEVICES)
+ .get().orElse(null);
} catch (ExecutionException | InterruptedException e) {
LOG.error("Error trying to read the whitelist devices", e);
return null;
// its created under CallHomeAuthorizationProvider.
// Will have to redesign a bit here.
// CallHomeAuthorization.
- ReadTransaction roConfigTx = dataBroker.newReadOnlyTransaction();
- ListenableFuture<Optional<AllowedDevices>> devicesFuture = roConfigTx
- .read(LogicalDatastoreType.CONFIGURATION, IetfZeroTouchCallHomeServerProvider.ALL_DEVICES);
+ final ListenableFuture<Optional<AllowedDevices>> devicesFuture;
+ try (ReadTransaction roConfigTx = dataBroker.newReadOnlyTransaction()) {
+ devicesFuture = roConfigTx.read(LogicalDatastoreType.CONFIGURATION,
+ IetfZeroTouchCallHomeServerProvider.ALL_DEVICES);
+ }
Set<InstanceIdentifier<?>> deletedDevices = new HashSet<>();
for (DataTreeModification<AllowedDevices> change : changes) {
package org.opendaylight.netconf.messagebus.eventsources.netconf;
import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import java.time.Instant;
import java.time.ZoneId;
* @throws InterruptedException if data read fails
*/
List<Stream> getAvailableStreams() throws InterruptedException, ExecutionException {
- DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction();
- FluentFuture<Optional<NormalizedNode<?, ?>>> checkFeature = tx.read(LogicalDatastoreType.OPERATIONAL,
- STREAMS_PATH);
- Optional<NormalizedNode<?, ?>> streams = checkFeature.get();
+ final Optional<NormalizedNode<?, ?>> streams;
+ try (DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction()) {
+ streams = tx.read(LogicalDatastoreType.OPERATIONAL, STREAMS_PATH).get();
+ }
if (streams.isPresent()) {
Streams streams1 = (Streams) CODEC_REGISTRY.fromNormalizedNode(STREAMS_PATH, streams.get()).getValue();
return streams1.getStream();