You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vi...@apache.org on 2018/07/19 19:55:19 UTC

[20/51] [partial] hive git commit: HIVE-20188 : Split server-specific code outside of standalone metastore-common (Alexander Kolbasov reviewed by Vihang Karajgaonkar)

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/model/MWMTrigger.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/model/MWMTrigger.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/model/MWMTrigger.java
deleted file mode 100644
index 21ac22a..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/model/MWMTrigger.java
+++ /dev/null
@@ -1,89 +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.model;
-
-import java.util.Set;
-
-public class MWMTrigger {
-  private MWMResourcePlan resourcePlan;
-  private String name;
-  private String triggerExpression;
-  private String actionExpression;
-  // This is integer because in Derby DN converts boolean to char, breaking sysdb.
-  private int isInUnmanaged;
-  private Set<MWMPool> pools;
-
-  public MWMTrigger(MWMResourcePlan resourcePlan, String name, String triggerExpression,
-      String actionExpression, Set<MWMPool> pools, boolean isInUnmanaged) {
-    this.resourcePlan = resourcePlan;
-    this.name = name;
-    this.triggerExpression = triggerExpression;
-    this.actionExpression = actionExpression;
-    this.pools = pools;
-    this.isInUnmanaged = isInUnmanaged ? 1 : 0;
-  }
-
-  public MWMResourcePlan getResourcePlan() {
-    return resourcePlan;
-  }
-
-  public void setResourcePlan(MWMResourcePlan resourcePlan) {
-    this.resourcePlan = resourcePlan;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getTriggerExpression() {
-    return triggerExpression;
-  }
-
-  public void setTriggerExpression(String triggerExpression) {
-    this.triggerExpression = triggerExpression;
-  }
-
-  public String getActionExpression() {
-    return actionExpression;
-  }
-
-  public void setActionExpression(String actionExpression) {
-    this.actionExpression = actionExpression;
-  }
-
-  public Set<MWMPool> getPools() {
-    return pools;
-  }
-
-  public void setPools(Set<MWMPool> pools) {
-    this.pools = pools;
-  }
-
-  public boolean getIsInUnmanaged() {
-    return isInUnmanaged == 1;
-  }
-
-  public void setIsInUnmanaged(boolean isInUnmanaged) {
-    this.isInUnmanaged = isInUnmanaged ? 1 : 0;
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/ExpressionTree.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/ExpressionTree.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/ExpressionTree.java
deleted file mode 100644
index 32267b4..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/ExpressionTree.java
+++ /dev/null
@@ -1,606 +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.parser;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CharStream;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.ColumnType;
-import org.apache.hadoop.hive.metastore.Warehouse;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Sets;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
-
-/**
- * The Class representing the filter as a  binary tree. The tree has TreeNode's
- * at intermediate level and the leaf level nodes are of type LeafNode.
- */
-public class ExpressionTree {
-  /** The empty tree that can be returned for an empty filter. */
-  public static final ExpressionTree EMPTY_TREE = new ExpressionTree();
-
-  /** The logical operations supported. */
-  public enum LogicalOperator {
-    AND,
-    OR
-  }
-
-  /** The operators supported. */
-  public enum Operator {
-    EQUALS  ("=", "==", "="),
-    GREATERTHAN  (">"),
-    LESSTHAN  ("<"),
-    LESSTHANOREQUALTO ("<="),
-    GREATERTHANOREQUALTO (">="),
-    LIKE ("LIKE", "matches", "like"),
-    NOTEQUALS2 ("!=", "!=", "<>"),
-    NOTEQUALS ("<>", "!=", "<>");
-
-    private final String op;
-    private final String jdoOp;
-    private final String sqlOp;
-
-    // private constructor
-    Operator(String op){
-      this.op = op;
-      this.jdoOp = op;
-      this.sqlOp = op;
-    }
-
-    Operator(String op, String jdoOp, String sqlOp){
-      this.op = op;
-      this.jdoOp = jdoOp;
-      this.sqlOp = sqlOp;
-    }
-
-    public String getOp() {
-      return op;
-    }
-
-    public String getJdoOp() {
-      return jdoOp;
-    }
-
-    public String getSqlOp() {
-      return sqlOp;
-    }
-
-    public static Operator fromString(String inputOperator) {
-      for(Operator op : Operator.values()) {
-        if(op.getOp().equals(inputOperator)){
-          return op;
-        }
-      }
-
-      throw new Error("Invalid value " + inputOperator +
-          " for " + Operator.class.getSimpleName());
-    }
-
-    @Override
-    public String toString() {
-      return op;
-    }
-
-  }
-
-  /**
-   * Depth first traversal of ExpressionTree.
-   * The users should override the subset of methods to do their stuff.
-   */
-  public static class TreeVisitor {
-    private void visit(TreeNode node) throws MetaException {
-      if (shouldStop()) return;
-      assert node != null && node.getLhs() != null && node.getRhs() != null;
-      beginTreeNode(node);
-      node.lhs.accept(this);
-      midTreeNode(node);
-      node.rhs.accept(this);
-      endTreeNode(node);
-    }
-
-    protected void beginTreeNode(TreeNode node) throws MetaException {}
-    protected void midTreeNode(TreeNode node) throws MetaException {}
-    protected void endTreeNode(TreeNode node) throws MetaException {}
-    protected void visit(LeafNode node) throws MetaException {}
-    protected boolean shouldStop() {
-      return false;
-    }
-  }
-
-  /**
-   * Helper class that wraps the stringbuilder used to build the filter over the tree,
-   * as well as error propagation in two modes - expect errors, i.e. filter might as well
-   * be unbuildable and that's not a failure condition; or don't expect errors, i.e. filter
-   * must be buildable.
-   */
-  public static class FilterBuilder {
-    private final StringBuilder result = new StringBuilder();
-    private String errorMessage = null;
-    private boolean expectNoErrors = false;
-
-    public FilterBuilder(boolean expectNoErrors) {
-      this.expectNoErrors = expectNoErrors;
-    }
-
-    public String getFilter() throws MetaException {
-      assert errorMessage == null;
-      if (errorMessage != null) {
-        throw new MetaException("Trying to get result after error: " + errorMessage);
-      }
-      return result.toString();
-    }
-
-    @Override
-    public String toString() {
-      try {
-        return getFilter();
-      } catch (MetaException ex) {
-        throw new RuntimeException(ex);
-      }
-    }
-
-    public String getErrorMessage() {
-      return errorMessage;
-    }
-
-    public boolean hasError() {
-      return errorMessage != null;
-    }
-
-    public FilterBuilder append(String filterPart) {
-      this.result.append(filterPart);
-      return this;
-    }
-
-    public void setError(String errorMessage) throws MetaException {
-      this.errorMessage = errorMessage;
-      if (expectNoErrors) {
-        throw new MetaException(errorMessage);
-      }
-    }
-  }
-
-  /**
-   * The Class representing a Node in the ExpressionTree.
-   */
-  public static class TreeNode {
-    private TreeNode lhs;
-    private LogicalOperator andOr;
-    private TreeNode rhs;
-
-    public TreeNode() {
-    }
-
-    public TreeNode(TreeNode lhs, LogicalOperator andOr, TreeNode rhs) {
-      this.lhs = lhs;
-      this.andOr = andOr;
-      this.rhs = rhs;
-    }
-
-    public TreeNode getLhs() {
-      return lhs;
-    }
-
-    public LogicalOperator getAndOr() {
-      return andOr;
-    }
-
-    public TreeNode getRhs() {
-      return rhs;
-    }
-
-    /** Double dispatch for TreeVisitor. */
-    protected void accept(TreeVisitor visitor) throws MetaException {
-      visitor.visit(this);
-    }
-
-    /**
-     * Generates a JDO filter statement
-     * @param table
-     *        The table on which the filter is applied.  If table is not null,
-     *        then this method generates a JDO statement to get all partitions
-     *        of the table that match the filter.
-     *        If table is null, then this method generates a JDO statement to get all
-     *        tables that match the filter.
-     * @param params
-     *        A map of parameter key to values for the filter statement.
-     * @param filterBuffer The filter builder that is used to build filter.
-     * @throws MetaException
-     */
-    public void generateJDOFilter(Configuration conf, Table table,
-        Map<String, Object> params, FilterBuilder filterBuffer) throws MetaException {
-      if (filterBuffer.hasError()) return;
-      if (lhs != null) {
-        filterBuffer.append (" (");
-        lhs.generateJDOFilter(conf, table, params, filterBuffer);
-
-        if (rhs != null) {
-          if( andOr == LogicalOperator.AND ) {
-            filterBuffer.append(" && ");
-          } else {
-            filterBuffer.append(" || ");
-          }
-
-          rhs.generateJDOFilter(conf, table, params, filterBuffer);
-        }
-        filterBuffer.append (") ");
-      }
-    }
-  }
-
-  /**
-   * The Class representing the leaf level nodes in the ExpressionTree.
-   */
-  public static class LeafNode extends TreeNode {
-    public String keyName;
-    public Operator operator;
-    /** Constant expression side of the operator. Can currently be a String or a Long. */
-    public Object value;
-    public boolean isReverseOrder = false;
-    private static final String PARAM_PREFIX = "hive_filter_param_";
-
-    @Override
-    protected void accept(TreeVisitor visitor) throws MetaException {
-      visitor.visit(this);
-    }
-
-    @Override
-    public void generateJDOFilter(Configuration conf, Table table, Map<String, Object> params,
-        FilterBuilder filterBuilder) throws MetaException {
-      if (table != null) {
-        generateJDOFilterOverPartitions(conf, table, params, filterBuilder);
-      } else {
-        generateJDOFilterOverTables(params, filterBuilder);
-      }
-    }
-
-    //can only support "=" and "!=" for now, because our JDO lib is buggy when
-    // using objects from map.get()
-    private static final Set<Operator> TABLE_FILTER_OPS = Sets.newHashSet(
-        Operator.EQUALS, Operator.NOTEQUALS, Operator.NOTEQUALS2, Operator.LIKE);
-
-    private void generateJDOFilterOverTables(Map<String, Object> params,
-        FilterBuilder filterBuilder) throws MetaException {
-      if (keyName.equals(hive_metastoreConstants.HIVE_FILTER_FIELD_OWNER)) {
-        keyName = "this.owner";
-      } else if (keyName.equals(hive_metastoreConstants.HIVE_FILTER_FIELD_LAST_ACCESS)) {
-        //lastAccessTime expects an integer, so we cannot use the "like operator"
-        if (operator == Operator.LIKE) {
-          filterBuilder.setError("Like is not supported for HIVE_FILTER_FIELD_LAST_ACCESS");
-          return;
-        }
-        keyName = "this.lastAccessTime";
-      } else if (keyName.startsWith(hive_metastoreConstants.HIVE_FILTER_FIELD_PARAMS)) {
-        if (!TABLE_FILTER_OPS.contains(operator)) {
-          filterBuilder.setError("Only " + TABLE_FILTER_OPS + " are supported " +
-            "operators for HIVE_FILTER_FIELD_PARAMS");
-          return;
-        }
-        String paramKeyName = keyName.substring(hive_metastoreConstants.HIVE_FILTER_FIELD_PARAMS.length());
-        keyName = "this.parameters.get(\"" + paramKeyName + "\")";
-        //value is persisted as a string in the db, so make sure it's a string here
-        // in case we get a long.
-        value = value.toString();
-      } else {
-        filterBuilder.setError("Invalid key name in filter.  " +
-          "Use constants from org.apache.hadoop.hive.metastore.api");
-        return;
-      }
-      generateJDOFilterGeneral(params, filterBuilder);
-    }
-
-    /**
-     * Generates a general filter.  Given a map of <key, value>,
-     * generates a statement of the form:
-     * key1 operator value2 (&& | || ) key2 operator value2 ...
-     *
-     * Currently supported types for value are String and Long.
-     * The LIKE operator for Longs is unsupported.
-     */
-    private void generateJDOFilterGeneral(Map<String, Object> params,
-        FilterBuilder filterBuilder) throws MetaException {
-      String paramName = PARAM_PREFIX + params.size();
-      params.put(paramName, value);
-
-      if (isReverseOrder) {
-        if (operator == Operator.LIKE) {
-          filterBuilder.setError("Value should be on the RHS for LIKE operator : " +
-              "Key <" + keyName + ">");
-        } else {
-          filterBuilder.append(paramName + " " + operator.getJdoOp() + " " + keyName);
-        }
-      } else {
-        if (operator == Operator.LIKE) {
-          filterBuilder.append(" " + keyName + "." + operator.getJdoOp() + "(" + paramName + ") ");
-        } else {
-          filterBuilder.append(" " + keyName + " " + operator.getJdoOp() + " " + paramName);
-        }
-      }
-    }
-
-    private void generateJDOFilterOverPartitions(Configuration conf, Table table,
-        Map<String, Object> params,  FilterBuilder filterBuilder) throws MetaException {
-      int partitionColumnCount = table.getPartitionKeys().size();
-      int partitionColumnIndex = getPartColIndexForFilter(table, filterBuilder);
-      if (filterBuilder.hasError()) return;
-
-      boolean canPushDownIntegral =
-          MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.INTEGER_JDO_PUSHDOWN);
-      String valueAsString = getJdoFilterPushdownParam(
-          table, partitionColumnIndex, filterBuilder, canPushDownIntegral);
-      if (filterBuilder.hasError()) return;
-
-      String paramName = PARAM_PREFIX + params.size();
-      params.put(paramName, valueAsString);
-
-      boolean isOpEquals = operator == Operator.EQUALS;
-      if (isOpEquals || operator == Operator.NOTEQUALS || operator == Operator.NOTEQUALS2) {
-        String partitionKey = table.getPartitionKeys().get(partitionColumnIndex).getName();
-        makeFilterForEquals(partitionKey, valueAsString, paramName, params,
-            partitionColumnIndex, partitionColumnCount, isOpEquals, filterBuilder);
-        return;
-      }
-      //get the value for a partition key form MPartition.values (PARTITION_KEY_VALUES)
-      String valString = "values.get(" + partitionColumnIndex + ")";
-
-      if (operator == Operator.LIKE) {
-        if (isReverseOrder) {
-          // For LIKE, the value should be on the RHS.
-          filterBuilder.setError(
-              "Value should be on the RHS for LIKE operator : Key <" + keyName + ">");
-        }
-        // TODO: in all likelihood, this won't actually work. Keep it for backward compat.
-        filterBuilder.append(" " + valString + "." + operator.getJdoOp() + "(" + paramName + ") ");
-      } else {
-        filterBuilder.append(isReverseOrder
-            ? paramName + " " + operator.getJdoOp() + " " + valString
-            : " " + valString + " " + operator.getJdoOp() + " " + paramName);
-      }
-    }
-
-    /**
-     * @return true iff filter pushdown for this operator can be done for integral types.
-     */
-    public boolean canJdoUseStringsWithIntegral() {
-      return (operator == Operator.EQUALS)
-          || (operator == Operator.NOTEQUALS)
-          || (operator == Operator.NOTEQUALS2);
-    }
-
-    /**
-     * Get partition column index in the table partition column list that
-     * corresponds to the key that is being filtered on by this tree node.
-     * @param table The table.
-     * @param filterBuilder filter builder used to report error, if any.
-     * @return The index.
-     */
-    public int getPartColIndexForFilter(
-        Table table, FilterBuilder filterBuilder) throws MetaException {
-      int partitionColumnIndex;
-      assert (table.getPartitionKeys().size() > 0);
-      for (partitionColumnIndex = 0; partitionColumnIndex < table.getPartitionKeys().size();
-          ++partitionColumnIndex) {
-        if (table.getPartitionKeys().get(partitionColumnIndex).getName().
-            equalsIgnoreCase(keyName)) {
-          break;
-        }
-      }
-      if( partitionColumnIndex == table.getPartitionKeys().size()) {
-        filterBuilder.setError("Specified key <" + keyName +
-            "> is not a partitioning key for the table");
-        return -1;
-      }
-
-      return partitionColumnIndex;
-    }
-
-    /**
-     * Validates and gets the query parameter for JDO filter pushdown based on the column
-     * and the constant stored in this node.
-     * @param table The table.
-     * @param partColIndex The index of the column to check.
-     * @param filterBuilder filter builder used to report error, if any.
-     * @return The parameter string.
-     */
-    private String getJdoFilterPushdownParam(Table table, int partColIndex,
-        FilterBuilder filterBuilder, boolean canPushDownIntegral) throws MetaException {
-      boolean isIntegralSupported = canPushDownIntegral && canJdoUseStringsWithIntegral();
-      String colType = table.getPartitionKeys().get(partColIndex).getType();
-      // Can only support partitions whose types are string, or maybe integers
-      if (!colType.equals(ColumnType.STRING_TYPE_NAME)
-          && (!isIntegralSupported || !ColumnType.IntegralTypes.contains(colType))) {
-        filterBuilder.setError("Filtering is supported only on partition keys of type " +
-            "string" + (isIntegralSupported ? ", or integral types" : ""));
-        return null;
-      }
-
-      // There's no support for date cast in JDO. Let's convert it to string; the date
-      // columns have been excluded above, so it will either compare w/string or fail.
-      Object val = value;
-      if (value instanceof Date) {
-        val = MetaStoreUtils.PARTITION_DATE_FORMAT.get().format((Date)value);
-      }
-      boolean isStringValue = val instanceof String;
-      if (!isStringValue && (!isIntegralSupported || !(val instanceof Long))) {
-        filterBuilder.setError("Filtering is supported only on partition keys of type " +
-            "string" + (isIntegralSupported ? ", or integral types" : ""));
-        return null;
-      }
-
-      return isStringValue ? (String)val : Long.toString((Long)val);
-    }
-  }
-
-  public void accept(TreeVisitor treeVisitor) throws MetaException {
-    if (this.root != null) {
-      this.root.accept(treeVisitor);
-    }
-  }
-
-  /**
-   * For equals and not-equals, we can make the JDO query much faster by filtering
-   * based on the partition name. For a condition like ds="2010-10-01", we can see
-   * if there are any partitions with a name that contains the substring "ds=2010-10-01/"
-   * False matches aren't possible since "=" is escaped for partition names
-   * and the trailing '/' ensures that we won't get a match with ds=2010-10-011
-   * Note that filters on integral type equality also work correctly by virtue of
-   * comparing them as part of ds=1234 string.
-   *
-   * Two cases to keep in mind: Case with only one partition column (no '/'s)
-   * Case where the partition key column is at the end of the name. (no
-   * tailing '/')
-   *
-   * @param keyName name of the partition column e.g. ds.
-   * @param value The value to compare to.
-   * @param paramName name of the parameter to use for JDOQL.
-   * @param params a map from the parameter name to their values.
-   * @param keyPos The index of the requisite partition column in the list of such columns.
-   * @param keyCount Partition column count for the table.
-   * @param isEq whether the operator is equals, or not-equals.
-   * @param fltr Filter builder used to append the filter, or report errors.
-   */
-  private static void makeFilterForEquals(String keyName, String value, String paramName,
-      Map<String, Object> params, int keyPos, int keyCount, boolean isEq, FilterBuilder fltr)
-          throws MetaException {
-    Map<String, String> partKeyToVal = new HashMap<>();
-    partKeyToVal.put(keyName, value);
-    // If a partition has multiple partition keys, we make the assumption that
-    // makePartName with one key will return a substring of the name made
-    // with both all the keys.
-    String escapedNameFragment = Warehouse.makePartName(partKeyToVal, false);
-    if (keyCount == 1) {
-      // Case where this is no other partition columns
-      params.put(paramName, escapedNameFragment);
-      fltr.append("partitionName ").append(isEq ? "== " : "!= ").append(paramName);
-    } else if (keyPos + 1 == keyCount) {
-      // Case where the partition column is at the end of the name. There will
-      // be a leading '/' but no trailing '/'
-      params.put(paramName, "/" + escapedNameFragment);
-      fltr.append(isEq ? "" : "!").append("partitionName.endsWith(")
-        .append(paramName).append(")");
-    } else if (keyPos == 0) {
-      // Case where the partition column is at the beginning of the name. There will
-      // be a trailing '/' but no leading '/'
-      params.put(paramName, escapedNameFragment + "/");
-      fltr.append(isEq ? "" : "!").append("partitionName.startsWith(")
-        .append(paramName).append(")");
-    } else {
-      // Case where the partition column is in the middle of the name. There will
-      // be a leading '/' and an trailing '/'
-      params.put(paramName, "/" + escapedNameFragment + "/");
-      fltr.append("partitionName.indexOf(").append(paramName).append(")")
-        .append(isEq ? ">= 0" : "< 0");
-    }
-  }
-
-  /**
-   * The root node for the tree.
-   */
-  private TreeNode root = null;
-
-  /**
-   * The node stack used to keep track of the tree nodes during parsing.
-   */
-  private final Stack<TreeNode> nodeStack = new Stack<>();
-
-  public TreeNode getRoot() {
-    return this.root;
-  }
-
-  @VisibleForTesting
-  public void setRootForTest(TreeNode tn) {
-    this.root = tn;
-  }
-
-
-  /**
-   * Adds a intermediate node of either type(AND/OR). Pops last two nodes from
-   * the stack and sets them as children of the new node and pushes itself
-   * onto the stack.
-   * @param andOr the operator type
-   */
-  public void addIntermediateNode(LogicalOperator andOr) {
-
-    TreeNode rhs = nodeStack.pop();
-    TreeNode lhs = nodeStack.pop();
-    TreeNode newNode = new TreeNode(lhs, andOr, rhs);
-    nodeStack.push(newNode);
-    root = newNode;
-  }
-
-  /**
-   * Adds a leaf node, pushes the new node onto the stack.
-   * @param newNode the new node
-   */
-  public void addLeafNode(LeafNode newNode) {
-    if( root == null ) {
-      root = newNode;
-    }
-    nodeStack.push(newNode);
-  }
-
-  /** Generate the JDOQL filter for the given expression tree
-   * @param table the table being queried
-   * @param params the input map which is updated with the
-   *     the parameterized values. Keys are the parameter names and values
-   *     are the parameter values
-   * @param filterBuilder the filter builder to append to.
-   */
-  public void generateJDOFilterFragment(Configuration conf, Table table,
-      Map<String, Object> params, FilterBuilder filterBuilder) throws MetaException {
-    if (root == null) {
-      return;
-    }
-
-    filterBuilder.append(" && ( ");
-    root.generateJDOFilter(conf, table, params, filterBuilder);
-    filterBuilder.append(" )");
-  }
-
-  /** Case insensitive ANTLR string stream */
-  public static class ANTLRNoCaseStringStream extends ANTLRStringStream {
-    public ANTLRNoCaseStringStream (String input) {
-      super(input);
-    }
-
-    @Override
-    public int LA (int i) {
-      int returnChar = super.LA (i);
-
-      if (returnChar == CharStream.EOF) {
-        return returnChar;
-      }
-      else if (returnChar == 0) {
-        return returnChar;
-      }
-
-      return Character.toUpperCase ((char) returnChar);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/Filter.g
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/Filter.g b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/Filter.g
deleted file mode 100644
index 4559383..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/Filter.g
+++ /dev/null
@@ -1,486 +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.
-
-grammar Filter;
-
-options
-{
-  k=3;
-}
-
-
-// Package headers
-@header {
-package org.apache.hadoop.hive.metastore.parser;
-
-import org.apache.hadoop.hive.metastore.parser.ExpressionTree;
-import org.apache.hadoop.hive.metastore.parser.ExpressionTree.LeafNode;
-import org.apache.hadoop.hive.metastore.parser.ExpressionTree.Operator;
-import org.apache.hadoop.hive.metastore.parser.ExpressionTree.LogicalOperator;
-}
-
-@lexer::header {
-package org.apache.hadoop.hive.metastore.parser;
-
-import java.sql.Date;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-}
-
-@lexer::members {
-  public String errorMsg;
-
-  private static final Pattern datePattern = Pattern.compile(".*(\\d\\d\\d\\d-\\d\\d-\\d\\d).*");
-  private static final ThreadLocal<SimpleDateFormat> dateFormat =
-       new ThreadLocal<SimpleDateFormat>() {
-    @Override
-    protected SimpleDateFormat initialValue() {
-      SimpleDateFormat val = new SimpleDateFormat("yyyy-MM-dd");
-      val.setLenient(false); // Without this, 2020-20-20 becomes 2021-08-20.
-      val.setTimeZone(TimeZone.getTimeZone("UTC"));
-      return val;
-    };
-  };
-
-  public static java.sql.Date ExtractDate (String input) {
-    Matcher m = datePattern.matcher(input);
-    if (!m.matches()) {
-      return null;
-    }
-    try {
-      return new java.sql.Date(dateFormat.get().parse(m.group(1)).getTime());
-    } catch (ParseException pe) {
-      return null;
-    }
-  }
-
-  @Override
-  public void emitErrorMessage(String msg) {
-    // save for caller to detect invalid filter
-    errorMsg = msg;
-  }
-}
-
-@members {
-  public ExpressionTree tree = new ExpressionTree();
-
-  public static String TrimQuotes (String input) {
-    if (input.length () > 1) {
-      if ((input.charAt (0) == '"' && input.charAt (input.length () - 1) == '"')
-        || (input.charAt (0) == '\'' && input.charAt (input.length () - 1) == '\'')) {
-        return input.substring (1, input.length () - 1);
-      }
-    }
-    return input;
-  }
-}
-
-@rulecatch{
-  catch (RecognitionException e){
-    throw e;
-  }
-}
-
-//main rule
-filter
-    :
-    orExpression 
-    ;
-
-orExpression
-    :
-    andExpression (KW_OR andExpression { tree.addIntermediateNode(LogicalOperator.OR); } )*
-    ;
-
-andExpression
-    :
-    expression (KW_AND expression  { tree.addIntermediateNode(LogicalOperator.AND); } )*
-    ;
-
-expression
-    :
-    LPAREN orExpression RPAREN
-    |
-    operatorExpression
-    ;
-
-operatorExpression
-    :
-    betweenExpression
-    |
-    inExpression
-    |
-    multiColInExpression
-    |
-    binOpExpression
-    ;
-
-binOpExpression
-@init {
-    boolean isReverseOrder = false;
-    Object val = null;
-}
-    :
-    (
-       (
-         (key = Identifier op = operator  value = DateLiteral)
-         |
-         (value = DateLiteral  op = operator key = Identifier) { isReverseOrder = true; }
-       ) { val = FilterLexer.ExtractDate(value.getText()); }
-       |
-       (
-         (key = Identifier op = operator  value = StringLiteral)
-         |
-         (value = StringLiteral  op = operator key = Identifier) { isReverseOrder = true; }
-       ) { val = TrimQuotes(value.getText()); }
-       |
-       (
-         (key = Identifier op = operator value = IntegralLiteral)
-         |
-         (value = IntegralLiteral op = operator key = Identifier) { isReverseOrder = true; }
-       ) { val = Long.parseLong(value.getText()); }
-    )
-    {
-        LeafNode node = new LeafNode();
-        node.keyName = key.getText();
-        node.value = val;
-        node.operator = op;
-        node.isReverseOrder = isReverseOrder;
-
-        tree.addLeafNode(node);
-    };
-
-operator returns [Operator op]
-   :
-   t = (LESSTHAN | LESSTHANOREQUALTO | GREATERTHAN | GREATERTHANOREQUALTO | KW_LIKE | EQUAL | NOTEQUAL)
-   {
-      $op = Operator.fromString(t.getText().toUpperCase());
-   };
-
-betweenExpression
-@init {
-    Object leftV = null;
-    Object rightV = null;
-    boolean isPositive = true;
-}
-    :
-    (
-       key = Identifier (KW_NOT { isPositive = false; } )? BETWEEN
-       (
-         (left = DateLiteral KW_AND right = DateLiteral) {
-            leftV = FilterLexer.ExtractDate(left.getText());
-            rightV = FilterLexer.ExtractDate(right.getText());
-         }
-         |
-         (left = StringLiteral KW_AND right = StringLiteral) { leftV = TrimQuotes(left.getText());
-            rightV = TrimQuotes(right.getText());
-         }
-         |
-         (left = IntegralLiteral KW_AND right = IntegralLiteral) { leftV = Long.parseLong(left.getText());
-            rightV = Long.parseLong(right.getText());
-         }
-       )
-    )
-    {
-        LeafNode leftNode = new LeafNode(), rightNode = new LeafNode();
-        leftNode.keyName = rightNode.keyName = key.getText();
-        leftNode.value = leftV;
-        rightNode.value = rightV;
-        leftNode.operator = isPositive ? Operator.GREATERTHANOREQUALTO : Operator.LESSTHAN;
-        rightNode.operator = isPositive ? Operator.LESSTHANOREQUALTO : Operator.GREATERTHAN;
-        tree.addLeafNode(leftNode);
-        tree.addLeafNode(rightNode);
-        tree.addIntermediateNode(isPositive ? LogicalOperator.AND : LogicalOperator.OR);
-    };
-
-inExpression
-@init {
-    List constants = new ArrayList();
-    Object constantV = null;
-    boolean isPositive = true;
-}
-    :
-    (
-        LPAREN key = Identifier RPAREN ( KW_NOT { isPositive = false; } )? IN LPAREN
-        (
-            (
-                constant = DateLiteral
-                {
-                    constantV = FilterLexer.ExtractDate(constant.getText());
-                    constants.add(constantV);
-                }
-                (
-                    COMMA constant = DateLiteral
-                    {
-                        constantV = FilterLexer.ExtractDate(constant.getText());
-                        constants.add(constantV);
-                    }
-                )*
-            )
-            |
-            (
-                constant = StringLiteral
-                {
-                    constantV = TrimQuotes(constant.getText());
-                    constants.add(constantV);
-                }
-                (
-                    COMMA constant = StringLiteral
-                    {
-                        constantV = TrimQuotes(constant.getText());
-                        constants.add(constantV);
-                    }
-                )*
-            )
-            |
-            (
-                constant = IntegralLiteral
-                {
-                    constantV = Long.parseLong(constant.getText());
-                    constants.add(constantV);
-                }
-                (
-                    COMMA constant = IntegralLiteral
-                    {
-                        constantV = Long.parseLong(constant.getText());
-                        constants.add(constantV);
-                    }
-                )*
-            )
-        ) RPAREN
-    )
-    {
-        for (int i = 0; i < constants.size(); i++) {
-            Object value = constants.get(i);
-            LeafNode leaf = new LeafNode();
-            leaf.keyName = key.getText();
-            leaf.value = value;
-            leaf.operator = isPositive ? Operator.EQUALS : Operator.NOTEQUALS2;
-            tree.addLeafNode(leaf);
-            if (i != 0) {
-                tree.addIntermediateNode(isPositive ? LogicalOperator.OR : LogicalOperator.AND);
-            }
-        }
-    };
-
-multiColInExpression
-@init {
-    List<String> keyNames = new ArrayList<String>();
-    List constants = new ArrayList();
-    List partialConstants;
-    String keyV = null;
-    Object constantV = null;
-    boolean isPositive = true;
-}
-    :
-    (
-        LPAREN
-        (
-            KW_STRUCT LPAREN key = Identifier
-            {
-                keyV = key.getText();
-                keyNames.add(keyV);
-            }
-            (
-                COMMA key = Identifier
-                {
-                    keyV = key.getText();
-                    keyNames.add(keyV);
-                }
-            )* RPAREN
-        ) RPAREN ( KW_NOT { isPositive = false; } )? IN LPAREN KW_CONST KW_STRUCT LPAREN
-        {
-            partialConstants = new ArrayList();
-        }
-        (
-            constant = DateLiteral
-            {
-                constantV = FilterLexer.ExtractDate(constant.getText());
-                partialConstants.add(constantV);
-            }
-            | constant = StringLiteral
-            {
-                constantV = TrimQuotes(constant.getText());
-                partialConstants.add(constantV);
-            }
-            | constant = IntegralLiteral
-            {
-                constantV = Long.parseLong(constant.getText());
-                partialConstants.add(constantV);
-            }
-        )
-        (
-            COMMA
-            (
-                constant = DateLiteral
-                {
-                    constantV = FilterLexer.ExtractDate(constant.getText());
-                    partialConstants.add(constantV);
-                }
-                | constant = StringLiteral
-                {
-                    constantV = TrimQuotes(constant.getText());
-                    partialConstants.add(constantV);
-                }
-                | constant = IntegralLiteral
-                {
-                    constantV = Long.parseLong(constant.getText());
-                    partialConstants.add(constantV);
-                }
-            )
-        )*
-        {
-            constants.add(partialConstants);
-        }
-        RPAREN
-        (
-            COMMA KW_CONST KW_STRUCT LPAREN
-            {
-                partialConstants = new ArrayList();
-            }
-            (
-                constant = DateLiteral
-                {
-                    constantV = FilterLexer.ExtractDate(constant.getText());
-                    partialConstants.add(constantV);
-                }
-                | constant = StringLiteral
-                {
-                    constantV = TrimQuotes(constant.getText());
-                    partialConstants.add(constantV);
-                }
-                | constant = IntegralLiteral
-                {
-                    constantV = Long.parseLong(constant.getText());
-                    partialConstants.add(constantV);
-                }
-            )
-            (
-                COMMA
-                (
-                    constant = DateLiteral
-                    {
-                        constantV = FilterLexer.ExtractDate(constant.getText());
-                        partialConstants.add(constantV);
-                    }
-                    | constant = StringLiteral
-                    {
-                        constantV = TrimQuotes(constant.getText());
-                        partialConstants.add(constantV);
-                    }
-                    | constant = IntegralLiteral
-                    {
-                        constantV = Long.parseLong(constant.getText());
-                        partialConstants.add(constantV);
-                    }
-                )
-            )*
-            {
-                constants.add(partialConstants);
-            }
-            RPAREN
-        )* RPAREN
-    )
-    {
-        for (int i = 0; i < constants.size(); i++) {
-            List list = (List) constants.get(i);
-            assert keyNames.size() == list.size();
-            for (int j=0; j < list.size(); j++) {
-                String keyName = keyNames.get(j);
-                Object value = list.get(j);
-                LeafNode leaf = new LeafNode();
-                leaf.keyName = keyName;
-                leaf.value = value;
-                leaf.operator = isPositive ? Operator.EQUALS : Operator.NOTEQUALS2;
-                tree.addLeafNode(leaf);
-                if (j != 0) {
-                    tree.addIntermediateNode(isPositive ? LogicalOperator.AND : LogicalOperator.OR);
-                }
-            }
-            if (i != 0) {
-                tree.addIntermediateNode(isPositive ? LogicalOperator.OR : LogicalOperator.AND);
-            }
-        }
-    };
-
-// Keywords
-KW_NOT : 'NOT';
-KW_AND : 'AND';
-KW_OR : 'OR';
-KW_LIKE : 'LIKE';
-KW_DATE : 'date';
-KW_CONST : 'CONST';
-KW_STRUCT : 'STRUCT';
-
-// Operators
-LPAREN : '(' ;
-RPAREN : ')' ;
-COMMA : ',' ;
-EQUAL : '=';
-NOTEQUAL : '<>' | '!=';
-LESSTHANOREQUALTO : '<=';
-LESSTHAN : '<';
-GREATERTHANOREQUALTO : '>=';
-GREATERTHAN : '>';
-BETWEEN : 'BETWEEN';
-IN : 'IN';
-
-// LITERALS
-fragment
-Letter
-    : 'a'..'z' | 'A'..'Z'
-    ;
-
-fragment
-Digit
-    :
-    '0'..'9'
-    ;
-
-fragment DateString
-    :
-    (Digit)(Digit)(Digit)(Digit) '-' (Digit)(Digit) '-' (Digit)(Digit)
-    ;
-
-/* When I figure out how to make lexer backtrack after validating predicate, dates would be able 
-to support single quotes [( '\'' DateString '\'' ) |]. For now, what we do instead is have a hack
-to parse the string in metastore code from StringLiteral. */
-DateLiteral
-    :
-    KW_DATE? DateString { ExtractDate(getText()) != null }?
-    ;
-
-StringLiteral
-    :
-    ( '\'' ( ~('\''|'\\') | ('\\' .) )* '\''
-    | '\"' ( ~('\"'|'\\') | ('\\' .) )* '\"'
-    )
-    ;
-
-IntegralLiteral
-    :
-    ('-')? (Digit)+
-    ;
-
-Identifier
-    :
-    (Letter | Digit) (Letter | Digit | '_')*
-    ;
-
-WS  :   (' '|'\r'|'\t'|'\n')+ { skip(); } ;

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/package-info.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/package-info.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/package-info.java
deleted file mode 100644
index 7280cc3..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/parser/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-
-/**
- * This package implements the parser for parsing the string filter
- * for the listPartitionsByFilter API.
- */
-package org.apache.hadoop.hive.metastore.parser;

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java
deleted file mode 100644
index 91d790a..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/CompositePartitionSpecProxy.java
+++ /dev/null
@@ -1,258 +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.partition.spec;
-
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.PartitionSpec;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
-
-/**
- * Implementation of PartitionSpecProxy that composes a list of PartitionSpecProxy.
- */
-public class CompositePartitionSpecProxy extends PartitionSpecProxy {
-
-  private String catName;
-  private String dbName;
-  private String tableName;
-  private List<PartitionSpec> partitionSpecs;
-  private List<PartitionSpecProxy> partitionSpecProxies;
-  private int size = 0;
-
-  protected CompositePartitionSpecProxy(List<PartitionSpec> partitionSpecs) throws MetaException {
-    this.partitionSpecs = partitionSpecs;
-    if (partitionSpecs.isEmpty()) {
-      catName = null;
-      dbName = null;
-      tableName = null;
-    }
-    else {
-      catName = partitionSpecs.get(0).getCatName();
-      dbName = partitionSpecs.get(0).getDbName();
-      tableName = partitionSpecs.get(0).getTableName();
-      this.partitionSpecProxies = new ArrayList<>(partitionSpecs.size());
-      for (PartitionSpec partitionSpec : partitionSpecs) {
-        PartitionSpecProxy partitionSpecProxy = Factory.get(partitionSpec);
-        this.partitionSpecProxies.add(partitionSpecProxy);
-        size += partitionSpecProxy.size();
-      }
-    }
-    // Assert class-invariant.
-    assert isValid() : "Invalid CompositePartitionSpecProxy!";
-  }
-
-  @Deprecated
-  protected CompositePartitionSpecProxy(String dbName, String tableName, List<PartitionSpec> partitionSpecs) throws MetaException {
-    this(DEFAULT_CATALOG_NAME, dbName, tableName, partitionSpecs);
-
-  }
-
-  protected CompositePartitionSpecProxy(String catName, String dbName, String tableName,
-                                        List<PartitionSpec> partitionSpecs) throws MetaException {
-    this.catName = catName;
-    this.dbName = dbName;
-    this.tableName = tableName;
-    this.partitionSpecs = partitionSpecs;
-    this.partitionSpecProxies = new ArrayList<>(partitionSpecs.size());
-    for (PartitionSpec partitionSpec : partitionSpecs) {
-      this.partitionSpecProxies.add(PartitionSpecProxy.Factory.get(partitionSpec));
-    }
-    // Assert class-invariant.
-    assert isValid() : "Invalid CompositePartitionSpecProxy!";
-  }
-
-  private boolean isValid() {
-    for (PartitionSpecProxy partitionSpecProxy : partitionSpecProxies) {
-      if (partitionSpecProxy instanceof CompositePartitionSpecProxy) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-
-  @Override
-  public int size() {
-    return size;
-  }
-
-  /**
-   * Iterator to iterate over all Partitions, across all PartitionSpecProxy instances within the Composite.
-   */
-  public static class Iterator implements PartitionIterator {
-
-    private CompositePartitionSpecProxy composite;
-    private List<PartitionSpecProxy> partitionSpecProxies;
-    private int index = -1; // Index into partitionSpecs.
-    private PartitionIterator iterator = null;
-
-    public Iterator(CompositePartitionSpecProxy composite) {
-      this.composite = composite;
-      this.partitionSpecProxies = composite.partitionSpecProxies;
-
-      if (this.partitionSpecProxies != null && !this.partitionSpecProxies.isEmpty()) {
-        this.index = 0;
-        this.iterator = this.partitionSpecProxies.get(this.index).getPartitionIterator();
-      }
-    }
-
-    @Override
-    public boolean hasNext() {
-
-      if (iterator == null) {
-        return false;
-      }
-
-      if (iterator.hasNext()) {
-        return true;
-      }
-
-      while ( ++index < partitionSpecProxies.size()
-          && !(iterator = partitionSpecProxies.get(index).getPartitionIterator()).hasNext());
-
-      return index < partitionSpecProxies.size() && iterator.hasNext();
-
-    }
-
-    @Override
-    public Partition next() {
-
-        if (iterator.hasNext())
-          return iterator.next();
-
-        while (++index < partitionSpecProxies.size()
-            && !(iterator = partitionSpecProxies.get(index).getPartitionIterator()).hasNext());
-
-        return index == partitionSpecProxies.size()? null : iterator.next();
-
-    }
-
-    @Override
-    public void remove() {
-      iterator.remove();
-    }
-
-    @Override
-    public Partition getCurrent() {
-      return iterator.getCurrent();
-    }
-
-    @Override
-    public String getCatName() {
-      return composite.getCatName();
-    }
-
-    @Override
-    public String getDbName() {
-      return composite.dbName;
-    }
-
-    @Override
-    public String getTableName() {
-      return composite.tableName;
-    }
-
-    @Override
-    public Map<String, String> getParameters() {
-      return iterator.getParameters();
-    }
-
-    @Override
-    public void setParameters(Map<String, String> parameters) {
-      iterator.setParameters(parameters);
-    }
-
-    @Override
-    public String getLocation() {
-      return iterator.getLocation();
-    }
-
-    @Override
-    public void putToParameters(String key, String value) {
-      iterator.putToParameters(key, value);
-    }
-
-    @Override
-    public void setCreateTime(long time) {
-      iterator.setCreateTime(time);
-    }
-  }
-
-  @Override
-  public void setCatName(String catName) {
-    this.catName = catName;
-    for (PartitionSpecProxy partSpecProxy : partitionSpecProxies) {
-      partSpecProxy.setCatName(catName);
-    }
-
-  }
-
-  @Override
-  public void setDbName(String dbName) {
-    this.dbName = dbName;
-    for (PartitionSpecProxy partSpecProxy : partitionSpecProxies) {
-      partSpecProxy.setDbName(dbName);
-    }
-  }
-
-  @Override
-  public void setTableName(String tableName) {
-    this.tableName = tableName;
-    for (PartitionSpecProxy partSpecProxy : partitionSpecProxies) {
-      partSpecProxy.setTableName(tableName);
-    }
-  }
-
-  @Override
-  public String getCatName() {
-    return catName;
-  }
-
-  @Override
-  public String getDbName() {
-    return dbName;
-  }
-
-  @Override
-  public String getTableName() {
-    return tableName;
-  }
-
-  @Override
-  public PartitionIterator getPartitionIterator() {
-    return new Iterator(this);
-  }
-
-  @Override
-  public List<PartitionSpec> toPartitionSpec() {
-    return partitionSpecs;
-  }
-
-  @Override
-  public void setRootLocation(String rootLocation) throws MetaException {
-    for (PartitionSpecProxy partSpecProxy : partitionSpecProxies) {
-      partSpecProxy.setRootLocation(rootLocation);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java
deleted file mode 100644
index 585b8fd..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionListComposingSpecProxy.java
+++ /dev/null
@@ -1,209 +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.partition.spec;
-
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec;
-import org.apache.hadoop.hive.metastore.api.PartitionSpec;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/**
- * PartitionSpecProxy implementation that composes a List of Partitions.
- */
-public class PartitionListComposingSpecProxy extends PartitionSpecProxy {
-
-  private PartitionSpec partitionSpec;
-
-  protected PartitionListComposingSpecProxy(PartitionSpec partitionSpec) throws MetaException {
-    assert partitionSpec.isSetPartitionList()
-        : "Partition-list should have been set.";
-    PartitionListComposingSpec partitionList = partitionSpec.getPartitionList();
-    if (partitionList == null || partitionList.getPartitions() == null) {
-      throw new MetaException("The partition list cannot be null.");
-    }
-    for (Partition partition : partitionList.getPartitions()) {
-      if (partition == null) {
-        throw new MetaException("Partition cannot be null.");
-      }
-      if (partition.getValues() == null || partition.getValues().isEmpty()) {
-        throw new MetaException("The partition value list cannot be null or empty.");
-      }
-      if (partition.getValues().contains(null)) {
-        throw new MetaException("Partition value cannot be null.");
-      }
-    }
-    this.partitionSpec = partitionSpec;
-  }
-
-  @Override
-  public String getCatName() {
-    return partitionSpec.getCatName();
-  }
-
-  @Override
-  public String getDbName() {
-    return partitionSpec.getDbName();
-  }
-
-  @Override
-  public String getTableName() {
-    return partitionSpec.getTableName();
-  }
-
-  @Override
-  public PartitionIterator getPartitionIterator() {
-    return new Iterator(this);
-  }
-
-  @Override
-  public List<PartitionSpec> toPartitionSpec() {
-    return Arrays.asList(partitionSpec);
-  }
-
-  @Override
-  public int size() {
-    return partitionSpec.getPartitionList().getPartitionsSize();
-  }
-
-  @Override
-  public void setCatName(String catName) {
-    partitionSpec.setCatName(catName);
-    for (Partition partition : partitionSpec.getPartitionList().getPartitions()) {
-      partition.setCatName(catName);
-    }
-  }
-
-  @Override
-  public void setDbName(String dbName) {
-    partitionSpec.setDbName(dbName);
-    for (Partition partition : partitionSpec.getPartitionList().getPartitions()) {
-      partition.setDbName(dbName);
-    }
-  }
-
-  @Override
-  public void setTableName(String tableName) {
-    partitionSpec.setTableName(tableName);
-    for (Partition partition : partitionSpec.getPartitionList().getPartitions()) {
-      partition.setTableName(tableName);
-    }
-  }
-
-  @Override
-  public void setRootLocation(String newRootPath) throws MetaException {
-
-    String oldRootPath = partitionSpec.getRootPath();
-
-    if (oldRootPath == null) {
-      throw new MetaException("No common root-path. Can't replace root-path!");
-    }
-
-    if (newRootPath == null) {
-      throw new MetaException("Root path cannot be null.");
-    }
-
-    for (Partition partition : partitionSpec.getPartitionList().getPartitions()) {
-      String location = partition.getSd().getLocation();
-      if (location.startsWith(oldRootPath)) {
-        partition.getSd().setLocation(location.replace(oldRootPath, newRootPath));
-      }
-      else {
-        throw new MetaException("Common root-path not found. Can't replace root-path!");
-      }
-    }
-  }
-
-  public static class Iterator implements PartitionIterator {
-
-    PartitionListComposingSpecProxy partitionSpecProxy;
-    List<Partition> partitionList;
-    int index;
-
-    public Iterator(PartitionListComposingSpecProxy partitionSpecProxy) {
-      this.partitionSpecProxy = partitionSpecProxy;
-      this.partitionList = partitionSpecProxy.partitionSpec.getPartitionList().getPartitions();
-      this.index = 0;
-    }
-
-    @Override
-    public Partition getCurrent() {
-      return partitionList.get(index);
-    }
-
-    @Override
-    public String getCatName() {
-      return partitionSpecProxy.getCatName();
-    }
-
-    @Override
-    public String getDbName() {
-      return partitionSpecProxy.getDbName();
-    }
-
-    @Override
-    public String getTableName() {
-      return partitionSpecProxy.getTableName();
-    }
-
-    @Override
-    public Map<String, String> getParameters() {
-      return partitionList.get(index).getParameters();
-    }
-
-    @Override
-    public void setParameters(Map<String, String> parameters) {
-      partitionList.get(index).setParameters(parameters);
-    }
-
-    @Override
-    public String getLocation() {
-      return partitionList.get(index).getSd().getLocation();
-    }
-
-    @Override
-    public void putToParameters(String key, String value) {
-      partitionList.get(index).putToParameters(key, value);
-    }
-
-    @Override
-    public void setCreateTime(long time) {
-      partitionList.get(index).setCreateTime((int)time);
-    }
-
-    @Override
-    public boolean hasNext() {
-      return index < partitionList.size();
-    }
-
-    @Override
-    public Partition next() {
-      return partitionList.get(index++);
-    }
-
-    @Override
-    public void remove() {
-      partitionList.remove(index);
-    }
-  } // class Iterator;
-
-} // class PartitionListComposingSpecProxy;

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
deleted file mode 100644
index 1866446..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
+++ /dev/null
@@ -1,220 +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.partition.spec;
-
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.PartitionSpec;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Polymorphic proxy class, equivalent to org.apache.hadoop.hive.metastore.api.PartitionSpec.
- */
-public abstract class PartitionSpecProxy {
-
-  /**
-   * The number of Partition instances represented by the PartitionSpec.
-   * @return Number of partitions.
-   */
-  public abstract int size();
-
-  /**
-   * Set catalog name.
-   * @param catName catalog name.
-   */
-  public abstract void setCatName(String catName);
-
-  /**
-   * Setter for name of the DB.
-   * @param dbName The name of the DB.
-   */
-  public abstract void setDbName(String dbName);
-
-  /**
-   * Setter for name of the table.
-   * @param tableName The name of the table.
-   */
-  public abstract void setTableName(String tableName);
-
-  /**
-   * Get catalog name.
-   * @return catalog name.
-   */
-  public abstract String getCatName();
-
-  /**
-   * Getter for name of the DB.
-   * @return The name of the DB.
-   */
-  public abstract String getDbName();
-
-  /**
-   * Getter for name of the table.
-   * @return The name of the table.
-   */
-  public abstract String getTableName();
-
-  /**
-   * Iterator to the (virtual) sequence of Partitions represented by the PartitionSpec.
-   * @return A PartitionIterator to the beginning of the Partition sequence.
-   */
-  public abstract PartitionIterator getPartitionIterator();
-
-  /**
-   * Conversion to a org.apache.hadoop.hive.metastore.api.PartitionSpec sequence.
-   * @return A list of org.apache.hadoop.hive.metastore.api.PartitionSpec instances.
-   */
-  public abstract List<PartitionSpec> toPartitionSpec();
-
-  /**
-   * Setter for the common root-location for all partitions in the PartitionSet.
-   * @param rootLocation The new common root-location.
-   * @throws MetaException
-   */
-  public abstract void setRootLocation(String rootLocation) throws MetaException;
-
-  /**
-   * Factory to construct PartitionSetProxy instances, from PartitionSets.
-   */
-  public static class Factory {
-
-    /**
-     * Factory method. Construct PartitionSpecProxy from raw PartitionSpec.
-     * @param partSpec Raw PartitionSpec from the Thrift API.
-     * @return PartitionSpecProxy instance.
-     * @throws MetaException
-     */
-    public static PartitionSpecProxy get(PartitionSpec partSpec) throws MetaException {
-
-      if (partSpec == null) {
-        return null;
-      }
-      else
-      if (partSpec.isSetPartitionList()) {
-        return new PartitionListComposingSpecProxy(partSpec);
-      }
-      else
-      if (partSpec.isSetSharedSDPartitionSpec()) {
-        return new PartitionSpecWithSharedSDProxy(partSpec);
-      }
-
-      assert false : "Unsupported type of PartitionSpec!";
-      return null;
-    }
-
-    /**
-     * Factory method to construct CompositePartitionSpecProxy.
-     * @param partitionSpecs List of raw PartitionSpecs.
-     * @return A CompositePartitionSpecProxy instance.
-     * @throws MetaException
-     */
-    public static PartitionSpecProxy get(List<PartitionSpec> partitionSpecs) throws MetaException {
-      return new CompositePartitionSpecProxy(partitionSpecs);
-    }
-
-  } // class Factory;
-
-  /**
-   * Iterator to iterate over Partitions corresponding to a PartitionSpec.
-   */
-  public interface PartitionIterator extends java.util.Iterator<Partition> {
-
-    /**
-     * Getter for the Partition "pointed to" by the iterator.
-     * Like next(), but without advancing the iterator.
-     * @return The "current" partition object.
-     */
-    Partition getCurrent();
-
-    /**
-     * Get the catalog name.
-     * @return catalog name.
-     */
-    String getCatName();
-
-    /**
-     * Getter for the name of the DB.
-     * @return Name of the DB.
-     */
-    String getDbName();
-
-    /**
-     * Getter for the name of the table.
-     * @return Name of the table.
-     */
-    String getTableName();
-
-    /**
-     * Getter for the Partition parameters.
-     * @return Key-value map for Partition-level parameters.
-     */
-    Map<String, String> getParameters();
-
-    /**
-     * Setter for Partition parameters.
-     * @param parameters Key-value map fo Partition-level parameters.
-     */
-    void setParameters(Map<String, String> parameters);
-
-    /**
-     * Insert an individual parameter to a Partition's parameter-set.
-     * @param key
-     * @param value
-     */
-    void putToParameters(String key, String value);
-
-    /**
-     * Getter for Partition-location.
-     * @return Partition's location.
-     */
-    String getLocation();
-
-    /**
-     * Setter for creation-time of a Partition.
-     * @param time Timestamp indicating the time of creation of the Partition.
-     */
-    void setCreateTime(long time);
-
-  } // class PartitionIterator;
-
-  /**
-   * Simple wrapper class for pre-constructed Partitions, to expose a PartitionIterator interface,
-   * where the iterator-sequence consists of just one Partition.
-   */
-  public static class SimplePartitionWrapperIterator implements PartitionIterator {
-    private Partition partition;
-    public SimplePartitionWrapperIterator(Partition partition) {this.partition = partition;}
-
-    @Override public Partition getCurrent() { return partition; }
-    @Override public String getCatName() { return partition.getCatName(); }
-    @Override public String getDbName() { return partition.getDbName(); }
-    @Override public String getTableName() { return partition.getTableName(); }
-    @Override public Map<String, String> getParameters() { return partition.getParameters(); }
-    @Override public void setParameters(Map<String, String> parameters) { partition.setParameters(parameters); }
-    @Override public void putToParameters(String key, String value) { partition.putToParameters(key, value);}
-    @Override public String getLocation() { return partition.getSd().getLocation(); }
-    @Override public void setCreateTime(long time) { partition.setCreateTime((int)time);}
-    @Override public boolean hasNext() { return false; } // No next partition.
-    @Override public Partition next() { return null; } // No next partition.
-    @Override public void remove() {} // Do nothing.
-  } // P
-
-} // class PartitionSpecProxy;

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java
deleted file mode 100644
index 5b46206..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecWithSharedSDProxy.java
+++ /dev/null
@@ -1,192 +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.partition.spec;
-
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.PartitionSpec;
-import org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD;
-import org.apache.hadoop.hive.metastore.api.PartitionWithoutSD;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Subclass of PartitionSpecProxy that pulls out commonality of
- * StorageDescriptor properties within a Partition-list into a common
- * StorageDescriptor instance.
- */
-public class PartitionSpecWithSharedSDProxy extends PartitionSpecProxy {
-
-  private PartitionSpec partitionSpec;
-
-  public PartitionSpecWithSharedSDProxy(PartitionSpec partitionSpec) throws MetaException {
-    assert partitionSpec.isSetSharedSDPartitionSpec();
-    if (partitionSpec.getSharedSDPartitionSpec().getSd() == null) {
-      throw new MetaException("The shared storage descriptor must be set.");
-    }
-    this.partitionSpec = partitionSpec;
-  }
-
-  @Override
-  public int size() {
-    return partitionSpec.getSharedSDPartitionSpec().getPartitionsSize();
-  }
-
-  @Override
-  public void setCatName(String catName) {
-    partitionSpec.setCatName(catName);
-  }
-
-  @Override
-  public void setDbName(String dbName) {
-    partitionSpec.setDbName(dbName);
-  }
-
-  @Override
-  public void setTableName(String tableName) {
-    partitionSpec.setTableName(tableName);
-  }
-
-  @Override
-  public String getCatName() {
-    return partitionSpec.getCatName();
-  }
-
-  @Override
-  public String getDbName() {
-    return partitionSpec.getDbName();
-  }
-
-  @Override
-  public String getTableName() {
-    return partitionSpec.getTableName();
-  }
-
-  public PartitionIterator getPartitionIterator() {
-    return new Iterator(this);
-  }
-
-  @Override
-  public List<PartitionSpec> toPartitionSpec() {
-    return Arrays.asList(partitionSpec);
-  }
-
-  @Override
-  public void setRootLocation(String rootLocation) throws MetaException {
-    partitionSpec.setRootPath(rootLocation);
-    partitionSpec.getSharedSDPartitionSpec().getSd().setLocation(rootLocation);
-  }
-
-  /**
-   * Iterator implementation to iterate over all Partitions within the PartitionSpecWithSharedSDProxy.
-   */
-  public static class Iterator implements PartitionIterator {
-
-    private PartitionSpecWithSharedSDProxy partitionSpecWithSharedSDProxy;
-    private PartitionSpecWithSharedSD pSpec;
-    private int index;
-
-    Iterator(PartitionSpecWithSharedSDProxy partitionSpecWithSharedSDProxy) {
-      this.partitionSpecWithSharedSDProxy = partitionSpecWithSharedSDProxy;
-      this.pSpec = this.partitionSpecWithSharedSDProxy.partitionSpec.getSharedSDPartitionSpec();
-      this.index = 0;
-    }
-
-    @Override
-    public boolean hasNext() {
-      return index < pSpec.getPartitions().size();
-    }
-
-    @Override
-    public Partition next() {
-      Partition partition = getCurrent();
-      ++index;
-      return partition;
-    }
-
-    @Override
-    public void remove() {
-      pSpec.getPartitions().remove(index);
-    }
-
-    @Override
-    public Partition getCurrent() {
-      PartitionWithoutSD partWithoutSD = pSpec.getPartitions().get(index);
-      StorageDescriptor partSD = new StorageDescriptor(pSpec.getSd());
-      partSD.setLocation(partSD.getLocation() + partWithoutSD.getRelativePath());
-
-      Partition p = new Partition(
-          partWithoutSD.getValues(),
-          partitionSpecWithSharedSDProxy.partitionSpec.getDbName(),
-          partitionSpecWithSharedSDProxy.partitionSpec.getTableName(),
-          partWithoutSD.getCreateTime(),
-          partWithoutSD.getLastAccessTime(),
-          partSD,
-          partWithoutSD.getParameters()
-      );
-      p.setCatName(partitionSpecWithSharedSDProxy.partitionSpec.getCatName());
-      return p;
-    }
-
-    @Override
-    public String getCatName() {
-      return partitionSpecWithSharedSDProxy.partitionSpec.getCatName();
-    }
-
-    @Override
-    public String getDbName() {
-      return partitionSpecWithSharedSDProxy.partitionSpec.getDbName();
-    }
-
-    @Override
-    public String getTableName() {
-      return partitionSpecWithSharedSDProxy.partitionSpec.getTableName();
-    }
-
-    @Override
-    public Map<String, String> getParameters() {
-      return pSpec.getPartitions().get(index).getParameters();
-    }
-
-    @Override
-    public void setParameters(Map<String, String> parameters) {
-      pSpec.getPartitions().get(index).setParameters(parameters);
-    }
-
-    @Override
-    public String getLocation() {
-      return pSpec.getSd().getLocation() + pSpec.getPartitions().get(index).getRelativePath();
-    }
-
-    @Override
-    public void putToParameters(String key, String value) {
-      pSpec.getPartitions().get(index).putToParameters(key, value);
-    }
-
-    @Override
-    public void setCreateTime(long time) {
-      pSpec.getPartitions().get(index).setCreateTime((int)time);
-    }
-
-  } // static class Iterator;
-
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DBTokenStore.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DBTokenStore.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DBTokenStore.java
deleted file mode 100644
index b59330c..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DBTokenStore.java
+++ /dev/null
@@ -1,180 +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.security;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge.Server.ServerMode;
-import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation;
-import org.apache.hadoop.security.token.delegation.MetastoreDelegationTokenSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DBTokenStore implements DelegationTokenStore {
-  private static final Logger LOG = LoggerFactory.getLogger(DBTokenStore.class);
-  private Configuration conf;
-
-  @Override
-  public int addMasterKey(String s) throws TokenStoreException {
-    LOG.trace("addMasterKey: s = {}", s);
-    return (Integer)invokeOnTokenStore("addMasterKey", new Object[]{s},String.class);
-  }
-
-  @Override
-  public void updateMasterKey(int keySeq, String s) throws TokenStoreException {
-    LOG.trace("updateMasterKey: s = {}, keySeq = {}", s, keySeq);
-    invokeOnTokenStore("updateMasterKey", new Object[] {Integer.valueOf(keySeq), s},
-        Integer.class, String.class);
-  }
-
-  @Override
-  public boolean removeMasterKey(int keySeq) {
-    return (Boolean)invokeOnTokenStore("removeMasterKey", new Object[] {Integer.valueOf(keySeq)},
-      Integer.class);
-  }
-
-  @Override
-  public String[] getMasterKeys() throws TokenStoreException {
-    return (String[])invokeOnTokenStore("getMasterKeys", new Object[0]);
-  }
-
-  @Override
-  public boolean addToken(DelegationTokenIdentifier tokenIdentifier,
-      DelegationTokenInformation token) throws TokenStoreException {
-
-    try {
-      String identifier = TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier);
-      String tokenStr = Base64.encodeBase64URLSafeString(
-        MetastoreDelegationTokenSupport.encodeDelegationTokenInformation(token));
-      boolean result = (Boolean)invokeOnTokenStore("addToken", new Object[] {identifier, tokenStr},
-        String.class, String.class);
-      LOG.trace("addToken: tokenIdentifier = {}, added = {}", tokenIdentifier, result);
-      return result;
-    } catch (IOException e) {
-      throw new TokenStoreException(e);
-    }
-  }
-
-  @Override
-  public DelegationTokenInformation getToken(DelegationTokenIdentifier tokenIdentifier)
-      throws TokenStoreException {
-    try {
-      String tokenStr = (String)invokeOnTokenStore("getToken", new Object[] {
-          TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier)}, String.class);
-      DelegationTokenInformation result = null;
-      if (StringUtils.isNotEmpty(tokenStr)) {
-        result = MetastoreDelegationTokenSupport.decodeDelegationTokenInformation(Base64.decodeBase64(tokenStr));
-      }
-      LOG.trace("getToken: tokenIdentifier = {}, result = {}", tokenIdentifier, result);
-      return result;
-    } catch (IOException e) {
-      throw new TokenStoreException(e);
-    }
-  }
-
-  @Override
-  public boolean removeToken(DelegationTokenIdentifier tokenIdentifier) throws TokenStoreException{
-    try {
-      boolean result = (Boolean)invokeOnTokenStore("removeToken", new Object[] {
-        TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier)}, String.class);
-      LOG.trace("removeToken: tokenIdentifier = {}, removed = {}", tokenIdentifier, result);
-      return result;
-    } catch (IOException e) {
-      throw new TokenStoreException(e);
-    }
-  }
-
-  @Override
-  public List<DelegationTokenIdentifier> getAllDelegationTokenIdentifiers() throws TokenStoreException{
-
-    List<String> tokenIdents = (List<String>)invokeOnTokenStore("getAllTokenIdentifiers", new Object[0]);
-    List<DelegationTokenIdentifier> delTokenIdents = new ArrayList<DelegationTokenIdentifier>(tokenIdents.size());
-
-    for (String tokenIdent : tokenIdents) {
-      DelegationTokenIdentifier delToken = new DelegationTokenIdentifier();
-      try {
-        TokenStoreDelegationTokenSecretManager.decodeWritable(delToken, tokenIdent);
-      } catch (IOException e) {
-        throw new TokenStoreException(e);
-      }
-      delTokenIdents.add(delToken);
-    }
-    return delTokenIdents;
-  }
-
-  private Object handler;
-  private ServerMode serverMode;
-
-  @Override
-  public void init(Object handler, HadoopThriftAuthBridge.Server.ServerMode serverMode) throws TokenStoreException {
-    this.handler = handler;
-    this.serverMode = serverMode;
-  }
-
-  private Object invokeOnTokenStore(String methName, Object[] params, Class<?> ... paramTypes)
-      throws TokenStoreException{
-    Object tokenStore;
-    try {
-      switch (serverMode) {
-      case METASTORE:
-        tokenStore = handler.getClass().getMethod("getMS").invoke(handler);
-        break;
-      case HIVESERVER2:
-        Object hiveObject = ((Class<?>) handler).getMethod("get").invoke(handler, null);
-        tokenStore = ((Class<?>) handler).getMethod("getMSC").invoke(hiveObject);
-        break;
-      default:
-        throw new IllegalArgumentException("Unexpected value of Server mode " + serverMode);
-      }
-      return tokenStore.getClass().getMethod(methName, paramTypes).invoke(tokenStore, params);
-    } catch (IllegalArgumentException e) {
-        throw new TokenStoreException(e);
-    } catch (SecurityException e) {
-        throw new TokenStoreException(e);
-    } catch (IllegalAccessException e) {
-        throw new TokenStoreException(e);
-    } catch (InvocationTargetException e) {
-        throw new TokenStoreException(e.getCause());
-    } catch (NoSuchMethodException e) {
-        throw new TokenStoreException(e);
-    }
-  }
-
-  @Override
-  public void setConf(Configuration conf) {
-    this.conf = conf;
-  }
-
-  @Override
-  public Configuration getConf() {
-    return conf;
-  }
-
-  @Override
-  public void close() throws IOException {
-    // No-op.
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenIdentifier.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenIdentifier.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenIdentifier.java
deleted file mode 100644
index ba6c7e3..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenIdentifier.java
+++ /dev/null
@@ -1,52 +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.security;
-
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier;
-
-/**
- * A delegation token identifier that is specific to Hive.
- */
-public class DelegationTokenIdentifier
-    extends AbstractDelegationTokenIdentifier {
-  public static final Text HIVE_DELEGATION_KIND = new Text("HIVE_DELEGATION_TOKEN");
-
-  /**
-   * Create an empty delegation token identifier for reading into.
-   */
-  public DelegationTokenIdentifier() {
-  }
-
-  /**
-   * Create a new delegation token identifier
-   * @param owner the effective username of the token owner
-   * @param renewer the username of the renewer
-   * @param realUser the real username of the token owner
-   */
-  public DelegationTokenIdentifier(Text owner, Text renewer, Text realUser) {
-    super(owner, renewer, realUser);
-  }
-
-  @Override
-  public Text getKind() {
-    return HIVE_DELEGATION_KIND;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenSecretManager.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenSecretManager.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenSecretManager.java
deleted file mode 100644
index af88107..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/DelegationTokenSecretManager.java
+++ /dev/null
@@ -1,134 +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.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.token.Token;
-import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager;
-
-/**
- * A Hive specific delegation token secret manager.
- * The secret manager is responsible for generating and accepting the password
- * for each token.
- */
-public class DelegationTokenSecretManager
-    extends AbstractDelegationTokenSecretManager<DelegationTokenIdentifier> {
-
-  /**
-   * Create a secret manager
-   * @param delegationKeyUpdateInterval the number of seconds for rolling new
-   *        secret keys.
-   * @param delegationTokenMaxLifetime the maximum lifetime of the delegation
-   *        tokens
-   * @param delegationTokenRenewInterval how often the tokens must be renewed
-   * @param delegationTokenRemoverScanInterval how often the tokens are scanned
-   *        for expired tokens
-   */
-  public DelegationTokenSecretManager(long delegationKeyUpdateInterval,
-                                      long delegationTokenMaxLifetime,
-                                      long delegationTokenRenewInterval,
-                                      long delegationTokenRemoverScanInterval) {
-    super(delegationKeyUpdateInterval, delegationTokenMaxLifetime,
-          delegationTokenRenewInterval, delegationTokenRemoverScanInterval);
-  }
-
-  @Override
-  public DelegationTokenIdentifier createIdentifier() {
-    return new DelegationTokenIdentifier();
-  }
-
-  /**
-   * Verify token string
-   * @param tokenStrForm
-   * @return user name
-   * @throws IOException
-   */
-  public synchronized String verifyDelegationToken(String tokenStrForm) throws IOException {
-    Token<DelegationTokenIdentifier> t = new Token<>();
-    t.decodeFromUrlString(tokenStrForm);
-
-    DelegationTokenIdentifier id = getTokenIdentifier(t);
-    verifyToken(id, t.getPassword());
-    return id.getUser().getShortUserName();
-  }
-
-  protected DelegationTokenIdentifier getTokenIdentifier(Token<DelegationTokenIdentifier> token)
-      throws IOException {
-    // turn bytes back into identifier for cache lookup
-    ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier());
-    DataInputStream in = new DataInputStream(buf);
-    DelegationTokenIdentifier id = createIdentifier();
-    id.readFields(in);
-    return id;
-  }
-
-  public synchronized void cancelDelegationToken(String tokenStrForm) throws IOException {
-    Token<DelegationTokenIdentifier> t= new Token<>();
-    t.decodeFromUrlString(tokenStrForm);
-    String user = UserGroupInformation.getCurrentUser().getUserName();
-    cancelToken(t, user);
-  }
-
-  public synchronized long renewDelegationToken(String tokenStrForm) throws IOException {
-    Token<DelegationTokenIdentifier> t= new Token<>();
-    t.decodeFromUrlString(tokenStrForm);
-    //when a token is created the renewer of the token is stored
-    //as shortName in AbstractDelegationTokenIdentifier.setRenewer()
-    //this seems like an inconsistency because while cancelling the token
-    //it uses the shortname to compare the renewer while it does not use
-    //shortname during token renewal. Use getShortUserName() until its fixed
-    //in HADOOP-15068
-    String user = UserGroupInformation.getCurrentUser().getShortUserName();
-    return renewToken(t, user);
-  }
-
-  public synchronized String getDelegationToken(final String ownerStr, final String renewer) throws IOException {
-    if (ownerStr == null) {
-      throw new RuntimeException("Delegation token owner is null");
-    }
-    Text owner = new Text(ownerStr);
-    Text realUser = null;
-    UserGroupInformation currentUgi = UserGroupInformation.getCurrentUser();
-    if (currentUgi.getUserName() != null) {
-      realUser = new Text(currentUgi.getUserName());
-    }
-    DelegationTokenIdentifier ident =
-      new DelegationTokenIdentifier(owner, new Text(renewer), realUser);
-    Token<DelegationTokenIdentifier> t = new Token<>(
-        ident, this);
-    return t.encodeToUrlString();
-  }
-
-  public String getUserFromToken(String tokenStr) throws IOException {
-    Token<DelegationTokenIdentifier> delegationToken = new Token<>();
-    delegationToken.decodeFromUrlString(tokenStr);
-
-    ByteArrayInputStream buf = new ByteArrayInputStream(delegationToken.getIdentifier());
-    DataInputStream in = new DataInputStream(buf);
-    DelegationTokenIdentifier id = createIdentifier();
-    id.readFields(in);
-    return id.getUser().getShortUserName();
-  }
-}
-