use of org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest in project hadoop by apache.
the class YarnClientImpl method getYarnClusterMetrics.
@Override
public YarnClusterMetrics getYarnClusterMetrics() throws YarnException, IOException {
GetClusterMetricsRequest request = Records.newRecord(GetClusterMetricsRequest.class);
GetClusterMetricsResponse response = rmClient.getClusterMetrics(request);
return response.getClusterMetrics();
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest in project hadoop by apache.
the class MiniYARNCluster method waitForNodeManagersToConnect.
/**
* Wait for all the NodeManagers to connect to the ResourceManager.
*
* @param timeout Time to wait (sleeps in 10 ms intervals) in milliseconds.
* @return true if all NodeManagers connect to the (Active)
* ResourceManager, false otherwise.
* @throws YarnException if there is no active RM
* @throws InterruptedException if any thread has interrupted
* the current thread
*/
public boolean waitForNodeManagersToConnect(long timeout) throws YarnException, InterruptedException {
GetClusterMetricsRequest req = GetClusterMetricsRequest.newInstance();
for (int i = 0; i < timeout / 10; i++) {
ResourceManager rm = getResourceManager();
if (rm == null) {
throw new YarnException("Can not find the active RM.");
} else if (nodeManagers.length == rm.getClientRMService().getClusterMetrics(req).getClusterMetrics().getNumNodeManagers()) {
LOG.info("All Node Managers connected in MiniYARNCluster");
return true;
}
Thread.sleep(10);
}
LOG.info("Node Managers did not connect within 5000ms");
return false;
}
Aggregations