Search in sources :

Example 1 with FlinkCluster

use of com.qlangtech.plugins.incr.flink.common.FlinkCluster in project plugins by qlangtech.

the class FlinkTaskNodeController method getRCDeployment.

@Override
public IDeploymentDetail getRCDeployment(TargetResName collection) {
    ExtendFlinkJobDeploymentDetails rcDeployment = null;
    JobID launchJobID = getLaunchJobID(collection);
    if (launchJobID == null) {
        return null;
    }
    try {
        try (RestClusterClient restClient = this.factory.getFlinkCluster()) {
            CompletableFuture<JobStatus> jobStatus = restClient.getJobStatus(launchJobID);
            JobStatus status = jobStatus.get(5, TimeUnit.SECONDS);
            // }
            if (status == null) {
                return null;
            }
            CompletableFuture<JobDetailsInfo> jobDetails = restClient.getJobDetails(launchJobID);
            JobDetailsInfo jobDetailsInfo = jobDetails.get(5, TimeUnit.SECONDS);
            rcDeployment = new ExtendFlinkJobDeploymentDetails(factory.getClusterCfg(), jobDetailsInfo);
            return rcDeployment;
        }
    } catch (TimeoutException e) {
        FlinkCluster clusterCfg = this.factory.getClusterCfg();
        throw new TisException("flinkClusterId:" + clusterCfg.getClusterId() + ",Address:" + clusterCfg.getJobManagerAddress().getURL() + "连接超时,请检查相应配置是否正确", e);
    } catch (ExecutionException e) {
        Throwable cause = e.getCause();
        if (StringUtils.indexOf(cause.getMessage(), "NotFoundException") > -1) {
            return null;
        }
        // }
        throw new RuntimeException(e);
    // if (cause instanceof ) {
    // 
    // }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : TisException(com.qlangtech.tis.lang.TisException) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TisException(com.qlangtech.tis.lang.TisException) JobStatus(org.apache.flink.api.common.JobStatus) JobDetailsInfo(org.apache.flink.runtime.rest.messages.job.JobDetailsInfo) ExecutionException(java.util.concurrent.ExecutionException) FlinkCluster(com.qlangtech.plugins.incr.flink.common.FlinkCluster) JobID(org.apache.flink.api.common.JobID) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with FlinkCluster

use of com.qlangtech.plugins.incr.flink.common.FlinkCluster in project plugins by qlangtech.

the class FlinkTaskNodeController method checkUseable.

@Override
public void checkUseable() {
    FlinkCluster cluster = factory.getClusterCfg();
    try {
        try (RestClusterClient restClient = cluster.createFlinkRestClusterClient(Optional.of(1000l))) {
            // restClient.getClusterId();
            CompletableFuture<Collection<JobStatusMessage>> status = restClient.listJobs();
            Collection<JobStatusMessage> jobStatus = status.get();
        }
    } catch (Exception e) {
        throw new TisException("Please check link is valid:" + cluster.getJobManagerAddress().getURL(), e);
    }
}
Also used : JobStatusMessage(org.apache.flink.runtime.client.JobStatusMessage) TisException(com.qlangtech.tis.lang.TisException) Collection(java.util.Collection) FlinkCluster(com.qlangtech.plugins.incr.flink.common.FlinkCluster) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TisException(com.qlangtech.tis.lang.TisException)

Aggregations

FlinkCluster (com.qlangtech.plugins.incr.flink.common.FlinkCluster)2 TisException (com.qlangtech.tis.lang.TisException)2 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 RestClusterClient (org.apache.flink.client.program.rest.RestClusterClient)2 Collection (java.util.Collection)1 JobID (org.apache.flink.api.common.JobID)1 JobStatus (org.apache.flink.api.common.JobStatus)1 JobStatusMessage (org.apache.flink.runtime.client.JobStatusMessage)1 JobDetailsInfo (org.apache.flink.runtime.rest.messages.job.JobDetailsInfo)1