You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/08/16 05:54:28 UTC
svn commit: r1514569 - in
/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization:
HiveAuthorizationProviderBase.java StorageBasedAuthorizationProvider.java
Author: hashutosh
Date: Fri Aug 16 03:54:28 2013
New Revision: 1514569
URL: http://svn.apache.org/r1514569
Log:
HIVE-5048 : StorageBasedAuthorization provider causes an NPE when asked to authorize from client side. (Sushanth Sowmyan via Ashutosh Chauhan)
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/StorageBasedAuthorizationProvider.java
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java?rev=1514569&r1=1514568&r2=1514569&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java Fri Aug 16 03:54:28 2013
@@ -57,10 +57,14 @@ public abstract class HiveAuthorizationP
this.handler = handler;
}
+ public boolean isRunFromMetaStore(){
+ return (this.hiveClient == null);
+ }
+
public PrincipalPrivilegeSet get_privilege_set(HiveObjectType column, String dbName,
String tableName, List<String> partValues, String col, String userName,
List<String> groupNames) throws HiveException {
- if (hiveClient != null) {
+ if (!isRunFromMetaStore()) {
return hiveClient.get_privilege_set(
column, dbName, tableName, partValues, col, userName, groupNames);
} else {
@@ -77,7 +81,7 @@ public abstract class HiveAuthorizationP
}
public Database getDatabase(String dbName) throws HiveException {
- if (hiveClient != null) {
+ if (!isRunFromMetaStore()) {
return hiveClient.getDatabase(dbName);
} else {
try {
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/StorageBasedAuthorizationProvider.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/StorageBasedAuthorizationProvider.java?rev=1514569&r1=1514568&r2=1514569&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/StorageBasedAuthorizationProvider.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/StorageBasedAuthorizationProvider.java Fri Aug 16 03:54:28 2013
@@ -63,6 +63,22 @@ public class StorageBasedAuthorizationPr
private Warehouse wh;
+ /**
+ * Make sure that the warehouse variable is set up properly.
+ * @throws MetaException if unable to instantiate
+ */
+ private void initWh() throws MetaException {
+ if (wh == null){
+ if(!hive_db.isRunFromMetaStore()){
+ this.wh = new Warehouse(getConf());
+ }else{
+ // not good if we reach here, this was initialized at setMetaStoreHandler() time.
+ // this means handler.getWh() is returning null. Error out.
+ throw new IllegalStateException("Unitialized Warehouse from MetastoreHandler");
+ }
+ }
+ }
+
@Override
public void init(Configuration conf) throws HiveException {
hive_db = new HiveProxy();
@@ -100,6 +116,7 @@ public class StorageBasedAuthorizationPr
// we try to determine what the path would be after the create table is issued.
Path path = null;
try {
+ initWh();
String location = table.getTTable().getSd().getLocation();
if (location == null || location.isEmpty()) {
path = wh.getTablePath(hive_db.getDatabase(table.getDbName()), table.getTableName());
@@ -305,6 +322,7 @@ public class StorageBasedAuthorizationPr
protected Path getDbLocation(Database db) throws HiveException {
try {
+ initWh();
String location = db.getLocationUri();
if (location == null) {
return wh.getDefaultDatabasePath(db.getName());