For debug logging we need a shortened string for better readability and
grepping. The standard toString is way too long. I changed toString to a
similar compact form that we had before. adding in the frontend generation id
and type, eg
member-1-datastore-config-fe-1-txn-3
member-1-datastore-operational-fe-1-chn-2-txn-3
Change-Id: I942eaaa0e8ceedf42eed964f2a2e3a76d8c09806
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
package org.opendaylight.controller.cluster.access.concepts;
import com.google.common.annotations.Beta;
package org.opendaylight.controller.cluster.access.concepts;
import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
private static final long serialVersionUID = 1L;
private final LocalHistoryIdentifier historyId;
private final long transactionId;
private static final long serialVersionUID = 1L;
private final LocalHistoryIdentifier historyId;
private final long transactionId;
+ private transient String shortString;
public TransactionIdentifier(final @Nonnull LocalHistoryIdentifier historyId, final long transactionId) {
this.historyId = Preconditions.checkNotNull(historyId);
public TransactionIdentifier(final @Nonnull LocalHistoryIdentifier historyId, final long transactionId) {
this.historyId = Preconditions.checkNotNull(historyId);
return transactionId == other.transactionId && historyId.equals(other.historyId);
}
return transactionId == other.transactionId && historyId.equals(other.historyId);
}
+ public String toShortString() {
+ if(shortString == null) {
+ String histStr = historyId.getHistoryId() == 0 ? "" : "-chn-" + historyId.getHistoryId();
+ shortString = historyId.getClientId().getFrontendId().getMemberName().getName() + "-" +
+ historyId.getClientId().getFrontendId().getClientType().getName() + "-fe-" +
+ historyId.getClientId().getGeneration() + histStr + "-txn-" + transactionId;
+ }
+
+ return shortString;
+ }
+
@Override
public String toString() {
@Override
public String toString() {
- return MoreObjects.toStringHelper(TransactionIdentifier.class).add("history", historyId)
- .add("transaction", transactionId).toString();
+ return toShortString();
}
private Object writeReplace() {
}
private Object writeReplace() {