Example usage for org.apache.hadoop.hdfs DistributedFileSystem getConf

List of usage examples for org.apache.hadoop.hdfs DistributedFileSystem getConf

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DistributedFileSystem getConf.

Prototype

@Override
    public Configuration getConf() 

Source Link

Usage

From source file:co.cask.cdap.operations.hdfs.HDFSOperationalStatsTest.java

License:Apache License

@Test
public void test() throws IOException {
    final DistributedFileSystem dfs = dfsCluster.getFileSystem();
    HDFSInfo hdfsInfo = new HDFSInfo(dfs.getConf());
    Assert.assertEquals(AbstractHDFSStats.SERVICE_NAME, hdfsInfo.getServiceName());
    Assert.assertEquals(HDFSInfo.STAT_TYPE, hdfsInfo.getStatType());
    Assert.assertNotNull(hdfsInfo.getVersion());
    String webAddress = hdfsInfo.getWebURL();
    Assert.assertNotNull(webAddress);//from  w w w  .  j ava 2s  . co m
    String logsAddress = hdfsInfo.getLogsURL();
    Assert.assertNotNull(logsAddress);
    URL webURL = new URL(webAddress);
    URL logsURL = new URL(logsAddress);
    Assert.assertNotNull(logsURL);
    Assert.assertEquals(webURL.getProtocol(), logsURL.getProtocol());
    Assert.assertEquals(webURL.getHost(), logsURL.getHost());
    Assert.assertEquals(webURL.getPort(), logsURL.getPort());
    Assert.assertEquals("/logs", logsURL.getPath());
    HDFSNodes hdfsNodes = new HDFSNodes(dfs.getConf());
    Assert.assertEquals(AbstractHDFSStats.SERVICE_NAME, hdfsNodes.getServiceName());
    Assert.assertEquals(HDFSNodes.STAT_TYPE, hdfsNodes.getStatType());
    Assert.assertEquals(0, hdfsNodes.getNamenodes());
    hdfsNodes.collect();
    Assert.assertEquals(1, hdfsNodes.getNamenodes());
    HDFSStorage hdfsStorage = new HDFSStorage(dfs.getConf());
    Assert.assertEquals(AbstractHDFSStats.SERVICE_NAME, hdfsStorage.getServiceName());
    Assert.assertEquals(HDFSStorage.STAT_TYPE, hdfsStorage.getStatType());
    Assert.assertEquals(0, hdfsStorage.getTotalBytes());
    Assert.assertEquals(0, hdfsStorage.getUsedBytes());
    Assert.assertEquals(0, hdfsStorage.getRemainingBytes());
    hdfsStorage.collect();
    Assert.assertEquals(0, hdfsStorage.getMissingBlocks());
    Assert.assertEquals(0, hdfsStorage.getUnderReplicatedBlocks());
    Assert.assertEquals(0, hdfsStorage.getCorruptBlocks());
    Assert.assertTrue(hdfsStorage.getTotalBytes() > hdfsStorage.getRemainingBytes());
    Assert.assertTrue(hdfsStorage.getTotalBytes() > hdfsStorage.getUsedBytes());
    Assert.assertTrue(hdfsStorage.getRemainingBytes() > 0);
    Assert.assertTrue(hdfsStorage.getUsedBytes() > 0);
}