http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java
 
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java
deleted file mode 100644
index 0add003..0000000
--- 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.metastore;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.lang.ClassUtils;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.utils.JavaUtils;
-import org.apache.hadoop.util.ReflectionUtils;
-
-@InterfaceAudience.Private
-@InterfaceStability.Evolving
-public class RawStoreProxy implements InvocationHandler {
-
-  private final RawStore base;
-  private final MetaStoreInit.MetaStoreInitData metaStoreInitData =
-    new MetaStoreInit.MetaStoreInitData();
-  private final Configuration hiveConf;
-  private final Configuration conf; // thread local conf from HMS
-  private final long socketTimeout;
-
-  protected RawStoreProxy(Configuration hiveConf, Configuration conf,
-      Class<? extends RawStore> rawStoreClass, int id) throws MetaException {
-    this.conf = conf;
-    this.hiveConf = hiveConf;
-    this.socketTimeout = MetastoreConf.getTimeVar(hiveConf,
-        MetastoreConf.ConfVars.CLIENT_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS);
-
-    // This has to be called before initializing the instance of RawStore
-    init();
-
-    this.base = ReflectionUtils.newInstance(rawStoreClass, conf);
-  }
-
-  public static RawStore getProxy(Configuration hiveConf, Configuration conf, 
String rawStoreClassName,
-      int id) throws MetaException {
-
-    Class<? extends RawStore> baseClass = 
JavaUtils.getClass(rawStoreClassName, RawStore.class);
-
-    RawStoreProxy handler = new RawStoreProxy(hiveConf, conf, baseClass, id);
-
-    // Look for interfaces on both the class and all base classes.
-    return (RawStore) 
Proxy.newProxyInstance(RawStoreProxy.class.getClassLoader(),
-        getAllInterfaces(baseClass), handler);
-  }
-
-  private static Class<?>[] getAllInterfaces(Class<?> baseClass) {
-    List interfaces = ClassUtils.getAllInterfaces(baseClass);
-    Class<?>[] result = new Class<?>[interfaces.size()];
-    int i = 0;
-    for (Object o : interfaces) {
-      result[i++] = (Class<?>)o;
-    }
-    return result;
-  }
-
-  private void init() throws MetaException {
-    // Using the hook on startup ensures that the hook always has priority
-    // over settings in *.xml.  The thread local conf needs to be used because 
at this point
-    // it has already been initialized using conf.
-    MetaStoreInit.updateConnectionURL(hiveConf, getConf(), null, 
metaStoreInitData);
-  }
-
-  @Override
-  public Object invoke(Object proxy, Method method, Object[] args) throws 
Throwable {
-    try {
-      Deadline.registerIfNot(socketTimeout);
-      boolean isTimerStarted = Deadline.startTimer(method.getName());
-      try {
-        return method.invoke(base, args);
-      } finally {
-        if (isTimerStarted) {
-          Deadline.stopTimer();
-        }
-      }
-    } catch (UndeclaredThrowableException e) {
-      throw e.getCause();
-    } catch (InvocationTargetException e) {
-      throw e.getCause();
-    }
-  }
-
-  public Configuration getConf() {
-    return conf;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
----------------------------------------------------------------------
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
deleted file mode 100644
index ac1d3c8..0000000
--- 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * 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.metastore;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.lang3.concurrent.BasicThreadFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileChecksum;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.PathFilter;
-import org.apache.hadoop.fs.Trash;
-import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.hadoop.hdfs.DFSConfigKeys;
-import org.apache.hadoop.hive.metastore.api.Database;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
-import org.apache.hadoop.hive.metastore.utils.FileUtils;
-import org.apache.hadoop.hive.metastore.utils.StringUtils;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReplChangeManager {
-  private static final Logger LOG = 
LoggerFactory.getLogger(ReplChangeManager.class);
-  static private ReplChangeManager instance;
-
-  private static boolean inited = false;
-  private static boolean enabled = false;
-  private static Path cmroot;
-  private static Configuration conf;
-  private String msUser;
-  private String msGroup;
-
-  private static final String ORIG_LOC_TAG = "user.original-loc";
-  static final String REMAIN_IN_TRASH_TAG = "user.remain-in-trash";
-  private static final String URI_FRAGMENT_SEPARATOR = "#";
-  public static final String SOURCE_OF_REPLICATION = "repl.source.for";
-  private static final String TXN_WRITE_EVENT_FILE_SEPARATOR = "]";
-
-  public enum RecycleType {
-    MOVE,
-    COPY
-  }
-
-  public static class FileInfo {
-    private FileSystem srcFs;
-    private Path sourcePath;
-    private Path cmPath;
-    private String checkSum;
-    private boolean useSourcePath;
-    private String subDir;
-    private boolean copyDone;
-
-    public FileInfo(FileSystem srcFs, Path sourcePath, String subDir) {
-      this(srcFs, sourcePath, null, null, true, subDir);
-    }
-    public FileInfo(FileSystem srcFs, Path sourcePath, Path cmPath,
-                    String checkSum, boolean useSourcePath, String subDir) {
-      this.srcFs = srcFs;
-      this.sourcePath = sourcePath;
-      this.cmPath = cmPath;
-      this.checkSum = checkSum;
-      this.useSourcePath = useSourcePath;
-      this.subDir = subDir;
-      this.copyDone = false;
-    }
-    public FileSystem getSrcFs() {
-      return srcFs;
-    }
-    public Path getSourcePath() {
-      return sourcePath;
-    }
-    public Path getCmPath() {
-      return cmPath;
-    }
-    public String getCheckSum() {
-      return checkSum;
-    }
-    public boolean isUseSourcePath() {
-      return useSourcePath;
-    }
-    public void setIsUseSourcePath(boolean useSourcePath) {
-      this.useSourcePath = useSourcePath;
-    }
-    public String getSubDir() {
-      return subDir;
-    }
-    public boolean isCopyDone() {
-      return copyDone;
-    }
-    public void setCopyDone(boolean copyDone) {
-      this.copyDone = copyDone;
-    }
-    public Path getEffectivePath() {
-      if (useSourcePath) {
-        return sourcePath;
-      } else {
-        return cmPath;
-      }
-    }
-  }
-
-  public static ReplChangeManager getInstance(Configuration conf) throws 
MetaException {
-    if (instance == null) {
-      instance = new ReplChangeManager(conf);
-    }
-    return instance;
-  }
-
-  private ReplChangeManager(Configuration conf) throws MetaException {
-    try {
-      if (!inited) {
-        if (MetastoreConf.getBoolVar(conf, ConfVars.REPLCMENABLED)) {
-          ReplChangeManager.enabled = true;
-          ReplChangeManager.cmroot = new Path(MetastoreConf.getVar(conf, 
ConfVars.REPLCMDIR));
-          ReplChangeManager.conf = conf;
-
-          FileSystem cmFs = cmroot.getFileSystem(conf);
-          // Create cmroot with permission 700 if not exist
-          if (!cmFs.exists(cmroot)) {
-            cmFs.mkdirs(cmroot);
-            cmFs.setPermission(cmroot, new FsPermission("700"));
-          }
-          UserGroupInformation usergroupInfo = 
UserGroupInformation.getCurrentUser();
-          msUser = usergroupInfo.getShortUserName();
-          msGroup = usergroupInfo.getPrimaryGroupName();
-        }
-        inited = true;
-      }
-    } catch (IOException e) {
-      throw new MetaException(StringUtils.stringifyException(e));
-    }
-  }
-
-  // Filter files starts with ".". Note Hadoop consider files starts with
-  // "." or "_" as hidden file. However, we need to replicate files starts
-  // with "_". We find at least 2 use cases:
-  // 1. For har files, _index and _masterindex is required files
-  // 2. _success file is required for Oozie to indicate availability of data 
source
-  private static final PathFilter hiddenFileFilter = new PathFilter(){
-    public boolean accept(Path p){
-      return !p.getName().startsWith(".");
-    }
-  };
-
-  /***
-   * Move a path into cmroot. If the path is a directory (of a partition, or 
table if nonpartitioned),
-   *   recursively move files inside directory to cmroot. Note the table must 
be managed table
-   * @param path a single file or directory
-   * @param type if the files to be copied or moved to cmpath.
-   *             Copy is costly but preserve the source file
-   * @param ifPurge if the file should skip Trash when move/delete source file.
-   *                This is referred only if type is MOVE.
-   * @return int
-   * @throws IOException
-   */
-  public int recycle(Path path, RecycleType type, boolean ifPurge) throws 
IOException {
-    if (!enabled) {
-      return 0;
-    }
-
-    int count = 0;
-    FileSystem fs = path.getFileSystem(conf);
-    if (fs.isDirectory(path)) {
-      FileStatus[] files = fs.listStatus(path, hiddenFileFilter);
-      for (FileStatus file : files) {
-        count += recycle(file.getPath(), type, ifPurge);
-      }
-    } else {
-      String fileCheckSum = checksumFor(path, fs);
-      Path cmPath = getCMPath(conf, path.getName(), fileCheckSum, 
cmroot.toString());
-
-      // set timestamp before moving to cmroot, so we can
-      // avoid race condition CM remove the file before setting
-      // timestamp
-      long now = System.currentTimeMillis();
-      fs.setTimes(path, now, -1);
-
-      boolean success = false;
-      if (fs.exists(cmPath) && 
fileCheckSum.equalsIgnoreCase(checksumFor(cmPath, fs))) {
-        // If already a file with same checksum exists in cmPath, just ignore 
the copy/move
-        // Also, mark the operation is unsuccessful to notify that file with 
same name already
-        // exist which will ensure the timestamp of cmPath is updated to avoid 
clean-up by
-        // CM cleaner.
-        success = false;
-      } else {
-        switch (type) {
-        case MOVE: {
-          LOG.info("Moving {} to {}", path.toString(), cmPath.toString());
-
-          // Rename fails if the file with same name already exist.
-          success = fs.rename(path, cmPath);
-          break;
-        }
-        case COPY: {
-          LOG.info("Copying {} to {}", path.toString(), cmPath.toString());
-
-          // It is possible to have a file with same checksum in cmPath but 
the content is
-          // partially copied or corrupted. In this case, just overwrite the 
existing file with
-          // new one.
-          success = FileUtils.copy(fs, path, fs, cmPath, false, true, conf);
-          break;
-        }
-        default:
-          // Operation fails as invalid input
-          break;
-        }
-      }
-
-      // Ignore if a file with same content already exist in cmroot
-      // We might want to setXAttr for the new location in the future
-      if (success) {
-        // set the file owner to hive (or the id metastore run as)
-        fs.setOwner(cmPath, msUser, msGroup);
-
-        // tag the original file name so we know where the file comes from
-        // Note we currently only track the last known trace as
-        // xattr has limited capacity. We shall revisit and store all original
-        // locations if orig-loc becomes important
-        try {
-          fs.setXAttr(cmPath, ORIG_LOC_TAG, path.toString().getBytes());
-        } catch (UnsupportedOperationException e) {
-          LOG.warn("Error setting xattr for {}", path.toString());
-        }
-
-        count++;
-      } else {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("A file with the same content of {} already exists, 
ignore", path.toString());
-        }
-        // Need to extend the tenancy if we saw a newer file with the same 
content
-        fs.setTimes(cmPath, now, -1);
-      }
-
-      // Tag if we want to remain in trash after deletion.
-      // If multiple files share the same content, then
-      // any file claim remain in trash would be granted
-      if ((type == RecycleType.MOVE) && !ifPurge) {
-        try {
-          fs.setXAttr(cmPath, REMAIN_IN_TRASH_TAG, new byte[] { 0 });
-        } catch (UnsupportedOperationException e) {
-          LOG.warn("Error setting xattr for {}", cmPath.toString());
-        }
-      }
-    }
-    return count;
-  }
-
-  // Get checksum of a file
-  static public String checksumFor(Path path, FileSystem fs) throws 
IOException {
-    // TODO: fs checksum only available on hdfs, need to
-    //       find a solution for other fs (eg, local fs, s3, etc)
-    String checksumString = null;
-    FileChecksum checksum = fs.getFileChecksum(path);
-    if (checksum != null) {
-      checksumString = StringUtils.byteToHexString(
-          checksum.getBytes(), 0, checksum.getLength());
-    }
-    return checksumString;
-  }
-
-  /***
-   * Convert a path of file inside a partition or table (if non-partitioned)
-   *   to a deterministic location of cmroot. So user can retrieve the file 
back
-   *   with the original location plus checksum.
-   * @param conf Hive configuration
-   * @param name original filename
-   * @param checkSum checksum of the file, can be retrieved by {@link 
#checksumFor(Path, FileSystem)}
-   * @param cmRootUri CM Root URI. (From remote source if REPL LOAD flow. From 
local config if recycle.)
-   * @return Path
-   */
-  static Path getCMPath(Configuration conf, String name, String checkSum, 
String cmRootUri) {
-    String newFileName = name + "_" + checkSum;
-    int maxLength = 
conf.getInt(DFSConfigKeys.DFS_NAMENODE_MAX_COMPONENT_LENGTH_KEY,
-        DFSConfigKeys.DFS_NAMENODE_MAX_COMPONENT_LENGTH_DEFAULT);
-
-    if (newFileName.length() > maxLength) {
-      newFileName = newFileName.substring(0, maxLength-1);
-    }
-
-    return new Path(cmRootUri, newFileName);
-  }
-
-  /***
-   * Get original file specified by src and chksumString. If the file exists 
and checksum
-   * matches, return the file; otherwise, use chksumString to retrieve it from 
cmroot
-   * @param src Original file location
-   * @param checksumString Checksum of the original file
-   * @param srcCMRootURI CM root URI of the source cluster
-   * @param subDir Sub directory to which the source file belongs to
-   * @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);
-      }
-
-      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);
-      }
-    } catch (IOException e) {
-      throw new MetaException(StringUtils.stringifyException(e));
-    }
-  }
-
-  /***
-   * Concatenate filename, checksum, source cmroot uri and subdirectory with 
"#"
-   * @param fileUriStr Filename string
-   * @param fileChecksum Checksum string
-   * @param encodedSubDir sub directory path into which this file belongs to. 
Here encoded means,
-   *                      the multiple levels of subdirectories are 
concatenated with path separator "/"
-   * @return Concatenated Uri string
-   */
-  // TODO: this needs to be enhanced once change management based filesystem 
is implemented
-  // Currently using fileuri#checksum#cmrooturi#subdirs as the format
-  public static String encodeFileUri(String fileUriStr, String fileChecksum, 
String encodedSubDir)
-          throws IOException {
-    String encodedUri = fileUriStr;
-    if ((fileChecksum != null) && (cmroot != null)) {
-      encodedUri = encodedUri + URI_FRAGMENT_SEPARATOR + fileChecksum
-              + URI_FRAGMENT_SEPARATOR + FileUtils.makeQualified(cmroot, conf);
-    } else {
-      encodedUri = encodedUri + URI_FRAGMENT_SEPARATOR + 
URI_FRAGMENT_SEPARATOR;
-    }
-    encodedUri = encodedUri + URI_FRAGMENT_SEPARATOR + ((encodedSubDir != 
null) ? encodedSubDir : "");
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Encoded URI: " + encodedUri);
-    }
-    return encodedUri;
-  }
-
-  /***
-   * Split uri with fragment into file uri, subdirs, checksum and source 
cmroot uri.
-   * Currently using fileuri#checksum#cmrooturi#subdirs as the format.
-   * @param fileURIStr uri with fragment
-   * @return array of file name, subdirs, checksum and source CM root URI
-   */
-  public static String[] decodeFileUri(String fileURIStr) {
-    String[] uriAndFragment = fileURIStr.split(URI_FRAGMENT_SEPARATOR);
-    String[] result = new String[4];
-    result[0] = uriAndFragment[0];
-    if ((uriAndFragment.length > 1) && 
!StringUtils.isEmpty(uriAndFragment[1])) {
-      result[1] = uriAndFragment[1];
-    }
-    if ((uriAndFragment.length > 2)  && 
!StringUtils.isEmpty(uriAndFragment[2])) {
-      result[2] = uriAndFragment[2];
-    }
-    if ((uriAndFragment.length > 3)  && 
!StringUtils.isEmpty(uriAndFragment[3])) {
-      result[3] = uriAndFragment[3];
-    }
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Reading Encoded URI: " + result[0] + ":: " + result[1] + ":: 
" + result[2] + ":: " + result[3]);
-    }
-    return result;
-  }
-
-  public static boolean isCMFileUri(Path fromPath) {
-    String[] result = decodeFileUri(fromPath.toString());
-    return result[1] != null;
-  }
-
-  /**
-   * Thread to clear old files of cmroot recursively
-   */
-  static class CMClearer implements Runnable {
-    private Path cmroot;
-    private long secRetain;
-    private Configuration conf;
-
-    CMClearer(String cmrootString, long secRetain, Configuration conf) {
-      this.cmroot = new Path(cmrootString);
-      this.secRetain = secRetain;
-      this.conf = conf;
-    }
-
-    @Override
-    public void run() {
-      try {
-        LOG.info("CMClearer started");
-
-        long now = System.currentTimeMillis();
-        FileSystem fs = cmroot.getFileSystem(conf);
-        FileStatus[] files = fs.listStatus(cmroot);
-
-        for (FileStatus file : files) {
-          long modifiedTime = file.getModificationTime();
-          if (now - modifiedTime > secRetain*1000) {
-            try {
-              if 
(fs.getXAttrs(file.getPath()).containsKey(REMAIN_IN_TRASH_TAG)) {
-                boolean succ = Trash.moveToAppropriateTrash(fs, 
file.getPath(), conf);
-                if (succ) {
-                  if (LOG.isDebugEnabled()) {
-                    LOG.debug("Move " + file.toString() + " to trash");
-                  }
-                } else {
-                  LOG.warn("Fail to move " + file.toString() + " to trash");
-                }
-              } else {
-                boolean succ = fs.delete(file.getPath(), false);
-                if (succ) {
-                  if (LOG.isDebugEnabled()) {
-                    LOG.debug("Remove " + file.toString());
-                  }
-                } else {
-                  LOG.warn("Fail to remove " + file.toString());
-                }
-              }
-            } catch (UnsupportedOperationException e) {
-              LOG.warn("Error getting xattr for " + file.getPath().toString());
-            }
-          }
-        }
-      } catch (IOException e) {
-        LOG.error("Exception when clearing cmroot:" + 
StringUtils.stringifyException(e));
-      }
-    }
-  }
-
-  // Schedule CMClearer thread. Will be invoked by metastore
-  static void scheduleCMClearer(Configuration conf) {
-    if (MetastoreConf.getBoolVar(conf, ConfVars.REPLCMENABLED)) {
-      ScheduledExecutorService executor = 
Executors.newSingleThreadScheduledExecutor(
-          new BasicThreadFactory.Builder()
-          .namingPattern("cmclearer-%d")
-          .daemon(true)
-          .build());
-      executor.scheduleAtFixedRate(new CMClearer(MetastoreConf.getVar(conf, 
ConfVars.REPLCMDIR),
-          MetastoreConf.getTimeVar(conf, ConfVars.REPLCMRETIAN, 
TimeUnit.SECONDS), conf),
-          0, MetastoreConf.getTimeVar(conf, ConfVars.REPLCMINTERVAL, 
TimeUnit.SECONDS), TimeUnit.SECONDS);
-    }
-  }
-
-  public static boolean isSourceOfReplication(Database db) {
-    assert (db != null);
-    String replPolicyIds = getReplPolicyIdString(db);
-    return  !StringUtils.isEmpty(replPolicyIds);
-  }
-
-  public static String getReplPolicyIdString(Database db) {
-    if (db != null) {
-      Map<String, String> m = db.getParameters();
-      if ((m != null) && (m.containsKey(SOURCE_OF_REPLICATION))) {
-        String replPolicyId = m.get(SOURCE_OF_REPLICATION);
-        LOG.debug("repl policy for database {} is {}", db.getName(), 
replPolicyId);
-        return replPolicyId;
-      }
-      LOG.debug("Repl policy is not set for database ", db.getName());
-    }
-    return null;
-  }
-
-  public static String joinWithSeparator(Iterable<?> strings) {
-    return 
org.apache.hadoop.util.StringUtils.join(TXN_WRITE_EVENT_FILE_SEPARATOR, 
strings);
-  }
-
-  public static String[] getListFromSeparatedString(String 
commaSeparatedString) {
-    return commaSeparatedString.split("\\s*" + TXN_WRITE_EVENT_FILE_SEPARATOR 
+ "\\s*");
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
 
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
deleted file mode 100644
index a830eb9..0000000
--- 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * 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.metastore;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
-import org.apache.hadoop.hive.metastore.metrics.PerfLogger;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
-import org.datanucleus.exceptions.NucleusException;
-
-@InterfaceAudience.Private
-@InterfaceStability.Evolving
-public class RetryingHMSHandler implements InvocationHandler {
-
-  private static final Logger LOG = 
LoggerFactory.getLogger(RetryingHMSHandler.class);
-  private static final String CLASS_NAME = RetryingHMSHandler.class.getName();
-
-  private static class Result {
-    private final Object result;
-    private final int numRetries;
-
-    public Result(Object result, int numRetries) {
-      this.result = result;
-      this.numRetries = numRetries;
-    }
-  }
-
-  private final IHMSHandler baseHandler;
-  private final MetaStoreInit.MetaStoreInitData metaStoreInitData =
-    new MetaStoreInit.MetaStoreInitData();
-
-  private final Configuration origConf;            // base configuration
-  private final Configuration activeConf;  // active configuration
-
-  private RetryingHMSHandler(Configuration origConf, IHMSHandler baseHandler, 
boolean local) throws MetaException {
-    this.origConf = origConf;
-    this.baseHandler = baseHandler;
-    if (local) {
-      baseHandler.setConf(origConf); // tests expect configuration changes 
applied directly to metastore
-    }
-    activeConf = baseHandler.getConf();
-    // This has to be called before initializing the instance of HMSHandler
-    // Using the hook on startup ensures that the hook always has priority
-    // over settings in *.xml.  The thread local conf needs to be used because 
at this point
-    // it has already been initialized using hiveConf.
-    MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), null, 
metaStoreInitData);
-    try {
-      //invoking init method of baseHandler this way since it adds the retry 
logic
-      //in case of transient failures in init method
-      invoke(baseHandler, baseHandler.getClass().getDeclaredMethod("init", 
(Class<?>[]) null),
-          null);
-    } catch (Throwable e) {
-      LOG.error("HMSHandler Fatal error: " + ExceptionUtils.getStackTrace(e));
-      MetaException me = new MetaException(e.getMessage());
-      me.initCause(e);
-      throw me;
-    }
-  }
-
-  public static IHMSHandler getProxy(Configuration conf, IHMSHandler 
baseHandler, boolean local)
-      throws MetaException {
-
-    RetryingHMSHandler handler = new RetryingHMSHandler(conf, baseHandler, 
local);
-
-    return (IHMSHandler) Proxy.newProxyInstance(
-      RetryingHMSHandler.class.getClassLoader(),
-      new Class[] { IHMSHandler.class }, handler);
-  }
-
-  @Override
-  public Object invoke(final Object proxy, final Method method, final Object[] 
args) throws Throwable {
-    int retryCount = -1;
-    int threadId = baseHandler.getThreadId();
-    boolean error = true;
-    PerfLogger perfLogger = PerfLogger.getPerfLogger(false);
-    perfLogger.PerfLogBegin(CLASS_NAME, method.getName());
-    try {
-      Result result = invokeInternal(proxy, method, args);
-      retryCount = result.numRetries;
-      error = false;
-      return result.result;
-    } finally {
-      StringBuilder additionalInfo = new StringBuilder();
-      additionalInfo.append("threadId=").append(threadId).append(" 
retryCount=").append(retryCount)
-        .append(" error=").append(error);
-      perfLogger.PerfLogEnd(CLASS_NAME, method.getName(), 
additionalInfo.toString());
-    }
-  }
-
-  public Result invokeInternal(final Object proxy, final Method method, final 
Object[] args) throws Throwable {
-
-    boolean gotNewConnectUrl = false;
-    boolean reloadConf = MetastoreConf.getBoolVar(origConf, 
ConfVars.HMS_HANDLER_FORCE_RELOAD_CONF);
-    long retryInterval = MetastoreConf.getTimeVar(origConf,
-        ConfVars.HMS_HANDLER_INTERVAL, TimeUnit.MILLISECONDS);
-    int retryLimit = MetastoreConf.getIntVar(origConf, 
ConfVars.HMS_HANDLER_ATTEMPTS);
-    long timeout = MetastoreConf.getTimeVar(origConf,
-        ConfVars.CLIENT_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS);
-
-    Deadline.registerIfNot(timeout);
-
-    if (reloadConf) {
-      MetaStoreInit.updateConnectionURL(origConf, getActiveConf(),
-        null, metaStoreInitData);
-    }
-
-    int retryCount = 0;
-    Throwable caughtException = null;
-    while (true) {
-      try {
-        if (reloadConf || gotNewConnectUrl) {
-          baseHandler.setConf(getActiveConf());
-        }
-        Object object = null;
-        boolean isStarted = Deadline.startTimer(method.getName());
-        try {
-          object = method.invoke(baseHandler, args);
-        } finally {
-          if (isStarted) {
-            Deadline.stopTimer();
-          }
-        }
-        return new Result(object, retryCount);
-
-      } catch (UndeclaredThrowableException e) {
-        if (e.getCause() != null) {
-          if (e.getCause() instanceof javax.jdo.JDOException) {
-            // Due to reflection, the jdo exception is wrapped in
-            // invocationTargetException
-            caughtException = e.getCause();
-          } else if (e.getCause() instanceof MetaException && 
e.getCause().getCause() != null
-              && e.getCause().getCause() instanceof javax.jdo.JDOException) {
-            // The JDOException may be wrapped further in a MetaException
-            caughtException = e.getCause().getCause();
-          } else {
-            LOG.error(ExceptionUtils.getStackTrace(e.getCause()));
-            throw e.getCause();
-          }
-        } else {
-          LOG.error(ExceptionUtils.getStackTrace(e));
-          throw e;
-        }
-      } catch (InvocationTargetException e) {
-        if (e.getCause() instanceof javax.jdo.JDOException) {
-          // Due to reflection, the jdo exception is wrapped in
-          // invocationTargetException
-          caughtException = e.getCause();
-        } else if (e.getCause() instanceof NoSuchObjectException || 
e.getTargetException().getCause() instanceof NoSuchObjectException) {
-          String methodName = method.getName();
-          if (!methodName.startsWith("get_database") && 
!methodName.startsWith("get_table")
-              && !methodName.startsWith("get_partition") && 
!methodName.startsWith("get_function")) {
-            LOG.error(ExceptionUtils.getStackTrace(e.getCause()));
-          }
-          throw e.getCause();
-        } else if (e.getCause() instanceof MetaException && 
e.getCause().getCause() != null) {
-          if (e.getCause().getCause() instanceof javax.jdo.JDOException ||
-              e.getCause().getCause() instanceof NucleusException) {
-            // The JDOException or the Nucleus Exception may be wrapped 
further in a MetaException
-            caughtException = e.getCause().getCause();
-          } else if (e.getCause().getCause() instanceof DeadlineException) {
-            // The Deadline Exception needs no retry and be thrown immediately.
-            Deadline.clear();
-            LOG.error("Error happens in method " + method.getName() + ": " +
-                ExceptionUtils.getStackTrace(e.getCause()));
-            throw e.getCause();
-          } else {
-            LOG.error(ExceptionUtils.getStackTrace(e.getCause()));
-            throw e.getCause();
-          }
-        } else {
-          LOG.error(ExceptionUtils.getStackTrace(e.getCause()));
-          throw e.getCause();
-        }
-      }
-
-      if (retryCount >= retryLimit) {
-        LOG.error("HMSHandler Fatal error: " + 
ExceptionUtils.getStackTrace(caughtException));
-        MetaException me = new MetaException(caughtException.getMessage());
-        me.initCause(caughtException);
-        throw me;
-      }
-
-      assert (retryInterval >= 0);
-      retryCount++;
-      LOG.error(
-        String.format(
-          "Retrying HMSHandler after %d ms (attempt %d of %d)", retryInterval, 
retryCount, retryLimit) +
-          " with error: " + ExceptionUtils.getStackTrace(caughtException));
-
-      Thread.sleep(retryInterval);
-      // If we have a connection error, the JDO connection URL hook might
-      // provide us with a new URL to access the datastore.
-      String lastUrl = MetaStoreInit.getConnectionURL(getActiveConf());
-      gotNewConnectUrl = MetaStoreInit.updateConnectionURL(origConf, 
getActiveConf(),
-        lastUrl, metaStoreInitData);
-    }
-  }
-
-  public Configuration getActiveConf() {
-    return activeConf;
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java
 
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java
deleted file mode 100644
index f97f638..0000000
--- 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * 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.metastore;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.common.classification.RetrySemantics;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
-import org.apache.hadoop.hive.metastore.utils.JavaUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.hadoop.hive.metastore.annotation.NoReconnect;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.thrift.TApplicationException;
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TProtocolException;
-import org.apache.thrift.transport.TTransportException;
-
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * RetryingMetaStoreClient. Creates a proxy for a IMetaStoreClient
- * implementation and retries calls to it on failure.
- * If the login user is authenticated using keytab, it relogins user before
- * each call.
- *
- */
-@InterfaceAudience.Public
-public class RetryingMetaStoreClient implements InvocationHandler {
-
-  private static final Logger LOG = 
LoggerFactory.getLogger(RetryingMetaStoreClient.class.getName());
-
-  private final IMetaStoreClient base;
-  private final UserGroupInformation ugi;
-  private final int retryLimit;
-  private final long retryDelaySeconds;
-  private final ConcurrentHashMap<String, Long> metaCallTimeMap;
-  private final long connectionLifeTimeInMillis;
-  private long lastConnectionTime;
-  private boolean localMetaStore;
-
-
-  protected RetryingMetaStoreClient(Configuration conf, Class<?>[] 
constructorArgTypes,
-                                    Object[] constructorArgs, 
ConcurrentHashMap<String, Long> metaCallTimeMap,
-                                    Class<? extends IMetaStoreClient> 
msClientClass) throws MetaException {
-
-    this.ugi = getUGI();
-
-    if (this.ugi == null) {
-      LOG.warn("RetryingMetaStoreClient unable to determine current user 
UGI.");
-    }
-
-    this.retryLimit = MetastoreConf.getIntVar(conf, 
ConfVars.THRIFT_FAILURE_RETRIES);
-    this.retryDelaySeconds = MetastoreConf.getTimeVar(conf,
-        ConfVars.CLIENT_CONNECT_RETRY_DELAY, TimeUnit.SECONDS);
-    this.metaCallTimeMap = metaCallTimeMap;
-    this.connectionLifeTimeInMillis = MetastoreConf.getTimeVar(conf,
-        ConfVars.CLIENT_SOCKET_LIFETIME, TimeUnit.MILLISECONDS);
-    this.lastConnectionTime = System.currentTimeMillis();
-    String msUri = MetastoreConf.getVar(conf, ConfVars.THRIFT_URIS);
-    localMetaStore = (msUri == null) || msUri.trim().isEmpty();
-
-    reloginExpiringKeytabUser();
-
-    this.base = JavaUtils.newInstance(msClientClass, constructorArgTypes, 
constructorArgs);
-
-    LOG.info("RetryingMetaStoreClient proxy=" + msClientClass + " ugi=" + 
this.ugi
-        + " retries=" + this.retryLimit + " delay=" + this.retryDelaySeconds
-        + " lifetime=" + this.connectionLifeTimeInMillis);
-  }
-
-  public static IMetaStoreClient getProxy(
-      Configuration hiveConf, boolean allowEmbedded) throws MetaException {
-    return getProxy(hiveConf, new Class[]{Configuration.class, 
HiveMetaHookLoader.class, Boolean.class},
-        new Object[]{hiveConf, null, allowEmbedded}, null, 
HiveMetaStoreClient.class.getName()
-    );
-  }
-
-  @VisibleForTesting
-  public static IMetaStoreClient getProxy(Configuration hiveConf, 
HiveMetaHookLoader hookLoader,
-      String mscClassName) throws MetaException {
-    return getProxy(hiveConf, hookLoader, null, mscClassName, true);
-  }
-
-  public static IMetaStoreClient getProxy(Configuration hiveConf, 
HiveMetaHookLoader hookLoader,
-      ConcurrentHashMap<String, Long> metaCallTimeMap, String mscClassName, 
boolean allowEmbedded)
-          throws MetaException {
-
-    return getProxy(hiveConf,
-        new Class[] {Configuration.class, HiveMetaHookLoader.class, 
Boolean.class},
-        new Object[] {hiveConf, hookLoader, allowEmbedded},
-        metaCallTimeMap,
-        mscClassName
-    );
-  }
-
-  /**
-   * This constructor is meant for Hive internal use only.
-   * Please use getProxy(HiveConf conf, HiveMetaHookLoader hookLoader) for 
external purpose.
-   */
-  public static IMetaStoreClient getProxy(Configuration hiveConf, Class<?>[] 
constructorArgTypes,
-      Object[] constructorArgs, String mscClassName) throws MetaException {
-    return getProxy(hiveConf, constructorArgTypes, constructorArgs, null, 
mscClassName);
-  }
-
-  /**
-   * This constructor is meant for Hive internal use only.
-   * Please use getProxy(HiveConf conf, HiveMetaHookLoader hookLoader) for 
external purpose.
-   */
-  public static IMetaStoreClient getProxy(Configuration hiveConf, Class<?>[] 
constructorArgTypes,
-      Object[] constructorArgs, ConcurrentHashMap<String, Long> 
metaCallTimeMap,
-      String mscClassName) throws MetaException {
-
-    @SuppressWarnings("unchecked")
-    Class<? extends IMetaStoreClient> baseClass =
-        JavaUtils.getClass(mscClassName, IMetaStoreClient.class);
-
-    RetryingMetaStoreClient handler =
-        new RetryingMetaStoreClient(hiveConf, constructorArgTypes, 
constructorArgs,
-            metaCallTimeMap, baseClass);
-    return (IMetaStoreClient) Proxy.newProxyInstance(
-        RetryingMetaStoreClient.class.getClassLoader(), 
baseClass.getInterfaces(), handler);
-  }
-
-  @Override
-  public Object invoke(Object proxy, Method method, Object[] args) throws 
Throwable {
-    Object ret;
-    int retriesMade = 0;
-    TException caughtException;
-
-    boolean allowReconnect = ! method.isAnnotationPresent(NoReconnect.class);
-    boolean allowRetry = true;
-    Annotation[] directives = method.getDeclaredAnnotations();
-    if(directives != null) {
-      for(Annotation a : directives) {
-        if(a instanceof RetrySemantics.CannotRetry) {
-          allowRetry = false;
-        }
-      }
-    }
-
-    while (true) {
-      try {
-        reloginExpiringKeytabUser();
-
-        if (allowReconnect) {
-          if (retriesMade > 0 || hasConnectionLifeTimeReached(method)) {
-            if (this.ugi != null) {
-              // Perform reconnect with the proper user context
-              try {
-                LOG.info("RetryingMetaStoreClient trying reconnect as " + 
this.ugi);
-
-                this.ugi.doAs(
-                  new PrivilegedExceptionAction<Object> () {
-                    @Override
-                    public Object run() throws MetaException {
-                      base.reconnect();
-                      return null;
-                    }
-                  });
-              } catch (UndeclaredThrowableException e) {
-                Throwable te = e.getCause();
-                if (te instanceof PrivilegedActionException) {
-                  throw te.getCause();
-                } else {
-                  throw te;
-                }
-              }
-              lastConnectionTime = System.currentTimeMillis();
-            } else {
-              LOG.warn("RetryingMetaStoreClient unable to reconnect. No UGI 
information.");
-              throw new MetaException("UGI information unavailable. Will not 
attempt a reconnect.");
-            }
-          }
-        }
-
-        if (metaCallTimeMap == null) {
-          ret = method.invoke(base, args);
-        } else {
-          // need to capture the timing
-          long startTime = System.currentTimeMillis();
-          ret = method.invoke(base, args);
-          long timeTaken = System.currentTimeMillis() - startTime;
-          addMethodTime(method, timeTaken);
-        }
-        break;
-      } catch (UndeclaredThrowableException e) {
-        throw e.getCause();
-      } catch (InvocationTargetException e) {
-        Throwable t = e.getCause();
-        if (t instanceof TApplicationException) {
-          TApplicationException tae = (TApplicationException)t;
-          switch (tae.getType()) {
-          case TApplicationException.UNSUPPORTED_CLIENT_TYPE:
-          case TApplicationException.UNKNOWN_METHOD:
-          case TApplicationException.WRONG_METHOD_NAME:
-          case TApplicationException.INVALID_PROTOCOL:
-            throw t;
-          default:
-            // TODO: most other options are probably unrecoverable... throw?
-            caughtException = tae;
-          }
-        } else if ((t instanceof TProtocolException) || (t instanceof 
TTransportException)) {
-          // TODO: most protocol exceptions are probably unrecoverable... 
throw?
-          caughtException = (TException)t;
-        } else if ((t instanceof MetaException) && t.getMessage().matches(
-            "(?s).*(JDO[a-zA-Z]*|TProtocol|TTransport)Exception.*") &&
-            
!t.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
-          caughtException = (MetaException)t;
-        } else {
-          throw t;
-        }
-      } catch (MetaException e) {
-        if (e.getMessage().matches("(?s).*(IO|TTransport)Exception.*") &&
-            
!e.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
-          caughtException = e;
-        } else {
-          throw e;
-        }
-      }
-
-
-      if (retriesMade >= retryLimit || base.isLocalMetaStore() || !allowRetry) 
{
-        throw caughtException;
-      }
-      retriesMade++;
-      LOG.warn("MetaStoreClient lost connection. Attempting to reconnect (" + 
retriesMade + " of " +
-          retryLimit + ") after " + retryDelaySeconds + "s. " + 
method.getName(), caughtException);
-      Thread.sleep(retryDelaySeconds * 1000);
-    }
-    return ret;
-  }
-
-  /**
-   * Returns the UGI for the current user.
-   * @return the UGI for the current user.
-   */
-  private UserGroupInformation getUGI() {
-    UserGroupInformation ugi = null;
-
-    try {
-      ugi = UserGroupInformation.getCurrentUser();
-    } catch (IOException e) {
-      // Swallow the exception and let the call determine what to do.
-    }
-
-    return ugi;
-  }
-
-  private void addMethodTime(Method method, long timeTaken) {
-    String methodStr = getMethodString(method);
-    while (true) {
-      Long curTime = metaCallTimeMap.get(methodStr), newTime = timeTaken;
-      if (curTime != null && metaCallTimeMap.replace(methodStr, curTime, 
newTime + curTime)) break;
-      if (curTime == null && (null == metaCallTimeMap.putIfAbsent(methodStr, 
newTime))) break;
-    }
-  }
-
-  /**
-   * @param method
-   * @return String representation with arg types. eg getDatabase_(String, )
-   */
-  private String getMethodString(Method method) {
-    StringBuilder methodSb = new StringBuilder(method.getName());
-    methodSb.append("_(");
-    for (Class<?> paramClass : method.getParameterTypes()) {
-      methodSb.append(paramClass.getSimpleName());
-      methodSb.append(", ");
-    }
-    methodSb.append(")");
-    return methodSb.toString();
-  }
-
-  private boolean hasConnectionLifeTimeReached(Method method) {
-    if (connectionLifeTimeInMillis <= 0 || localMetaStore) {
-      return false;
-    }
-
-    boolean shouldReconnect =
-        (System.currentTimeMillis() - lastConnectionTime) >= 
connectionLifeTimeInMillis;
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Reconnection status for Method: " + method.getName() + " is " 
+ shouldReconnect);
-    }
-    return shouldReconnect;
-  }
-
-  /**
-   * Relogin if login user is logged in using keytab
-   * Relogin is actually done by ugi code only if sufficient time has passed
-   * A no-op if kerberos security is not enabled
-   * @throws MetaException
-   */
-  private void reloginExpiringKeytabUser() throws MetaException {
-    if(!UserGroupInformation.isSecurityEnabled()){
-      return;
-    }
-    try {
-      UserGroupInformation ugi = UserGroupInformation.getLoginUser();
-      //checkTGT calls ugi.relogin only after checking if it is close to tgt 
expiry
-      //hadoop relogin is actually done only every x minutes (x=10 in hadoop 
1.x)
-      if(ugi.isFromKeytab()){
-        ugi.checkTGTAndReloginFromKeytab();
-      }
-    } catch (IOException e) {
-      String msg = "Error doing relogin using keytab " + e.getMessage();
-      LOG.error(msg, e);
-      throw new MetaException(msg);
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RuntimeStatsCleanerTask.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RuntimeStatsCleanerTask.java
 
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RuntimeStatsCleanerTask.java
deleted file mode 100644
index ccec93d..0000000
--- 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RuntimeStatsCleanerTask.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.metastore;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.hadoop.hive.metastore.RawStore;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Metastore task to handle RuntimeStat related expiration.
- */
-public class RuntimeStatsCleanerTask implements MetastoreTaskThread {
-  private static final Logger LOG = 
LoggerFactory.getLogger(RuntimeStatsCleanerTask.class);
-
-  private Configuration conf;
-
-  @Override
-  public long runFrequency(TimeUnit unit) {
-    return MetastoreConf.getTimeVar(conf, 
MetastoreConf.ConfVars.RUNTIME_STATS_CLEAN_FREQUENCY, unit);
-  }
-
-  @Override
-  public void setConf(Configuration configuration) {
-    conf = configuration;
-  }
-
-  @Override
-  public Configuration getConf() {
-    return conf;
-  }
-
-  @Override
-  public void run() {
-
-    try {
-      RawStore ms = HiveMetaStore.HMSHandler.getMSForConf(conf);
-      int maxRetainSecs=(int) MetastoreConf.getTimeVar(conf, 
MetastoreConf.ConfVars.RUNTIME_STATS_MAX_AGE, TimeUnit.SECONDS);
-      int deleteCnt = ms.deleteRuntimeStats(maxRetainSecs);
-
-      if (deleteCnt > 0L){
-        LOG.info("Number of deleted entries: " + deleteCnt);
-      }
-    } catch (Exception e) {
-      LOG.error("Exception while trying to delete: " + e.getMessage(), e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/SessionPropertiesListener.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/SessionPropertiesListener.java
 
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/SessionPropertiesListener.java
deleted file mode 100644
index 6f97605..0000000
--- 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/SessionPropertiesListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.metastore;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * It handles the changed properties in the change event.
- */
-public class SessionPropertiesListener extends MetaStoreEventListener {
-
-  public SessionPropertiesListener(Configuration configuration) {
-    super(configuration);
-  }
-
-  @Override
-  public void onConfigChange(ConfigChangeEvent changeEvent) throws 
MetaException {
-    if 
(changeEvent.getKey().equals(MetastoreConf.ConfVars.CLIENT_SOCKET_TIMEOUT.getVarname())
 ||
-        
changeEvent.getKey().equals(MetastoreConf.ConfVars.CLIENT_SOCKET_TIMEOUT.getHiveName()))
 {
-      // TODO: this only applies to current thread, so it's not useful at all.
-      
Deadline.resetTimeout(MetastoreConf.convertTimeStr(changeEvent.getNewValue(), 
TimeUnit.SECONDS,
-          TimeUnit.MILLISECONDS));
-    }
-  }
-}

Reply via email to