PageRenderTime 32ms CodeModel.GetById 8ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java

#
Java | 683 lines | 157 code | 66 blank | 460 comment | 0 complexity | afc1fa825554b8e1ccf650ef933a1549 MD5 | raw file
  1/**
  2 * Licensed to the Apache Software Foundation (ASF) under one
  3 * or more contributor license agreements.  See the NOTICE file
  4 * distributed with this work for additional information
  5 * regarding copyright ownership.  The ASF licenses this file
  6 * to you under the Apache License, Version 2.0 (the
  7 * "License"); you may not use this file except in compliance
  8 * with the License.  You may obtain a copy of the License at
  9 *
 10 *     http://www.apache.org/licenses/LICENSE-2.0
 11 *
 12 * Unless required by applicable law or agreed to in writing, software
 13 * distributed under the License is distributed on an "AS IS" BASIS,
 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15 * See the License for the specific language governing permissions and
 16 * limitations under the License.
 17 */
 18
 19package org.apache.hadoop.hive.metastore;
 20
 21import java.util.List;
 22import java.util.Map;
 23
 24import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
 25import org.apache.hadoop.hive.metastore.api.ConfigValSecurityException;
 26import org.apache.hadoop.hive.metastore.api.Database;
 27import org.apache.hadoop.hive.metastore.api.FieldSchema;
 28import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
 29import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
 30import org.apache.hadoop.hive.metastore.api.Index;
 31import org.apache.hadoop.hive.metastore.api.InvalidObjectException;
 32import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
 33import org.apache.hadoop.hive.metastore.api.MetaException;
 34import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 35import org.apache.hadoop.hive.metastore.api.Partition;
 36import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet;
 37import org.apache.hadoop.hive.metastore.api.PrincipalType;
 38import org.apache.hadoop.hive.metastore.api.PrivilegeBag;
 39import org.apache.hadoop.hive.metastore.api.Role;
 40import org.apache.hadoop.hive.metastore.api.Table;
 41import org.apache.hadoop.hive.metastore.api.UnknownDBException;
 42import org.apache.hadoop.hive.metastore.api.UnknownTableException;
 43import org.apache.thrift.TException;
 44
 45/**
 46 * TODO Unnecessary when the server sides for both dbstore and filestore are
 47 * merged
 48 */
 49public interface IMetaStoreClient {
 50
 51  public void close();
 52
 53  /**
 54   * Get the names of all databases in the MetaStore that match the given pattern.
 55   * @param databasePattern
 56   * @return List of database names.
 57   * @throws MetaException
 58   * @throws TException
 59   */
 60  public List<String> getDatabases(String databasePattern)
 61      throws MetaException, TException;
 62
 63  /**
 64   * Get the names of all databases in the MetaStore.
 65   * @return List of database names.
 66   * @throws MetaException
 67   * @throws TException
 68   */
 69  public List<String> getAllDatabases()
 70      throws MetaException, TException;
 71
 72  /**
 73   * Get the names of all tables in the specified database that satisfy the supplied
 74   * table name pattern.
 75   * @param dbName
 76   * @param tablePattern
 77   * @return List of table names.
 78   * @throws MetaException
 79   * @throws TException
 80   * @throws UnknownDBException
 81   */
 82  public List<String> getTables(String dbName, String tablePattern)
 83      throws MetaException, TException, UnknownDBException;
 84
 85  /**
 86   * Get the names of all tables in the specified database.
 87   * @param dbName
 88   * @return List of table names.
 89   * @throws MetaException
 90   * @throws TException
 91   * @throws UnknownDBException
 92   */
 93  public List<String> getAllTables(String dbName)
 94      throws MetaException, TException, UnknownDBException;
 95
 96
 97  /**
 98   * Drop the table.
 99   *
100   * @param dbname
101   *          The database for this table
102   * @param tableName
103   *          The table to drop
104   * @throws MetaException
105   *           Could not drop table properly.
106   * @throws NoSuchObjectException
107   *           The table wasn't found.
108   * @throws TException
109   *           A thrift communication error occurred
110   * @throws ExistingDependentsException
111   */
112  public void dropTable(String dbname, String tableName, boolean deleteData,
113      boolean ignoreUknownTab) throws MetaException, TException,
114      NoSuchObjectException;
115
116  /**
117   * Drop the table in the DEFAULT database.
118   *
119   * @param tableName
120   *          The table to drop
121   * @param deleteData
122   *          Should we delete the underlying data
123   * @throws MetaException
124   *           Could not drop table properly.
125   * @throws UnknownTableException
126   *           The table wasn't found.
127   * @throws TException
128   *           A thrift communication error occurred
129   * @throws NoSuchObjectException
130   *           The table wasn't found.
131   *
132   * @deprecated As of release 0.6.0 replaced by {@link #dropTable(String, String, boolean, boolean)}.
133   *             This method will be removed in release 0.7.0.
134   */
135  @Deprecated
136  public void dropTable(String tableName, boolean deleteData)
137      throws MetaException, UnknownTableException, TException,
138      NoSuchObjectException;
139
140  public void dropTable(String dbname, String tableName)
141      throws MetaException, TException, NoSuchObjectException;
142
143  public boolean tableExists(String databaseName, String tableName) throws MetaException,
144      TException, UnknownDBException;
145
146  /**
147   * Check to see if the specified table exists in the DEFAULT database.
148   * @param tableName
149   * @return TRUE if DEFAULT.tableName exists, FALSE otherwise.
150   * @throws MetaException
151   * @throws TException
152   * @throws UnknownDBException
153   * @deprecated As of release 0.6.0 replaced by {@link #tableExists(String, String)}.
154   *             This method will be removed in release 0.7.0.
155   */
156  @Deprecated
157  public boolean tableExists(String tableName) throws MetaException,
158      TException, UnknownDBException;
159
160  /**
161   * Get a table object from the DEFAULT database.
162   *
163   * @param tableName
164   *          Name of the table to fetch.
165   * @return An object representing the table.
166   * @throws MetaException
167   *           Could not fetch the table
168   * @throws TException
169   *           A thrift communication error occurred
170   * @throws NoSuchObjectException
171   *           In case the table wasn't found.
172   * @deprecated As of release 0.6.0 replaced by {@link #getTable(String, String)}.
173   *             This method will be removed in release 0.7.0.
174   */
175  @Deprecated
176  public Table getTable(String tableName) throws MetaException, TException,
177      NoSuchObjectException;
178
179  /**
180   * Get a Database Object
181   * @param databaseName  name of the database to fetch
182   * @return
183   * @throws NoSuchObjectException The database does not exist
184   * @throws MetaException Could not fetch the database
185   * @throws TException A thrift communication error occurred
186   */
187    public Database getDatabase(String databaseName)
188        throws NoSuchObjectException, MetaException, TException;
189
190
191  /**
192   * Get a table object.
193   *
194   * @param dbName
195   *          The database the table is located in.
196   * @param tableName
197   *          Name of the table to fetch.
198   * @return An object representing the table.
199   * @throws MetaException
200   *           Could not fetch the table
201   * @throws TException
202   *           A thrift communication error occurred
203   * @throws NoSuchObjectException
204   *           In case the table wasn't found.
205   */
206  public Table getTable(String dbName, String tableName) throws MetaException,
207      TException, NoSuchObjectException;
208
209  /**
210   * @param tableName
211   * @param dbName
212   * @param partVals
213   * @return the partition object
214   * @throws InvalidObjectException
215   * @throws AlreadyExistsException
216   * @throws MetaException
217   * @throws TException
218   * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#append_partition(java.lang.String,
219   *      java.lang.String, java.util.List)
220   */
221  public Partition appendPartition(String tableName, String dbName,
222      List<String> partVals) throws InvalidObjectException,
223      AlreadyExistsException, MetaException, TException;
224
225  public Partition appendPartition(String tableName, String dbName, String name)
226      throws InvalidObjectException, AlreadyExistsException, MetaException, TException;
227  /**
228   * Add a partition to the table.
229   *
230   * @param partition
231   *          The partition to add
232   * @return The partition added
233   * @throws InvalidObjectException
234   *           Could not find table to add to
235   * @throws AlreadyExistsException
236   *           Partition already exists
237   * @throws MetaException
238   *           Could not add partition
239   * @throws TException
240   *           Thrift exception
241   */
242  public Partition add_partition(Partition partition)
243      throws InvalidObjectException, AlreadyExistsException, MetaException,
244      TException;
245
246  /**
247   * @param tblName
248   * @param dbName
249   * @param partVals
250   * @return the partition object
251   * @throws MetaException
252   * @throws TException
253   * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_partition(java.lang.String,
254   *      java.lang.String, java.util.List)
255   */
256  public Partition getPartition(String tblName, String dbName,
257      List<String> partVals) throws NoSuchObjectException, MetaException, TException;
258
259  /**
260   * @param dbName
261   * @param tblName
262   * @param name - partition name i.e. 'ds=2010-02-03/ts=2010-02-03 18%3A16%3A01'
263   * @return the partition object
264   * @throws MetaException
265   * @throws TException
266   * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_partition(java.lang.String,
267   *      java.lang.String, java.util.List)
268   */
269  public Partition getPartition(String dbName, String tblName,
270      String name) throws MetaException, UnknownTableException, NoSuchObjectException, TException;
271
272  
273  /**
274   * @param dbName
275   * @param tableName
276   * @param pvals
277   * @param userName
278   * @param groupNames
279   * @return
280   * @throws MetaException
281   * @throws UnknownTableException
282   * @throws NoSuchObjectException
283   * @throws TException
284   */
285  public Partition getPartitionWithAuthInfo(String dbName, String tableName,
286      List<String> pvals, String userName, List<String> groupNames)
287      throws MetaException, UnknownTableException, NoSuchObjectException, TException;
288  
289  /**
290   * @param tbl_name
291   * @param db_name
292   * @param max_parts
293   * @return the list of partitions
294   * @throws NoSuchObjectException
295   * @throws MetaException
296   * @throws TException
297   */
298  public List<Partition> listPartitions(String db_name, String tbl_name,
299      short max_parts) throws NoSuchObjectException, MetaException, TException;
300
301  public List<Partition> listPartitions(String db_name, String tbl_name,
302      List<String> part_vals, short max_parts) throws NoSuchObjectException, MetaException, TException;
303
304  public List<String> listPartitionNames(String db_name, String tbl_name,
305      short max_parts) throws MetaException, TException;
306
307  public List<String> listPartitionNames(String db_name, String tbl_name,
308      List<String> part_vals, short max_parts) throws MetaException, TException;
309
310  /**
311   * @param dbName
312   * @param tableName
313   * @param s
314   * @param userName
315   * @param groupNames
316   * @return
317   * @throws NoSuchObjectException 
318   */
319  public List<Partition> listPartitionsWithAuthInfo(String dbName,
320      String tableName, short s, String userName, List<String> groupNames)
321      throws MetaException, TException, NoSuchObjectException;
322
323  /**
324   * @param dbName
325   * @param tableName
326   * @param partialPvals
327   * @param s
328   * @param userName
329   * @param groupNames
330   * @return
331   * @throws NoSuchObjectException 
332   */
333  public List<Partition> listPartitionsWithAuthInfo(String dbName,
334      String tableName, List<String> partialPvals, short s, String userName,
335      List<String> groupNames) throws MetaException, TException, NoSuchObjectException;
336
337  /**
338   * @param tbl
339   * @throws AlreadyExistsException
340   * @throws InvalidObjectException
341   * @throws MetaException
342   * @throws NoSuchObjectException
343   * @throws TException
344   * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#create_table(org.apache.hadoop.hive.metastore.api.Table)
345   */
346  public void createTable(Table tbl) throws AlreadyExistsException,
347      InvalidObjectException, MetaException, NoSuchObjectException, TException;
348
349  public void alter_table(String defaultDatabaseName, String tblName,
350      Table table) throws InvalidOperationException, MetaException, TException;
351
352  public void createDatabase(Database db)
353      throws InvalidObjectException, AlreadyExistsException, MetaException, TException;
354
355  public void dropDatabase(String name)
356      throws NoSuchObjectException, InvalidOperationException, MetaException, TException;
357
358  public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb)
359      throws NoSuchObjectException, InvalidOperationException, MetaException, TException;
360
361  public void alterDatabase(String name, Database db)
362      throws NoSuchObjectException, MetaException, TException;
363
364  /**
365   * @param db_name
366   * @param tbl_name
367   * @param part_vals
368   * @param deleteData
369   *          delete the underlying data or just delete the table in metadata
370   * @return true or false
371   * @throws NoSuchObjectException
372   * @throws MetaException
373   * @throws TException
374   * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#drop_partition(java.lang.String,
375   *      java.lang.String, java.util.List, boolean)
376   */
377  public boolean dropPartition(String db_name, String tbl_name,
378      List<String> part_vals, boolean deleteData) throws NoSuchObjectException,
379      MetaException, TException;
380
381  public boolean dropPartition(String db_name, String tbl_name,
382      String name, boolean deleteData) throws NoSuchObjectException,
383      MetaException, TException;
384  /**
385   * updates a partition to new partition
386   *
387   * @param dbName
388   *          database of the old partition
389   * @param tblName
390   *          table name of the old partition
391   * @param newPart
392   *          new partition
393   * @throws InvalidOperationException
394   *           if the old partition does not exist
395   * @throws MetaException
396   *           if error in updating metadata
397   * @throws TException
398   *           if error in communicating with metastore server
399   */
400  public void alter_partition(String dbName, String tblName, Partition newPart)
401      throws InvalidOperationException, MetaException, TException;
402
403  /**
404   * @param db
405   * @param tableName
406   * @throws UnknownTableException
407   * @throws UnknownDBException
408   * @throws MetaException
409   * @throws TException
410   * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_fields(java.lang.String,
411   *      java.lang.String)
412   */
413  public List<FieldSchema> getFields(String db, String tableName)
414      throws MetaException, TException, UnknownTableException,
415      UnknownDBException;
416
417  /**
418   * @param db
419   * @param tableName
420   * @throws UnknownTableException
421   * @throws UnknownDBException
422   * @throws MetaException
423   * @throws TException
424   * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_schema(java.lang.String,
425   *      java.lang.String)
426   */
427  public List<FieldSchema> getSchema(String db, String tableName)
428      throws MetaException, TException, UnknownTableException,
429      UnknownDBException;
430
431  /**
432   * @param name
433   *          name of the configuration property to get the value of
434   * @param defaultValue
435   *          the value to return if property with the given name doesn't exist
436   * @return value of the specified configuration property
437   * @throws TException
438   * @throws ConfigValSecurityException
439   */
440  public String getConfigValue(String name, String defaultValue)
441      throws TException, ConfigValSecurityException;
442
443  /**
444   *
445   * @param name
446   *          the partition name e.g. ("ds=2010-03-03/hr=12")
447   * @return a list containing the partition col values, in the same order as the name
448   * @throws MetaException
449   * @throws TException
450   */
451  public List<String> partitionNameToVals(String name)
452      throws MetaException, TException;
453  /**
454   *
455   * @param name
456   *          the partition name e.g. ("ds=2010-03-03/hr=12")
457   * @return a map from the partition col to the value, as listed in the name
458   * @throws MetaException
459   * @throws TException
460   */
461  public Map<String, String> partitionNameToSpec(String name)
462      throws MetaException, TException;
463
464  /**
465   * create an index
466   * @param index the index object
467   * @throws InvalidObjectException
468   * @throws MetaException
469   * @throws NoSuchObjectException
470   * @throws TException
471   * @throws AlreadyExistsException
472   */
473  public void createIndex(Index index, Table indexTable) throws InvalidObjectException,
474      MetaException, NoSuchObjectException, TException, AlreadyExistsException;
475
476  public void alter_index(String dbName, String tblName, String indexName,
477      Index index) throws InvalidOperationException, MetaException, TException;
478
479  /**
480   *
481   * @param dbName
482   * @param tblName
483   * @param indexName
484   * @return
485   * @throws MetaException
486   * @throws UnknownTableException
487   * @throws NoSuchObjectException
488   * @throws TException
489   */
490  public Index getIndex(String dbName, String tblName, String indexName)
491      throws MetaException, UnknownTableException, NoSuchObjectException,
492      TException;
493
494
495  /**
496   * list indexes of the give base table
497   * @param db_name
498   * @param tbl_name
499   * @param max
500   * @return
501   * @throws NoSuchObjectException
502   * @throws MetaException
503   * @throws TException
504   */
505  public List<Index> listIndexes(String db_name, String tbl_name,
506      short max) throws NoSuchObjectException, MetaException, TException;
507
508  /**
509   * list all the index names of the give base table.
510   *
511   * @param db_name
512   * @param tbl_name
513   * @param max
514   * @return
515   * @throws MetaException
516   * @throws TException
517   */
518  public List<String> listIndexNames(String db_name, String tbl_name,
519      short max) throws MetaException, TException;
520
521  /**
522   * @param db_name
523   * @param tbl_name
524   * @param name index name
525   * @param deleteData
526   * @return
527   * @throws NoSuchObjectException
528   * @throws MetaException
529   * @throws TException
530   */
531  public boolean dropIndex(String db_name, String tbl_name,
532      String name, boolean deleteData) throws NoSuchObjectException,
533      MetaException, TException;
534  
535  /**
536   * @param Role
537   *          role object
538   * @return
539   * @throws MetaException
540   * @throws TException
541   */
542  public boolean create_role(Role role)
543      throws MetaException, TException;
544
545  /**
546   * @param role_name
547   *          role name
548   * @param db_name 
549   * 
550   * @return
551   * @throws MetaException
552   * @throws TException
553   */
554  public boolean drop_role(String role_name) throws MetaException, TException;
555
556  /**
557   * list all role names
558   * @return
559   * @throws TException 
560   * @throws MetaException 
561   */
562  public List<String> listRoleNames() throws MetaException, TException;
563
564  /**
565   * 
566   * @param role_name
567   * @param user_name
568   * @param principalType
569   * @param grantor
570   * @param grantorType
571   * @param grantOption
572   * @return
573   * @throws MetaException
574   * @throws TException
575   */
576  public boolean grant_role(String role_name, String user_name,
577      PrincipalType principalType, String grantor, PrincipalType grantorType,
578      boolean grantOption) throws MetaException, TException;
579
580  /**
581   * @param role_name
582   *          role name
583   * @param user_name
584   *          user name
585   * @param principalType
586   * @param db_name
587   * 
588   * @return
589   * @throws MetaException
590   * @throws TException
591   */
592  public boolean revoke_role(String role_name, String user_name,
593      PrincipalType principalType) throws MetaException, TException;
594
595  /**
596   * 
597   * @param principalName
598   * @param principalType
599   * @return
600   * @throws MetaException
601   * @throws TException
602   */
603  public List<Role> list_roles(String principalName, PrincipalType principalType)
604      throws MetaException, TException;
605
606  /**
607   * @param hiveObject
608   * @param user_name
609   * @param group_names
610   * @return
611   * @throws MetaException
612   * @throws TException
613   */
614  public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject,
615      String user_name, List<String> group_names) throws MetaException,
616      TException;
617  
618  /**
619   * @param principal_name
620   * @param principal_type
621   * @param hiveObject
622   * @return
623   * @throws MetaException
624   * @throws TException
625   */
626  public List<HiveObjectPrivilege> list_privileges(String principal_name,
627      PrincipalType principal_type, HiveObjectRef hiveObject)
628      throws MetaException, TException;
629
630  /**
631   * @param privileges
632   * @return
633   * @throws MetaException
634   * @throws TException
635   */
636  public boolean grant_privileges(PrivilegeBag privileges)
637      throws MetaException, TException;
638
639  /**
640   * @param privileges
641   * @return
642   * @throws MetaException
643   * @throws TException
644   */
645  public boolean revoke_privileges(PrivilegeBag privileges)
646      throws MetaException, TException;
647
648  /**
649   * @param renewerKerberosPrincipalName
650   * @param tokenSignature
651   * @return
652   * @throws MetaException
653   * @throws TException
654   */
655  public String getDelegationTokenWithSignature(String renewerKerberosPrincipalName, String tokenSignature)
656      throws MetaException, TException;
657
658  /**
659   * @param renewerKerberosPrincipalName
660   * @return
661   * @throws MetaException
662   * @throws TException
663   */
664  public String getDelegationToken(String renewerKerberosPrincipalName)
665      throws MetaException, TException;
666
667  /**
668   * @param tokenStrForm
669   * @return
670   * @throws MetaException
671   * @throws TException
672   */
673  public long renewDelegationToken(String tokenStrForm) throws MetaException, TException;
674
675  /**
676   * @param tokenStrForm
677   * @throws MetaException
678   * @throws TException
679   */
680  public void cancelDelegationToken(String tokenStrForm) throws MetaException, TException;
681
682
683}