PageRenderTime 277ms CodeModel.GetById 19ms RepoModel.GetById 3ms app.codeStats 1ms

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