Java Code Examples for org.apache.hadoop.hdfs.tools.JMXGet#init()

The following examples show how to use org.apache.hadoop.hdfs.tools.JMXGet#init() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   File: TestJMXGet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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());
}
 
Example 2
Source Project: big-c   File: TestJMXGet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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());
}
 
Example 3
Source Project: RDFS   File: TestJMXGet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example 4
Source Project: RDFS   File: TestJMXGet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example 5
Source Project: hadoop   File: TestJMXGet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 6
Source Project: big-c   File: TestJMXGet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 7
Source Project: hadoop   File: LazyPersistTestCase.java    License: Apache License 2.0 4 votes vote down vote up
private JMXGet initJMX() throws Exception {
  JMXGet jmx = new JMXGet();
  jmx.setService(JMX_SERVICE_NAME);
  jmx.init();
  return jmx;
}
 
Example 8
Source Project: big-c   File: LazyPersistTestCase.java    License: Apache License 2.0 4 votes vote down vote up
private JMXGet initJMX() throws Exception {
  JMXGet jmx = new JMXGet();
  jmx.setService(JMX_SERVICE_NAME);
  jmx.init();
  return jmx;
}