Package org.apache.hadoop.hdfs.metrics

Examples of org.apache.hadoop.hdfs.metrics.DFSClientMetrics


  private static final long WRITE_SIZE_VALUE = 13;
  private static final long READ_SIZE_VALUE = 17;

  public void testSync() throws Exception{
    Thread[] threads = new Thread[THREAD_COUNT];
    final DFSClientMetrics metrics = new DFSClientMetrics();
    for(int i = 0; i < threads.length; i++) {
      threads[i] = new Thread(new Runnable() {

        @Override
        public void run() {
          for(int i = 0; i < OPERATIONS_PER_THREAD; i++) {
            metrics.incLsCalls();
            metrics.incNumCreateDirOps();
            metrics.incNumCreateFileOps();
            metrics.incPreadOps();
            metrics.incPreadSize(PREAD_SIZE_VALUE);
            metrics.incPreadTime(PREAD_TIME_VALUE);
            metrics.incReadOps();
            metrics.incReadsFromLocalFile();
            metrics.incReadSize(READ_SIZE_VALUE);
            metrics.incReadTime(READ_TIME_VALUE);
            metrics.incSyncTime(SYNC_TIME_VALUE);
            metrics.incWriteOps();
            metrics.incWriteSize(WRITE_SIZE_VALUE);
          }
        }
      });
    }
    for(int i = 0; i < threads.length; i++) {
View Full Code Here


  private static final long WRITE_SIZE_VALUE = 13;
  private static final long READ_SIZE_VALUE = 17;

  public void testSync() throws Exception{
    Thread[] threads = new Thread[THREAD_COUNT];
    final DFSClientMetrics metrics = new DFSClientMetrics(true);
    for(int i = 0; i < threads.length; i++) {
      threads[i] = new Thread(new Runnable() {

        @Override
        public void run() {
          for(int i = 0; i < OPERATIONS_PER_THREAD; i++) {
            metrics.incLsCalls();
            metrics.incNumCreateDirOps();
            metrics.incNumCreateFileOps();
            metrics.incPreadOps();
            metrics.incPreadSize(PREAD_SIZE_VALUE);
            metrics.incPreadTime(PREAD_TIME_VALUE);
            metrics.incReadOps();
            metrics.incReadsFromLocalFile();
            metrics.incReadSize(READ_SIZE_VALUE);
            metrics.incReadTime(READ_TIME_VALUE);
            metrics.incSyncTime(SYNC_TIME_VALUE);
            metrics.incWriteOps();
            metrics.incWriteSize(WRITE_SIZE_VALUE);
          }
        }
      });
    }
    for(int i = 0; i < threads.length; i++) {
      threads[i].start();
    }
    for(int i = 0; i < threads.length; i++) {
      threads[i].join();
    }

    // This is dependent to DFSClientMetrics private API; used to obtain value
    // of lsCalls.
    Method privateStringMethod = DFSClientMetrics.class
        .getDeclaredMethod("getAndResetLsCalls");
    privateStringMethod.setAccessible(true);

    long returnValue = (Long) privateStringMethod.invoke(metrics);
    assertEquals(THREAD_COUNT * OPERATIONS_PER_THREAD, returnValue);

    metrics.doUpdates(null);
   
    assertEquals(THREAD_COUNT * OPERATIONS_PER_THREAD,
        metrics.numCreateDirOps.getPreviousIntervalValue());
    assertEquals(THREAD_COUNT * OPERATIONS_PER_THREAD,
        metrics.numCreateFileOps.getPreviousIntervalValue());
View Full Code Here

      Configuration conf, FileSystem.Statistics stats, long uniqueId,
      DistributedFileSystem dfs)
    throws IOException {
    this.dfs = dfs;
    this.conf = conf;
    this.metrics = new DFSClientMetrics(conf.getBoolean(
        "dfs.client.metrics.enable", false));
    this.stats = stats;
    this.socketTimeout = conf.getInt("dfs.socket.timeout",
                                     HdfsConstants.READ_TIMEOUT);
    this.socketReadExtentionTimeout = conf.getInt(
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.metrics.DFSClientMetrics

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.