001 /** 002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved. 003 * Licensed under the Apache License, Version 2.0 (the "License"); 004 * you may not use this file except in compliance with the License. 005 * You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software 010 * distributed under the License is distributed on an "AS IS" BASIS, 011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 * See the License for the specific language governing permissions and 013 * limitations under the License. See accompanying LICENSE file. 014 */ 015 package org.apache.oozie.coord; 016 017 import org.apache.hadoop.conf.Configuration; 018 import org.apache.oozie.client.OozieClient; 019 import org.apache.oozie.util.ParamChecker; 020 import org.jdom.Element; 021 022 public class CoordUtils { 023 public static final String HADOOP_UGI = "hadoop.job.ugi"; 024 025 public static final String HADOOP_USER = "user.name"; 026 027 public static String getDoneFlag(Element doneFlagElement) { 028 if (doneFlagElement != null) { 029 return doneFlagElement.getTextTrim(); 030 } 031 else { 032 return CoordELConstants.DEFAULT_DONE_FLAG; 033 } 034 } 035 036 public static Configuration getHadoopConf(Configuration jobConf) { 037 Configuration conf = new Configuration(); 038 ParamChecker.notNull(jobConf, "Configuration to be used for hadoop setup "); 039 String user = ParamChecker.notEmpty(jobConf.get(OozieClient.USER_NAME), OozieClient.USER_NAME); 040 String group = ParamChecker.notEmpty(jobConf.get(OozieClient.GROUP_NAME), OozieClient.GROUP_NAME); 041 conf.set(HADOOP_USER, user); 042 conf.set(HADOOP_UGI, user + "," + group); 043 return conf; 044 } 045 }