HBASE-23333 Include Call.toShortString() in sendCall exceptions
This commit is contained in:
parent
c44a5c47dd
commit
f98085e44e
|
@ -149,7 +149,7 @@ class BlockingRpcConnection extends RpcConnection implements Runnable {
|
||||||
|
|
||||||
public void sendCall(final Call call) throws IOException {
|
public void sendCall(final Call call) throws IOException {
|
||||||
if (callsToWrite.size() >= maxQueueSize) {
|
if (callsToWrite.size() >= maxQueueSize) {
|
||||||
throw new IOException("Can't add the call " + call.id
|
throw new IOException("Can't add " + call.toShortString()
|
||||||
+ " to the write queue. callsToWrite.size()=" + callsToWrite.size());
|
+ " to the write queue. callsToWrite.size()=" + callsToWrite.size());
|
||||||
}
|
}
|
||||||
callsToWrite.offer(call);
|
callsToWrite.offer(call);
|
||||||
|
@ -161,7 +161,7 @@ class BlockingRpcConnection extends RpcConnection implements Runnable {
|
||||||
// By removing the call from the expected call list, we make the list smaller, but
|
// By removing the call from the expected call list, we make the list smaller, but
|
||||||
// it means as well that we don't know how many calls we cancelled.
|
// it means as well that we don't know how many calls we cancelled.
|
||||||
calls.remove(call.id);
|
calls.remove(call.id);
|
||||||
call.setException(new CallCancelledException("Call id=" + call.id + ", waitTime="
|
call.setException(new CallCancelledException(call.toShortString() + ", waitTime="
|
||||||
+ (EnvironmentEdgeManager.currentTime() - call.getStartTime()) + ", rpcTimeout="
|
+ (EnvironmentEdgeManager.currentTime() - call.getStartTime()) + ", rpcTimeout="
|
||||||
+ call.timeout));
|
+ call.timeout));
|
||||||
}
|
}
|
||||||
|
@ -193,9 +193,7 @@ class BlockingRpcConnection extends RpcConnection implements Runnable {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// exception here means the call has not been added to the pendingCalls yet, so we need
|
// exception here means the call has not been added to the pendingCalls yet, so we need
|
||||||
// to fail it by our own.
|
// to fail it by our own.
|
||||||
if (LOG.isDebugEnabled()) {
|
LOG.debug("call write error for {}", call.toShortString());
|
||||||
LOG.debug("call write error for call #" + call.id, e);
|
|
||||||
}
|
|
||||||
call.setException(e);
|
call.setException(e);
|
||||||
closeConn(e);
|
closeConn(e);
|
||||||
}
|
}
|
||||||
|
@ -628,7 +626,7 @@ class BlockingRpcConnection extends RpcConnection implements Runnable {
|
||||||
call.callStats.setRequestSizeBytes(write(this.out, requestHeader, call.param, cellBlock));
|
call.callStats.setRequestSizeBytes(write(this.out, requestHeader, call.param, cellBlock));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
if(LOG.isTraceEnabled()) {
|
if(LOG.isTraceEnabled()) {
|
||||||
LOG.trace("Error while writing call, call_id:" + call.id, t);
|
LOG.trace("Error while writing {}", call.toShortString());
|
||||||
}
|
}
|
||||||
IOException e = IPCUtil.toIOE(t);
|
IOException e = IPCUtil.toIOE(t);
|
||||||
closeConn(e);
|
closeConn(e);
|
||||||
|
|
|
@ -17,21 +17,21 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.ipc;
|
package org.apache.hadoop.hbase.ipc;
|
||||||
|
|
||||||
import org.apache.hbase.thirdparty.io.netty.util.Timeout;
|
|
||||||
|
|
||||||
import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors;
|
|
||||||
import org.apache.hbase.thirdparty.com.google.protobuf.Message;
|
|
||||||
import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback;
|
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import org.apache.hadoop.hbase.CellScanner;
|
import org.apache.hadoop.hbase.CellScanner;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
|
||||||
import org.apache.hadoop.hbase.client.MetricsConnection;
|
import org.apache.hadoop.hbase.client.MetricsConnection;
|
||||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||||
import org.apache.htrace.core.Span;
|
import org.apache.htrace.core.Span;
|
||||||
import org.apache.htrace.core.Tracer;
|
import org.apache.htrace.core.Tracer;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors;
|
||||||
|
import org.apache.hbase.thirdparty.com.google.protobuf.Message;
|
||||||
|
import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback;
|
||||||
|
import org.apache.hbase.thirdparty.io.netty.util.Timeout;
|
||||||
|
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
|
||||||
|
|
||||||
/** A call waiting for a value. */
|
/** A call waiting for a value. */
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
|
@ -56,7 +56,7 @@ class Call {
|
||||||
final int timeout; // timeout in millisecond for this call; 0 means infinite.
|
final int timeout; // timeout in millisecond for this call; 0 means infinite.
|
||||||
final int priority;
|
final int priority;
|
||||||
final MetricsConnection.CallStats callStats;
|
final MetricsConnection.CallStats callStats;
|
||||||
final RpcCallback<Call> callback;
|
private final RpcCallback<Call> callback;
|
||||||
final Span span;
|
final Span span;
|
||||||
Timeout timeoutTask;
|
Timeout timeoutTask;
|
||||||
|
|
||||||
|
@ -76,10 +76,24 @@ class Call {
|
||||||
this.span = Tracer.getCurrentSpan();
|
this.span = Tracer.getCurrentSpan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a simplified {@link #toString()} that includes just the id and method name.
|
||||||
|
*/
|
||||||
|
public String toShortString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||||
|
.append("id", id)
|
||||||
|
.append("methodName", md.getName())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "callId: " + this.id + " methodName: " + this.md.getName() + " param {"
|
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||||
+ (this.param != null ? ProtobufUtil.getShortTextFormat(this.param) : "") + "}";
|
.appendSuper(toShortString())
|
||||||
|
.append("param", Optional.ofNullable(param)
|
||||||
|
.map(ProtobufUtil::getShortTextFormat)
|
||||||
|
.orElse(""))
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -230,7 +230,7 @@ class IPCUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setCancelled(Call call) {
|
static void setCancelled(Call call) {
|
||||||
call.setException(new CallCancelledException("Call id=" + call.id + ", waitTime="
|
call.setException(new CallCancelledException(call.toShortString() + ", waitTime="
|
||||||
+ (EnvironmentEdgeManager.currentTime() - call.getStartTime()) + ", rpcTimeout="
|
+ (EnvironmentEdgeManager.currentTime() - call.getStartTime()) + ", rpcTimeout="
|
||||||
+ call.timeout));
|
+ call.timeout));
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ abstract class RpcConnection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Timeout timeout) throws Exception {
|
public void run(Timeout timeout) throws Exception {
|
||||||
call.setTimeout(new CallTimeoutException("Call id=" + call.id + ", waitTime="
|
call.setTimeout(new CallTimeoutException(call.toShortString() + ", waitTime="
|
||||||
+ (EnvironmentEdgeManager.currentTime() - call.getStartTime()) + ", rpcTimeout="
|
+ (EnvironmentEdgeManager.currentTime() - call.getStartTime()) + ", rpcTimeout="
|
||||||
+ call.timeout));
|
+ call.timeout));
|
||||||
callTimeout(call);
|
callTimeout(call);
|
||||||
|
|
|
@ -80,6 +80,8 @@ public class TestFutureUtils {
|
||||||
startsWith("org.apache.hadoop.hbase.util.TestFutureUtils.testRecordStackTrace"));
|
startsWith("org.apache.hadoop.hbase.util.TestFutureUtils.testRecordStackTrace"));
|
||||||
assertTrue(Stream.of(elements)
|
assertTrue(Stream.of(elements)
|
||||||
.anyMatch(element -> element.toString().contains("--------Future.get--------")));
|
.anyMatch(element -> element.toString().contains("--------Future.get--------")));
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new AssertionError("Caught unexpected Throwable", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue