HBASE-9989 Add a test on get in TestClientNoCluster
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1543514 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
335071f342
commit
56d089a3e4
|
@ -437,10 +437,21 @@ public class TestClientNoCluster extends Configured implements Tool {
|
||||||
throws ServiceException {
|
throws ServiceException {
|
||||||
boolean metaRegion = isMetaRegion(request.getRegion().getValue().toByteArray(),
|
boolean metaRegion = isMetaRegion(request.getRegion().getValue().toByteArray(),
|
||||||
request.getRegion().getType());
|
request.getRegion().getType());
|
||||||
if (!metaRegion) throw new UnsupportedOperationException();
|
if (!metaRegion) {
|
||||||
|
return doGetResponse(request);
|
||||||
|
}
|
||||||
return doMetaGetResponse(meta, request);
|
return doMetaGetResponse(meta, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GetResponse doGetResponse(GetRequest request) {
|
||||||
|
ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
|
||||||
|
ByteString row = request.getGet().getRow();
|
||||||
|
resultBuilder.addCell(getStartCode(row));
|
||||||
|
GetResponse.Builder builder = GetResponse.newBuilder();
|
||||||
|
builder.setResult(resultBuilder.build());
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MutateResponse mutate(RpcController controller,
|
public MutateResponse mutate(RpcController controller,
|
||||||
MutateRequest request) throws ServiceException {
|
MutateRequest request) throws ServiceException {
|
||||||
|
@ -693,19 +704,25 @@ public class TestClientNoCluster extends Configured implements Tool {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
final int printInterval = 100000;
|
final int printInterval = 100000;
|
||||||
Random rd = new Random(id);
|
Random rd = new Random(id);
|
||||||
|
boolean get = c.getBoolean("hbase.test.do.gets", false);
|
||||||
try {
|
try {
|
||||||
Stopwatch stopWatch = new Stopwatch();
|
Stopwatch stopWatch = new Stopwatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
for (int i = 0; i < namespaceSpan; i++) {
|
for (int i = 0; i < namespaceSpan; i++) {
|
||||||
byte [] b = format(rd.nextLong());
|
byte [] b = format(rd.nextLong());
|
||||||
Put p = new Put(b);
|
if (get){
|
||||||
p.add(HConstants.CATALOG_FAMILY, b, b);
|
Get g = new Get(b);
|
||||||
|
table.get(g);
|
||||||
|
} else {
|
||||||
|
Put p = new Put(b);
|
||||||
|
p.add(HConstants.CATALOG_FAMILY, b, b);
|
||||||
|
table.put(p);
|
||||||
|
}
|
||||||
if (i % printInterval == 0) {
|
if (i % printInterval == 0) {
|
||||||
LOG.info("Put " + printInterval + "/" + stopWatch.elapsedMillis());
|
LOG.info("Put " + printInterval + "/" + stopWatch.elapsedMillis());
|
||||||
stopWatch.reset();
|
stopWatch.reset();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
}
|
}
|
||||||
table.put(p);
|
|
||||||
}
|
}
|
||||||
LOG.info("Finished a cycle putting " + namespaceSpan + " in " +
|
LOG.info("Finished a cycle putting " + namespaceSpan + " in " +
|
||||||
(System.currentTimeMillis() - startTime) + "ms");
|
(System.currentTimeMillis() - startTime) + "ms");
|
||||||
|
|
Loading…
Reference in New Issue