Skip to content

Commit

Permalink
HBASE-24282 'scanDetail' log message is missing when responseTooSlow …
Browse files Browse the repository at this point in the history
…happens on the first scan rpc call (#1604)

Signed-off-by: Guangxu Cheng <gxcheng@apache.org>
Signed-off-by: stack <stack@apache.org>
  • Loading branch information
songxincun authored and Huaxiang Sun committed May 1, 2020
1 parent 13f36d9 commit aceba6f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,15 @@ void logResponse(Message param, String methodName, String call, boolean tooLarge
responseInfo.put("param", stringifiedParam);
if (param instanceof ClientProtos.ScanRequest && rsRpcServices != null) {
ClientProtos.ScanRequest request = ((ClientProtos.ScanRequest) param);
String scanDetails;
if (request.hasScannerId()) {
long scannerId = request.getScannerId();
String scanDetails = rsRpcServices.getScanDetailsWithId(scannerId);
if (scanDetails != null) {
responseInfo.put("scandetails", scanDetails);
}
scanDetails = rsRpcServices.getScanDetailsWithId(scannerId);
} else {
scanDetails = rsRpcServices.getScanDetailsWithRequest(request);
}
if (scanDetails != null) {
responseInfo.put("scandetails", scanDetails);
}
}
if (param instanceof ClientProtos.MultiRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,21 @@ public String getScanDetailsWithId(long scannerId) {
return builder.toString();
}

public String getScanDetailsWithRequest(ScanRequest request) {
try {
if (!request.hasRegion()) {
return null;
}
Region region = getRegion(request.getRegion());
StringBuilder builder = new StringBuilder();
builder.append("table: ").append(region.getRegionInfo().getTable().getNameAsString());
builder.append(" region: ").append(region.getRegionInfo().getRegionNameAsString());
return builder.toString();
} catch (IOException ignored) {
return null;
}
}

/**
* Get the vtime associated with the scanner.
* Currently the vtime is the number of "next" calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.client;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.mockito.Mockito;

/**
Expand All @@ -39,12 +39,17 @@ public class HConnectionTestingUtility {
* probably not what you want.
* @param conf configuration
* @return ConnectionImplementation object for <code>conf</code>
* @throws ZooKeeperConnectionException
* @throws IOException
*/
public static Connection getMockedConnection(final Configuration conf)
throws ZooKeeperConnectionException {
throws IOException {
Connection connection = Mockito.mock(Connection.class);
Mockito.when(connection.getConfiguration()).thenReturn(conf);
Table t = Mockito.mock(Table.class);
Mockito.when(connection.getTable(Mockito.any())).thenReturn(t);
ResultScanner rs = Mockito.mock(ResultScanner.class);
Mockito.when(t.getScanner((Scan)Mockito.any())).thenReturn(rs);

return connection;
}
}

0 comments on commit aceba6f

Please sign in to comment.