diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/SerDeStorageSchemaReader.java b/metastore/src/java/org/apache/hadoop/hive/metastore/SerDeStorageSchemaReader.java index 59bcd5ca34..da7f070ea2 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/SerDeStorageSchemaReader.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/SerDeStorageSchemaReader.java @@ -23,7 +23,6 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.Table; -import org.apache.hadoop.hive.metastore.utils.StringUtils; import java.util.List; @@ -47,7 +46,6 @@ Deserializer s = HiveMetaStoreUtils.getDeserializer(conf, tbl, false); return HiveMetaStoreUtils.getFieldsFromDeserializer(tbl.getTableName(), s); } catch (Exception e) { - StringUtils.stringifyException(e); throw new MetaException(e.getMessage()); } finally { if (orgHiveLoader != null) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/ReplCopyTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/ReplCopyTask.java index 6b3635d05a..32a1bf1894 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/ReplCopyTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/ReplCopyTask.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hive.ql.exec; import org.apache.hadoop.hive.metastore.ReplChangeManager; -import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.ql.ErrorMsg; import org.apache.hadoop.hive.ql.exec.repl.util.ReplUtils; import org.apache.hadoop.hive.ql.io.AcidUtils; @@ -48,7 +47,6 @@ import org.apache.hadoop.hive.ql.DriverContext; import org.apache.hadoop.hive.ql.parse.LoadSemanticAnalyzer; import org.apache.hadoop.hive.ql.plan.api.StageType; -import org.apache.hadoop.util.StringUtils; import static org.apache.hadoop.hive.common.FileUtils.HIDDEN_FILES_PATH_FILTER; import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.REPL_ENABLE_MOVE_OPTIMIZATION; @@ -264,7 +262,7 @@ public int execute(DriverContext driverContext) { renameFileCopiedFromCmPath(toPath, dstFs, srcFiles); return 0; } catch (Exception e) { - LOG.error(StringUtils.stringifyException(e)); + LOG.error("Repl Execute Error", e); setException(e); return ErrorMsg.getErrorMsg(e.getMessage()).getErrorCode(); } @@ -293,10 +291,10 @@ public int execute(DriverContext driverContext) { ReplChangeManager.FileInfo f = ReplChangeManager .getFileInfo(new Path(fragments[0]), fragments[1], fragments[2], fragments[3], conf); filePaths.add(f); - } catch (MetaException e) { + } catch (IOException e) { // issue warning for missing file and throw exception LOG.warn("Cannot find {} in source repo or cmroot", fragments[0]); - throw new IOException(e.getMessage()); + throw e; } // Note - we need srcFs rather than fs, because it is possible that the _files lists files // which are from a different filesystem than the fs where the _files file itself was loaded diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java index 54289afc97..9ad8b53c0a 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java @@ -154,7 +154,8 @@ private ReplChangeManager(Configuration conf) throws MetaException { inited = true; } } catch (IOException e) { - throw new MetaException(StringUtils.stringifyException(e)); + LOG.warn("Could not instantiate ReplChangeManager", e); + throw new MetaException(e.getMessage()); } } @@ -315,33 +316,32 @@ static Path getCMPath(Configuration conf, String name, String checkSum, String c * @param conf Hive configuration * @return Corresponding FileInfo object */ - public static FileInfo getFileInfo(Path src, String checksumString, String srcCMRootURI, String subDir, - Configuration conf) throws MetaException { - try { - FileSystem srcFs = src.getFileSystem(conf); - if (checksumString == null) { - return new FileInfo(srcFs, src, subDir); - } + public static FileInfo getFileInfo(Path src, String checksumString, + String srcCMRootURI, String subDir, Configuration conf) + throws IOException { - Path cmPath = getCMPath(conf, src.getName(), checksumString, srcCMRootURI); - if (!srcFs.exists(src)) { - return new FileInfo(srcFs, src, cmPath, checksumString, false, subDir); - } + FileSystem srcFs = src.getFileSystem(conf); + if (checksumString == null) { + return new FileInfo(srcFs, src, subDir); + } - String currentChecksumString; - try { - currentChecksumString = checksumFor(src, srcFs); - } catch (IOException ex) { - // If the file is missing or getting modified, then refer CM path - return new FileInfo(srcFs, src, cmPath, checksumString, false, subDir); - } - if ((currentChecksumString == null) || checksumString.equals(currentChecksumString)) { - return new FileInfo(srcFs, src, cmPath, checksumString, true, subDir); - } else { - return new FileInfo(srcFs, src, cmPath, checksumString, false, subDir); - } - } catch (IOException e) { - throw new MetaException(StringUtils.stringifyException(e)); + Path cmPath = getCMPath(conf, src.getName(), checksumString, srcCMRootURI); + if (!srcFs.exists(src)) { + return new FileInfo(srcFs, src, cmPath, checksumString, false, subDir); + } + + String currentChecksumString; + try { + currentChecksumString = checksumFor(src, srcFs); + } catch (IOException ex) { + // If the file is missing or getting modified, then refer CM path + return new FileInfo(srcFs, src, cmPath, checksumString, false, subDir); + } + if ((currentChecksumString == null) + || checksumString.equals(currentChecksumString)) { + return new FileInfo(srcFs, src, cmPath, checksumString, true, subDir); + } else { + return new FileInfo(srcFs, src, cmPath, checksumString, false, subDir); } } @@ -448,7 +448,7 @@ public void run() { } } } catch (IOException e) { - LOG.error("Exception when clearing cmroot:" + StringUtils.stringifyException(e)); + LOG.error("Exception when clearing cmroot", e); } } } diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/StringUtils.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/StringUtils.java index e49a4233ce..c5663fa331 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/StringUtils.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/StringUtils.java @@ -17,8 +17,6 @@ */ package org.apache.hadoop.hive.metastore.utils; -import java.io.PrintWriter; -import java.io.StringWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -94,19 +92,6 @@ public static String normalizeIdentifier(String identifier) { return identifier.trim().toLowerCase(); } - /** - * Make a string representation of the exception. - * @param e The exception to stringify - * @return A string with exception name and call stack. - */ - public static String stringifyException(Throwable e) { - StringWriter stm = new StringWriter(); - PrintWriter wrt = new PrintWriter(stm); - e.printStackTrace(wrt); - wrt.close(); - return stm.toString(); - } - /** * Given an array of bytes it will convert the bytes to a hex string * representation of the bytes. diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java index a30b6bf4f7..f511ae1ab7 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java @@ -1153,8 +1153,9 @@ public static void setNestedProperty(Object bean, String propertyName, Object va } PropertyUtils.setNestedProperty(bean, propertyName, value); } catch (Exception e) { - throw new MetaException( - org.apache.hadoop.hive.metastore.utils.StringUtils.stringifyException(e)); + // Log to preserve cause stack trace which is lost in MetaException + LOG.error("Failed to set nested properties", e); + throw new MetaException(e.getMessage()); } }