diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java index 902985d..c80790b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java @@ -82,6 +82,26 @@ public class MapRedTask extends Task implements Serializable { String hiveConfArgs = ExecDriver.generateCmdLine(conf); File scratchDir = new File(conf.getVar(HiveConf.ConfVars.SCRATCHDIR)); + // Check if the scratch directory exists. If not, create it. + if (!scratchDir.exists()) { + LOG.info("Local scratch directory " + scratchDir.getPath() + + " not found. Attempting to create."); + if (!scratchDir.mkdirs()) { + // Unable to create this directory - it might have been created due + // to another process. + if (!scratchDir.exists()) { + throw new TaskExecutionException( + "Cannot create scratch directory " + + "\"" + scratchDir.getPath() + "\". " + + "To configure a different directory, " + + "set the configuration " + + "\"hive.exec.scratchdir\" " + + "in the session, or permanently by modifying the " + + "appropriate hive configuration file such as hive-site.xml."); + } + } + } + MapredWork plan = getWork(); File planFile = File.createTempFile("plan", ".xml", scratchDir); diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/TaskExecutionException.java ql/src/java/org/apache/hadoop/hive/ql/exec/TaskExecutionException.java new file mode 100644 index 0000000..86b7fa5 --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/exec/TaskExecutionException.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hive.ql.exec; + +/** + * Exception thrown by any task processor to signal a problem with task + * execution. + */ +public class TaskExecutionException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public TaskExecutionException(String msg) { + super(msg); + } + + public TaskExecutionException(String msg, Throwable cause) { + super(msg, cause); + } + + public TaskExecutionException(Throwable cause) { + super(cause); + } + +} diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/package-info.java ql/src/java/org/apache/hadoop/hive/ql/exec/package-info.java new file mode 100644 index 0000000..307b772 --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/exec/package-info.java @@ -0,0 +1,22 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Hive QL execution tasks, operators, functions and other handlers. + */ +package org.apache.hadoop.hive.ql.exec;