ITPub博客

首页 > 大数据 > Hadoop > oozie java api

oozie java api

原创 Hadoop 作者:破棉袄 时间:2014-08-23 15:25:42 0 删除 编辑
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Properties;

public class GenerateLookupDirs {

    
/**
    * 
@param args
    
*/
    
public static final long dayMillis = 1000 * 60 * 60 * 24;
    
private static final String OOZIE_ACTION_OUTPUT_PROPERTIES = "oozie.action.output.properties";

    
public static void main(String[] args) throws Exception {
        Calendar curDate 
= new GregorianCalendar();
        
int year, month, date;
        String propKey, propVal;

        String oozieProp 
= System.getProperty(OOZIE_ACTION_OUTPUT_PROPERTIES);
        
if (oozieProp != null) {
            File propFile 
= new File(oozieProp);
            Properties props 
= new Properties();

            
for (int i = 0; I < 8; ++i) {
                year 
= curDate.get(Calendar.YEAR);
                month 
= curDate.get(Calendar.MONTH) + 1;
                date 
= curDate.get(Calendar.DATE);
                propKey 
= "dir"+i;
                propVal 
= year + "-" +
                    (month 
< 10 ? "0" + month : month) + "-" +
                    (date 
< 10 ? "0" + date : date);
                props.setProperty(propKey, propVal);
                curDate.setTimeInMillis(curDate.getTimeInMillis() 
- dayMillis);
            }
            OutputStream os 
= new FileOutputStream(propFile);
            props.store(os, 
"");
            os.close();
        } 
else
            
throw new RuntimeException(OOZIE_ACTION_OUTPUT_PROPERTIES
             
+ " System property not defined");
        }
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29754888/viewspace-1256485/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: oozie入门
请登录后发表评论 登录
全部评论

注册时间:2014-07-16

  • 博文量
    180
  • 访问量
    1158184