2 * Copyright (c) 2015 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
9 package org.opendaylight.controller.cluster.datastore.identifiers;
11 import com.google.common.base.Supplier;
12 import com.google.common.base.Suppliers;
13 import java.util.concurrent.atomic.AtomicLong;
15 public class TransactionChainIdentifier {
17 protected static final String CHAIN_SEPARATOR = "-chn-";
19 private final AtomicLong txnCounter = new AtomicLong();
20 private final Supplier<String> stringRepresentation;
21 private final String memberName;
23 public TransactionChainIdentifier(final String memberName, final long counter) {
24 this.memberName = memberName;
25 stringRepresentation = Suppliers.memoize(new Supplier<String>() {
28 final StringBuilder sb = new StringBuilder();
29 sb.append(memberName).append(CHAIN_SEPARATOR);
36 public String toString() {
37 return stringRepresentation.get();
40 public TransactionIdentifier newTransactionIdentifier(){
41 return new ChainedTransactionIdentifier(this, txnCounter.incrementAndGet());
44 public String getMemberName() {