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;
}
Aggregations