summaryrefslogtreecommitdiffstats
path: root/infra/data-impl/src/main/java/io/fd
diff options
context:
space:
mode:
authorMaros Marsalek <maros.mars@gmail.com>2017-09-04 14:37:57 +0200
committerMaroš Maršalek <maros.mars@gmail.com>2017-09-05 11:18:28 +0000
commit0d4a04e1452e19ce96c308cd45a430a3f5b72f04 (patch)
tree22f71b904209922ad2a3f8ed77f0e647346196db /infra/data-impl/src/main/java/io/fd
parent6506878ae7ad2b9ade390127ece11f7a1a3b67dd (diff)
Make DataModification closeable
and close the modification from transactions. This enables cleanup of underlay resources per transaction. It is not needed when managing VPP, but might be useful for other use-cases where underlay transactions are involved. Change-Id: If14197052172be0158fd7efb5ee1794935d576bc Signed-off-by: Maros Marsalek <maros.mars@gmail.com>
Diffstat (limited to 'infra/data-impl/src/main/java/io/fd')
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadOnlyTransaction.java13
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java3
2 files changed, 12 insertions, 4 deletions
diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadOnlyTransaction.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadOnlyTransaction.java
index e21098a3b..dcd456a27 100644
--- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadOnlyTransaction.java
+++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadOnlyTransaction.java
@@ -25,6 +25,7 @@ import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import io.fd.honeycomb.data.DataModification;
import io.fd.honeycomb.data.ReadableDataManager;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -43,7 +44,7 @@ final class ReadOnlyTransaction implements DOMDataReadOnlyTransaction {
@Nullable
private ReadableDataManager operationalData;
@Nullable
- private ReadableDataManager configSnapshot;
+ private DataModification configSnapshot;
private boolean closed = false;
@@ -51,7 +52,7 @@ final class ReadOnlyTransaction implements DOMDataReadOnlyTransaction {
* @param configData config data tree manager. Null if config reads are not to be supported
* @param operationalData operational data tree manager. Null if operational reads are not to be supported
*/
- private ReadOnlyTransaction(@Nullable final ReadableDataManager configData,
+ private ReadOnlyTransaction(@Nullable final DataModification configData,
@Nullable final ReadableDataManager operationalData) {
this.configSnapshot = configData;
this.operationalData = operationalData;
@@ -59,6 +60,10 @@ final class ReadOnlyTransaction implements DOMDataReadOnlyTransaction {
@Override
public synchronized void close() {
+ if(configSnapshot != null) {
+ configSnapshot.close();
+ }
+
closed = true;
configSnapshot = null;
operationalData = null;
@@ -101,12 +106,12 @@ final class ReadOnlyTransaction implements DOMDataReadOnlyTransaction {
}
@Nonnull
- static ReadOnlyTransaction createConfigOnly(@Nonnull final ReadableDataManager configData) {
+ static ReadOnlyTransaction createConfigOnly(@Nonnull final DataModification configData) {
return new ReadOnlyTransaction(requireNonNull(configData), null);
}
@Nonnull
- static ReadOnlyTransaction create(@Nonnull final ReadableDataManager configData,
+ static ReadOnlyTransaction create(@Nonnull final DataModification configData,
@Nonnull final ReadableDataManager operationalData) {
return new ReadOnlyTransaction(requireNonNull(configData), requireNonNull(operationalData));
}
diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java
index 93043ce07..ce0e3c6fb 100644
--- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java
+++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java
@@ -104,6 +104,9 @@ final class WriteTransaction implements DOMDataWriteTransaction {
// only NEW transactions can be cancelled
return false;
} else {
+ if (configModification != null) {
+ configModification.close();
+ }
status = CANCELED;
return true;
}