当前位置: 首页>>代码示例>>Java>>正文


Java MetricsAsserts.getLongGauge方法代码示例

本文整理汇总了Java中org.apache.hadoop.test.MetricsAsserts.getLongGauge方法的典型用法代码示例。如果您正苦于以下问题:Java MetricsAsserts.getLongGauge方法的具体用法?Java MetricsAsserts.getLongGauge怎么用?Java MetricsAsserts.getLongGauge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.test.MetricsAsserts的用法示例。


在下文中一共展示了MetricsAsserts.getLongGauge方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForDnMetricValue

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
/**
 * Wait for the named gauge value from the metrics source to reach the
 * desired value.
 *
 * There's an initial delay then a spin cycle of sleep and poll. Because
 * all the tests use a shared FS instance, these tests are not independent;
 * that's why the initial sleep is in there.
 *
 * @param source metrics source
 * @param name gauge name
 * @param expected expected value
 * @return the last metrics record polled
 * @throws Exception if something went wrong.
 */
private MetricsRecordBuilder waitForDnMetricValue(String source,
                                                  String name,
                                                  long expected)
    throws Exception {
  MetricsRecordBuilder rb;
  long gauge;
  //initial wait.
  waitForDeletion();
  //lots of retries are allowed for slow systems; fast ones will still
  //exit early
  int retries = (DATANODE_COUNT + 1) * WAIT_GAUGE_VALUE_RETRIES;
  rb = getMetrics(source);
  gauge = MetricsAsserts.getLongGauge(name, rb);
  while (gauge != expected && (--retries > 0)) {
    Thread.sleep(DFS_REPLICATION_INTERVAL * 500);
    rb = getMetrics(source);
    gauge = MetricsAsserts.getLongGauge(name, rb);
  }
  //at this point the assertion is valid or the retry count ran out
  assertGauge(name, expected, rb);
  return rb;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestNameNodeMetrics.java

示例2: waitForDnMetricValue

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
/**
 * Wait for the named gauge value from the metrics source to reach the
 * desired value.
 * <p/>
 * There's an initial delay then a spin cycle of sleep and poll. Because
 * all the tests use a shared FS instance, these tests are not independent;
 * that's why the initial sleep is in there.
 *
 * @param source
 *     metrics source
 * @param name
 *     gauge name
 * @param expected
 *     expected value
 * @return the last metrics record polled
 * @throws Exception
 *     if something went wrong.
 */
private MetricsRecordBuilder waitForDnMetricValue(String source, String name,
    long expected) throws Exception {
  MetricsRecordBuilder rb;
  long gauge;
  //initial wait.
  waitForDeletion();
  //lots of retries are allowed for slow systems; fast ones will still
  //exit early
  int retries = (DATANODE_COUNT + 1) * WAIT_GAUGE_VALUE_RETRIES;
  rb = getMetrics(source);
  gauge = MetricsAsserts.getLongGauge(name, rb);
  while (gauge != expected && (--retries > 0)) {
    Thread.sleep(DFS_REPLICATION_INTERVAL * 500);
    rb = getMetrics(source);
    gauge = MetricsAsserts.getLongGauge(name, rb);
  }
  //at this point the assertion is valid or the retry count ran out
  assertGauge(name, expected, rb);
  return rb;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:39,代码来源:TestNameNodeMetrics.java

示例3: testCapacityMetrics

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
/**
 * Test that capacity metrics are exported and pass
 * basic sanity tests.
 */
@Test (timeout = 1800)
public void testCapacityMetrics() throws Exception {
  MetricsRecordBuilder rb = getMetrics(NS_METRICS);
  long capacityTotal = MetricsAsserts.getLongGauge("CapacityTotal", rb);
  assert(capacityTotal != 0);
  long capacityUsed = MetricsAsserts.getLongGauge("CapacityUsed", rb);
  long capacityRemaining =
      MetricsAsserts.getLongGauge("CapacityRemaining", rb);
  long capacityUsedNonDFS =
      MetricsAsserts.getLongGauge("CapacityUsedNonDFS", rb);
  assert(capacityUsed + capacityRemaining + capacityUsedNonDFS ==
      capacityTotal);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestNameNodeMetrics.java

示例4: testTransactionAndCheckpointMetrics

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
/**
 * Test NN checkpoint and transaction-related metrics.
 */
@Test
public void testTransactionAndCheckpointMetrics() throws Exception {
  long lastCkptTime = MetricsAsserts.getLongGauge("LastCheckpointTime",
      getMetrics(NS_METRICS));
  
  assertGauge("LastCheckpointTime", lastCkptTime, getMetrics(NS_METRICS));
  assertGauge("LastWrittenTransactionId", 1L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 1L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 1L, getMetrics(NS_METRICS));
  
  fs.mkdirs(new Path(TEST_ROOT_DIR_PATH, "/tmp"));
  updateMetrics();
  
  assertGauge("LastCheckpointTime", lastCkptTime, getMetrics(NS_METRICS));
  assertGauge("LastWrittenTransactionId", 2L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 2L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 2L, getMetrics(NS_METRICS));
  
  cluster.getNameNodeRpc().rollEditLog();
  updateMetrics();
  
  assertGauge("LastCheckpointTime", lastCkptTime, getMetrics(NS_METRICS));
  assertGauge("LastWrittenTransactionId", 4L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 4L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 1L, getMetrics(NS_METRICS));
  
  cluster.getNameNodeRpc().setSafeMode(SafeModeAction.SAFEMODE_ENTER, false);
  cluster.getNameNodeRpc().saveNamespace();
  cluster.getNameNodeRpc().setSafeMode(SafeModeAction.SAFEMODE_LEAVE, false);
  updateMetrics();
  
  long newLastCkptTime = MetricsAsserts.getLongGauge("LastCheckpointTime",
      getMetrics(NS_METRICS));
  assertTrue(lastCkptTime < newLastCkptTime);
  assertGauge("LastWrittenTransactionId", 6L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 1L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 1L, getMetrics(NS_METRICS));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:TestNameNodeMetrics.java

示例5: testTransactionAndCheckpointMetrics

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
/**
 * Test NN checkpoint and transaction-related metrics.
 */
@Test
public void testTransactionAndCheckpointMetrics() throws Exception {
  long lastCkptTime = MetricsAsserts.getLongGauge("LastCheckpointTime",
      getMetrics(NS_METRICS));
  
  assertGauge("LastCheckpointTime", lastCkptTime, getMetrics(NS_METRICS));
  assertGauge("LastWrittenTransactionId", 1L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 1L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 1L, getMetrics(NS_METRICS));
  
  fs.mkdirs(new Path(TEST_ROOT_DIR_PATH, "/tmp"));
  
  assertGauge("LastCheckpointTime", lastCkptTime, getMetrics(NS_METRICS));
  assertGauge("LastWrittenTransactionId", 2L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 2L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 2L, getMetrics(NS_METRICS));
  
  cluster.getNameNodeRpc().rollEditLog();
  
  assertGauge("LastCheckpointTime", lastCkptTime, getMetrics(NS_METRICS));
  assertGauge("LastWrittenTransactionId", 4L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 4L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 1L, getMetrics(NS_METRICS));
  
  cluster.getNameNodeRpc().setSafeMode(SafeModeAction.SAFEMODE_ENTER, false);
  cluster.getNameNodeRpc().saveNamespace(0, 0);
  cluster.getNameNodeRpc().setSafeMode(SafeModeAction.SAFEMODE_LEAVE, false);
  
  long newLastCkptTime = MetricsAsserts.getLongGauge("LastCheckpointTime",
      getMetrics(NS_METRICS));
  assertTrue(lastCkptTime < newLastCkptTime);
  assertGauge("LastWrittenTransactionId", 6L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastCheckpoint", 1L, getMetrics(NS_METRICS));
  assertGauge("TransactionsSinceLastLogRoll", 1L, getMetrics(NS_METRICS));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:39,代码来源:TestNameNodeMetrics.java

示例6: testJournal

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
@Test(timeout=100000)
public void testJournal() throws Exception {
  MetricsRecordBuilder metrics = MetricsAsserts.getMetrics(
      journal.getMetricsForTests().getName());
  MetricsAsserts.assertCounter("BatchesWritten", 0L, metrics);
  MetricsAsserts.assertCounter("BatchesWrittenWhileLagging", 0L, metrics);
  MetricsAsserts.assertGauge("CurrentLagTxns", 0L, metrics);
  MetricsAsserts.assertGauge("LastJournalTimestamp", 0L, metrics);

  long beginTimestamp = System.currentTimeMillis();
  IPCLoggerChannel ch = new IPCLoggerChannel(
      conf, FAKE_NSINFO, journalId, jn.getBoundIpcAddress());
  ch.newEpoch(1).get();
  ch.setEpoch(1);
  ch.startLogSegment(1, NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION).get();
  ch.sendEdits(1L, 1, 1, "hello".getBytes(Charsets.UTF_8)).get();
  
  metrics = MetricsAsserts.getMetrics(
      journal.getMetricsForTests().getName());
  MetricsAsserts.assertCounter("BatchesWritten", 1L, metrics);
  MetricsAsserts.assertCounter("BatchesWrittenWhileLagging", 0L, metrics);
  MetricsAsserts.assertGauge("CurrentLagTxns", 0L, metrics);
  long lastJournalTimestamp = MetricsAsserts.getLongGauge(
      "LastJournalTimestamp", metrics);
  assertTrue(lastJournalTimestamp > beginTimestamp);
  beginTimestamp = lastJournalTimestamp;

  ch.setCommittedTxId(100L);
  ch.sendEdits(1L, 2, 1, "goodbye".getBytes(Charsets.UTF_8)).get();

  metrics = MetricsAsserts.getMetrics(
      journal.getMetricsForTests().getName());
  MetricsAsserts.assertCounter("BatchesWritten", 2L, metrics);
  MetricsAsserts.assertCounter("BatchesWrittenWhileLagging", 1L, metrics);
  MetricsAsserts.assertGauge("CurrentLagTxns", 98L, metrics);
  lastJournalTimestamp = MetricsAsserts.getLongGauge(
      "LastJournalTimestamp", metrics);
  assertTrue(lastJournalTimestamp > beginTimestamp);

}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:41,代码来源:TestJournalNode.java

示例7: testCapacityMetrics

import org.apache.hadoop.test.MetricsAsserts; //导入方法依赖的package包/类
/**
 * Test that capacity metrics are exported and pass
 * basic sanity tests.
 */
@Test(timeout = 1800)
public void testCapacityMetrics() throws Exception {
  MetricsRecordBuilder rb = getMetrics(NS_METRICS);
  long capacityTotal = MetricsAsserts.getLongGauge("CapacityTotal", rb);
  assert (capacityTotal != 0);
  long capacityUsed = MetricsAsserts.getLongGauge("CapacityUsed", rb);
  long capacityRemaining =
      MetricsAsserts.getLongGauge("CapacityRemaining", rb);
  long capacityUsedNonDFS =
      MetricsAsserts.getLongGauge("CapacityUsedNonDFS", rb);
  assert (capacityUsed + capacityRemaining + capacityUsedNonDFS ==
      capacityTotal);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:18,代码来源:TestNameNodeMetrics.java


注:本文中的org.apache.hadoop.test.MetricsAsserts.getLongGauge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。