Skip to content

Commit

Permalink
HBASE-13158 When client supports CellBlock, return the result Cells a…
Browse files Browse the repository at this point in the history
…s controller payload for get(Get) API also.
  • Loading branch information
anoopsjohn committed Dec 18, 2015
1 parent 2716095 commit 408666a
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public Result call(int callTimeout) throws IOException {
try {
ClientProtos.GetResponse response = getStub().get(controller, request);
if (response == null) return null;
return ProtobufUtil.toResult(response.getResult());
return ProtobufUtil.toResult(response.getResult(), controller.cellScanner());
} catch (ServiceException se) {
throw ProtobufUtil.getRemoteException(se);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Result call(int callTimeout) throws Exception {
if (response == null) {
return null;
}
return ProtobufUtil.toResult(response.getResult());
return ProtobufUtil.toResult(response.getResult(), controller.cellScanner());
} catch (ServiceException se) {
throw ProtobufUtil.getRemoteException(se);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3137,7 +3137,13 @@ public static List<ReplicationLoadSource> toReplicationLoadSourceList(
*/
public static HBaseProtos.VersionInfo getVersionInfo() {
HBaseProtos.VersionInfo.Builder builder = HBaseProtos.VersionInfo.newBuilder();
builder.setVersion(VersionInfo.getVersion());
String version = VersionInfo.getVersion();
builder.setVersion(version);
String[] components = version.split("\\.");
if (components != null && components.length > 2) {
builder.setVersionMajor(Integer.parseInt(components[0]));
builder.setVersionMinor(Integer.parseInt(components[1]));
}
builder.setUrl(VersionInfo.getUrl());
builder.setRevision(VersionInfo.getRevision());
builder.setUser(VersionInfo.getUser());
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions hbase-protocol/src/main/protobuf/HBase.proto
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ message VersionInfo {
required string user = 4;
required string date = 5;
required string src_checksum = 6;
optional uint32 version_major = 7;
optional uint32 version_minor = 8;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public static boolean hasMinimumVersion(HBaseProtos.VersionInfo versionInfo,
int major,
int minor) {
if (versionInfo != null) {
if (versionInfo.hasVersionMajor() && versionInfo.hasVersionMinor()) {
int clientMajor = versionInfo.getVersionMajor();
if (clientMajor != major) {
return clientMajor > major;
}
int clientMinor = versionInfo.getVersionMinor();
return clientMinor >= minor;
}
try {
String[] components = versionInfo.getVersion().split("\\.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.RowMutations;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.VersionInfoUtil;
import org.apache.hadoop.hbase.conf.ConfigurationObserver;
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
import org.apache.hadoop.hbase.exceptions.MergeRegionException;
Expand Down Expand Up @@ -2100,7 +2101,16 @@ public GetResponse get(final RpcController controller,
ProtobufUtil.toResult(existence, region.getRegionInfo().getReplicaId() != 0);
builder.setResult(pbr);
} else if (r != null) {
ClientProtos.Result pbr = ProtobufUtil.toResult(r);
ClientProtos.Result pbr;
RpcCallContext call = RpcServer.getCurrentCall();
if (isClientCellBlockSupport(call) && controller instanceof PayloadCarryingRpcController
&& VersionInfoUtil.hasMinimumVersion(call.getClientVersionInfo(), 1, 3)) {
pbr = ProtobufUtil.toResultNoData(r);
((PayloadCarryingRpcController) controller).setCellScanner(CellUtil.createCellScanner(r
.rawCells()));
} else {
pbr = ProtobufUtil.toResult(r);
}
builder.setResult(pbr);
}
if (r != null) {
Expand Down

0 comments on commit 408666a

Please sign in to comment.