org.apache.hadoop.hdfs.tools.JMXGet Java Examples
The following examples show how to use
org.apache.hadoop.hdfs.tools.JMXGet.
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 File: TestJMXGet.java From big-c with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: TestJMXGet.java From RDFS with Apache License 2.0 | 6 votes |
/** * 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 #3
Source File: TestJMXGet.java From RDFS with Apache License 2.0 | 6 votes |
/** * 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 File: TestJMXGet.java From big-c with Apache License 2.0 | 6 votes |
/** * 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 #5
Source File: TestJMXGet.java From hadoop with Apache License 2.0 | 6 votes |
/** * 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 #6
Source File: TestJMXGet.java From hadoop with Apache License 2.0 | 6 votes |
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; }
Example #7
Source File: TestTools.java From hadoop with Apache License 2.0 | 5 votes |
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); } }
Example #8
Source File: TestTools.java From hadoop with Apache License 2.0 | 5 votes |
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); } }
Example #9
Source File: TestJMXGet.java From big-c with Apache License 2.0 | 5 votes |
/** * 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 #10
Source File: TestJMXGet.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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 #11
Source File: TestTools.java From big-c with Apache License 2.0 | 5 votes |
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); } }
Example #12
Source File: TestTools.java From big-c with Apache License 2.0 | 5 votes |
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); } }
Example #13
Source File: TestTools.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testJMXToolAdditionParameter() { String pattern = "key = -addition"; checkOutput(new String[] { "-service=NameNode", "-server=localhost", "-addition" }, pattern, System.err, JMXGet.class); }
Example #14
Source File: LazyPersistTestCase.java From hadoop with Apache License 2.0 | 4 votes |
private JMXGet initJMX() throws Exception { JMXGet jmx = new JMXGet(); jmx.setService(JMX_SERVICE_NAME); jmx.init(); return jmx; }
Example #15
Source File: TestTools.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testJMXToolHelp() { String pattern = "usage: jmxget options are:"; checkOutput(new String[] { "-help" }, pattern, System.out, JMXGet.class); }
Example #16
Source File: TestTools.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testJMXToolHelp() { String pattern = "usage: jmxget options are:"; checkOutput(new String[] { "-help" }, pattern, System.out, JMXGet.class); }
Example #17
Source File: TestTools.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testJMXToolAdditionParameter() { String pattern = "key = -addition"; checkOutput(new String[] { "-service=NameNode", "-server=localhost", "-addition" }, pattern, System.err, JMXGet.class); }
Example #18
Source File: LazyPersistTestCase.java From big-c with Apache License 2.0 | 4 votes |
private JMXGet initJMX() throws Exception { JMXGet jmx = new JMXGet(); jmx.setService(JMX_SERVICE_NAME); jmx.init(); return jmx; }