[ 
https://issues.apache.org/jira/browse/HBASE-18869?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16197233#comment-16197233
 ] 

Chenxi Tong commented on HBASE-18869:
-------------------------------------

Hi, [~yuzhih...@gmail.com] thanks for reply! 
The ReadRequestsCount not satisfy my requirement, it records scan results in 
RSRpcServices, it bigger much than readRequest of requestCount in 
RSRpcServices, so i want to use rpcReadRequestsCount to accumulate the 
rpcGetRequestCount and rpcScanRequestCount to compute read request per second.

{code:java}
while (i < maxResults) {
          // Reset the batch progress to 0 before every call to 
RegionScanner#nextRaw. The
          // batch limit is a limit on the number of cells per Result. Thus, if 
progress is
          // being tracked (i.e. scannerContext.keepProgress() is true) then we 
need to
          // reset the batch progress between nextRaw invocations since we 
don't want the
          // batch progress from previous calls to affect future calls
          scannerContext.setBatchProgress(0);

          // Collect values to be returned here
          moreRows = scanner.nextRaw(values, scannerContext);

          if (!values.isEmpty()) {
            Result r = Result.create(values, null, stale, 
scannerContext.hasMoreCellsInRow());
            lastBlock.setValue(addSize(context, r, lastBlock.getValue()));
            results.add(r);
            i++;
          }

          boolean sizeLimitReached = 
scannerContext.checkSizeLimit(LimitScope.BETWEEN_ROWS);
          boolean timeLimitReached = 
scannerContext.checkTimeLimit(LimitScope.BETWEEN_ROWS);
          boolean rowLimitReached = i >= maxResults;
          limitReached = sizeLimitReached || timeLimitReached || 
rowLimitReached;

          if (limitReached || !moreRows) {
            if (LOG.isTraceEnabled()) {
              LOG.trace("Done scanning. limitReached: " + limitReached + " 
moreRows: " + moreRows
                  + " scannerContext: " + scannerContext);
            }
            // We only want to mark a ScanResponse as a heartbeat message in 
the event that
            // there are more values to be read server side. If there aren't 
more values,
            // marking it as a heartbeat is wasteful because the client will 
need to issue
            // another ScanRequest only to realize that they already have all 
the values
            if (moreRows) {
              // Heartbeat messages occur when the time limit has been reached.
              builder.setHeartbeatMessage(timeLimitReached);
            }
            break;
          }
          values.clear();
        }
        if (limitReached || moreRows) {
          // We stopped prematurely
          builder.setMoreResultsInRegion(true);
        } else {
          // We didn't get a single batch
          builder.setMoreResultsInRegion(false);
        }

        // Check to see if the client requested that we track metrics server 
side. If the
        // client requested metrics, retrieve the metrics from the scanner 
context.
        if (trackMetrics) {
          Map<String, Long> metrics = 
scannerContext.getMetrics().getMetricsMap();
          ScanMetrics.Builder metricBuilder = ScanMetrics.newBuilder();
          NameInt64Pair.Builder pairBuilder = NameInt64Pair.newBuilder();

          for (Entry<String, Long> entry : metrics.entrySet()) {
            pairBuilder.setName(entry.getKey());
            pairBuilder.setValue(entry.getValue());
            metricBuilder.addMetrics(pairBuilder.build());
          }

          builder.setScanMetrics(metricBuilder.build());
        }
      }
      +region.updateReadRequestsCount(i);+
{code}

this patch is for branch-1.3.0, if you think the idea is feasible, i will 
attach the branch for master
thanks~~

> Table rpc metrics
> -----------------
>
>                 Key: HBASE-18869
>                 URL: https://issues.apache.org/jira/browse/HBASE-18869
>             Project: HBase
>          Issue Type: Wish
>          Components: metrics
>    Affects Versions: 1.3.0
>            Reporter: Chenxi Tong
>            Priority: Minor
>              Labels: metrics
>         Attachments: HBASE-18869.patch
>
>
> Hi all
> In the HBASE-15518, uses the MetricsTableWrapperAggregateImpl to aggregate 
> each region`s 
> totalRequestsCount,readRequestsCount,writeRequestsCount,memstoresSize 
> storeFilesSize, tableSize metrics and exports them to jmx, so i want to use 
> the totalRequestsCount`rate as table`rpc request, but found it is bigger much 
> more than ServerLoad`s requestsPerSecond, i am not sure if it is a correct 
> way to do this, how we can collect each table`s rpc request?
> Best wishes!



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to