/**
 * 
 */
package org.springblade.etl.engine;

import java.nio.file.Path;
import java.util.List;

import org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory;
import org.apache.flink.runtime.rest.messages.checkpoints.CheckpointingStatistics;
import org.apache.flink.runtime.rest.messages.job.JobDetailsInfo;
import org.springblade.etl.engine.flink.dto.SubmitJobReq;
import org.springblade.etl.engine.flink.dto.SubmitJobRes;
import org.springblade.etl.enums.ResourceProvider;

/**
 * @author wookvn
 *
 * 作业管理
 */
public interface JobService {

	/**
	 * 提交任务
	 * @param submitJobDto
	 */
	public SubmitJobRes submit(SubmitJobReq submitJobDto) throws Exception;
	
	/**
	 * 任务详情
	 * @param jobId
	 * @return
	 * @throws Exception
	 */
	public JobDetailsInfo info(String jobId, String webInterfaceUrl) throws Exception;
	
	/**
	 * 取消作业
	 * @param jobId
	 */
	public void cancel(String jobId, String webInterfaceUrl) throws Exception;
	
	/**
	 * 获取任务异常信息
	 * @param jobId
	 */
	public JobExceptionsInfoWithHistory exception(String jobId, String webInterfaceUrl) throws Exception;
	
	/**
	 * 获取checkpoint信息
	 * @param jobId
	 * @throws Exception
	 */
	public CheckpointingStatistics checkpoints(String jobId, String webInterfaceUrl) throws Exception;
	
	/**
	 * 创建Session集群
	 * @return
	 */
	public String createSessionCluster(ResourceProvider resourceProvider);
	
	/**
	 * 获取一个轻量负载的webInterfaceUrl
	 * @param webInterfaceUrls
	 * @return
	 */
	public String lighterLoad(List<String> webInterfaceUrls);
	
	/**
	 * 关闭作业集群
	 * @param clusterId
	 * @param clusterCredentialPath
	 */
	default void shutdown(String clusterId, Path clusterCredentialPath) {
		throw new RuntimeException("开发中...");
	}
	
}