// Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// 	public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
// 
// 	public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// 			"yyyy-MM-dd HH:mm:ss");
// 	public static String DATA_FILE_EXTENSION = ".gz";
// 	public static String WORKING_DIRECTORY_ROOT = "/tmp";
// 	public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// 	public static int MAX_RESULT_DATA_NUMBER = 1000000;
// 	// result data will be stored in this location
// 	public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
// 
// 	// hadoop security
// 	public static String HADOOP_PRINCIPAL = "hadoop@DIANPING.COM";
// 	public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
// 
// 	public static String LOCAL_HOST_ADDRESS;
// 
// 	static {
// 		try {
// 			LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// 			LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// 		} catch (UnknownHostException uhe) {
// 			LOG.error("get local host address failed, " + uhe);
// 		}
// 
// 		InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// 		Properties pros = new Properties();
// 		try {
// 			pros.load(is);
// 
// 			DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// 					DATA_FILE_EXTENSION);
// 
// 			WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// 					WORKING_DIRECTORY_ROOT);
// 
// 			DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// 					"DEFAULT_RESULT_DATA_NUMBER",
// 					String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
// 
// 			MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// 					"MAX_RESULT_DATA_NUMBER",
// 					String.valueOf(MAX_RESULT_DATA_NUMBER)));
// 
// 			HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// 					HDFS_DATA_ROOT_PATH);
// 
// 			HADOOP_PRINCIPAL = pros.getProperty(
// 					pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// }
// 
// Path: src/main/java/com/dianping/polestar/PolestarException.java
// public class PolestarException extends RuntimeException {
// 	private static final long serialVersionUID = 6525L;
// 
// 	public PolestarException() {
// 		super();
// 	}
// 
// 	public PolestarException(String message) {
// 		super(message);
// 	}
// 
// 	public PolestarException(Throwable e) {
// 		super(e);
// 	}
// 
// 	public PolestarException(String msg, Throwable e) {
// 		super(msg, e);
// 	}
// }
// 
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// 	private static final long serialVersionUID = 6788167073159708825L;
// 
// 	public BadParamException(String msg) {
// 		super(Status.BAD_REQUEST.getStatusCode(), msg);
// 	}
// 	
// 	public BadParamException(Status status, String msg) {
// 		super(status.getStatusCode(), msg);
// 	}
// }


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.PolestarException;
import com.dianping.polestar.rest.BadParamException;
				UserGroupInformation.setConfiguration(conf);
				SecurityUtil.login(conf, "hadoop.keytab.file",
						"hadoop.principal");
			} catch (IOException e) {
				LOG.error(e);
				e.printStackTrace();
			}
		} else {
			LOG.error("core-site.xml or hdfs-site.xml is not found in the system environment!");
		}
		return conf;
	}

	public static String getHadoopConfDir() {
		String confDir = System.getenv("HADOOP_CONF_DIR");
		if (StringUtils.isBlank(confDir)) {
			confDir = getHadoopHome() + File.separator + "conf";
		}
		return confDir;
	}

	public static String getHadoopHome() {
		return System.getenv("HADOOP_HOME");
	}

	public static String getHiveHome() {
		return System.getenv("HIVE_HOME");
	}

	public static InputStream openFSDataInputStream(String absolutePath)
// Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// 	public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
// 
// 	public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// 			"yyyy-MM-dd HH:mm:ss");
// 	public static String DATA_FILE_EXTENSION = ".gz";
// 	public static String WORKING_DIRECTORY_ROOT = "/tmp";
// 	public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// 	public static int MAX_RESULT_DATA_NUMBER = 1000000;
// 	// result data will be stored in this location
// 	public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
// 
// 	// hadoop security
// 	public static String HADOOP_PRINCIPAL = "hadoop@DIANPING.COM";
// 	public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
// 
// 	public static String LOCAL_HOST_ADDRESS;
// 
// 	static {
// 		try {
// 			LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// 			LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// 		} catch (UnknownHostException uhe) {
// 			LOG.error("get local host address failed, " + uhe);
// 		}
// 
// 		InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// 		Properties pros = new Properties();
// 		try {
// 			pros.load(is);
// 
// 			DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// 					DATA_FILE_EXTENSION);
// 
// 			WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// 					WORKING_DIRECTORY_ROOT);
// 
// 			DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// 					"DEFAULT_RESULT_DATA_NUMBER",
// 					String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
// 
// 			MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// 					"MAX_RESULT_DATA_NUMBER",
// 					String.valueOf(MAX_RESULT_DATA_NUMBER)));
// 
// 			HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// 					HDFS_DATA_ROOT_PATH);
// 
// 			HADOOP_PRINCIPAL = pros.getProperty(
// 					pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// }
// 
// Path: src/main/java/com/dianping/polestar/PolestarException.java
// public class PolestarException extends RuntimeException {
// 	private static final long serialVersionUID = 6525L;
// 
// 	public PolestarException() {
// 		super();
// 	}
// 
// 	public PolestarException(String message) {
// 		super(message);
// 	}
// 
// 	public PolestarException(Throwable e) {
// 		super(e);
// 	}
// 
// 	public PolestarException(String msg, Throwable e) {
// 		super(msg, e);
// 	}
// }
// 
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// 	private static final long serialVersionUID = 6788167073159708825L;
// 
// 	public BadParamException(String msg) {
// 		super(Status.BAD_REQUEST.getStatusCode(), msg);
// 	}
// 	
// 	public BadParamException(Status status, String msg) {
// 		super(status.getStatusCode(), msg);
// 	}
// }


// Path: src/main/java/com/dianping/polestar/store/HDFSManager.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.PolestarException;
import com.dianping.polestar.rest.BadParamException;

				UserGroupInformation.setConfiguration(conf);
				SecurityUtil.login(conf, "hadoop.keytab.file",
						"hadoop.principal");
			} catch (IOException e) {
				LOG.error(e);
				e.printStackTrace();
			}
		} else {
			LOG.error("core-site.xml or hdfs-site.xml is not found in the system environment!");
		}
		return conf;
	}

	public static String getHadoopConfDir() {
		String confDir = System.getenv("HADOOP_CONF_DIR");
		if (StringUtils.isBlank(confDir)) {
			confDir = getHadoopHome() + File.separator + "conf";
		}
		return confDir;
	}

	public static String getHadoopHome() {
		return System.getenv("HADOOP_HOME");
	}

	public static String getHiveHome() {
		return System.getenv("HIVE_HOME");
	}

	public static InputStream openFSDataInputStream(String absolutePath)
			throws BadParamException {