Search in sources :

Example 1 with HadoopConf

use of com.dtstack.taier.yarn.util.HadoopConf in project Taier by DTStack.

the class DtYarnClient method testYarnConnect.

private ComponentTestResult testYarnConnect(ComponentTestResult testResult, Config allConfig) {
    try {
        HadoopConf hadoopConf = new HadoopConf();
        hadoopConf.initYarnConf(allConfig.getYarnConf());
        YarnClient testYarnClient = YarnClient.createYarnClient();
        testYarnClient.init(hadoopConf.getYarnConfiguration());
        testYarnClient.start();
        List<NodeReport> nodes = testYarnClient.getNodeReports(NodeState.RUNNING);
        int totalMemory = 0;
        int totalCores = 0;
        for (NodeReport rep : nodes) {
            totalMemory += rep.getCapability().getMemory();
            totalCores += rep.getCapability().getVirtualCores();
        }
        boolean isFullPath = hadoopConf.getYarnConfiguration().getBoolean(ConfigConstrant.IS_FULL_PATH_KEY, false);
        String rootQueueName = isFullPath ? getRootQueueName(testYarnClient) : "";
        List<ComponentTestResult.QueueDescription> descriptions = getQueueDescription(rootQueueName, testYarnClient.getRootQueueInfos(), isFullPath);
        testResult.setClusterResourceDescription(new ComponentTestResult.ClusterResourceDescription(nodes.size(), totalMemory, totalCores, descriptions));
    } catch (Exception e) {
        LOG.error("test yarn connect error", e);
        throw new PluginDefineException(e);
    }
    testResult.setResult(true);
    return testResult;
}
Also used : YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) IOException(java.io.IOException) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException) ComponentTestResult(com.dtstack.taier.pluginapi.pojo.ComponentTestResult) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException) HadoopConf(com.dtstack.taier.yarn.util.HadoopConf) NodeReport(org.apache.hadoop.yarn.api.records.NodeReport)

Aggregations

PluginDefineException (com.dtstack.taier.pluginapi.exception.PluginDefineException)1 ComponentTestResult (com.dtstack.taier.pluginapi.pojo.ComponentTestResult)1 HadoopConf (com.dtstack.taier.yarn.util.HadoopConf)1 IOException (java.io.IOException)1 NodeReport (org.apache.hadoop.yarn.api.records.NodeReport)1 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)1