Search in sources :

Example 1 with ClusterRetrieveException

use of org.apache.flink.client.deployment.ClusterRetrieveException in project flink by apache.

the class YarnClusterDescriptor method retrieve.

// -------------------------------------------------------------
// ClusterClient overrides
// -------------------------------------------------------------
@Override
public ClusterClientProvider<ApplicationId> retrieve(ApplicationId applicationId) throws ClusterRetrieveException {
    try {
        // check if required Hadoop environment variables are set. If not, warn user
        if (System.getenv("HADOOP_CONF_DIR") == null && System.getenv("YARN_CONF_DIR") == null) {
            LOG.warn("Neither the HADOOP_CONF_DIR nor the YARN_CONF_DIR environment variable is set." + "The Flink YARN Client needs one of these to be set to properly load the Hadoop " + "configuration for accessing YARN.");
        }
        final ApplicationReport report = yarnClient.getApplicationReport(applicationId);
        if (report.getFinalApplicationStatus() != FinalApplicationStatus.UNDEFINED) {
            // Flink cluster is not running anymore
            LOG.error("The application {} doesn't run anymore. It has previously completed with final status: {}", applicationId, report.getFinalApplicationStatus());
            throw new RuntimeException("The Yarn application " + applicationId + " doesn't run anymore.");
        }
        setClusterEntrypointInfoToConfig(report);
        return () -> {
            try {
                return new RestClusterClient<>(flinkConfiguration, report.getApplicationId());
            } catch (Exception e) {
                throw new RuntimeException("Couldn't retrieve Yarn cluster", e);
            }
        };
    } catch (Exception e) {
        throw new ClusterRetrieveException("Couldn't retrieve Yarn cluster", e);
    }
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ClusterRetrieveException(org.apache.flink.client.deployment.ClusterRetrieveException) InvocationTargetException(java.lang.reflect.InvocationTargetException) FlinkException(org.apache.flink.util.FlinkException) IOException(java.io.IOException) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ClusterRetrieveException(org.apache.flink.client.deployment.ClusterRetrieveException)

Aggregations

IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ClusterDeploymentException (org.apache.flink.client.deployment.ClusterDeploymentException)1 ClusterRetrieveException (org.apache.flink.client.deployment.ClusterRetrieveException)1 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)1 FlinkException (org.apache.flink.util.FlinkException)1 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1