Remove CSS-related files from the toaster
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / utils / TransactionIdentifierUtils.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.datastore.utils;
9
10 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
11 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
12 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
13 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
14
15 public final class TransactionIdentifierUtils {
16     private TransactionIdentifierUtils() {
17         throw new UnsupportedOperationException();
18     }
19
20     public static String actorNameFor(final TransactionIdentifier txId) {
21         final LocalHistoryIdentifier historyId = txId.getHistoryId();
22         final ClientIdentifier clientId = historyId.getClientId();
23         final FrontendIdentifier frontendId = clientId.getFrontendId();
24
25         final StringBuilder sb = new StringBuilder();
26         sb.append(frontendId.getMemberName().getName()).append(':');
27         sb.append(frontendId.getClientType().getName()).append('@');
28         sb.append(clientId.getGeneration()).append(':');
29         if (historyId.getHistoryId() != 0) {
30             sb.append(historyId.getHistoryId()).append('-');
31         }
32
33         return sb.append(txId.getTransactionId()).toString();
34     }
35 }