Oozie4.3shell
Hadoop生态的工做流调度器apache
Oozie is a workflow scheduler system to manage Apache Hadoop jobs.app
Oozie Workflow jobs are Directed Acyclical Graphs (DAGs) of actions.异步
Oozie Coordinator jobs are recurrent Oozie Workflow jobs triggered by time (frequency) and data availability.tcp
Oozie is integrated with the rest of the Hadoop stack supporting several types of Hadoop jobs out of the box (such as Java map-reduce, Streaming map-reduce, Pig, Hive, Sqoop and Distcp) as well as system specific jobs (such as Java programs and shell scripts).分布式
Oozie is a scalable, reliable and extensible system.oop
wf_jobs:工做流实例url
wf_actions:任务实例scala
coord_jobs:调度实例
coord_actions:调度任务实例
l Control Node:工做流的开始、结束以及决定Workflow的执行路径的节点(start、end、kill、decision、fork/join)
l Action Node:工做流执行的计算任务,支持的类型包括(HDFS、MapReduce、Java、Shell、SSH、Pig、Hive、E-Mail、Sub-Workflow、Sqoop、Distcp),即任务
l Workflow:由Control Node以及一系列Action Node组成的工做流,即工做流
l Coordinator:根据指定Cron信息触发workflow,即调度
l Bundle:按照组的方式批量管理Coordinator任务,实现集中的启停
加载配置的全部service:
ServicesLoader.contextInitialized
Services.init
Services.loadServices (oozie.services, oozie.services.ext)
Service结构:
Service
org.apache.oozie.service.SchedulerService,
org.apache.oozie.service.InstrumentationService,
org.apache.oozie.service.MemoryLocksService,
org.apache.oozie.service.UUIDService,
org.apache.oozie.service.ELService,
org.apache.oozie.service.AuthorizationService,
org.apache.oozie.service.UserGroupInformationService,
org.apache.oozie.service.HadoopAccessorService,
org.apache.oozie.service.JobsConcurrencyService,
org.apache.oozie.service.URIHandlerService,
org.apache.oozie.service.DagXLogInfoService,
org.apache.oozie.service.SchemaService,
org.apache.oozie.service.LiteWorkflowAppService,
org.apache.oozie.service.JPAService,
org.apache.oozie.service.StoreService,
org.apache.oozie.service.SLAStoreService,
org.apache.oozie.service.DBLiteWorkflowStoreService,
org.apache.oozie.service.CallbackService,
org.apache.oozie.service.ActionService,
org.apache.oozie.service.ShareLibService,
org.apache.oozie.service.CallableQueueService,
org.apache.oozie.service.ActionCheckerService,
org.apache.oozie.service.RecoveryService,
org.apache.oozie.service.PurgeService,
org.apache.oozie.service.CoordinatorEngineService,
org.apache.oozie.service.BundleEngineService,
org.apache.oozie.service.DagEngineService,
org.apache.oozie.service.CoordMaterializeTriggerService,
org.apache.oozie.service.StatusTransitService,
org.apache.oozie.service.PauseTransitService,
org.apache.oozie.service.GroupsService,
org.apache.oozie.service.ProxyUserService,
org.apache.oozie.service.XLogStreamingService,
org.apache.oozie.service.JvmPauseMonitorService,
org.apache.oozie.service.SparkConfigurationService
BaseEngine
DAGEngine (负责workflow执行)
CoordinatorEngine (负责coordinator执行)
BundleEngine (负责bundle执行)
DAGEngine.submitJob| submitJobFromCoordinator (提交workflow)
SubmitXCommand.call
execute
LiteWorkflowAppService.parseDef (解析获得WorkflowApp)
LiteWorkflowLib.parseDef
LiteWorkflowAppParser.validateAndParse
parse
WorkflowLib.createInstance (建立WorkflowInstance)
BatchQueryExecutor.executeBatchInsertUpdateDelete (保存WorkflowJobBean 到wf_jobs)
StartXCommand.call
SignalXCommand.call
execute
WorkflowInstance.start
LiteWorkflowInstance.start
signal
NodeHandler.enter
ActionNodeHandler.enter
start
LiteWorkflowStoreService.liteExecute (添加WorkflowActionBean到ACTIONS_TO_START)
WorkflowStoreService.getActionsToStart (从ACTIONS_TO_START取Action)
ActionStartXCommand.call
ActionExecutor.start
WorkflowNotificationXCommand.call
BatchQueryExecutor.executeBatchInsertUpdateDelete (保存WorkflowActionBean到wf_actions)
ActionExecutor.start是异步的,还须要检查Action执行状态来推动流程,有两种状况:
一种是Oozie Server正常运行:利用JobEndNotification
CallbackServlet.doGet
DagEngine.processCallback
CompletedActionXCommand.call
ActionCheckXCommand.call
ActionExecutor.check
ActionEndXCommand.call
SignalXCommand.call
一种是Oozie Server重启:利用ActionCheckerService
ActionCheckerService.init
ActionCheckRunnable.run
runWFActionCheck (GET_RUNNING_ACTIONS, oozie.service.ActionCheckerService.action.check.delay=600)
ActionCheckXCommand.call
ActionExecutor.check
ActionEndXCommand.call
SignalXCommand.call
runCoordActionCheck
CoordinatorEngine.submitJob(提交coordinator)
CoordSubmitXCommand.call
submit
submitJob
storeToDB
CoordJobQueryExecutor.insert (保存CoordinatorJobBean到coord_jobs)
queueMaterializeTransitionXCommand
CoordMaterializeTransitionXCommand.call
execute
materialize
materializeActions
CoordCommandUtils.materializeOneInstance(建立CoordinatorActionBean)
storeToDB
performWrites
BatchQueryExecutor.executeBatchInsertUpdateDelete(保存CoordinatorActionBean到coord_actions)
CoordActionInputCheckXCommand.call
CoordActionReadyXCommand.call
CoordActionStartXCommand.call
DAGEngine.submitJobFromCoordinator
定时任务触发Materialize:
CoordMaterializeTriggerService.init
CoordMaterializeTriggerRunnable.run
CoordMaterializeTriggerService.runCoordJobMatLookup
materializeCoordJobs (GET_COORD_JOBS_OLDER_FOR_MATERIALIZATION)
CoordMaterializeTransitionXCommand.call
有些内部任务只能启动一个,单server环境Oozie中经过MemoryLocksService来保证,多server环境Oozie经过ZKLocksService来保证,要开启ZK,须要开启一些service:
org.apache.oozie.service.ZKLocksService,
org.apache.oozie.service.ZKXLogStreamingService,
org.apache.oozie.service.ZKJobsConcurrencyService,
org.apache.oozie.service.ZKUUIDService
同时须要配置oozie.zookeeper.connection.string
ActionExecutor是任务执行的核心抽象基类,全部的具体任务都是这个类的子类
ActionExecutor
JavaActionExecutor
SshActionExecutor
FsActionExecutor
SubWorkflowActionExecutor
其中JavaActionExecutor是最重要的一个子类,不少其余的任务都是这个类的子类(好比HiveActionExecutor、SparkActionExecutor等)
JavaActionExecutor.start
prepareActionDir
submitLauncher
JobClient.getJob
injectLauncherCallback
ActionExecutor.Context.getCallbackUrl
job.end.notification.url
createLauncherConf
LauncherMapperHelper.setupLauncherInfo
JobClient.submitJob
check
JavaActionExecutor执行时会提交一个map任务到yarn,即LauncherMapper,
LauncherMapper.map
LauncherMain.main
LauncherMain是具体任务的执行类
LauncherMain
JavaMain
HiveMain
Hive2Main
SparkMain
ShellMain
SqoopMain