Package org.apache.hadoop.hbase.rest.metrics

Examples of org.apache.hadoop.hbase.rest.metrics.RESTMetrics


public class TestRESTMetrics {

  @Test
  public void testRESTMetrics() throws InterruptedException {
    long timeout = 2000;
    RESTMetrics test = new RESTMetrics();
    int incrementSucessfulGet = 20000;
    int incrementSucessfulDelete = 3000000;
    int incrementSucessfulPut = 3000000;
    int incrementRequest = incrementSucessfulGet + incrementSucessfulDelete + incrementSucessfulPut;

    int incrementFailedGetRequests = 100;
    int incrementFailedDeleteRequests = 30;
    int incrementFailedPutRequests = 2;

    long start1 = System.currentTimeMillis();
    test.doUpdates(null);

    // started value
    assertEquals(0, test.getRequests(), 0.01);
    assertEquals(0, test.getSucessfulDeleteCount(), 0.01);
    assertEquals(0, test.getSucessfulPutCount(), 0.01);
    assertEquals(0, test.getSucessfulGetCount(), 0.01);
    assertEquals(0, test.getFailedDeleteCount(), 0.01);
    assertEquals(0, test.getFailedGetCount(), 0.01);
    assertEquals(0, test.getFailedPutCount(), 0.01);

    // sleep some seconds
    Thread.sleep(timeout);
    test.incrementRequests(incrementRequest);
    test.incrementSucessfulGetRequests(incrementSucessfulGet);
    test.incrementSucessfulDeleteRequests(incrementSucessfulDelete);
    test.incrementSucessfulPutRequests(incrementSucessfulPut);
    test.incrementFailedGetRequests(incrementFailedGetRequests);
    test.incrementFailedDeleteRequests(incrementFailedDeleteRequests);
    test.incrementFailedPutRequests(incrementFailedPutRequests);

    test.doUpdates(null);

    // The maximum time for stability test
    long tmax = System.currentTimeMillis() - start1;

    testData(tmax, timeout, test.getRequests(), incrementRequest);
    testData(tmax, timeout, test.getSucessfulGetCount(), incrementSucessfulGet);
    testData(tmax, timeout, test.getSucessfulDeleteCount(), incrementSucessfulDelete);
    testData(tmax, timeout, test.getSucessfulPutCount(), incrementSucessfulPut);
    testData(tmax, timeout, test.getFailedGetCount(), incrementFailedGetRequests);
    testData(tmax, timeout, test.getFailedDeleteCount(), incrementFailedDeleteRequests);
    testData(tmax, timeout, test.getFailedPutCount(), incrementFailedPutRequests);

    test.shutdown();
  }
View Full Code Here


   * @throws IOException.
   */
  RESTServlet(Configuration conf) throws IOException {
    this.conf = conf;
    this.pool = new HTablePool(conf, 10);
    this.metrics = new RESTMetrics();
    this.admin = new HBaseAdmin(conf);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.rest.metrics.RESTMetrics

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.