introduce WriteTrackingTransaction 30/75630/4
authorMichael Vorburger <vorburger@redhat.com>
Fri, 31 Aug 2018 16:11:48 +0000 (18:11 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Tue, 4 Sep 2018 13:46:44 +0000 (13:46 +0000)
this is used in the next commit to reduce code duplication

Change-Id: I336e7d53ee54b05b58d775ca801af597edb7dec3
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/infra/WriteTrackingReadWriteTransaction.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/infra/WriteTrackingTransaction.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/infra/WriteTrackingTypedReadWriteTransactionImpl.java

index ac6f4b30d0a629452b30f2e45e413e695279dd42..ba620e5655d935c5eea3d64130a8584551f7f1d1 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 /**
  * Read-write transaction which keeps track of writes.
  */
-class WriteTrackingReadWriteTransaction extends ForwardingReadWriteTransaction {
+class WriteTrackingReadWriteTransaction extends ForwardingReadWriteTransaction implements WriteTrackingTransaction {
     // This is volatile to ensure we get the latest value; transactions aren't supposed to be used in multiple threads,
     // but the cost here is tiny (one read penalty at the end of a transaction) so we play it safe
     private volatile boolean written;
@@ -57,7 +57,8 @@ class WriteTrackingReadWriteTransaction extends ForwardingReadWriteTransaction {
         written = true;
     }
 
-    boolean isWritten() {
+    @Override
+    public boolean isWritten() {
         return written;
     }
 }
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/infra/WriteTrackingTransaction.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/infra/WriteTrackingTransaction.java
new file mode 100644 (file)
index 0000000..e9295ff
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2018 Red Hat, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.genius.infra;
+
+// intentionally package local, not public
+interface WriteTrackingTransaction {
+
+    boolean isWritten();
+
+}
index 7ecaf2e05e46cbe15a9ef71a50afd395b2cfc168..e75104679cbeacb28400c9722d38db3f36005553 100644 (file)
@@ -14,7 +14,9 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 /**
  * Read-write typed transaction which keeps track of writes.
  */
-class WriteTrackingTypedReadWriteTransactionImpl<D extends Datastore> extends TypedReadWriteTransactionImpl<D> {
+class WriteTrackingTypedReadWriteTransactionImpl<D extends Datastore> extends TypedReadWriteTransactionImpl<D>
+        implements WriteTrackingTransaction {
+
     // This is volatile to ensure we get the latest value; transactions aren't supposed to be used in multiple threads,
     // but the cost here is tiny (one read penalty at the end of a transaction) so we play it safe
     private volatile boolean written;
@@ -53,7 +55,8 @@ class WriteTrackingTypedReadWriteTransactionImpl<D extends Datastore> extends Ty
         written = true;
     }
 
-    boolean isWritten() {
+    @Override
+    public boolean isWritten() {
         return written;
     }
 }