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


Java JMXGet类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.tools.JMXGet的典型用法代码示例。如果您正苦于以下问题:Java JMXGet类的具体用法?Java JMXGet怎么用?Java JMXGet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JMXGet类属于org.apache.hadoop.hdfs.tools包,在下文中一共展示了JMXGet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkPrintAllValues

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
private static boolean checkPrintAllValues(JMXGet jmx) throws Exception {
  int size = 0; 
  byte[] bytes = null;
  String pattern = "List of all the available keys:";
  PipedOutputStream pipeOut = new PipedOutputStream();
  PipedInputStream pipeIn = new PipedInputStream(pipeOut);
  System.setErr(new PrintStream(pipeOut));
  jmx.printAllValues();
  if ((size = pipeIn.available()) != 0) {
    bytes = new byte[size];
    pipeIn.read(bytes, 0, bytes.length);            
  }
  pipeOut.close();
  pipeIn.close();
  return bytes != null ? new String(bytes).contains(pattern) : false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestJMXGet.java

示例2: testDataNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to DataNode..
 * @throws Exception 
 */
@Test
public void testDataNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test"), 2);

  JMXGet jmx = new JMXGet();
  String serviceName = "DataNode";
  jmx.setService(serviceName);
  jmx.init();
  assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));

  cluster.shutdown();
  MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
  ObjectName query = new ObjectName("Hadoop:service=" + serviceName + ",*");
  Set<ObjectName> names = mbsc.queryNames(query, null);
  assertTrue("No beans should be registered for " + serviceName, names.isEmpty());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestJMXGet.java

示例3: checkPrintAllValues

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
private static boolean checkPrintAllValues(JMXGet jmx) throws Exception {
  int size = 0; 
  byte[] bytes = null;
  String pattern = "List of all the available keys:";
  PipedOutputStream pipeOut = new PipedOutputStream();
  PipedInputStream pipeIn = new PipedInputStream(pipeOut);
  PrintStream oldErr = System.err;
  System.setErr(new PrintStream(pipeOut));
  try {
    jmx.printAllValues();
    if ((size = pipeIn.available()) != 0) {
      bytes = new byte[size];
      pipeIn.read(bytes, 0, bytes.length);
    }
    pipeOut.close();
    pipeIn.close();
  } finally {
    System.setErr(oldErr);
  }
  return bytes != null ? new String(bytes).contains(pattern) : false;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:22,代码来源:TestJMXGet.java

示例4: testDataNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to DataNode..
 * @throws Exception 
 */
@Test
public void testDataNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  DFSTestUtil.createFile(cluster.getFileSystem(), new Path("/test"),
      fileSize, fileSize, blockSize, (short) 2, seed);

  JMXGet jmx = new JMXGet();
  String serviceName = "DataNode";
  jmx.setService(serviceName);
  jmx.init();
  DFSTestUtil.waitForMetric(jmx, "BytesWritten", fileSize);
  assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));

  cluster.shutdown();
  MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
  ObjectName query = new ObjectName("Hadoop:service=" + serviceName + ",*");
  Set<ObjectName> names = mbsc.queryNames(query, null);
  assertTrue("No beans should be registered for " + serviceName, names.isEmpty());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestJMXGet.java

示例5: waitForMetric

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
public static void waitForMetric(final JMXGet jmx, final String metricName, final int expectedValue)
    throws TimeoutException, InterruptedException {
  GenericTestUtils.waitFor(new Supplier<Boolean>() {
    @Override
    public Boolean get() {
      try {
        final int currentValue = Integer.parseInt(jmx.getValue(metricName));
        LOG.info("Waiting for " + metricName +
                     " to reach value " + expectedValue +
                     ", current value = " + currentValue);
        return currentValue == expectedValue;
      } catch (Exception e) {
        throw new UnhandledException("Test failed due to unexpected exception", e);
      }
    }
  }, 1000, Integer.MAX_VALUE);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:DFSTestUtil.java

示例6: testNameNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to NameNode..
 * @throws Exception 
 */
public void testNameNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster(0, config, numDatanodes, true, true, null, 
      null, null);
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test1"), 2);

  JMXGet jmx = new JMXGet();
  jmx.init();


  //get some data from different sources
  int blocks_corrupted = NameNode.getNameNodeMetrics().
  numBlocksCorrupted.get();
  assertEquals(Integer.parseInt(
      jmx.getValue("NumLiveDataNodes")), 2);
  assertEquals(Integer.parseInt(
      jmx.getValue("BlocksCorrupted")), blocks_corrupted);
  assertEquals(Long.parseLong(
      jmx.getValue("NumOpenConnectionsAvgTime")), 0);

  cluster.shutdown();
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:29,代码来源:TestJMXGet.java

示例7: testDataNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to DataNode..
 * @throws Exception 
 */
public void testDataNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster(0, config, numDatanodes, true, true, null,
      null, null);
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test"), 2);

  JMXGet jmx = new JMXGet();
  jmx.setService("DataNode");
  jmx.init();
  assertEquals(Integer.parseInt(jmx.getValue("bytes_written")), 0);

  cluster.shutdown();
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:20,代码来源:TestJMXGet.java

示例8: testNameNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to NameNode..
 * @throws Exception 
 */
@Test
public void testNameNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test1"), 2);

  JMXGet jmx = new JMXGet();
  //jmx.setService("*"); // list all hadoop services
  //jmx.init();
  //jmx = new JMXGet();
  jmx.init(); // default lists namenode mbeans only

  //get some data from different source
  assertEquals(numDatanodes, Integer.parseInt(
      jmx.getValue("NumLiveDataNodes")));
  assertGauge("CorruptBlocks", Long.parseLong(jmx.getValue("CorruptBlocks")),
              getMetrics("FSNamesystem"));
  assertEquals(numDatanodes, Integer.parseInt(
      jmx.getValue("NumOpenConnections")));

  cluster.shutdown();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:29,代码来源:TestJMXGet.java

示例9: testDataNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to DataNode..
 * @throws Exception 
 */
@Test
public void testDataNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test"), 2);

  JMXGet jmx = new JMXGet();
  //jmx.setService("*"); // list all hadoop services
  //jmx.init();
  //jmx = new JMXGet();
  jmx.setService("DataNode");
  jmx.init();
  assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));

  cluster.shutdown();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:23,代码来源:TestJMXGet.java

示例10: testDataNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to DataNode..
 *
 * @throws Exception
 */
@Test
public void testDataNode() throws Exception {
  int numDatanodes = 2;
  cluster =
      new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test"), 2);

  JMXGet jmx = new JMXGet();
  //jmx.setService("*"); // list all hadoop services
  //jmx.init();
  //jmx = new JMXGet();
  jmx.setService("DataNode");
  jmx.init();
  Thread.sleep(15000);
  assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));

  cluster.shutdown();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:26,代码来源:TestJMXGet.java

示例11: testNameNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to NameNode..
 * @throws Exception 
 */
public void testNameNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test1"), 2);

  JMXGet jmx = new JMXGet();
  jmx.init();


  //get some data from different sources
  int blocks_corrupted = NameNode.getNameNodeMetrics().
  numBlocksCorrupted.get();
  assertEquals(Integer.parseInt(
      jmx.getValue("NumLiveDataNodes")), 2);
  assertEquals(Integer.parseInt(
      jmx.getValue("BlocksCorrupted")), blocks_corrupted);
  assertEquals(Integer.parseInt(
      jmx.getValue("NumOpenConnections")), 0);

  cluster.shutdown();
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:28,代码来源:TestJMXGet.java

示例12: testNameNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to NameNode..
 * @throws Exception 
 */
public void testNameNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster(0, config, numDatanodes, true, true, null, 
      null, null);
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test1"), 2);

  JMXGet jmx = new JMXGet();
  jmx.init();


  //get some data from different sources
  int blocks_corrupted = NameNode.getNameNodeMetrics().
  numBlocksCorrupted.get();
  assertEquals(Integer.parseInt(
      jmx.getValue("NumLiveDataNodes")), 2);
  assertEquals(Integer.parseInt(
      jmx.getValue("BlocksCorrupted")), blocks_corrupted);
  assertEquals(Integer.parseInt(
      jmx.getValue("NumOpenConnections")), 0);

  cluster.shutdown();
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:29,代码来源:TestJMXGet.java

示例13: testNameNode

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
/**
 * test JMX connection to NameNode..
 * @throws Exception 
 */
@Test
public void testNameNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test1"), 2);

  JMXGet jmx = new JMXGet();
  String serviceName = "NameNode";
  jmx.setService(serviceName);
  jmx.init(); // default lists namenode mbeans only
  assertTrue("error printAllValues", checkPrintAllValues(jmx));

  //get some data from different source
  assertEquals(numDatanodes, Integer.parseInt(
      jmx.getValue("NumLiveDataNodes")));
  assertGauge("CorruptBlocks", Long.parseLong(jmx.getValue("CorruptBlocks")),
              getMetrics("FSNamesystem"));
  assertEquals(numDatanodes, Integer.parseInt(
      jmx.getValue("NumOpenConnections")));

  cluster.shutdown();
  MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
  ObjectName query = new ObjectName("Hadoop:service=" + serviceName + ",*");
  Set<ObjectName> names = mbsc.queryNames(query, null);
  assertTrue("No beans should be registered for " + serviceName, names.isEmpty());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:TestJMXGet.java

示例14: checkOutput

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
private void checkOutput(String[] args, String pattern, PrintStream out,
    Class<?> clazz) {       
  ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
  try {
    PipedOutputStream pipeOut = new PipedOutputStream();
    PipedInputStream pipeIn = new PipedInputStream(pipeOut, PIPE_BUFFER_SIZE);
    if (out == System.out) {
      System.setOut(new PrintStream(pipeOut));
    } else if (out == System.err) {
      System.setErr(new PrintStream(pipeOut));
    }

    if (clazz == DelegationTokenFetcher.class) {
      expectDelegationTokenFetcherExit(args);
    } else if (clazz == JMXGet.class) {
      expectJMXGetExit(args);
    } else if (clazz == DFSAdmin.class) {
      expectDfsAdminPrint(args);
    }
    pipeOut.close();
    ByteStreams.copy(pipeIn, outBytes);      
    pipeIn.close();
    assertTrue(new String(outBytes.toByteArray()).contains(pattern));            
  } catch (Exception ex) {
    fail("checkOutput error " + ex);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestTools.java

示例15: expectJMXGetExit

import org.apache.hadoop.hdfs.tools.JMXGet; //导入依赖的package包/类
private static void expectJMXGetExit(String[] args) {
  try {
    JMXGet.main(args);
    fail("should call exit");
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } catch (Exception ex) {
    fail("expectJMXGetExit ex error " + ex);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestTools.java


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