oozie基本概念

为什么80%的码农都做不了架构师?>>>   hot3.png

基础文档

工作流不能循环, 其中的节点包括:控制流节点(start, end, decision, fork, join, kill) ,动作流节点 (map-reduce, pig, etc.)。

控制流节点:

1.  start节点:

A workflow definition must have one start node.

Syntax:


  ...
  
  ...

The to attribute is the name of first workflow node to execute.

Example:


    ...
    
    ...

2.  end节点:

A workflow definition must have one end node,如果有一个流程分支到达了end节点,其它的分支流程会被杀掉,并且认为运行成功。

Syntax:


    ...
    
    ...

The name attribute is the name of the transition to do to end the workflow job.

Example:


    ...
    

3.  kill节点:

A workflow definition may have zero or more kill nodes.

Syntax:


    ...
    
        [MESSAGE-TO-LOG]
    
    ...

The name attribute in the kill node is the name of the Kill action node.

The content of the message element will be logged as the kill reason for the workflow job.

A kill node does not have transition elements because it ends the workflow job, as KILLED .

Example:


    ...
    
        Input unavailable
    
    ...

4.  decision 节点,根据EL表达式条件,控制流程的走向,类似switch-case语句:

Syntax:


    ...
    
        
            [PREDICATE]
            ...
            [PREDICATE]
            
        
    
    ...

case分支依次进行测试,直到找到一个条件为true的分支

所有分支都不满足,执行default分支

所有的decision分支,必须有一个default分支

Example:


    ...
    
        
            
              ${fs:fileSize(secondjobOutputDir) gt 10 * GB}
             
              ${fs:fileSize(secondjobOutputDir) lt 100 * MB}
            
            
              ${ hadoop:counters('secondjob')[RECORDS][REDUCE_OUT] lt 1000000 }
            
            
        
    
    ...

5.  Fork 和 Join 节点:

fork将一个分支分成多个并发执行的路径,join节点等待所有fork分割成的分支到达。

这两个节点必须成对使用,join认为到达的每一个分支属于同一个fork节点。

Syntax:


    ...
    
        
        ...
        
    
    ...
    
    ...

path表明由fork分成的多个并发执行路径。join节点的to属性,将在所有的分支到达后执行。

Example:


    ...
    
        
        
    
    
        
            foo:8021
            bar:8020
            job1.xml
        
        
        
    
    
        
            foo:8021
            bar:8020
            job2.xml
        
        
        
    
    
    ...

默认情况下,oozie会对每一个fork进行一些验证,以避免错误的fork。如果确认作业可以正常运行,可以禁用oozie的这些验证。job.properties文件中设置oozie.wf.validate.ForkJoin=false,禁用单个工作流中的验证;oozie-site.xml文件中设置oozie.validate.ForkJoin=false,禁用所有的工作流验证。是否进行验证取决于这两个设置,只有都设置为true或不设置,才进行验证。

Workflow Action Nodes:
 Map-Reduce Action:

必须配置好必要的jobconf属性

Hadoop JobConf properties can be specified as part of

  • the config-default.xml or
  • JobConf XML file bundled with the workflow application or
  • tag in workflow definition or
  • Inline map-reduce action configuration or
  • An implementation of OozieActionConfigurator specified by the tag in workflow definition.

加载顺序为: streaming , job-xml , configuration , andconfig-class ,后面的覆盖前面的。mapred.job.tracker 和 fs.default.name properties 不能出现在job-xml 和 inline configuration中。

为job添加需要的文件和jar包:

#######占位#########

通过java配置mapreduce任务:实现OozieActionConfigurator接口, 在工作流的config-class元素下,配置该实现类。

public interface OozieActionConfigurator {
    public void configure(JobConf actionConf) throws OozieActionConfiguratorException;
}

之前配置的jobconf属性,已经包含在actionConf中了,这个方式oozie在最后调用。

Stream:内容待丰富

在streaming元素中配置,包含mapper和reducer元素,用来指定map和reduce脚本。

使用的脚本必须在streaming的file元素中指定,如果不指定,则代表在slave的PATH中可用。

一样通过file和archive元素指定要使用到的文件。

配置的mapper和reducer可以在job-xml元素指定的文件中,使用mapred.mapper.class 和mapred.reducer.class 覆盖(设置为新的map和reduce脚本),或者configuration 元素中也可以覆盖。

job-xml元素:指向hadoop JobConf的job.xml,可以按顺序指定多个文件。

configuration :设置jobconf对象的相关属性,会覆盖job-xml文件中设置的相同属性。

config-class :会覆盖configuration中设置的属性。

External Stats can be turned on/off by specifying the property oozie.action.external.stats.write as true or false in the configuration element of workflow.xml. The default value for this property is false .

The file element, if present, must specify the target symbolic link for binaries by separating the original file and target with a # (file#target-sym-link). This is not required for libraries.

The mapper and reducer process for streaming jobs, should specify the executable command with URL encoding. e.g. '%' should be replaced by '%25'.

Syntax


    ...
    
        
            [JOB-TRACKER]
            [NAME-NODE]
            
                
                ...
                
                ...
            
            
                [MAPPER-PROCESS]
                [REDUCER-PROCESS]
                [RECORD-READER-CLASS]
                [NAME=VALUE]
                ...
                [NAME=VALUE]
                ...
            
			
            
                [MAPPER]
                [REDUCER]
                [INPUTFORMAT]
                [PARTITIONER]
                [OUTPUTFORMAT]
                [EXECUTABLE]
            
            [JOB-XML-FILE]
            
                
                    [PROPERTY-NAME]
                    [PROPERTY-VALUE]
                
                ...
            
            com.example.MyConfigClass
            [FILE-PATH]
            ...
            [FILE-PATH]
            ...
                
        
    
    ...

Streaming Example:


    ...
    
        
            foo:8021
            bar:8020
            
                
            
            
                /bin/bash testarchive/bin/mapper.sh testfile
                /bin/bash testarchive/bin/reducer.sh
            
            
                
                    mapred.input.dir
                    ${input}
                
                
                    mapred.output.dir
                    ${output}
                
                
                    stream.num.map.output.key.fields
                    3
                
            
            /users/blabla/testfile.sh#testfile
            /users/blabla/testarchive.jar#testarchive
        
        
        
    
  ...

Pipes Example:


    ...
    
        
            foo:8021
            bar:8020
            
                
            
            
                bin/wordcount-simple#wordcount-simple
            
            
                
                    mapred.input.dir
                    ${input}
                
                
                    mapred.output.dir
                    ${output}
                
            
            /users/blabla/testarchive.jar#testarchive
        
        
        
    
  ...

FS 动作(HDFS动作):

支持的命令有:move , delete , mkdir , chmod , touchz 和 chgrp 。是同步执行的,job会等待命令完成。

路径可以参数化,使用EL表达式获取,每个文件必须指定uri,move元素,target一定不能指定uri。

Path names specified in the fs action can be parameterized (templatized) using EL expressions. Path name should be specified as a absolute path. In case of move , delete , chmod and chgrp commands, a glob pattern can also be specified instead of an absolute path. For move , glob pattern can only be specified for source path and not the target.

fs元素中指定的命令,并不是原子自行的,如果中间失败的话,已经成功的命名不会rollback。在执行fs的任何命令之前,都会验证路径,以确保源路径存在,目的路径不存在。

Syntax:


    ...
    
        
             
            ...
              
            ...
            
            ...
            
            
            ...
               
            ...
            
        
        
        
    
    ...

Example:

0.5">
    ...
    
         
            
            
            
            
            
        
        
        
    
    ...

schema 0.4中:


    ...
    
        
           hdfs://foo:8020
           fs-info.xml
           
             
               some.property
               some.value
             
           
           
        
        
        
    
    ...

转载于:https://my.oschina.net/sskxyz/blog/756161

你可能感兴趣的:(oozie基本概念)