public interface ThriftHiveMetastore extends Closeable
{
    void create_database(Database database) throws AlreadyExistsException, InvalidObjectException, MetaException, TException;

    Database get_database(String name) throws NoSuchObjectException, MetaException, TException;

    void drop_database(String name, boolean deleteData, boolean cascade) throws NoSuchObjectException, InvalidOperationException, MetaException, TException;

    List<String> get_databases(String pattern) throws MetaException, TException;

    List<String> get_all_databases() throws MetaException, TException;

    void alter_database(String dbname, Database db) throws MetaException, NoSuchObjectException, TException;

    Type get_type(String name) throws MetaException, NoSuchObjectException, TException;

    boolean create_type(Type type) throws AlreadyExistsException, InvalidObjectException, MetaException, TException;

    boolean drop_type(String type) throws MetaException, NoSuchObjectException, TException;

    Map<String, Type> get_type_all(String name) throws MetaException, TException;

    List<FieldSchema> get_fields(String db_name, String table_name) throws MetaException, UnknownTableException, UnknownDBException, TException;

    List<FieldSchema> get_schema(String db_name, String table_name) throws MetaException, UnknownTableException, UnknownDBException, TException;

    void create_table(Table tbl) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException;

    void create_table_with_environment_context(Table tbl, EnvironmentContext environment_context) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException;

    void create_table_link(String dbName, String targetDbName, String targetTableName, String owner, boolean isStatic, Map<String, String> linkProperties) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException,
        InvalidTableLinkDescriptionException, TException;

    void drop_table(String dbname, String name, boolean deleteData) throws NoSuchObjectException, MetaException, TException;

    void drop_table_link(String dbName, String targetDbName, String targetTableName) throws NoSuchObjectException, MetaException, TException;

    void drop_table_with_environment_context(String dbname, String name, boolean deleteData, EnvironmentContext environment_context) throws NoSuchObjectException, MetaException, TException;

    List<String> get_tables(String db_name, String pattern) throws MetaException, TException;

    List<String> get_all_tables(String db_name) throws MetaException, TException;

    Table get_table(String dbname, String tbl_name) throws MetaException, NoSuchObjectException, TException;

    boolean exists_table(String dbname, String tbl_name) throws MetaException, TException;

    Table get_table_link(String dbName, String targetDbName, String targetTableName) throws MetaException, NoSuchObjectException, TException;

    List<Table> get_table_objects_by_name(String dbname, List<String> tbl_names) throws MetaException, InvalidOperationException, UnknownDBException, TException;

    List<String> get_table_names_by_filter(String dbname, String filter, short max_tables) throws MetaException, InvalidOperationException, UnknownDBException, TException;

    void alter_table(String dbname, String tbl_name, Table new_tbl) throws InvalidOperationException, MetaException, TException;

    void alter_table_with_environment_context(String dbname, String tbl_name, Table new_tbl, EnvironmentContext environment_context) throws InvalidOperationException, MetaException, TException;

    void alter_table_link(String dbName, String targetDbName, String targetTableName, Table new_tbl) throws InvalidOperationException, MetaException, TException;

    void alter_table_link_properties(String dbName, String targetDbName, String targetTableName, Map<String, String> updatedProperties) throws InvalidOperationException, MetaException, NoSuchObjectException, TException;

    Partition add_partition(Partition new_part) throws InvalidObjectException, AlreadyExistsException, MetaException, TException;

    Partition add_partition_with_environment_context(Partition new_part, EnvironmentContext environment_context) throws InvalidObjectException, AlreadyExistsException, MetaException, TException;

    Partition add_table_link_partition(String dbName, String targetDbName, String targetTableName, String partitionName) throws InvalidObjectException, AlreadyExistsException, NoSuchObjectException, MetaException, TException;

    int add_partitions(List<Partition> new_parts) throws InvalidObjectException, AlreadyExistsException, MetaException, TException;

    Partition append_partition(String db_name, String tbl_name, List<String> part_vals) throws InvalidObjectException, AlreadyExistsException, MetaException, TException;

    Partition append_partition_with_environment_context(String db_name, String tbl_name, List<String> part_vals, EnvironmentContext environment_context) throws InvalidObjectException, AlreadyExistsException, MetaException,
        TException;

    Partition append_partition_by_name(String db_name, String tbl_name, String part_name) throws InvalidObjectException, AlreadyExistsException, MetaException, TException;

    Partition append_partition_by_name_with_environment_context(String db_name, String tbl_name, String part_name, EnvironmentContext environment_context) throws InvalidObjectException, AlreadyExistsException, MetaException,
        TException;

    boolean drop_partition(String db_name, String tbl_name, List<String> part_vals, boolean deleteData) throws NoSuchObjectException, MetaException, TException;

    boolean drop_partition_with_environment_context(String db_name, String tbl_name, List<String> part_vals, boolean deleteData, EnvironmentContext environment_context) throws NoSuchObjectException, MetaException, TException;

    boolean drop_partition_by_name(String db_name, String tbl_name, String part_name, boolean deleteData) throws NoSuchObjectException, MetaException, TException;

    boolean drop_partition_by_name_with_environment_context(String db_name, String tbl_name, String part_name, boolean deleteData, EnvironmentContext environment_context) throws NoSuchObjectException, MetaException, TException;

    boolean drop_table_link_partition(String dbName, String targetDbName, String targetTableName, String partitionName) throws NoSuchObjectException, MetaException, TException;

    Partition get_partition_template(String db_name, String tbl_name, List<String> part_vals) throws InvalidObjectException, MetaException, TException;

    Partition get_partition(String db_name, String tbl_name, List<String> part_vals) throws MetaException, NoSuchObjectException, TException;

    List<Partition> exchange_partition(Map<String, String> partitionSpecs, String source_db, String source_table_name, String dest_db, String dest_table_name, boolean overwrite) throws MetaException, NoSuchObjectException, InvalidObjectException,
        InvalidInputException, AlreadyExistsException, TException;

    Partition get_partition_with_auth(String db_name, String tbl_name, List<String> part_vals, String user_name, List<String> group_names) throws MetaException, NoSuchObjectException, TException;

    Partition get_partition_by_name(String db_name, String tbl_name, String part_name) throws MetaException, NoSuchObjectException, TException;

    List<Partition> get_partitions(String db_name, String tbl_name, short max_parts) throws NoSuchObjectException, MetaException, TException;

    List<Partition> get_partitions_with_auth(String db_name, String tbl_name, short max_parts, String user_name, List<String> group_names) throws NoSuchObjectException, MetaException, TException;

    List<String> get_partition_names(String db_name, String tbl_name, short max_parts) throws MetaException, TException;

    int get_total_partitions(String db_name, String tbl_name) throws MetaException, TException;

    List<Partition> get_partitions_ps(String db_name, String tbl_name, List<String> part_vals, short max_parts) throws MetaException, NoSuchObjectException, TException;

    List<Partition> get_partitions_ps_with_auth(String db_name, String tbl_name, List<String> part_vals, short max_parts, String user_name, List<String> group_names) throws NoSuchObjectException, MetaException, TException;

    List<String> get_partition_names_ps(String db_name, String tbl_name, List<String> part_vals, short max_parts) throws MetaException, NoSuchObjectException, TException;

    List<Partition> get_partitions_by_filter(String db_name, String tbl_name, String filter, short max_parts) throws MetaException, NoSuchObjectException, TException;

    List<Partition> get_partitions_by_names(String db_name, String tbl_name, List<String> names) throws MetaException, NoSuchObjectException, TException;

    void alter_partition(String db_name, String tbl_name, Partition new_part) throws InvalidOperationException, MetaException, TException;

    void alter_partitions(String db_name, String tbl_name, List<Partition> new_parts) throws InvalidOperationException, MetaException, TException;

    void alter_partition_with_environment_context(String db_name, String tbl_name, Partition new_part, EnvironmentContext environment_context) throws InvalidOperationException, MetaException, TException;

    void rename_partition(String db_name, String tbl_name, List<String> part_vals, Partition new_part) throws InvalidOperationException, MetaException, TException;

    boolean partition_name_has_valid_characters(List<String> part_vals, boolean throw_exception) throws MetaException, TException;

    String get_config_value(String name, String defaultValue) throws ConfigValSecurityException, TException;

    List<String> partition_name_to_vals(String part_name) throws MetaException, TException;

    Map<String, String> partition_name_to_spec(String part_name) throws MetaException, TException;

    void markPartitionForEvent(String db_name, String tbl_name, Map<String, String> part_vals, PartitionEventType eventType) throws MetaException, NoSuchObjectException, UnknownDBException, UnknownTableException, UnknownPartitionException,
        InvalidPartitionException, TException;

    boolean isPartitionMarkedForEvent(String db_name, String tbl_name, Map<String, String> part_vals, PartitionEventType eventType) throws MetaException, NoSuchObjectException, UnknownDBException, UnknownTableException, UnknownPartitionException,
        InvalidPartitionException, TException;

    Index add_index(Index new_index, Table index_table) throws InvalidObjectException, AlreadyExistsException, MetaException, TException;

    void alter_index(String dbname, String base_tbl_name, String idx_name, Index new_idx) throws InvalidOperationException, MetaException, TException;

    boolean drop_index_by_name(String db_name, String tbl_name, String index_name, boolean deleteData) throws NoSuchObjectException, MetaException, TException;

    Index get_index_by_name(String db_name, String tbl_name, String index_name) throws MetaException, NoSuchObjectException, TException;

    List<Index> get_indexes(String db_name, String tbl_name, short max_indexes) throws NoSuchObjectException, MetaException, TException;

    List<String> get_index_names(String db_name, String tbl_name, short max_indexes) throws MetaException, TException;

    boolean update_table_column_statistics(ColumnStatistics stats_obj) throws NoSuchObjectException,
        InvalidObjectException, MetaException, InvalidInputException, TException;

    boolean update_partition_column_statistics(ColumnStatistics stats_obj) throws NoSuchObjectException,
        InvalidObjectException, MetaException, InvalidInputException, TException;

    ColumnStatistics get_table_column_statistics(String db_name, String tbl_name, String col_name) throws
        NoSuchObjectException, MetaException, InvalidInputException, InvalidObjectException, TException;

    ColumnStatistics get_partition_column_statistics(String db_name, String tbl_name, String part_name, String col_name)
        throws NoSuchObjectException, MetaException, InvalidInputException, InvalidObjectException, TException;

    boolean delete_partition_column_statistics(String db_name, String tbl_name, String part_name, String col_name) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException, TException;

    boolean delete_table_column_statistics(String db_name, String tbl_name, String col_name) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException, TException;

    boolean create_role(Role role) throws MetaException, TException;

    boolean drop_role(String role_name) throws MetaException, TException;

    List<String> get_role_names() throws MetaException, TException;

    boolean grant_role(String role_name, String principal_name, PrincipalType principal_type, String grantor, PrincipalType grantorType, boolean grant_option) throws MetaException, TException;

    boolean revoke_role(String role_name, String principal_name, PrincipalType principal_type) throws MetaException, TException;

    List<Role> list_roles(String principal_name, PrincipalType principal_type) throws MetaException, TException;

    PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, String user_name, List<String> group_names) throws MetaException, TException;

    List<HiveObjectPrivilege> list_privileges(String principal_name, PrincipalType principal_type, HiveObjectRef hiveObject) throws MetaException, TException;

    boolean grant_privileges(PrivilegeBag privileges) throws MetaException, TException;

    boolean revoke_privileges(PrivilegeBag privileges) throws MetaException, TException;

    List<String> set_ugi(String user_name, List<String> group_names) throws MetaException, TException;

    String get_delegation_token(String token_owner, String renewer_kerberos_principal_name) throws MetaException, TException;

    long renew_delegation_token(String token_str_form) throws MetaException, TException;

    void cancel_delegation_token(String token_str_form) throws MetaException, TException;

    public static class Client implements ThriftHiveMetastore
    {
        public static Client forHiveMetastore(final HiveMetastore hiveMetastore)
        {
            return new Client(hiveMetastore);
        }

        private final HiveMetastore delegate;

        public Client(final HiveMetastore delegate)
        {
            this.delegate = checkNotNull(delegate, "delegate is null");
        }

        @Override
        public void close()
        {
            delegate.close();
        }

        @Override
        public void create_database(Database database) throws AlreadyExistsException, InvalidObjectException, MetaException, TException
        {
            delegate.createDatabase(database);
        }

        @Override
        public Database get_database(String name) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.getDatabase(name);
        }

        @Override
        public void drop_database(String name, boolean deleteData, boolean cascade) throws NoSuchObjectException, InvalidOperationException, MetaException, TException
        {
            delegate.dropDatabase(name, deleteData, cascade);
        }

        @Override
        public List<String> get_databases(String pattern) throws MetaException, TException
        {
            return delegate.getDatabases(pattern);
        }

        @Override
        public List<String> get_all_databases() throws MetaException, TException
        {
            return delegate.getAllDatabases();
        }

        @Override
        public void alter_database(String dbname, Database db) throws MetaException, NoSuchObjectException, TException
        {
            delegate.alterDatabase(dbname, db);
        }

        @Override
        public Type get_type(String name) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getType(name);
        }

        @Override
        public boolean create_type(Type type) throws AlreadyExistsException, InvalidObjectException, MetaException, TException
        {
            return delegate.createType(type);
        }

        @Override
        public boolean drop_type(String type) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.dropType(type);
        }

        @Override
        public Map<String, Type> get_type_all(String name) throws MetaException, TException
        {
            return delegate.getTypeAll(name);
        }

        @Override
        public List<FieldSchema> get_fields(String db_name, String table_name) throws MetaException, UnknownTableException, UnknownDBException, TException
        {
            return delegate.getFields(db_name, table_name);
        }

        @Override
        public List<FieldSchema> get_schema(String db_name, String table_name) throws MetaException, UnknownTableException, UnknownDBException, TException
        {
            return delegate.getSchema(db_name, table_name);
        }

        @Override
        public void create_table(Table tbl) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException
        {
            delegate.createTable(tbl);
        }

        @Override
        public void create_table_with_environment_context(Table tbl, EnvironmentContext environment_context) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException
        {
            delegate.createTableWithEnvironmentContext(tbl, environment_context);
        }

        @Override
        public void create_table_link(String dbName, String targetDbName, String targetTableName, String owner, boolean isStatic, Map<String, String> linkProperties) throws AlreadyExistsException, InvalidObjectException, MetaException,
            NoSuchObjectException, InvalidTableLinkDescriptionException, TException
        {
            delegate.createTableLink(dbName, targetDbName, targetTableName, owner, isStatic, linkProperties);
        }

        @Override
        public void drop_table(String dbname, String name, boolean deleteData) throws NoSuchObjectException, MetaException, TException
        {
            delegate.dropTable(dbname, name, deleteData);
        }

        @Override
        public void drop_table_link(String dbName, String targetDbName, String targetTableName) throws NoSuchObjectException, MetaException, TException
        {
            delegate.dropTableLink(dbName, targetDbName, targetTableName);
        }

        @Override
        public void drop_table_with_environment_context(String dbname, String name, boolean deleteData, EnvironmentContext environment_context) throws NoSuchObjectException, MetaException, TException
        {
            delegate.dropTableWithEnvironmentContext(dbname, name, deleteData, environment_context);
        }

        @Override
        public List<String> get_tables(String db_name, String pattern) throws MetaException, TException
        {
            return delegate.getTables(db_name, pattern);
        }

        @Override
        public List<String> get_all_tables(String db_name) throws MetaException, TException
        {
            return delegate.getAllTables(db_name);
        }

        @Override
        public Table get_table(String dbname, String tbl_name) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getTable(dbname, tbl_name);
        }

        @Override
        public boolean exists_table(String dbname, String tbl_name) throws MetaException, TException
        {
            return delegate.existsTable(dbname, tbl_name);
        }

        @Override
        public Table get_table_link(String dbName, String targetDbName, String targetTableName) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getTableLink(dbName, targetDbName, targetTableName);
        }

        @Override
        public List<Table> get_table_objects_by_name(String dbname, List<String> tbl_names) throws MetaException, InvalidOperationException, UnknownDBException, TException
        {
            return delegate.getTableObjectsByName(dbname, tbl_names);
        }

        @Override
        public List<String> get_table_names_by_filter(String dbname, String filter, short max_tables) throws MetaException, InvalidOperationException, UnknownDBException, TException
        {
            return delegate.getTableNamesByFilter(dbname, filter, max_tables);
        }

        @Override
        public void alter_table(String dbname, String tbl_name, Table new_tbl) throws InvalidOperationException, MetaException, TException
        {
            delegate.alterTable(dbname, tbl_name, new_tbl);
        }

        @Override
        public void alter_table_with_environment_context(String dbname, String tbl_name, Table new_tbl, EnvironmentContext environment_context) throws InvalidOperationException, MetaException, TException
        {
            delegate.alterTableWithEnvironmentContext(dbname, tbl_name, new_tbl, environment_context);
        }

        @Override
        public void alter_table_link(String dbName, String targetDbName, String targetTableName, Table new_tbl) throws InvalidOperationException, MetaException, TException
        {
            delegate.alterTableLink(dbName, targetDbName, targetTableName, new_tbl);
        }

        @Override
        public void alter_table_link_properties(String dbName, String targetDbName, String targetTableName, Map<String, String> updatedProperties) throws InvalidOperationException, MetaException, NoSuchObjectException, TException
        {
            delegate.alterTableLinkProperties(dbName, targetDbName, targetTableName, updatedProperties);
        }

        @Override
        public Partition add_partition(Partition new_part) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.addPartition(new_part);
        }

        @Override
        public Partition add_partition_with_environment_context(Partition new_part, EnvironmentContext environment_context) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.addPartitionWithEnvironmentContext(new_part, environment_context);
        }

        @Override
        public Partition add_table_link_partition(String dbName, String targetDbName, String targetTableName, String partitionName) throws InvalidObjectException, AlreadyExistsException, NoSuchObjectException, MetaException, TException
        {
            return delegate.addTableLinkPartition(dbName, targetDbName, targetTableName, partitionName);
        }

        @Override
        public int add_partitions(List<Partition> new_parts) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.addPartitions(new_parts);
        }

        @Override
        public Partition append_partition(String db_name, String tbl_name, List<String> part_vals) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.appendPartition(db_name, tbl_name, part_vals);
        }

        @Override
        public Partition append_partition_with_environment_context(String db_name, String tbl_name, List<String> part_vals, EnvironmentContext environment_context) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.appendPartitionWithEnvironmentContext(db_name, tbl_name, part_vals, environment_context);
        }

        @Override
        public Partition append_partition_by_name(String db_name, String tbl_name, String part_name) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.appendPartitionByName(db_name, tbl_name, part_name);
        }

        @Override
        public Partition append_partition_by_name_with_environment_context(String db_name, String tbl_name, String part_name, EnvironmentContext environment_context) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.appendPartitionByNameWithEnvironmentContext(db_name, tbl_name, part_name, environment_context);
        }

        @Override
        public boolean drop_partition(String db_name, String tbl_name, List<String> part_vals, boolean deleteData) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.dropPartition(db_name, tbl_name, part_vals, deleteData);
        }

        @Override
        public boolean drop_partition_with_environment_context(String db_name, String tbl_name, List<String> part_vals, boolean deleteData, EnvironmentContext environment_context) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.dropPartitionWithEnvironmentContext(db_name, tbl_name, part_vals, deleteData, environment_context);
        }

        @Override
        public boolean drop_partition_by_name(String db_name, String tbl_name, String part_name, boolean deleteData) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.dropPartitionByName(db_name, tbl_name, part_name, deleteData);
        }

        @Override
        public boolean drop_partition_by_name_with_environment_context(String db_name, String tbl_name, String part_name, boolean deleteData, EnvironmentContext environment_context) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.dropPartitionByNameWithEnvironmentContext(db_name, tbl_name, part_name, deleteData, environment_context);
        }

        @Override
        public boolean drop_table_link_partition(String dbName, String targetDbName, String targetTableName, String partitionName) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.dropTableLinkPartition(dbName, targetDbName, targetTableName, partitionName);
        }

        @Override
        public Partition get_partition_template(String db_name, String tbl_name, List<String> part_vals) throws InvalidObjectException, MetaException, TException
        {
            return delegate.getPartitionTemplate(db_name, tbl_name, part_vals);
        }

        @Override
        public Partition get_partition(String db_name, String tbl_name, List<String> part_vals) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getPartition(db_name, tbl_name, part_vals);
        }

        @Override
        public List<Partition> exchange_partition(Map<String, String> partitionSpecs, String source_db, String source_table_name, String dest_db, String dest_table_name, boolean overwrite) throws MetaException, NoSuchObjectException,
            InvalidObjectException, InvalidInputException, AlreadyExistsException, TException
        {
            return delegate.exchangePartition(partitionSpecs, source_db, source_table_name, dest_db, dest_table_name, overwrite);
        }

        @Override
        public Partition get_partition_with_auth(String db_name, String tbl_name, List<String> part_vals, String user_name, List<String> group_names) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getPartitionWithAuth(db_name, tbl_name, part_vals, user_name, group_names);
        }

        @Override
        public Partition get_partition_by_name(String db_name, String tbl_name, String part_name) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getPartitionByName(db_name, tbl_name, part_name);
        }

        @Override
        public List<Partition> get_partitions(String db_name, String tbl_name, short max_parts) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.getPartitions(db_name, tbl_name, max_parts);
        }

        @Override
        public List<Partition> get_partitions_with_auth(String db_name, String tbl_name, short max_parts, String user_name, List<String> group_names) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.getPartitionsWithAuth(db_name, tbl_name, max_parts, user_name, group_names);
        }

        @Override
        public List<String> get_partition_names(String db_name, String tbl_name, short max_parts) throws MetaException, TException
        {
            return delegate.getPartitionNames(db_name, tbl_name, max_parts);
        }

        @Override
        public int get_total_partitions(String db_name, String tbl_name) throws MetaException, TException
        {
            return delegate.getTotalPartitions(db_name, tbl_name);
        }

        @Override
        public List<Partition> get_partitions_ps(String db_name, String tbl_name, List<String> part_vals, short max_parts) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getPartitionsPs(db_name, tbl_name, part_vals, max_parts);
        }

        @Override
        public List<Partition> get_partitions_ps_with_auth(String db_name, String tbl_name, List<String> part_vals, short max_parts, String user_name, List<String> group_names) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.getPartitionsPsWithAuth(db_name, tbl_name, part_vals, max_parts, user_name, group_names);
        }

        @Override
        public List<String> get_partition_names_ps(String db_name, String tbl_name, List<String> part_vals, short max_parts) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getPartitionNamesPs(db_name, tbl_name, part_vals, max_parts);
        }

        @Override
        public List<Partition> get_partitions_by_filter(String db_name, String tbl_name, String filter, short max_parts) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getPartitionsByFilter(db_name, tbl_name, filter, max_parts);
        }

        @Override
        public List<Partition> get_partitions_by_names(String db_name, String tbl_name, List<String> names) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getPartitionsByNames(db_name, tbl_name, names);
        }

        @Override
        public void alter_partition(String db_name, String tbl_name, Partition new_part) throws InvalidOperationException, MetaException, TException
        {
            delegate.alterPartition(db_name, tbl_name, new_part);
        }

        @Override
        public void alter_partitions(String db_name, String tbl_name, List<Partition> new_parts) throws InvalidOperationException, MetaException, TException
        {
            delegate.alterPartitions(db_name, tbl_name, new_parts);
        }

        @Override
        public void alter_partition_with_environment_context(String db_name, String tbl_name, Partition new_part, EnvironmentContext environment_context) throws InvalidOperationException, MetaException, TException
        {
            delegate.alterPartitionWithEnvironmentContext(db_name, tbl_name, new_part, environment_context);
        }

        @Override
        public void rename_partition(String db_name, String tbl_name, List<String> part_vals, Partition new_part) throws InvalidOperationException, MetaException, TException
        {
            delegate.renamePartition(db_name, tbl_name, part_vals, new_part);
        }

        @Override
        public boolean partition_name_has_valid_characters(List<String> part_vals, boolean throw_exception) throws MetaException, TException
        {
            return delegate.partitionNameHasValidCharacters(part_vals, throw_exception);
        }

        @Override
        public String get_config_value(String name, String defaultValue) throws ConfigValSecurityException, TException
        {
            return delegate.getConfigValue(name, defaultValue);
        }

        @Override
        public List<String> partition_name_to_vals(String part_name) throws MetaException, TException
        {
            return delegate.partitionNameToVals(part_name);
        }

        @Override
        public Map<String, String> partition_name_to_spec(String part_name) throws MetaException, TException
        {
            return delegate.partitionNameToSpec(part_name);
        }

        @Override
        public void markPartitionForEvent(String db_name, String tbl_name, Map<String, String> part_vals, PartitionEventType eventType) throws MetaException, NoSuchObjectException, UnknownDBException, UnknownTableException, UnknownPartitionException,
            InvalidPartitionException, TException
        {
            delegate.markPartitionForEvent(db_name, tbl_name, part_vals, eventType);
        }

        @Override
        public boolean isPartitionMarkedForEvent(String db_name, String tbl_name, Map<String, String> part_vals, PartitionEventType eventType) throws MetaException, NoSuchObjectException, UnknownDBException, UnknownTableException,
            UnknownPartitionException, InvalidPartitionException, TException
        {
            return delegate.isPartitionMarkedForEvent(db_name, tbl_name, part_vals, eventType);
        }

        @Override
        public Index add_index(Index new_index, Table index_table) throws InvalidObjectException, AlreadyExistsException, MetaException, TException
        {
            return delegate.addIndex(new_index, index_table);
        }

        @Override
        public void alter_index(String dbname, String base_tbl_name, String idx_name, Index new_idx) throws InvalidOperationException, MetaException, TException
        {
            delegate.alterIndex(dbname, base_tbl_name, idx_name, new_idx);
        }

        @Override
        public boolean drop_index_by_name(String db_name, String tbl_name, String index_name, boolean deleteData) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.dropIndexByName(db_name, tbl_name, index_name, deleteData);
        }

        @Override
        public Index get_index_by_name(String db_name, String tbl_name, String index_name) throws MetaException, NoSuchObjectException, TException
        {
            return delegate.getIndexByName(db_name, tbl_name, index_name);
        }

        @Override
        public List<Index> get_indexes(String db_name, String tbl_name, short max_indexes) throws NoSuchObjectException, MetaException, TException
        {
            return delegate.getIndexes(db_name, tbl_name, max_indexes);
        }

        @Override
        public List<String> get_index_names(String db_name, String tbl_name, short max_indexes) throws MetaException, TException
        {
            return delegate.getIndexNames(db_name, tbl_name, max_indexes);
        }

        @Override
        public boolean update_table_column_statistics(ColumnStatistics stats_obj) throws NoSuchObjectException, InvalidObjectException, MetaException, InvalidInputException, TException
        {
            return delegate.updateTableColumnStatistics(stats_obj);
        }

        @Override
        public boolean update_partition_column_statistics(ColumnStatistics stats_obj) throws NoSuchObjectException, InvalidObjectException, MetaException, InvalidInputException, TException
        {
            return delegate.updatePartitionColumnStatistics(stats_obj);
        }

        @Override
        public ColumnStatistics get_table_column_statistics(String db_name, String tbl_name, String col_name) throws NoSuchObjectException, MetaException, InvalidInputException, InvalidObjectException, TException
        {
            return delegate.getTableColumnStatistics(db_name, tbl_name, col_name);
        }

        @Override
        public ColumnStatistics get_partition_column_statistics(String db_name, String tbl_name, String part_name, String col_name) throws NoSuchObjectException, MetaException, InvalidInputException, InvalidObjectException, TException
        {
            return delegate.getPartitionColumnStatistics(db_name, tbl_name, part_name, col_name);
        }

        @Override
        public boolean delete_partition_column_statistics(String db_name, String tbl_name, String part_name, String col_name) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException, TException
        {
            return delegate.deletePartitionColumnStatistics(db_name, tbl_name, part_name, col_name);
        }

        @Override
        public boolean delete_table_column_statistics(String db_name, String tbl_name, String col_name) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException, TException
        {
            return delegate.deleteTableColumnStatistics(db_name, tbl_name, col_name);
        }

        @Override
        public boolean create_role(Role role) throws MetaException, TException
        {
            return delegate.createRole(role);
        }

        @Override
        public boolean drop_role(String role_name) throws MetaException, TException
        {
            return delegate.dropRole(role_name);
        }

        @Override
        public List<String> get_role_names() throws MetaException, TException
        {
            return delegate.getRoleNames();
        }

        @Override
        public boolean grant_role(String role_name, String principal_name, PrincipalType principal_type, String grantor, PrincipalType grantorType, boolean grant_option) throws MetaException, TException
        {
            return delegate.grantRole(role_name, principal_name, principal_type, grantor, grantorType, grant_option);
        }

        @Override
        public boolean revoke_role(String role_name, String principal_name, PrincipalType principal_type) throws MetaException, TException
        {
            return delegate.revokeRole(role_name, principal_name, principal_type);
        }

        @Override
        public List<Role> list_roles(String principal_name, PrincipalType principal_type) throws MetaException, TException
        {
            return delegate.listRoles(principal_name, principal_type);
        }

        @Override
        public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, String user_name, List<String> group_names) throws MetaException, TException
        {
            return delegate.getPrivilegeSet(hiveObject, user_name, group_names);
        }

        @Override
        public List<HiveObjectPrivilege> list_privileges(String principal_name, PrincipalType principal_type, HiveObjectRef hiveObject) throws MetaException, TException
        {
            return delegate.listPrivileges(principal_name, principal_type, hiveObject);
        }

        @Override
        public boolean grant_privileges(PrivilegeBag privileges) throws MetaException, TException
        {
            return delegate.grantPrivileges(privileges);
        }

        @Override
        public boolean revoke_privileges(PrivilegeBag privileges) throws MetaException, TException
        {
            return delegate.revokePrivileges(privileges);
        }

        @Override
        public List<String> set_ugi(String user_name, List<String> group_names) throws MetaException, TException
        {
            return delegate.setUgi(user_name, group_names);
        }

        @Override
        public String get_delegation_token(String token_owner, String renewer_kerberos_principal_name) throws MetaException, TException
        {
            return delegate.getDelegationToken(token_owner, renewer_kerberos_principal_name);
        }

        @Override
        public long renew_delegation_token(String token_str_form) throws MetaException, TException
        {
            return delegate.renewDelegationToken(token_str_form);
        }

        @Override
        public void cancel_delegation_token(String token_str_form) throws MetaException, TException
        {
            delegate.cancelDelegationToken(token_str_form);
        }
    }
} public class HiveMetastoreClientConfig
{
    private String host = "localhost";
    private int port = 9083;
    private boolean framed = false;
    private int maxRetries = 0;
    private Duration retryTimeout = new Duration (1, TimeUnit.MINUTES);
    private Duration retrySleep = new Duration (10, TimeUnit.SECONDS);

    @NotNull
    public String getHost()
    {
        return host;
    }

    @Config("hive-metastore.host")
    public HiveMetastoreClientConfig setHost(final String host)
    {
        this.host = host;
        return this;
    }

    @Min(1)
    @Max(65535)
    public int getPort()
    {
        return port;
    }

    @Config("hive-metastore.port")
    public HiveMetastoreClientConfig setPort(final int port)
    {
        this.port = port;
        return this;
    }

    public boolean isFramed()
    {
        return framed;
    }

    @Config("hive-metastore.framed")
    public HiveMetastoreClientConfig setFramed(final boolean framed)
    {
        this.framed = framed;
        return this;
    }

    public HostAndPort getHostAndPort()
    {
        return HostAndPort.fromParts(host, port);
    }

    @Min(0)
    public int getMaxRetries()
    {
        return maxRetries;
    }

    @Config("hive-metastore.max-retries")
    public HiveMetastoreClientConfig setMaxRetries(final int maxRetries)
    {
        this.maxRetries = maxRetries;
        return this;
    }

    @MinDuration("1ms")
    public Duration getRetryTimeout()
    {
        return retryTimeout;
    }

    @Config("hive-metastore.retry-timeout")
    public HiveMetastoreClientConfig setRetryTimeout(final Duration retryTimeout)
    {
        this.retryTimeout = retryTimeout;
        return this;
    }

    @MinDuration("1ms")
    public Duration getRetrySleep()
    {
        return retrySleep;
    }

    @Config("hive-metastore.retry-sleep")
    public HiveMetastoreClientConfig setRetrySleep(final Duration retrySleep)
    {
        this.retrySleep = retrySleep;
        return this;
    }

} public interface HiveMetastoreFactory
    extends HiveMetastoreProvider<HiveMetastore>
{
    /**
     * Returns a client connected to the store using the default configuration settings.
     */
    HiveMetastore getDefaultClient();

    /**
     * Return a client connected to the store described in the supplied {@link HostAndPort} element. All
     * additional settings are taken from the default configuration settings.
     */
    HiveMetastore getClientForHost(HostAndPort hostAndPort);

    /**
     * Return a client connected to the store described in the {@link HiveMetastoreClientConfig} object.
     */
    HiveMetastore getClientForHost(HiveMetastoreClientConfig config);

    /**
     * Return a client connected to one of the stores described in the supplied set of {@link HostAndPort} elements.
     * All additional settings are taken from the default configuration settings. When retrying, another store is used.
     */
    HiveMetastore getClientForHost(Set<HostAndPort> hostAndPorts);

    /**
     * Return a client connected to one of the stores described in the supplied set of {@link HostAndPort} elements.
     * All additional settings are taken from the configuration supplied. When retrying, another store is used.
     */
    HiveMetastore getClientForHost(Set<HostAndPort> hostAndPorts, HiveMetastoreClientConfig config);
} public final class SimpleHiveMetastoreFactory
    extends GuiceHiveMetastoreFactory
{
    public SimpleHiveMetastoreFactory(final ThriftClientManager thriftClientManager,
                                      final ThriftClientConfig thriftClientConfig,
                                      final HiveMetastoreClientConfig hiveMetastoreClientConfig)
    {
        super(hiveMetastoreClientConfig,
              new ThriftClient<>(checkNotNull(thriftClientManager, "thiftClientManager is null"),
                                 HiveMetastore.class,
                                 checkNotNull(thriftClientConfig, "thriftClientConfig is null"),
                                 "hive-metastore"));
    }
} @ThriftStruct("AlreadyExistsException")
public class AlreadyExistsException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public AlreadyExistsException(
                                  @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public AlreadyExistsException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("ColumnStatistics")
public class ColumnStatistics
{
    @ThriftConstructor
    public ColumnStatistics(
                            @ThriftField(value = 1, name = "statsDesc") final ColumnStatisticsDesc statsDesc,
                            @ThriftField(value = 2, name = "statsObj") final List<ColumnStatisticsObj> statsObj)
    {
        this.statsDesc = statsDesc;
        this.statsObj = statsObj;
    }

    public ColumnStatistics()
    {
    }

    private ColumnStatisticsDesc statsDesc;

    @ThriftField(value = 1, name = "statsDesc")
    public ColumnStatisticsDesc getStatsDesc()
    {
        return statsDesc;
    }

    public void setStatsDesc(final ColumnStatisticsDesc statsDesc)
    {
        this.statsDesc = statsDesc;
    }

    private List<ColumnStatisticsObj> statsObj;

    @ThriftField(value = 2, name = "statsObj")
    public List<ColumnStatisticsObj> getStatsObj()
    {
        return statsObj;
    }

    public void setStatsObj(final List<ColumnStatisticsObj> statsObj)
    {
        this.statsObj = statsObj;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("statsDesc", statsDesc)
            .add("statsObj", statsObj)
            .toString();
    }
} @ThriftStruct("ConfigValSecurityException")
public class ConfigValSecurityException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public ConfigValSecurityException(
                                      @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public ConfigValSecurityException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("Database")
public class Database
{
    @ThriftConstructor
    public Database(
                    @ThriftField(value = 1, name = "name") final String name,
                    @ThriftField(value = 2, name = "description") final String description,
                    @ThriftField(value = 3, name = "locationUri") final String locationUri,
                    @ThriftField(value = 4, name = "parameters") final Map<String, String> parameters,
                    @ThriftField(value = 5, name = "privileges") final PrincipalPrivilegeSet privileges)
    {
        this.name = name;
        this.description = description;
        this.locationUri = locationUri;
        this.parameters = parameters;
        this.privileges = privileges;
    }

    public Database()
    {
    }

    private String name;

    @ThriftField(value = 1, name = "name")
    public String getName()
    {
        return name;
    }

    public void setName(final String name)
    {
        this.name = name;
    }

    private String description;

    @ThriftField(value = 2, name = "description")
    public String getDescription()
    {
        return description;
    }

    public void setDescription(final String description)
    {
        this.description = description;
    }

    private String locationUri;

    @ThriftField(value = 3, name = "locationUri")
    public String getLocationUri()
    {
        return locationUri;
    }

    public void setLocationUri(final String locationUri)
    {
        this.locationUri = locationUri;
    }

    private Map<String, String> parameters;

    @ThriftField(value = 4, name = "parameters")
    public Map<String, String> getParameters()
    {
        return parameters;
    }

    public void setParameters(final Map<String, String> parameters)
    {
        this.parameters = parameters;
    }

    private PrincipalPrivilegeSet privileges;

    @ThriftField(value = 5, name = "privileges")
    public PrincipalPrivilegeSet getPrivileges()
    {
        return privileges;
    }

    public void setPrivileges(final PrincipalPrivilegeSet privileges)
    {
        this.privileges = privileges;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("name", name)
            .add("description", description)
            .add("locationUri", locationUri)
            .add("parameters", parameters)
            .add("privileges", privileges)
            .toString();
    }
} @ThriftStruct("EnvironmentContext")
public class EnvironmentContext
{
    @ThriftConstructor
    public EnvironmentContext(
                              @ThriftField(value = 1, name = "properties") final Map<String, String> properties)
    {
        this.properties = properties;
    }

    public EnvironmentContext()
    {
    }

    private Map<String, String> properties;

    @ThriftField(value = 1, name = "properties")
    public Map<String, String> getProperties()
    {
        return properties;
    }

    public void setProperties(final Map<String, String> properties)
    {
        this.properties = properties;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("properties", properties)
            .toString();
    }
} @ThriftStruct("FieldSchema")
public class FieldSchema
{
    @ThriftConstructor
    public FieldSchema(
                       @ThriftField(value = 1, name = "name") final String name,
                       @ThriftField(value = 2, name = "type") final String type,
                       @ThriftField(value = 3, name = "comment") final String comment)
    {
        this.name = name;
        this.type = type;
        this.comment = comment;
    }

    public FieldSchema()
    {
    }

    private String name;

    @ThriftField(value = 1, name = "name")
    public String getName()
    {
        return name;
    }

    public void setName(final String name)
    {
        this.name = name;
    }

    private String type;

    @ThriftField(value = 2, name = "type")
    public String getType()
    {
        return type;
    }

    public void setType(final String type)
    {
        this.type = type;
    }

    private String comment;

    @ThriftField(value = 3, name = "comment")
    public String getComment()
    {
        return comment;
    }

    public void setComment(final String comment)
    {
        this.comment = comment;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("name", name)
            .add("type", type)
            .add("comment", comment)
            .toString();
    }
} @ThriftStruct("HiveObjectPrivilege")
public class HiveObjectPrivilege
{
    @ThriftConstructor
    public HiveObjectPrivilege(
                               @ThriftField(value = 1, name = "hiveObject") final HiveObjectRef hiveObject,
                               @ThriftField(value = 2, name = "principalName") final String principalName,
                               @ThriftField(value = 3, name = "principalType") final PrincipalType principalType,
                               @ThriftField(value = 4, name = "grantInfo") final PrivilegeGrantInfo grantInfo)
    {
        this.hiveObject = hiveObject;
        this.principalName = principalName;
        this.principalType = principalType;
        this.grantInfo = grantInfo;
    }

    public HiveObjectPrivilege()
    {
    }

    private HiveObjectRef hiveObject;

    @ThriftField(value = 1, name = "hiveObject")
    public HiveObjectRef getHiveObject()
    {
        return hiveObject;
    }

    public void setHiveObject(final HiveObjectRef hiveObject)
    {
        this.hiveObject = hiveObject;
    }

    private String principalName;

    @ThriftField(value = 2, name = "principalName")
    public String getPrincipalName()
    {
        return principalName;
    }

    public void setPrincipalName(final String principalName)
    {
        this.principalName = principalName;
    }

    private PrincipalType principalType;

    @ThriftField(value = 3, name = "principalType")
    public PrincipalType getPrincipalType()
    {
        return principalType;
    }

    public void setPrincipalType(final PrincipalType principalType)
    {
        this.principalType = principalType;
    }

    private PrivilegeGrantInfo grantInfo;

    @ThriftField(value = 4, name = "grantInfo")
    public PrivilegeGrantInfo getGrantInfo()
    {
        return grantInfo;
    }

    public void setGrantInfo(final PrivilegeGrantInfo grantInfo)
    {
        this.grantInfo = grantInfo;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("hiveObject", hiveObject)
            .add("principalName", principalName)
            .add("principalType", principalType)
            .add("grantInfo", grantInfo)
            .toString();
    }
} @ThriftStruct("HiveObjectRef")
public class HiveObjectRef
{
    @ThriftConstructor
    public HiveObjectRef(
                         @ThriftField(value = 1, name = "objectType") final HiveObjectType objectType,
                         @ThriftField(value = 2, name = "dbName") final String dbName,
                         @ThriftField(value = 3, name = "objectName") final String objectName,
                         @ThriftField(value = 4, name = "partValues") final List<String> partValues,
                         @ThriftField(value = 5, name = "columnName") final String columnName)
    {
        this.objectType = objectType;
        this.dbName = dbName;
        this.objectName = objectName;
        this.partValues = partValues;
        this.columnName = columnName;
    }

    public HiveObjectRef()
    {
    }

    private HiveObjectType objectType;

    @ThriftField(value = 1, name = "objectType")
    public HiveObjectType getObjectType()
    {
        return objectType;
    }

    public void setObjectType(final HiveObjectType objectType)
    {
        this.objectType = objectType;
    }

    private String dbName;

    @ThriftField(value = 2, name = "dbName")
    public String getDbName()
    {
        return dbName;
    }

    public void setDbName(final String dbName)
    {
        this.dbName = dbName;
    }

    private String objectName;

    @ThriftField(value = 3, name = "objectName")
    public String getObjectName()
    {
        return objectName;
    }

    public void setObjectName(final String objectName)
    {
        this.objectName = objectName;
    }

    private List<String> partValues;

    @ThriftField(value = 4, name = "partValues")
    public List<String> getPartValues()
    {
        return partValues;
    }

    public void setPartValues(final List<String> partValues)
    {
        this.partValues = partValues;
    }

    private String columnName;

    @ThriftField(value = 5, name = "columnName")
    public String getColumnName()
    {
        return columnName;
    }

    public void setColumnName(final String columnName)
    {
        this.columnName = columnName;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("objectType", objectType)
            .add("dbName", dbName)
            .add("objectName", objectName)
            .add("partValues", partValues)
            .add("columnName", columnName)
            .toString();
    }
} @ThriftStruct("Index")
public class Index
{
    @ThriftConstructor
    public Index(
                 @ThriftField(value = 1, name = "indexName") final String indexName,
                 @ThriftField(value = 2, name = "indexHandlerClass") final String indexHandlerClass,
                 @ThriftField(value = 3, name = "dbName") final String dbName,
                 @ThriftField(value = 4, name = "origTableName") final String origTableName,
                 @ThriftField(value = 5, name = "createTime") final int createTime,
                 @ThriftField(value = 6, name = "lastAccessTime") final int lastAccessTime,
                 @ThriftField(value = 7, name = "indexTableName") final String indexTableName,
                 @ThriftField(value = 8, name = "sd") final StorageDescriptor sd,
                 @ThriftField(value = 9, name = "parameters") final Map<String, String> parameters,
                 @ThriftField(value = 10, name = "deferredRebuild") final boolean deferredRebuild)
    {
        this.indexName = indexName;
        this.indexHandlerClass = indexHandlerClass;
        this.dbName = dbName;
        this.origTableName = origTableName;
        this.createTime = createTime;
        this.lastAccessTime = lastAccessTime;
        this.indexTableName = indexTableName;
        this.sd = sd;
        this.parameters = parameters;
        this.deferredRebuild = deferredRebuild;
    }

    public Index()
    {
    }

    private String indexName;

    @ThriftField(value = 1, name = "indexName")
    public String getIndexName()
    {
        return indexName;
    }

    public void setIndexName(final String indexName)
    {
        this.indexName = indexName;
    }

    private String indexHandlerClass;

    @ThriftField(value = 2, name = "indexHandlerClass")
    public String getIndexHandlerClass()
    {
        return indexHandlerClass;
    }

    public void setIndexHandlerClass(final String indexHandlerClass)
    {
        this.indexHandlerClass = indexHandlerClass;
    }

    private String dbName;

    @ThriftField(value = 3, name = "dbName")
    public String getDbName()
    {
        return dbName;
    }

    public void setDbName(final String dbName)
    {
        this.dbName = dbName;
    }

    private String origTableName;

    @ThriftField(value = 4, name = "origTableName")
    public String getOrigTableName()
    {
        return origTableName;
    }

    public void setOrigTableName(final String origTableName)
    {
        this.origTableName = origTableName;
    }

    private int createTime;

    @ThriftField(value = 5, name = "createTime")
    public int getCreateTime()
    {
        return createTime;
    }

    public void setCreateTime(final int createTime)
    {
        this.createTime = createTime;
    }

    private int lastAccessTime;

    @ThriftField(value = 6, name = "lastAccessTime")
    public int getLastAccessTime()
    {
        return lastAccessTime;
    }

    public void setLastAccessTime(final int lastAccessTime)
    {
        this.lastAccessTime = lastAccessTime;
    }

    private String indexTableName;

    @ThriftField(value = 7, name = "indexTableName")
    public String getIndexTableName()
    {
        return indexTableName;
    }

    public void setIndexTableName(final String indexTableName)
    {
        this.indexTableName = indexTableName;
    }

    private StorageDescriptor sd;

    @ThriftField(value = 8, name = "sd")
    public StorageDescriptor getSd()
    {
        return sd;
    }

    public void setSd(final StorageDescriptor sd)
    {
        this.sd = sd;
    }

    private Map<String, String> parameters;

    @ThriftField(value = 9, name = "parameters")
    public Map<String, String> getParameters()
    {
        return parameters;
    }

    public void setParameters(final Map<String, String> parameters)
    {
        this.parameters = parameters;
    }

    private boolean deferredRebuild;

    @ThriftField(value = 10, name = "deferredRebuild")
    public boolean isDeferredRebuild()
    {
        return deferredRebuild;
    }

    public void setDeferredRebuild(final boolean deferredRebuild)
    {
        this.deferredRebuild = deferredRebuild;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("indexName", indexName)
            .add("indexHandlerClass", indexHandlerClass)
            .add("dbName", dbName)
            .add("origTableName", origTableName)
            .add("createTime", createTime)
            .add("lastAccessTime", lastAccessTime)
            .add("indexTableName", indexTableName)
            .add("sd", sd)
            .add("parameters", parameters)
            .add("deferredRebuild", deferredRebuild)
            .toString();
    }
} @ThriftStruct("InvalidInputException")
public class InvalidInputException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public InvalidInputException(
                                 @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public InvalidInputException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("InvalidObjectException")
public class InvalidObjectException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public InvalidObjectException(
                                  @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public InvalidObjectException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("InvalidOperationException")
public class InvalidOperationException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public InvalidOperationException(
                                     @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public InvalidOperationException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("InvalidPartitionException")
public class InvalidPartitionException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public InvalidPartitionException(
                                     @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public InvalidPartitionException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("MetaException")
public class MetaException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public MetaException(@ThriftField(value = 1, name = "message") final String message)
    {
        super(message);
    }

    public MetaException(final Throwable t)
    {
        super(t);
    }

    public MetaException(final String message, final Throwable t)
    {
        super(message, t);
    }

    public MetaException()
    {
    }

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return super.getMessage();
    }
} @ThriftStruct("NoSuchObjectException")
public class NoSuchObjectException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public NoSuchObjectException(
                                 @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public NoSuchObjectException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("Partition")
public class Partition
{
    @ThriftConstructor
    public Partition(
                     @ThriftField(value = 1, name = "values") final List<String> values,
                     @ThriftField(value = 2, name = "dbName") final String dbName,
                     @ThriftField(value = 3, name = "tableName") final String tableName,
                     @ThriftField(value = 4, name = "createTime") final int createTime,
                     @ThriftField(value = 5, name = "lastAccessTime") final int lastAccessTime,
                     @ThriftField(value = 6, name = "sd") final StorageDescriptor sd,
                     @ThriftField(value = 7, name = "parameters") final Map<String, String> parameters,
                     @ThriftField(value = 8, name = "privileges") final PrincipalPrivilegeSet privileges,
                     @ThriftField(value = 9, name = "linkTarget") final PartitionIdentifier linkTarget,
                     @ThriftField(value = 10, name = "linkPartitions") final List<PartitionIdentifier> linkPartitions)
    {
        this.values = values;
        this.dbName = dbName;
        this.tableName = tableName;
        this.createTime = createTime;
        this.lastAccessTime = lastAccessTime;
        this.sd = sd;
        this.parameters = parameters;
        this.privileges = privileges;
        this.linkTarget = linkTarget;
        this.linkPartitions = linkPartitions;
    }

    public Partition()
    {
    }

    private List<String> values;

    @ThriftField(value = 1, name = "values")
    public List<String> getValues()
    {
        return values;
    }

    public void setValues(final List<String> values)
    {
        this.values = values;
    }

    private String dbName;

    @ThriftField(value = 2, name = "dbName")
    public String getDbName()
    {
        return dbName;
    }

    public void setDbName(final String dbName)
    {
        this.dbName = dbName;
    }

    private String tableName;

    @ThriftField(value = 3, name = "tableName")
    public String getTableName()
    {
        return tableName;
    }

    public void setTableName(final String tableName)
    {
        this.tableName = tableName;
    }

    private int createTime;

    @ThriftField(value = 4, name = "createTime")
    public int getCreateTime()
    {
        return createTime;
    }

    public void setCreateTime(final int createTime)
    {
        this.createTime = createTime;
    }

    private int lastAccessTime;

    @ThriftField(value = 5, name = "lastAccessTime")
    public int getLastAccessTime()
    {
        return lastAccessTime;
    }

    public void setLastAccessTime(final int lastAccessTime)
    {
        this.lastAccessTime = lastAccessTime;
    }

    private StorageDescriptor sd;

    @ThriftField(value = 6, name = "sd")
    public StorageDescriptor getSd()
    {
        return sd;
    }

    public void setSd(final StorageDescriptor sd)
    {
        this.sd = sd;
    }

    private Map<String, String> parameters;

    @ThriftField(value = 7, name = "parameters")
    public Map<String, String> getParameters()
    {
        return parameters;
    }

    public void setParameters(final Map<String, String> parameters)
    {
        this.parameters = parameters;
    }

    private PrincipalPrivilegeSet privileges;

    @ThriftField(value = 8, name = "privileges")
    public PrincipalPrivilegeSet getPrivileges()
    {
        return privileges;
    }

    public void setPrivileges(final PrincipalPrivilegeSet privileges)
    {
        this.privileges = privileges;
    }

    private PartitionIdentifier linkTarget;

    @ThriftField(value = 9, name = "linkTarget")
    public PartitionIdentifier getLinkTarget()
    {
        return linkTarget;
    }

    public void setLinkTarget(final PartitionIdentifier linkTarget)
    {
        this.linkTarget = linkTarget;
    }

    private List<PartitionIdentifier> linkPartitions;

    @ThriftField(value = 10, name = "linkPartitions")
    public List<PartitionIdentifier> getLinkPartitions()
    {
        return linkPartitions;
    }

    public void setLinkPartitions(final List<PartitionIdentifier> linkPartitions)
    {
        this.linkPartitions = linkPartitions;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("values", values)
            .add("dbName", dbName)
            .add("tableName", tableName)
            .add("createTime", createTime)
            .add("lastAccessTime", lastAccessTime)
            .add("sd", sd)
            .add("parameters", parameters)
            .add("privileges", privileges)
            .add("linkTarget", linkTarget)
            .add("linkPartitions", linkPartitions)
            .toString();
    }
} public enum PartitionEventType
{
    LOAD__DONE(1);

    private final int value;

    PartitionEventType(final int value)
    {
        this.value = value;
    }

    @ThriftEnumValue
    public int getValue()
    {
        return value;
    }
} @ThriftStruct("PrincipalPrivilegeSet")
public class PrincipalPrivilegeSet
{
    @ThriftConstructor
    public PrincipalPrivilegeSet(
                                 @ThriftField(value = 1, name = "userPrivileges") final Map<String, List<PrivilegeGrantInfo>> userPrivileges,
                                 @ThriftField(value = 2, name = "groupPrivileges") final Map<String, List<PrivilegeGrantInfo>> groupPrivileges,
                                 @ThriftField(value = 3, name = "rolePrivileges") final Map<String, List<PrivilegeGrantInfo>> rolePrivileges)
    {
        this.userPrivileges = userPrivileges;
        this.groupPrivileges = groupPrivileges;
        this.rolePrivileges = rolePrivileges;
    }

    public PrincipalPrivilegeSet()
    {
    }

    private Map<String, List<PrivilegeGrantInfo>> userPrivileges;

    @ThriftField(value = 1, name = "userPrivileges")
    public Map<String, List<PrivilegeGrantInfo>> getUserPrivileges()
    {
        return userPrivileges;
    }

    public void setUserPrivileges(final Map<String, List<PrivilegeGrantInfo>> userPrivileges)
    {
        this.userPrivileges = userPrivileges;
    }

    private Map<String, List<PrivilegeGrantInfo>> groupPrivileges;

    @ThriftField(value = 2, name = "groupPrivileges")
    public Map<String, List<PrivilegeGrantInfo>> getGroupPrivileges()
    {
        return groupPrivileges;
    }

    public void setGroupPrivileges(final Map<String, List<PrivilegeGrantInfo>> groupPrivileges)
    {
        this.groupPrivileges = groupPrivileges;
    }

    private Map<String, List<PrivilegeGrantInfo>> rolePrivileges;

    @ThriftField(value = 3, name = "rolePrivileges")
    public Map<String, List<PrivilegeGrantInfo>> getRolePrivileges()
    {
        return rolePrivileges;
    }

    public void setRolePrivileges(final Map<String, List<PrivilegeGrantInfo>> rolePrivileges)
    {
        this.rolePrivileges = rolePrivileges;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("userPrivileges", userPrivileges)
            .add("groupPrivileges", groupPrivileges)
            .add("rolePrivileges", rolePrivileges)
            .toString();
    }
} public enum PrincipalType
{
    USER(1), ROLE(2), GROUP(3);

    private final int value;

    PrincipalType(final int value)
    {
        this.value = value;
    }

    @ThriftEnumValue
    public int getValue()
    {
        return value;
    }
} @ThriftStruct("PrivilegeBag")
public class PrivilegeBag
{
    @ThriftConstructor
    public PrivilegeBag(
                        @ThriftField(value = 1, name = "privileges") final List<HiveObjectPrivilege> privileges)
    {
        this.privileges = privileges;
    }

    public PrivilegeBag()
    {
    }

    private List<HiveObjectPrivilege> privileges;

    @ThriftField(value = 1, name = "privileges")
    public List<HiveObjectPrivilege> getPrivileges()
    {
        return privileges;
    }

    public void setPrivileges(final List<HiveObjectPrivilege> privileges)
    {
        this.privileges = privileges;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("privileges", privileges)
            .toString();
    }
} @ThriftStruct("Role")
public class Role
{
    @ThriftConstructor
    public Role(
                @ThriftField(value = 1, name = "roleName") final String roleName,
                @ThriftField(value = 2, name = "createTime") final int createTime,
                @ThriftField(value = 3, name = "ownerName") final String ownerName)
    {
        this.roleName = roleName;
        this.createTime = createTime;
        this.ownerName = ownerName;
    }

    public Role()
    {
    }

    private String roleName;

    @ThriftField(value = 1, name = "roleName")
    public String getRoleName()
    {
        return roleName;
    }

    public void setRoleName(final String roleName)
    {
        this.roleName = roleName;
    }

    private int createTime;

    @ThriftField(value = 2, name = "createTime")
    public int getCreateTime()
    {
        return createTime;
    }

    public void setCreateTime(final int createTime)
    {
        this.createTime = createTime;
    }

    private String ownerName;

    @ThriftField(value = 3, name = "ownerName")
    public String getOwnerName()
    {
        return ownerName;
    }

    public void setOwnerName(final String ownerName)
    {
        this.ownerName = ownerName;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("roleName", roleName)
            .add("createTime", createTime)
            .add("ownerName", ownerName)
            .toString();
    }
} @ThriftStruct("Table")
public class Table
{
    @ThriftConstructor
    public Table(
                 @ThriftField(value = 1, name = "tableName") final String tableName,
                 @ThriftField(value = 2, name = "dbName") final String dbName,
                 @ThriftField(value = 3, name = "owner") final String owner,
                 @ThriftField(value = 4, name = "createTime") final int createTime,
                 @ThriftField(value = 5, name = "lastAccessTime") final int lastAccessTime,
                 @ThriftField(value = 6, name = "retention") final int retention,
                 @ThriftField(value = 7, name = "sd") final StorageDescriptor sd,
                 @ThriftField(value = 8, name = "partitionKeys") final List<FieldSchema> partitionKeys,
                 @ThriftField(value = 9, name = "parameters") final Map<String, String> parameters,
                 @ThriftField(value = 10, name = "viewOriginalText") final String viewOriginalText,
                 @ThriftField(value = 11, name = "viewExpandedText") final String viewExpandedText,
                 @ThriftField(value = 12, name = "tableType") final String tableType,
                 @ThriftField(value = 13, name = "privileges") final PrincipalPrivilegeSet privileges,
                 @ThriftField(value = 14, name = "linkTarget") final TableIdentifier linkTarget,
                 @ThriftField(value = 15, name = "linkTables") final List<TableIdentifier> linkTables)
    {
        this.tableName = tableName;
        this.dbName = dbName;
        this.owner = owner;
        this.createTime = createTime;
        this.lastAccessTime = lastAccessTime;
        this.retention = retention;
        this.sd = sd;
        this.partitionKeys = partitionKeys;
        this.parameters = parameters;
        this.viewOriginalText = viewOriginalText;
        this.viewExpandedText = viewExpandedText;
        this.tableType = tableType;
        this.privileges = privileges;
        this.linkTarget = linkTarget;
        this.linkTables = linkTables;
    }

    public Table()
    {
    }

    private String tableName;

    @ThriftField(value = 1, name = "tableName")
    public String getTableName()
    {
        return tableName;
    }

    public void setTableName(final String tableName)
    {
        this.tableName = tableName;
    }

    private String dbName;

    @ThriftField(value = 2, name = "dbName")
    public String getDbName()
    {
        return dbName;
    }

    public void setDbName(final String dbName)
    {
        this.dbName = dbName;
    }

    private String owner;

    @ThriftField(value = 3, name = "owner")
    public String getOwner()
    {
        return owner;
    }

    public void setOwner(final String owner)
    {
        this.owner = owner;
    }

    private int createTime;

    @ThriftField(value = 4, name = "createTime")
    public int getCreateTime()
    {
        return createTime;
    }

    public void setCreateTime(final int createTime)
    {
        this.createTime = createTime;
    }

    private int lastAccessTime;

    @ThriftField(value = 5, name = "lastAccessTime")
    public int getLastAccessTime()
    {
        return lastAccessTime;
    }

    public void setLastAccessTime(final int lastAccessTime)
    {
        this.lastAccessTime = lastAccessTime;
    }

    private int retention;

    @ThriftField(value = 6, name = "retention")
    public int getRetention()
    {
        return retention;
    }

    public void setRetention(final int retention)
    {
        this.retention = retention;
    }

    private StorageDescriptor sd;

    @ThriftField(value = 7, name = "sd")
    public StorageDescriptor getSd()
    {
        return sd;
    }

    public void setSd(final StorageDescriptor sd)
    {
        this.sd = sd;
    }

    private List<FieldSchema> partitionKeys;

    @ThriftField(value = 8, name = "partitionKeys")
    public List<FieldSchema> getPartitionKeys()
    {
        return partitionKeys;
    }

    public void setPartitionKeys(final List<FieldSchema> partitionKeys)
    {
        this.partitionKeys = partitionKeys;
    }

    private Map<String, String> parameters;

    @ThriftField(value = 9, name = "parameters")
    public Map<String, String> getParameters()
    {
        return parameters;
    }

    public void setParameters(final Map<String, String> parameters)
    {
        this.parameters = parameters;
    }

    private String viewOriginalText;

    @ThriftField(value = 10, name = "viewOriginalText")
    public String getViewOriginalText()
    {
        return viewOriginalText;
    }

    public void setViewOriginalText(final String viewOriginalText)
    {
        this.viewOriginalText = viewOriginalText;
    }

    private String viewExpandedText;

    @ThriftField(value = 11, name = "viewExpandedText")
    public String getViewExpandedText()
    {
        return viewExpandedText;
    }

    public void setViewExpandedText(final String viewExpandedText)
    {
        this.viewExpandedText = viewExpandedText;
    }

    private String tableType;

    @ThriftField(value = 12, name = "tableType")
    public String getTableType()
    {
        return tableType;
    }

    public void setTableType(final String tableType)
    {
        this.tableType = tableType;
    }

    private PrincipalPrivilegeSet privileges;

    @ThriftField(value = 13, name = "privileges")
    public PrincipalPrivilegeSet getPrivileges()
    {
        return privileges;
    }

    public void setPrivileges(final PrincipalPrivilegeSet privileges)
    {
        this.privileges = privileges;
    }

    private TableIdentifier linkTarget;

    @ThriftField(value = 14, name = "linkTarget")
    public TableIdentifier getLinkTarget()
    {
        return linkTarget;
    }

    public void setLinkTarget(final TableIdentifier linkTarget)
    {
        this.linkTarget = linkTarget;
    }

    private List<TableIdentifier> linkTables;

    @ThriftField(value = 15, name = "linkTables")
    public List<TableIdentifier> getLinkTables()
    {
        return linkTables;
    }

    public void setLinkTables(final List<TableIdentifier> linkTables)
    {
        this.linkTables = linkTables;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("tableName", tableName)
            .add("dbName", dbName)
            .add("owner", owner)
            .add("createTime", createTime)
            .add("lastAccessTime", lastAccessTime)
            .add("retention", retention)
            .add("sd", sd)
            .add("partitionKeys", partitionKeys)
            .add("parameters", parameters)
            .add("viewOriginalText", viewOriginalText)
            .add("viewExpandedText", viewExpandedText)
            .add("tableType", tableType)
            .add("privileges", privileges)
            .add("linkTarget", linkTarget)
            .add("linkTables", linkTables)
            .toString();
    }
} @ThriftStruct("Type")
public class Type
{
    @ThriftConstructor
    public Type(
                @ThriftField(value = 1, name = "name") final String name,
                @ThriftField(value = 2, name = "type1") final String type1,
                @ThriftField(value = 3, name = "type2") final String type2,
                @ThriftField(value = 4, name = "fields") final List<FieldSchema> fields)
    {
        this.name = name;
        this.type1 = type1;
        this.type2 = type2;
        this.fields = fields;
    }

    public Type()
    {
    }

    private String name;

    @ThriftField(value = 1, name = "name")
    public String getName()
    {
        return name;
    }

    public void setName(final String name)
    {
        this.name = name;
    }

    private String type1;

    @ThriftField(value = 2, name = "type1")
    public String getType1()
    {
        return type1;
    }

    public void setType1(final String type1)
    {
        this.type1 = type1;
    }

    private String type2;

    @ThriftField(value = 3, name = "type2")
    public String getType2()
    {
        return type2;
    }

    public void setType2(final String type2)
    {
        this.type2 = type2;
    }

    private List<FieldSchema> fields;

    @ThriftField(value = 4, name = "fields")
    public List<FieldSchema> getFields()
    {
        return fields;
    }

    public void setFields(final List<FieldSchema> fields)
    {
        this.fields = fields;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
            .add("name", name)
            .add("type1", type1)
            .add("type2", type2)
            .add("fields", fields)
            .toString();
    }
} @ThriftStruct("UnknownDBException")
public class UnknownDBException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public UnknownDBException(
                              @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public UnknownDBException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("UnknownPartitionException")
public class UnknownPartitionException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public UnknownPartitionException(
                                     @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public UnknownPartitionException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} @ThriftStruct("UnknownTableException")
public class UnknownTableException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    @ThriftConstructor
    public UnknownTableException(
                                 @ThriftField(value = 1, name = "message") final String message)
    {
        this.message = message;
    }

    public UnknownTableException()
    {
    }

    private String message;

    @Override
    @ThriftField(value = 1, name = "message")
    public String getMessage()
    {
        return message;
    }

    public void setMessage(final String message)
    {
        this.message = message;
    }
} public static final String DEFAULT_DATABASE_NAME = "default"; public static boolean isIndexTable(Table table) {
  if (table == null) {
    return false;
  }
  return TableType.INDEX_TABLE.toString().equals(table.getTableType());
}
import com.facebook.hive.metastore.api.ThriftHiveMetastore;
import com.facebook.hive.metastore.client.HiveMetastoreClientConfig;
import com.facebook.hive.metastore.client.HiveMetastoreFactory;
import com.facebook.hive.metastore.client.SimpleHiveMetastoreFactory;
import com.facebook.swift.service.ThriftClientConfig;
import com.facebook.swift.service.ThriftClientManager;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.io.Closer;
import com.google.common.net.HostAndPort;
import io.airlift.log.Logger;
import io.airlift.units.Duration;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
import org.apache.hadoop.hive.metastore.api.ConfigValSecurityException;
import org.apache.hadoop.hive.metastore.api.Database;
import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
import org.apache.hadoop.hive.metastore.api.Index;
import org.apache.hadoop.hive.metastore.api.InvalidInputException;
import org.apache.hadoop.hive.metastore.api.InvalidObjectException;
import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
import org.apache.hadoop.hive.metastore.api.InvalidPartitionException;
import org.apache.hadoop.hive.metastore.api.MetaException;
import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
import org.apache.hadoop.hive.metastore.api.Partition;
import org.apache.hadoop.hive.metastore.api.PartitionEventType;
import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet;
import org.apache.hadoop.hive.metastore.api.PrincipalType;
import org.apache.hadoop.hive.metastore.api.PrivilegeBag;
import org.apache.hadoop.hive.metastore.api.Role;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.api.Type;
import org.apache.hadoop.hive.metastore.api.UnknownDBException;
import org.apache.hadoop.hive.metastore.api.UnknownPartitionException;
import org.apache.hadoop.hive.metastore.api.UnknownTableException;
import org.apache.hadoop.hive.shims.HadoopShims;
import org.apache.hadoop.hive.shims.ShimLoader;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.StringUtils;
import org.apache.thrift.TException;
import org.apache.thrift.transport.TTransportException;
import javax.security.auth.login.LoginException;
import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import static org.apache.hadoop.hive.metastore.MetaStoreUtils.DEFAULT_DATABASE_NAME;
import static org.apache.hadoop.hive.metastore.MetaStoreUtils.isIndexTable;
                    Thread.sleep(retryDelaySeconds * 1000L);
                } catch (InterruptedException ignore) {
                    Thread.currentThread().interrupt();
                    break;
                }
            }
        }

        if (!isConnected) {
            throw new MetaException("Could not connect to meta store using any of the URIs provided." +
                                    " Most recent failure: " + StringUtils.stringifyException(tte));
        }
        logger.info("Connected to metastore.");
    }

    @Override
    public void close()
    {
        isConnected = false;

        try {
            closer.close();
        }
        catch (IOException ioe) {
            logger.error(ioe, "While closing");
        }

    }

    /**
     * @param new_part
     * @return the added partition
     * @throws InvalidObjectException
     * @throws AlreadyExistsException
     * @throws MetaException
     * @throws TException
     * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#add_partition(org.apache.hadoop.hive.metastore.api.Partition)
     */
    public Partition add_partition(Partition new_part)
        throws InvalidObjectException, AlreadyExistsException, MetaException,
        TException {
        return add_partition(new_part, null);
    }

    public Partition add_partition(Partition new_part, EnvironmentContext envContext)
        throws InvalidObjectException, AlreadyExistsException, MetaException,
        TException {
        return deepCopy(client.add_partition_with_environment_context(new_part, envContext));
    }

    /**
     * @param new_parts
     * @throws InvalidObjectException
     * @throws AlreadyExistsException
     * @throws MetaException
     * @throws TException
     * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#add_partitions(List)
     */
    public int add_partitions(List<Partition> new_parts)
        throws InvalidObjectException, AlreadyExistsException, MetaException,
        TException {
        return client.add_partitions(new_parts);
    }

    /**
     * @param table_name
     * @param db_name
     * @param part_vals
     * @return the appended partition
     * @throws InvalidObjectException
     * @throws AlreadyExistsException
     * @throws MetaException
     * @throws TException
     * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#append_partition(java.lang.String,
     *      java.lang.String, java.util.List)
     */
    public Partition appendPartition(String db_name, String table_name,
                                     List<String> part_vals) throws InvalidObjectException,
        AlreadyExistsException, MetaException, TException {
        return appendPartition(db_name, table_name, part_vals, null);
    }

    public Partition appendPartition(String db_name, String table_name, List<String> part_vals,
                                     EnvironmentContext envContext) throws InvalidObjectException, AlreadyExistsException,
        MetaException, TException {
        return deepCopy(client.append_partition_with_environment_context(db_name, table_name,
                                                                         part_vals, envContext));
    }

    public Partition appendPartition(String dbName, String tableName, String partName)
        throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
        return appendPartition(dbName, tableName, partName, null);
    }

    public Partition getPartitionTemplate(String db_name, String table_name,
                                          List<String> part_vals) throws InvalidObjectException,
        MetaException, TException {
        return deepCopy(client.get_partition_template(db_name, table_name, part_vals));
    }

    public Partition appendPartition(String dbName, String tableName, String partName,
                                     EnvironmentContext envContext) throws InvalidObjectException, AlreadyExistsException,
        MetaException, TException {
        return deepCopy(client.append_partition_by_name_with_environment_context(dbName, tableName,
                                                                                 partName, envContext));
    }

    /**
     * Exchange the partition between two tables
     * @param partitionSpecs partitions specs of the parent partition to be exchanged
     * @param destDb the db of the destination table
     * @param destinationTableName the destination table name
     * @param overwrite overwrite partition if exists in destination table
     @ @return list of new partitions after exchanging
    */
    @Override
    public List<Partition> exchange_partition(Map<String, String> partitionSpecs,
                                              String sourceDb, String sourceTable, String destDb,
                                              String destinationTableName, boolean overwrite) throws MetaException,
        NoSuchObjectException, InvalidObjectException, TException, AlreadyExistsException,
        InvalidInputException, InvalidOperationException {