Search in sources :

Example 1 with GetClusterMetricsRequest

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();
}
Also used : GetClusterMetricsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse) GetClusterMetricsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest)

Example 2 with GetClusterMetricsRequest

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;
}
Also used : GetClusterMetricsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Aggregations

GetClusterMetricsRequest (org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest)2 GetClusterMetricsResponse (org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)1