HBASE-15413 Procedure-V2: print out ProcedureInfo during trace (Stephen Yuan Jiang)

This commit is contained in:
Stephen Yuan Jiang 2016-03-07 20:28:45 -08:00
parent e477c143bc
commit 1c6beb3dc1
1 changed files with 40 additions and 0 deletions

View File

@ -27,8 +27,10 @@ import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos;
import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureState; import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureState;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.ByteStringer; import org.apache.hadoop.hbase.util.ByteStringer;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.ForeignExceptionUtil; import org.apache.hadoop.hbase.util.ForeignExceptionUtil;
import org.apache.hadoop.hbase.util.NonceKey; import org.apache.hadoop.hbase.util.NonceKey;
import org.apache.hadoop.util.StringUtils;
/** /**
* Procedure information * Procedure information
@ -82,6 +84,40 @@ public class ProcedureInfo implements Cloneable {
exception, lastUpdate, startTime, result); exception, lastUpdate, startTime, result);
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Procedure=");
sb.append(procName);
sb.append(" (id=");
sb.append(procId);
if (hasParentId()) {
sb.append(", parent=");
sb.append(parentId);
}
if (hasOwner()) {
sb.append(", owner=");
sb.append(procOwner);
}
sb.append(", state=");
sb.append(procState);
long now = EnvironmentEdgeManager.currentTime();
sb.append(", startTime=");
sb.append(StringUtils.formatTime(now - startTime));
sb.append(" ago, lastUpdate=");
sb.append(StringUtils.formatTime(now - startTime));
sb.append(" ago");
if (isFailed()) {
sb.append(", exception=\"");
sb.append(getExceptionMessage());
sb.append("\"");
}
sb.append(")");
return sb.toString();
}
public long getProcId() { public long getProcId() {
return procId; return procId;
} }
@ -90,6 +126,10 @@ public class ProcedureInfo implements Cloneable {
return procName; return procName;
} }
private boolean hasOwner() {
return procOwner != null;
}
public String getProcOwner() { public String getProcOwner() {
return procOwner; return procOwner;
} }