X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fidentifiers%2FTransactionIdentifier.java;h=6023e555288b58e18f6eab4e215615ffdd7254f0;hp=5a365f28a3e45abcc794b6de1f8349125cd9a2ee;hb=74fc38503a3565bed6218f65ab8f4425c61460a3;hpb=86e398bb1e1a60f7516b398a0f27268bf232049d diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/TransactionIdentifier.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/TransactionIdentifier.java index 5a365f28a3..6023e55528 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/TransactionIdentifier.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/TransactionIdentifier.java @@ -13,27 +13,33 @@ import com.google.common.base.Preconditions; public class TransactionIdentifier { protected static final String TX_SEPARATOR = "-txn-"; - protected String getMemberName() { - return memberName; - } - - protected long getCounter() { - return counter; - } - private final String memberName; private final long counter; + private final long timestamp; private String stringRepresentation; public TransactionIdentifier(String memberName, long counter) { this.memberName = Preconditions.checkNotNull(memberName, "memberName should not be null"); this.counter = counter; + this.timestamp = System.currentTimeMillis(); } public String getChainId() { return ""; } + protected String getMemberName() { + return memberName; + } + + protected long getCounter() { + return counter; + } + + protected long getTimestamp() { + return timestamp; + } + public static TransactionIdentifier create(String memberName, long counter) { return new TransactionIdentifier(memberName, counter); } @@ -52,6 +58,11 @@ public class TransactionIdentifier { if (counter != that.counter) { return false; } + + if (timestamp != that.timestamp) { + return false; + } + if (!memberName.equals(that.memberName)) { return false; } @@ -63,14 +74,16 @@ public class TransactionIdentifier { public int hashCode() { int result = memberName.hashCode(); result = 31 * result + (int) (counter ^ (counter >>> 32)); + result = 31 * result + (int)(timestamp ^ (timestamp >>> 32)); return result; } + @Override public String toString() { if(stringRepresentation == null) { - stringRepresentation = new StringBuilder(memberName.length() + TX_SEPARATOR.length() + 10). - append(memberName).append(TX_SEPARATOR).append(counter).toString(); + stringRepresentation = new StringBuilder(memberName.length() + TX_SEPARATOR.length() + 21). + append(memberName).append(TX_SEPARATOR).append(counter).append('-').append(timestamp).toString(); } return stringRepresentation;