137 lines
4.9 KiB
C
137 lines
4.9 KiB
C
|
|
/*
|
|||
|
|
* CWorkflowService.h
|
|||
|
|
*
|
|||
|
|
* Created on: 2011-8-23
|
|||
|
|
* Author: dev
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifndef PAI_FRAME_WORKFLOWENGINE_CWORKFLOWSERVICE_H
|
|||
|
|
#define PAI_FRAME_WORKFLOWENGINE_CWORKFLOWSERVICE_H
|
|||
|
|
|
|||
|
|
#include <string>
|
|||
|
|
#include "WorkFlowFile.h"
|
|||
|
|
#include "WorkflowGenerator.h"
|
|||
|
|
#include "WorkflowFileParser.h"
|
|||
|
|
#include "WorkflowResourceMgr.h"
|
|||
|
|
#include "../../JobManager/client/include/JobStatus.h"
|
|||
|
|
#include "../../IOService/include/WorkflowJob.h"
|
|||
|
|
//using workflow::generator::CWorkflowGenerator;
|
|||
|
|
|
|||
|
|
namespace pai {
|
|||
|
|
namespace workflow {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 将工作流文件名称与作业的信息匹配,界面显示信息的结构体
|
|||
|
|
*/
|
|||
|
|
struct JobInfo
|
|||
|
|
{
|
|||
|
|
std::string workflowName;
|
|||
|
|
std::string jobId;
|
|||
|
|
JobStatus state;
|
|||
|
|
JobInfo():workflowName(), jobId(), state(){}
|
|||
|
|
};
|
|||
|
|
/**
|
|||
|
|
* CWorkflowService为工作流子系统内部和外部接口定义及实现类
|
|||
|
|
*/
|
|||
|
|
class PAI_WORKFLOWENGINE_EXPORT CWorkflowService {
|
|||
|
|
public:
|
|||
|
|
CWorkflowService();
|
|||
|
|
virtual ~CWorkflowService();
|
|||
|
|
/*
|
|||
|
|
* @brief 从指定的工作流文件生成对应的CWorkFlowFile对象
|
|||
|
|
* @param jsonfilename 工作流文件路径
|
|||
|
|
* @return jsonfilename对应的CWorkFlowFile对象
|
|||
|
|
*/
|
|||
|
|
CWorkFlowFile& ReadWorkflow(const std::string& jsonfilename);
|
|||
|
|
/**
|
|||
|
|
* @brief 保存CWorkFlowFile对象至jsonfilename文件
|
|||
|
|
* @param jsonfilename 目标工作流文件
|
|||
|
|
* @param file 目标工作流文件对象
|
|||
|
|
* @return 如果保存成功,返回true,否则返回false
|
|||
|
|
*/
|
|||
|
|
bool SaveWorkflow(const std::string& jsonfilename, CWorkFlowFile* file);
|
|||
|
|
/**
|
|||
|
|
* @Deprecated
|
|||
|
|
* @brief 提交指定的工作流
|
|||
|
|
* @param jsonfilename 待提交的工作流对应的工作流文件
|
|||
|
|
* @param styleJsonFileName 待提交的工作流对应的工作流文件
|
|||
|
|
* @param[in/out] errorMsg 校验错误信息
|
|||
|
|
* @pre 要先初始化errorMsg
|
|||
|
|
* @return 如果提交成功,返回true,否则返回false
|
|||
|
|
*/
|
|||
|
|
bool Submit(const std::string& jsonFileName,const std::string& styleJsonFileName,std::string& errorMsg);
|
|||
|
|
/**
|
|||
|
|
* @brief 提交指定的工作流(核心算法)
|
|||
|
|
* @param jsonfilename 待提交的工作流对应的工作流文件
|
|||
|
|
* @param styleJsonFileName 待提交的工作流对应的工作流文件
|
|||
|
|
* @param[in/out] job 返回提交成功的job信息
|
|||
|
|
* @param[in/out] errorMsg 校验错误信息
|
|||
|
|
* @pre 要先初始化errorMsg
|
|||
|
|
* @return 如果提交成功,返回true,否则返回false
|
|||
|
|
*/
|
|||
|
|
bool Submit(const std::string& jsonFileName,const std::string& styleJsonFileName,pai::ios::job::WorkflowJobPtr job,std::string& errorMsg);
|
|||
|
|
/**
|
|||
|
|
* @brief 在本地试运行指定工作流
|
|||
|
|
* @param jsonfilename 工作流对应的工作流文件
|
|||
|
|
* @return 如果正常退出运行,则返回true,否则返回false
|
|||
|
|
*/
|
|||
|
|
bool RunLocally(const std::string& jsonfilename);
|
|||
|
|
/**
|
|||
|
|
* @brief 将工作流保存为工作流模板文件
|
|||
|
|
* @param templatefilename 待保存的工作流模板文件
|
|||
|
|
* @param file 待保存的CWorkFlowFile对象
|
|||
|
|
* @return 如果保存成功,返回true, 否则返回false
|
|||
|
|
*/
|
|||
|
|
bool SaveAsTemplate(const std::string& templatefilename, CWorkFlowFile* file);
|
|||
|
|
/**
|
|||
|
|
* @brief 从工作流模板文件中生成工作流文件对象
|
|||
|
|
* @param templatefilename 工作流模板文件
|
|||
|
|
* @return 生成的CWorkFlowFile对象
|
|||
|
|
*/
|
|||
|
|
CWorkFlowFile& ReadFromTemplate(const std::string& templatefilename);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
/**
|
|||
|
|
* @brief 将一个提交成功后的作业Id保存到工作流编译临时目录
|
|||
|
|
* @param jobid 作业的ID
|
|||
|
|
* @param strCompileTmpDir 工作流编译临时目录
|
|||
|
|
*/
|
|||
|
|
void SaveJobIdToLocalCompileTmp(const std::string& jobid, std::string strCompileTmpDir);
|
|||
|
|
/**
|
|||
|
|
* @brief 将提交的json文件拷贝到工作流编译临时目录
|
|||
|
|
* @param jsonfilename json文件的路径
|
|||
|
|
* @param strCompileTmpDir 工作流编译临时目录
|
|||
|
|
*/
|
|||
|
|
bool SaveJsonToLocalCompileTmp(const std::string& jsonfilename,const std::string& strCompileTmpDir);
|
|||
|
|
/**
|
|||
|
|
* @brief 编译成功之后将工作流生成的可执行文件,以及调试配置文件,调试脚本文件拷贝到临时目录下
|
|||
|
|
* @param resource 工作流提交的临时编译目录信息
|
|||
|
|
*/
|
|||
|
|
bool CopyDebugFileToCompilerTmp(const SWorkflowResource& resource);
|
|||
|
|
/**
|
|||
|
|
* @brief 在本地执行工作流
|
|||
|
|
*/
|
|||
|
|
bool SubmitToLocal(const SWorkflowResource& resource,std::string& errorMsg);
|
|||
|
|
/**
|
|||
|
|
* @brief 提交jar作业到集群
|
|||
|
|
*/
|
|||
|
|
bool SubmitToCluster(CWorkFlowFile* workflowfile, const std::string& jsonFileName,const std::string& styleJsonFileName, SWorkflowResource resource,pai::ios::job::WorkflowJobPtr job, std::string& errorMsg);
|
|||
|
|
|
|||
|
|
CWorkflowService(const CWorkflowService & service);
|
|||
|
|
CWorkflowService & operator=(const CWorkflowService & service);
|
|||
|
|
/**
|
|||
|
|
//FIXME *@brief 本地工作流输出数据建立索引(已经可以成功建立,现注掉等索引功能完善)
|
|||
|
|
*/
|
|||
|
|
// bool GenerateLocalOutputFilesIndex(std::vector<std::string>outputPaths,std::string &errorMessage);
|
|||
|
|
private:
|
|||
|
|
// CWorkflowFileParser* parser;
|
|||
|
|
// CWorkflowGenerator* generator;
|
|||
|
|
// CWorkFlowFile* workflow;
|
|||
|
|
JobInfo jobinfo;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif
|