2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore.identifiers;
10 import com.google.common.base.Preconditions;
11 import com.google.common.base.Supplier;
12 import com.google.common.base.Suppliers;
15 * A TransactionIdentifier which is tied to a backend transaction chain.
17 public class ChainedTransactionIdentifier extends TransactionIdentifier {
18 private final String chainId;
19 private Supplier<String> stringRepresentation;
21 public ChainedTransactionIdentifier(final TransactionChainIdentifier chainId, final long txnCounter) {
22 super(chainId.getMemberName(), txnCounter);
23 Preconditions.checkNotNull(chainId);
24 this.chainId = chainId.toString();
25 stringRepresentation = Suppliers.memoize(new Supplier<String>() {
28 return new StringBuilder(chainId.toString().length() + TX_SEPARATOR.length() + 10).
29 append(chainId).append(TX_SEPARATOR).append(getCounter()).toString();
36 public String getChainId() {
41 public String toString() {
42 return stringRepresentation.get();