Package org.apache.hadoop.hbase.client.metrics

Examples of org.apache.hadoop.hbase.client.metrics.ScanMetrics


        Scan.SCAN_ATTRIBUTES_METRICS_DATA);
    if (serializedMetrics == null || serializedMetrics.length == 0 ) {
      return;
    }

    ScanMetrics scanMetrics = ProtobufUtil.toScanMetrics(serializedMetrics);

    updateCounters(scanMetrics, numRestarts, getCounter, context);
  }
View Full Code Here


      return;
    }

    DataInputBuffer in = new DataInputBuffer();
    in.reset(serializedMetrics, 0, serializedMetrics.length);
    ScanMetrics scanMetrics = new ScanMetrics();
    scanMetrics.readFields(in);
    MetricsTimeVaryingLong[] mlvs =
      scanMetrics.getMetricsTimeVaryingLongArray();

    try {
      for (MetricsTimeVaryingLong mlv : mlvs) {
        Counter ct = (Counter)this.getCounter.invoke(context,
          HBASE_COUNTER_GROUP_NAME, mlv.getName());
View Full Code Here

    try {
      pScanMetrics = parser.parseFrom(bytes);
    } catch (InvalidProtocolBufferException e) {
      //Ignored there are just no key values to add.
    }
    ScanMetrics scanMetrics = new ScanMetrics();
    if (pScanMetrics != null) {
      for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
        if (pair.hasName() && pair.hasValue()) {
          scanMetrics.setCounter(pair.getName(), pair.getValue());
        }
      }
    }
    return scanMetrics;
  }
View Full Code Here

      // create region scanner
      this.scanner = region.getScanner(scan);
      values = new ArrayList<KeyValue>();
      this.more = true;
      this.scanMetrics = new ScanMetrics();

      if (context != null) {
        this.context = context;
        getCounter = retrieveGetCounterWithStringsParams(context);
      }
View Full Code Here

    // the end of the scanner. So this is asking for 2 of the 3 rows we inserted.
    for (Result result : scanner.next(numRecords - 1)) {
    }
    scanner.close();

    ScanMetrics scanMetrics = getScanMetrics(scan);
    assertEquals("Did not access all the regions in the table", numOfRegions,
        scanMetrics.countOfRegions.getCurrentIntervalValue());

    // set caching to 100
    scan = new Scan();
    scan.setCaching(100);
    scan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE));
    scanner = ht.getScanner(scan);
    for (Result result : scanner.next(numRecords - 1)) {
    }
    scanner.close();
   
    scanMetrics = getScanMetrics(scan);
    assertEquals("Did not access all the regions in the table", numOfRegions,
        scanMetrics.countOfRegions.getCurrentIntervalValue());
   
    // now, test that the metrics are still collected even if you don't call close, but do
    // run past the end of all the records
    Scan scanWithoutClose = new Scan();
    scanWithoutClose.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE));
    ResultScanner scannerWithoutClose = ht.getScanner(scanWithoutClose);
    for (Result result : scannerWithoutClose.next(numRecords + 1)) {
    }
    ScanMetrics scanMetricsWithoutClose = getScanMetrics(scanWithoutClose);
    assertEquals("Did not access all the regions in the table", numOfRegions,
        scanMetricsWithoutClose.countOfRegions.getCurrentIntervalValue());

    // finally, test that the metrics are collected correctly if you both run past all the records,
    // AND close the scanner
    Scan scanWithClose = new Scan();
    scanWithClose.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE));
    ResultScanner scannerWithClose = ht.getScanner(scanWithClose);
    for (Result result : scannerWithClose.next(numRecords + 1)) {
    }
    scannerWithClose.close();
    ScanMetrics scanMetricsWithClose = getScanMetrics(scanWithClose);
    assertEquals("Did not access all the regions in the table", numOfRegions,
        scanMetricsWithClose.countOfRegions.getCurrentIntervalValue());
  }
View Full Code Here

    byte[] serializedMetrics = scan.getAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA);
    assertTrue("Serialized metrics were not found.", serializedMetrics != null);

    DataInputBuffer in = new DataInputBuffer();
    in.reset(serializedMetrics, 0, serializedMetrics.length);
    ScanMetrics scanMetrics = new ScanMetrics();
    scanMetrics.readFields(in);
    return scanMetrics;
  }
View Full Code Here

      // check if application wants to collect scan metrics
      byte[] enableMetrics = scan.getAttribute(
        Scan.SCAN_ATTRIBUTES_METRICS_ENABLE);
      if (enableMetrics != null && Bytes.toBoolean(enableMetrics)) {
        scanMetrics = new ScanMetrics();
      }

      // Use the caching from the Scan.  If not set, use the default cache setting for this table.
      if (this.scan.getCaching() > 0) {
        this.caching = this.scan.getCaching();
View Full Code Here

    try {
      pScanMetrics = parser.parseFrom(bytes);
    } catch (InvalidProtocolBufferException e) {
      //Ignored there are just no key values to add.
    }
    ScanMetrics scanMetrics = new ScanMetrics();
    if (pScanMetrics != null) {
      for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
        if (pair.hasName() && pair.hasValue()) {
          scanMetrics.setCounter(pair.getName(), pair.getValue());
        }
      }
    }
    return scanMetrics;
  }
View Full Code Here

    try {
      pScanMetrics = parser.parseFrom(bytes);
    } catch (InvalidProtocolBufferException e) {
      //Ignored there are just no key values to add.
    }
    ScanMetrics scanMetrics = new ScanMetrics();
    if (pScanMetrics != null) {
      for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
        if (pair.hasName() && pair.hasValue()) {
          scanMetrics.setCounter(pair.getName(), pair.getValue());
        }
      }
    }
    return scanMetrics;
  }
View Full Code Here

      if (this.row == null) {
        this.row = new ImmutableBytesWritable();
      }
      this.row.set(result.getRow());

      ScanMetrics scanMetrics = scanner.getScanMetrics();
      if (scanMetrics != null && context != null) {
        TableRecordReaderImpl.updateCounters(scanMetrics, 0, getCounter, context);
      }

      return true;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.metrics.ScanMetrics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.