You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by sr...@apache.org on 2014/06/23 21:50:26 UTC
[1/3] SENTRY-162: Cleanup DB store privilege metadata on Hive DDL
statements ( Prasad Mujumdar via Sravya Tirukkovalur)
Repository: incubator-sentry
Updated Branches:
refs/heads/master 598849509 -> b11f5aab9
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index cf381e5..78f41d3 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -65,6 +65,7 @@ import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
@@ -262,7 +263,6 @@ public class SentryStore {
}
}
- //TODO: handle case where a) privilege already exists, b) role to privilege mapping already exists
public CommitContext alterSentryRoleGrantPrivilege(String roleName, TSentryPrivilege privilege)
throws SentryNoSuchObjectException, SentryInvalidInputException {
boolean rollbackTransaction = true;
@@ -270,54 +270,10 @@ public class SentryStore {
roleName = trimAndLower(roleName);
try {
pm = openTransaction();
- MSentryRole mRole = getMSentryRole(pm, roleName);
- if (mRole == null) {
- throw new SentryNoSuchObjectException("Role: " + roleName);
- } else {
-
- if ((privilege.getTableName() != null)||(privilege.getDbName() != null)) {
- // If Grant is for ALL and Either INSERT/SELECT already exists..
- // need to remove it and GRANT ALL..
- if (privilege.getAction().equalsIgnoreCase("*")) {
- TSentryPrivilege tNotAll = new TSentryPrivilege(privilege);
- tNotAll.setAction(AccessConstants.SELECT);
- MSentryPrivilege mSelect = getMSentryPrivilege(constructPrivilegeName(tNotAll), pm);
- tNotAll.setAction(AccessConstants.INSERT);
- MSentryPrivilege mInsert = getMSentryPrivilege(constructPrivilegeName(tNotAll), pm);
- if ((mSelect != null)&&(mRole.getPrivileges().contains(mSelect))) {
- mSelect.removeRole(mRole);
- pm.makePersistent(mSelect);
- }
- if ((mInsert != null)&&(mRole.getPrivileges().contains(mInsert))) {
- mInsert.removeRole(mRole);
- pm.makePersistent(mInsert);
- }
- } else {
- // If Grant is for Either INSERT/SELECT and ALL already exists..
- // do nothing..
- TSentryPrivilege tAll = new TSentryPrivilege(privilege);
- tAll.setAction(AccessConstants.ALL);
- MSentryPrivilege mAll = getMSentryPrivilege(constructPrivilegeName(tAll), pm);
- if ((mAll != null)&&(mRole.getPrivileges().contains(mAll))) {
- CommitContext commit = commitUpdateTransaction(pm);
- rollbackTransaction = false;
- return commit;
- }
- }
- }
-
- MSentryPrivilege mPrivilege = getMSentryPrivilege(constructPrivilegeName(privilege), pm);
- if (mPrivilege == null) {
- mPrivilege = convertToMSentryPrivilege(privilege);
- }
- mPrivilege.appendRole(mRole);
- pm.makePersistent(mRole);
- pm.makePersistent(mPrivilege);
-
- CommitContext commit = commitUpdateTransaction(pm);
- rollbackTransaction = false;
- return commit;
- }
+ alterSentryRoleGrantPrivilegeCore(pm, roleName, privilege);
+ CommitContext commit = commitUpdateTransaction(pm);
+ rollbackTransaction = false;
+ return commit;
} finally {
if (rollbackTransaction) {
rollbackTransaction(pm);
@@ -325,41 +281,70 @@ public class SentryStore {
}
}
+ private void alterSentryRoleGrantPrivilegeCore(PersistenceManager pm,
+ String roleName, TSentryPrivilege privilege)
+ throws SentryNoSuchObjectException, SentryInvalidInputException {
+ MSentryRole mRole = getMSentryRole(pm, roleName);
+ if (mRole == null) {
+ throw new SentryNoSuchObjectException("Role: " + roleName);
+ } else {
+
+ if ((privilege.getTableName() != null) || (privilege.getDbName() != null)) {
+ // If Grant is for ALL and Either INSERT/SELECT already exists..
+ // need to remove it and GRANT ALL..
+ if (privilege.getAction().equalsIgnoreCase("*")) {
+ TSentryPrivilege tNotAll = new TSentryPrivilege(privilege);
+ tNotAll.setAction(AccessConstants.SELECT);
+ MSentryPrivilege mSelect = getMSentryPrivilege(
+ constructPrivilegeName(tNotAll), pm);
+ tNotAll.setAction(AccessConstants.INSERT);
+ MSentryPrivilege mInsert = getMSentryPrivilege(
+ constructPrivilegeName(tNotAll), pm);
+ if ((mSelect != null) && (mRole.getPrivileges().contains(mSelect))) {
+ mSelect.removeRole(mRole);
+ pm.makePersistent(mSelect);
+ }
+ if ((mInsert != null) && (mRole.getPrivileges().contains(mInsert))) {
+ mInsert.removeRole(mRole);
+ pm.makePersistent(mInsert);
+ }
+ } else {
+ // If Grant is for Either INSERT/SELECT and ALL already exists..
+ // do nothing..
+ TSentryPrivilege tAll = new TSentryPrivilege(privilege);
+ tAll.setAction(AccessConstants.ALL);
+ MSentryPrivilege mAll = getMSentryPrivilege(
+ constructPrivilegeName(tAll), pm);
+ if ((mAll != null) && (mRole.getPrivileges().contains(mAll))) {
+ return;
+ }
+ }
+ }
+
+ MSentryPrivilege mPrivilege = getMSentryPrivilege(
+ constructPrivilegeName(privilege), pm);
+ if (mPrivilege == null) {
+ mPrivilege = convertToMSentryPrivilege(privilege);
+ }
+ mPrivilege.appendRole(mRole);
+ pm.makePersistent(mRole);
+ pm.makePersistent(mPrivilege);
+ }
+ return;
+ }
public CommitContext alterSentryRoleRevokePrivilege(String roleName,
TSentryPrivilege tPrivilege) throws SentryNoSuchObjectException, SentryInvalidInputException {
boolean rollbackTransaction = true;
PersistenceManager pm = null;
- roleName = roleName.trim().toLowerCase();
+ roleName = safeTrimLower(roleName);
try {
pm = openTransaction();
- Query query = pm.newQuery(MSentryRole.class);
- query.setFilter("this.roleName == t");
- query.declareParameters("java.lang.String t");
- query.setUnique(true);
- MSentryRole mRole = (MSentryRole) query.execute(roleName);
- if (mRole == null) {
- throw new SentryNoSuchObjectException("Role: " + roleName);
- } else {
- query = pm.newQuery(MSentryPrivilege.class);
- MSentryPrivilege mPrivilege = getMSentryPrivilege(constructPrivilegeName(tPrivilege), pm);
- if (mPrivilege == null) {
- mPrivilege = convertToMSentryPrivilege(tPrivilege);
- } else {
- mPrivilege = (MSentryPrivilege)pm.detachCopy(mPrivilege);
- }
+ alterSentryRoleRevokePrivilegeCore(pm, roleName, tPrivilege);
- Set<MSentryPrivilege> privilegeGraph = Sets.newHashSet(mPrivilege);
- // Get the privilege graph
- populateChildren(Sets.newHashSet(roleName), mPrivilege, privilegeGraph);
- for (MSentryPrivilege childPriv : privilegeGraph) {
- revokePartial(pm, tPrivilege, mRole, childPriv);
- }
- pm.makePersistent(mRole);
- CommitContext commit = commitUpdateTransaction(pm);
- rollbackTransaction = false;
- return commit;
- }
+ CommitContext commit = commitUpdateTransaction(pm);
+ rollbackTransaction = false;
+ return commit;
} finally {
if (rollbackTransaction) {
rollbackTransaction(pm);
@@ -367,6 +352,35 @@ public class SentryStore {
}
}
+ private void alterSentryRoleRevokePrivilegeCore(PersistenceManager pm,
+ String roleName, TSentryPrivilege tPrivilege)
+ throws SentryNoSuchObjectException, SentryInvalidInputException {
+ Query query = pm.newQuery(MSentryRole.class);
+ query.setFilter("this.roleName == t");
+ query.declareParameters("java.lang.String t");
+ query.setUnique(true);
+ MSentryRole mRole = (MSentryRole) query.execute(roleName);
+ if (mRole == null) {
+ throw new SentryNoSuchObjectException("Role: " + roleName);
+ } else {
+ query = pm.newQuery(MSentryPrivilege.class);
+ MSentryPrivilege mPrivilege = getMSentryPrivilege(
+ constructPrivilegeName(tPrivilege), pm);
+ if (mPrivilege == null) {
+ mPrivilege = convertToMSentryPrivilege(tPrivilege);
+ } else {
+ mPrivilege = (MSentryPrivilege) pm.detachCopy(mPrivilege);
+ }
+
+ Set<MSentryPrivilege> privilegeGraph = Sets.newHashSet(mPrivilege);
+ // Get the privilege graph
+ populateChildren(Sets.newHashSet(roleName), mPrivilege, privilegeGraph);
+ for (MSentryPrivilege childPriv : privilegeGraph) {
+ revokePartial(pm, tPrivilege, mRole, childPriv);
+ }
+ pm.makePersistent(mRole);
+ }
+ }
/**
* Roles can be granted ALL, SELECT, and INSERT on tables. When
@@ -506,7 +520,7 @@ public class SentryStore {
String dbName = safeTrimLower(privilege.getDbName());
String tableName = safeTrimLower(privilege.getTableName());
String uri = privilege.getURI();
- String action = privilege.getAction();
+ String action = safeTrimLower(privilege.getAction());
PrivilegeScope scope;
if (serverName == null) {
@@ -520,6 +534,9 @@ public class SentryStore {
throw new SentryInvalidInputException("Either Table name or Db name must be NON-NULL for SELECT/INSERT privilege");
}
}
+ if (action == null) {
+ action = AccessConstants.ALL;
+ }
// Validate privilege scope
try {
@@ -1175,8 +1192,153 @@ public class SentryStore {
rollbackTransaction(pm);
}
}
+ }
+
+ /**
+ * Drop given privilege from all roles
+ */
+ public void dropPrivilege(TSentryAuthorizable tAuthorizable)
+ throws SentryNoSuchObjectException, SentryInvalidInputException {
+ PersistenceManager pm = null;
+ boolean rollbackTransaction = true;
+
+ TSentryPrivilege tPrivilege = toSentryPrivilege(tAuthorizable);
+ try {
+ pm = openTransaction();
+
+ if (isMultiActionsSupported(tPrivilege)) {
+ for (String privilegeAction : Sets.newHashSet(AccessConstants.ALL,
+ AccessConstants.SELECT, AccessConstants.INSERT)) {
+ tPrivilege.setAction(privilegeAction);
+ dropPrivilegeForAllRoles(pm, new TSentryPrivilege(tPrivilege));
+ }
+ } else {
+ dropPrivilegeForAllRoles(pm, new TSentryPrivilege(tPrivilege));
+ }
+ rollbackTransaction = false;
+ commitTransaction(pm);
+ } catch (JDODataStoreException e) {
+ throw new SentryInvalidInputException("Failed to get privileges: "
+ + e.getMessage());
+ } finally {
+ if (rollbackTransaction) {
+ rollbackTransaction(pm);
+ }
+ }
+ }
+
+ /**
+ * Rename given privilege from all roles drop the old privilege and create the new one
+ * @param tAuthorizable
+ * @param newTAuthorizable
+ * @throws SentryNoSuchObjectException
+ * @throws SentryInvalidInputException
+ */
+ public void renamePrivilege(TSentryAuthorizable tAuthorizable,
+ TSentryAuthorizable newTAuthorizable) throws SentryNoSuchObjectException,
+ SentryInvalidInputException {
+ PersistenceManager pm = null;
+ boolean rollbackTransaction = true;
+ TSentryPrivilege tPrivilege = toSentryPrivilege(tAuthorizable);
+ TSentryPrivilege newPrivilege = toSentryPrivilege(newTAuthorizable);
+ try {
+ pm = openTransaction();
+ // In case of tables or DBs, check all actions
+ if (isMultiActionsSupported(tPrivilege)) {
+ for (String privilegeAction : Sets.newHashSet(AccessConstants.ALL,
+ AccessConstants.SELECT, AccessConstants.INSERT)) {
+ tPrivilege.setAction(privilegeAction);
+ newPrivilege.setAction(privilegeAction);
+ renamePrivilegeForAllRoles(pm, tPrivilege, newPrivilege);
+ }
+ } else {
+ renamePrivilegeForAllRoles(pm, tPrivilege, newPrivilege);
+ }
+ rollbackTransaction = false;
+ commitTransaction(pm);
+ } catch (JDODataStoreException e) {
+ throw new SentryInvalidInputException("Failed to get privileges: "
+ + e.getMessage());
+ } finally {
+ if (rollbackTransaction) {
+ rollbackTransaction(pm);
+ }
+ }
+ }
+
+ // Currently INSERT/SELECT/ALL are supported for Table and DB level privileges
+ private boolean isMultiActionsSupported(TSentryPrivilege tPrivilege) {
+ return tPrivilege.getDbName() != null;
+
+ }
+ // wrapper for dropOrRename
+ private void renamePrivilegeForAllRoles(PersistenceManager pm,
+ TSentryPrivilege tPrivilege,
+ TSentryPrivilege newPrivilege) throws SentryNoSuchObjectException,
+ SentryInvalidInputException {
+ dropOrRenamePrivilegeForAllRoles(pm, tPrivilege, newPrivilege);
+ }
+
+ /**
+ * Drop given privilege from all roles
+ * @param tPrivilege
+ * @throws SentryNoSuchObjectException
+ * @throws SentryInvalidInputException
+ */
+ private void dropPrivilegeForAllRoles(PersistenceManager pm,
+ TSentryPrivilege tPrivilege)
+ throws SentryNoSuchObjectException, SentryInvalidInputException {
+ dropOrRenamePrivilegeForAllRoles(pm, tPrivilege, null);
}
+ /**
+ * Drop given privilege from all roles Create the new privilege if asked
+ * @param tPrivilege
+ * @param pm
+ * @throws SentryNoSuchObjectException
+ * @throws SentryInvalidInputException
+ */
+ private void dropOrRenamePrivilegeForAllRoles(PersistenceManager pm,
+ TSentryPrivilege tPrivilege,
+ TSentryPrivilege newTPrivilege) throws SentryNoSuchObjectException,
+ SentryInvalidInputException {
+ HashSet<MSentryRole> roleSet = Sets.newHashSet();
+ tPrivilege.setPrivilegeName(constructPrivilegeName(tPrivilege));
+
+ MSentryPrivilege mPrivilege = getMSentryPrivilege(
+ tPrivilege.getPrivilegeName(), pm);
+ if (mPrivilege != null) {
+ roleSet.addAll(ImmutableSet.copyOf((mPrivilege.getRoles())));
+ }
+ for (MSentryRole role : roleSet) {
+ alterSentryRoleRevokePrivilegeCore(pm, role.getRoleName(), tPrivilege);
+ if (newTPrivilege != null) {
+ alterSentryRoleGrantPrivilegeCore(pm, role.getRoleName(), newTPrivilege);
+ }
+ }
+ }
+ // convert TSentryAuthorizable to TSentryPrivilege
+ private TSentryPrivilege toSentryPrivilege(TSentryAuthorizable tAuthorizable)
+ throws SentryInvalidInputException {
+ TSentryPrivilege tSentryPrivilege = new TSentryPrivilege();
+ tSentryPrivilege.setDbName(tAuthorizable.getDb());
+ tSentryPrivilege.setServerName(tAuthorizable.getServer());
+ tSentryPrivilege.setTableName(tAuthorizable.getTable());
+ tSentryPrivilege.setURI(tAuthorizable.getUri());
+ PrivilegeScope scope;
+ if (tSentryPrivilege.getTableName() != null) {
+ scope = PrivilegeScope.TABLE;
+ } else if (tSentryPrivilege.getDbName() != null) {
+ scope = PrivilegeScope.DATABASE;
+ } else if (tSentryPrivilege.getURI() != null) {
+ scope = PrivilegeScope.URI;
+ } else {
+ scope = PrivilegeScope.SERVER;
+ }
+ tSentryPrivilege.setPrivilegeScope(scope.name());
+ tSentryPrivilege.setAction(AccessConstants.ALL);
+ return tSentryPrivilege;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
index 2db73c6..5fd4f8f 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
@@ -55,6 +55,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
public class SentryPolicyServiceClient {
@@ -253,19 +254,7 @@ public class SentryPolicyServiceClient {
request.setRequestorUserName(requestorUserName);
request.setRoleName(roleName);
if (authorizable != null) {
- TSentryAuthorizable tSentryAuthorizable = new TSentryAuthorizable();
- // TODO : Needed to support SearchModelAuthorizable
- for (Authorizable authzble : authorizable) {
- if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.Server.toString())) {
- tSentryAuthorizable.setServer(authzble.getName());
- } else if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.URI.toString())) {
- tSentryAuthorizable.setUri(authzble.getName());
- } else if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.Db.toString())) {
- tSentryAuthorizable.setDb(authzble.getName());
- } else if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.Table.toString())) {
- tSentryAuthorizable.setTable(authzble.getName());
- }
- }
+ TSentryAuthorizable tSentryAuthorizable = setupSentryAuthorizable(authorizable);
request.setAuthorizableHierarchy(tSentryAuthorizable);
}
TListSentryPrivilegesResponse response;
@@ -317,6 +306,29 @@ public class SentryPolicyServiceClient {
db, table, action);
}
+ private TSentryAuthorizable setupSentryAuthorizable(
+ List<? extends Authorizable> authorizable) {
+ TSentryAuthorizable tSentryAuthorizable = new TSentryAuthorizable();
+
+ for (Authorizable authzble : authorizable) {
+ if (authzble.getTypeName().equalsIgnoreCase(
+ DBModelAuthorizable.AuthorizableType.Server.toString())) {
+ tSentryAuthorizable.setServer(authzble.getName());
+ } else if (authzble.getTypeName().equalsIgnoreCase(
+ DBModelAuthorizable.AuthorizableType.URI.toString())) {
+ tSentryAuthorizable.setUri(authzble.getName());
+ } else if (authzble.getTypeName().equalsIgnoreCase(
+ DBModelAuthorizable.AuthorizableType.Db.toString())) {
+ tSentryAuthorizable.setDb(authzble.getName());
+ } else if (authzble.getTypeName().equalsIgnoreCase(
+ DBModelAuthorizable.AuthorizableType.Table.toString())) {
+ tSentryAuthorizable.setTable(authzble.getName());
+ }
+ }
+ return tSentryAuthorizable;
+ }
+
+
private void grantPrivilege(String requestorUserName,
String roleName, PrivilegeScope scope, String serverName, String uri, String db, String table, String action)
throws SentryUserException {
@@ -403,19 +415,8 @@ public class SentryPolicyServiceClient {
new TListSentryPrivilegesForProviderRequest(ThriftConstants.
TSENTRY_SERVICE_VERSION_CURRENT, groups, thriftRoleSet);
if ((authorizable != null)&&(authorizable.length > 0)) {
- TSentryAuthorizable tSentryAuthorizable = new TSentryAuthorizable();
- // TODO : Needed to support SearchModelAuthorizable
- for (Authorizable authzble : authorizable) {
- if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.Server.toString())) {
- tSentryAuthorizable.setServer(authzble.getName());
- } else if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.URI.toString())) {
- tSentryAuthorizable.setUri(authzble.getName());
- } else if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.Db.toString())) {
- tSentryAuthorizable.setDb(authzble.getName());
- } else if (authzble.getTypeName().equalsIgnoreCase(DBModelAuthorizable.AuthorizableType.Table.toString())) {
- tSentryAuthorizable.setTable(authzble.getName());
- }
- }
+ TSentryAuthorizable tSentryAuthorizable = setupSentryAuthorizable(Lists
+ .newArrayList(authorizable));
request.setAuthorizableHierarchy(tSentryAuthorizable);
}
try {
@@ -455,6 +456,40 @@ TSENTRY_SERVICE_VERSION_CURRENT, requestorUserName,
}
}
+ public synchronized void dropPrivileges(String requestorUserName,
+ List<? extends Authorizable> authorizableObjects)
+ throws SentryUserException {
+ TSentryAuthorizable tSentryAuthorizable = setupSentryAuthorizable(authorizableObjects);
+
+ TDropPrivilegesRequest request = new TDropPrivilegesRequest(
+ ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT, requestorUserName,
+ tSentryAuthorizable);
+ try {
+ TDropPrivilegesResponse response = client.drop_sentry_privilege(request);
+ Status.throwIfNotOk(response.getStatus());
+ } catch (TException e) {
+ throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e);
+ }
+ }
+
+ public synchronized void renamePrivileges(String requestorUserName,
+ List<? extends Authorizable> oldAuthorizables,
+ List<? extends Authorizable> newAuthorizables) throws SentryUserException {
+ TSentryAuthorizable tOldSentryAuthorizable = setupSentryAuthorizable(oldAuthorizables);
+ TSentryAuthorizable tNewSentryAuthorizable = setupSentryAuthorizable(newAuthorizables);
+
+ TRenamePrivilegesRequest request = new TRenamePrivilegesRequest(
+ ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT, requestorUserName,
+ tOldSentryAuthorizable, tNewSentryAuthorizable);
+ try {
+ TRenamePrivilegesResponse response = client
+ .rename_sentry_privilege(request);
+ Status.throwIfNotOk(response.getStatus());
+ } catch (TException e) {
+ throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e);
+ }
+ }
+
public void close() {
if (transport != null) {
transport.close();
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
index 724dfa9..8964a18 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
@@ -447,4 +447,46 @@ public class SentryPolicyStoreProcessor implements SentryPolicyService.Iface {
}
return groupMappingService.getGroups(userName);
}
+
+ @Override
+ public TDropPrivilegesResponse drop_sentry_privilege(
+ TDropPrivilegesRequest request) throws TException {
+ TDropPrivilegesResponse response = new TDropPrivilegesResponse();
+ try {
+ authorize(request.getRequestorUserName(), adminGroups);
+ sentryStore.dropPrivilege(request.getAuthorizable());
+ response.setStatus(Status.OK());
+ } catch (SentryAccessDeniedException e) {
+ LOGGER.error(e.getMessage(), e);
+ response.setStatus(Status.AccessDenied(e.getMessage(), e));
+ } catch (Exception e) {
+ String msg = "Unknown error for request: " + request + ", message: "
+ + e.getMessage();
+ LOGGER.error(msg, e);
+ response.setStatus(Status.RuntimeError(msg, e));
+ }
+ return response;
+ }
+
+ @Override
+ public TRenamePrivilegesResponse rename_sentry_privilege(
+ TRenamePrivilegesRequest request) throws TException {
+ TRenamePrivilegesResponse response = new TRenamePrivilegesResponse();
+ try {
+ authorize(request.getRequestorUserName(), adminGroups);
+ sentryStore.renamePrivilege(request.getOldAuthorizable(),
+ request.getNewAuthorizable());
+ response.setStatus(Status.OK());
+ } catch (SentryAccessDeniedException e) {
+ LOGGER.error(e.getMessage(), e);
+ response.setStatus(Status.AccessDenied(e.getMessage(), e));
+ } catch (Exception e) {
+ String msg = "Unknown error for request: " + request + ", message: "
+ + e.getMessage();
+ LOGGER.error(msg, e);
+ response.setStatus(Status.RuntimeError(msg, e));
+ }
+ return response;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift b/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
index 86ff221..fdc7b9c 100644
--- a/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
+++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
@@ -149,6 +149,28 @@ struct TListSentryPrivilegesResponse {
2: optional set<TSentryPrivilege> privileges
}
+# Drop privilege
+struct TDropPrivilegesRequest {
+1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V1,
+2: required string requestorUserName, # user on whose behalf the request is issued
+3: required TSentryAuthorizable authorizable
+}
+
+struct TDropPrivilegesResponse {
+1: required sentry_common_service.TSentryResponseStatus status
+}
+
+struct TRenamePrivilegesRequest {
+1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V1,
+2: required string requestorUserName, # user on whose behalf the request is issued
+3: required TSentryAuthorizable oldAuthorizable
+4: required TSentryAuthorizable newAuthorizable
+}
+
+struct TRenamePrivilegesResponse {
+1: required sentry_common_service.TSentryResponseStatus status
+}
+
# This API was created specifically for ProviderBackend.getPrivileges
# and is not mean for general purpose privilege retrieval.
# This request/response pair are created specifically so we can
@@ -185,4 +207,8 @@ service SentryPolicyService
# For use with ProviderBackend.getPrivileges only
TListSentryPrivilegesForProviderResponse list_sentry_privileges_for_provider(1:TListSentryPrivilegesForProviderRequest request)
+
+ TDropPrivilegesResponse drop_sentry_privilege(1:TDropPrivilegesRequest request);
+
+ TRenamePrivilegesResponse rename_sentry_privilege(1:TRenamePrivilegesRequest request);
}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
index 144e20e..acc8b3a 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
@@ -353,4 +353,193 @@ public class TestSentryStore {
assertEquals(2, sentryStore.getTSentryRolesByGroupName(Sets.newHashSet(group2)).size());
assertEquals(3, sentryStore.getTSentryRolesByGroupName(Sets.newHashSet(group1,group2)).size());
}
+
+ /**
+ * Assign multiple table and SERVER privileges to roles
+ * drop privilege for the object verify that it's removed correctl
+ * @throws Exception
+ */
+ @Test
+ public void testDropDbObject() throws Exception {
+ String roleName1 = "list-privs-r1", roleName2 = "list-privs-r2", roleName3 = "list-privs-r3";
+ String grantor = "g1";
+ sentryStore.createSentryRole(roleName1, grantor);
+ sentryStore.createSentryRole(roleName2, grantor);
+ sentryStore.createSentryRole(roleName3, grantor);
+
+ TSentryPrivilege privilege_tbl1 = new TSentryPrivilege();
+ privilege_tbl1.setPrivilegeScope("TABLE");
+ privilege_tbl1.setServerName("server1");
+ privilege_tbl1.setDbName("db1");
+ privilege_tbl1.setTableName("tbl1");
+ privilege_tbl1.setGrantorPrincipal(grantor);
+ privilege_tbl1.setCreateTime(System.currentTimeMillis());
+ privilege_tbl1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege_tbl1));
+
+ TSentryPrivilege privilege1 = new TSentryPrivilege(privilege_tbl1);
+ privilege1.setAction("SELECT");
+ privilege1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege1));
+
+ TSentryPrivilege privilege2_1 = new TSentryPrivilege(privilege_tbl1);
+ privilege2_1.setAction("INSERT");
+ privilege2_1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege2_1));
+ TSentryPrivilege privilege3_1 = new TSentryPrivilege(privilege_tbl1);
+ privilege3_1.setAction("*");
+ privilege3_1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege3_1));
+
+ TSentryPrivilege privilege_server = new TSentryPrivilege();
+ privilege_server.setPrivilegeScope("SERVER");
+ privilege_server.setServerName("server1");
+ privilege_server.setGrantorPrincipal(grantor);
+ privilege_server.setCreateTime(System.currentTimeMillis());
+ privilege_server.setPrivilegeName(SentryStore.constructPrivilegeName(privilege_server));
+
+ TSentryPrivilege privilege_tbl2 = new TSentryPrivilege();
+ privilege_tbl2.setPrivilegeScope("TABLE");
+ privilege_tbl2.setServerName("server1");
+ privilege_tbl2.setDbName("db1");
+ privilege_tbl2.setTableName("tbl2");
+ privilege_tbl2.setGrantorPrincipal(grantor);
+ privilege_tbl2.setCreateTime(System.currentTimeMillis());
+
+ TSentryPrivilege privilege2_3 = new TSentryPrivilege(privilege_tbl2);
+ privilege2_3.setAction("SELECT");
+ privilege2_3.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege2_3));
+
+ TSentryPrivilege privilege3_2 = new TSentryPrivilege(privilege_tbl2);
+ privilege3_2.setAction("INSERT");
+ privilege2_3.setPrivilegeName(SentryStore.constructPrivilegeName(privilege2_3));
+
+ sentryStore.alterSentryRoleGrantPrivilege(roleName1, privilege1);
+
+ sentryStore.alterSentryRoleGrantPrivilege(roleName2, privilege2_1);
+ sentryStore.alterSentryRoleGrantPrivilege(roleName2, privilege_server);
+ sentryStore.alterSentryRoleGrantPrivilege(roleName2, privilege2_3);
+
+ sentryStore.alterSentryRoleGrantPrivilege(roleName3, privilege3_1);
+ sentryStore.alterSentryRoleGrantPrivilege(roleName3, privilege3_2);
+
+ sentryStore.dropPrivilege(toTSentryAuthorizable(privilege_tbl1));
+ assertEquals(0, sentryStore.getAllTSentryPrivilegesByRoleName(roleName1)
+ .size());
+ assertEquals(2, sentryStore.getAllTSentryPrivilegesByRoleName(roleName2)
+ .size());
+ assertEquals(1, sentryStore.getAllTSentryPrivilegesByRoleName(roleName3)
+ .size());
+
+ sentryStore.dropPrivilege(toTSentryAuthorizable(privilege_tbl2));
+ assertEquals(0, sentryStore.getAllTSentryPrivilegesByRoleName(roleName1)
+ .size());
+ assertEquals(1, sentryStore.getAllTSentryPrivilegesByRoleName(roleName2)
+ .size());
+ assertEquals(0, sentryStore.getAllTSentryPrivilegesByRoleName(roleName3)
+ .size());
+ }
+
+ @Test
+ public void testDropOverlappedPrivileges() throws Exception {
+ String roleName1 = "list-privs-r1";
+ String grantor = "g1";
+ sentryStore.createSentryRole(roleName1, grantor);
+
+ TSentryPrivilege privilege_tbl1 = new TSentryPrivilege();
+ privilege_tbl1.setPrivilegeScope("TABLE");
+ privilege_tbl1.setServerName("server1");
+ privilege_tbl1.setDbName("db1");
+ privilege_tbl1.setTableName("tbl1");
+ privilege_tbl1.setGrantorPrincipal(grantor);
+ privilege_tbl1.setCreateTime(System.currentTimeMillis());
+ privilege_tbl1.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege_tbl1));
+
+ TSentryPrivilege privilege_tbl1_insert = new TSentryPrivilege(
+ privilege_tbl1);
+ privilege_tbl1_insert.setAction("INSERT");
+ privilege_tbl1_insert.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege_tbl1_insert));
+
+ TSentryPrivilege privilege_tbl1_all = new TSentryPrivilege(privilege_tbl1);
+ privilege_tbl1_all.setAction("*");
+ privilege_tbl1_all.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege_tbl1_all));
+
+ sentryStore.alterSentryRoleGrantPrivilege(roleName1, privilege_tbl1_insert);
+ sentryStore.alterSentryRoleGrantPrivilege(roleName1, privilege_tbl1_all);
+
+ sentryStore.dropPrivilege(toTSentryAuthorizable(privilege_tbl1));
+ assertEquals(0, sentryStore.getAllTSentryPrivilegesByRoleName(roleName1)
+ .size());
+ }
+
+ private TSentryAuthorizable toTSentryAuthorizable(
+ TSentryPrivilege tSentryPrivilege) {
+ TSentryAuthorizable tSentryAuthorizable = new TSentryAuthorizable();
+ tSentryAuthorizable.setServer(tSentryPrivilege.getServerName());
+ tSentryAuthorizable.setDb(tSentryPrivilege.getDbName());
+ tSentryAuthorizable.setTable(tSentryPrivilege.getTableName());
+ tSentryAuthorizable.setUri(tSentryPrivilege.getURI());
+ return tSentryAuthorizable;
+ }
+
+ /***
+ * Create roles and assign privileges for same table rename the privileges for
+ * the table and verify the new privileges
+ * @throws Exception
+ */
+ @Test
+ public void testRenameTable() throws Exception {
+ String roleName1 = "role1", roleName2 = "role2", roleName3 = "role3";
+ String grantor = "g1";
+ String table1 = "tbl1", table2 = "tbl2";
+
+ sentryStore.createSentryRole(roleName1, grantor);
+ sentryStore.createSentryRole(roleName2, grantor);
+ sentryStore.createSentryRole(roleName3, grantor);
+
+ TSentryPrivilege privilege_tbl1 = new TSentryPrivilege();
+ privilege_tbl1.setPrivilegeScope("TABLE");
+ privilege_tbl1.setServerName("server1");
+ privilege_tbl1.setDbName("db1");
+ privilege_tbl1.setTableName(table1);
+ privilege_tbl1.setGrantorPrincipal(grantor);
+ privilege_tbl1.setCreateTime(System.currentTimeMillis());
+ privilege_tbl1.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege_tbl1));
+
+ TSentryPrivilege privilege_tbl1_insert = new TSentryPrivilege(
+ privilege_tbl1);
+ privilege_tbl1_insert.setAction(AccessConstants.INSERT);
+ privilege_tbl1_insert.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege_tbl1_insert));
+
+ TSentryPrivilege privilege_tbl1_select = new TSentryPrivilege(
+ privilege_tbl1);
+ privilege_tbl1_select.setAction(AccessConstants.SELECT);
+ privilege_tbl1_select.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege_tbl1_select));
+
+ TSentryPrivilege privilege_tbl1_all = new TSentryPrivilege(privilege_tbl1);
+ privilege_tbl1_all.setAction(AccessConstants.ALL);
+ privilege_tbl1_all.setPrivilegeName(SentryStore
+ .constructPrivilegeName(privilege_tbl1_all));
+
+ sentryStore.alterSentryRoleGrantPrivilege(roleName1, privilege_tbl1_insert);
+ sentryStore.alterSentryRoleGrantPrivilege(roleName2, privilege_tbl1_select);
+ sentryStore.alterSentryRoleGrantPrivilege(roleName3, privilege_tbl1_all);
+
+ TSentryAuthorizable oldTable = toTSentryAuthorizable(privilege_tbl1);
+ TSentryAuthorizable newTable = toTSentryAuthorizable(privilege_tbl1);
+ newTable.setTable(table2);
+ sentryStore.renamePrivilege(oldTable, newTable);
+
+ for (String roleName : Sets.newHashSet(roleName1, roleName2, roleName3)) {
+ Set<TSentryPrivilege> privilegeSet = sentryStore
+ .getAllTSentryPrivilegesByRoleName(roleName);
+ assertEquals(1, privilegeSet.size());
+ for (TSentryPrivilege privilege : privilegeSet) {
+ assertTrue(table2.equalsIgnoreCase(privilege.getTableName()));
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java
new file mode 100644
index 0000000..a885b8f
--- /dev/null
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java
@@ -0,0 +1,292 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sentry.tests.e2e.dbprovider;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+import com.google.common.io.Resources;
+
+public class TestDbPrivilegeCleanupOnDrop extends
+ AbstractTestWithStaticConfiguration {
+
+ private final static int SHOW_GRANT_TABLE_POSITION = 2;
+ private final static int SHOW_GRANT_DB_POSITION = 1;
+
+ private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
+
+ private final static String dbName1 = "db_1";
+ private final static String dbName2 = "prod";
+ private final static String tableName1 = "tb_1";
+ private final static String tableName2 = "tb_2";
+ private final static String tableName3 = "tb_3";
+ private final static String tableName4 = "tb_4";
+ private final static String renameTag = "_new";
+
+ @BeforeClass
+ public static void setupTestStaticConfiguration() throws Exception {
+ useSentryService = true;
+ setMetastoreListener = true;
+ AbstractTestWithStaticConfiguration.setupTestStaticConfiguration();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ // context = createContext();
+ File dataFile = new File(dataDir, SINGLE_TYPE_DATA_FILE_NAME);
+ setupAdmin();
+ FileOutputStream to = new FileOutputStream(dataFile);
+ Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to);
+ to.close();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ /**
+ * drop table and verify that the no privileges are referring to it drop db
+ * and verify that the no privileges are referring to it drop db cascade
+ * verify that the no privileges are referring to db and tables under it
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testDropObjects() throws Exception {
+ Connection connection = context.createConnection(ADMIN1);
+ Statement statement = context.createStatement(connection);
+
+ setupRoles(statement); // create required roles
+ setupDbObjects(statement); // create test DBs and Tables
+ setupPrivileges(statement); // setup privileges for USER1
+ dropDbObjects(statement); // drop objects
+ verifyPrivilegesDropped(statement); // verify privileges are removed
+
+ statement.close();
+ connection.close();
+ }
+
+ /**
+ * drop table and verify that the no privileges are referring to it drop db
+ * and verify that the no privileges are referring to it drop db cascade
+ * verify that the no privileges are referring to db and tables under it
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testReCreateObjects() throws Exception {
+ Connection connection = context.createConnection(ADMIN1);
+ Statement statement = context.createStatement(connection);
+ setupRoles(statement); // create required roles
+ setupDbObjects(statement); // create test DBs and Tables
+ setupPrivileges(statement); // setup privileges for USER1
+ dropDbObjects(statement); // drop DB and tables
+
+ setupDbObjects(statement); // recreate same DBs and tables
+ verifyPrivilegesDropped(statement); // verify the stale privileges removed
+ }
+
+ /**
+ * rename table and verify that the no privileges are referring to it old table
+ * verify that the same privileges are created for the new table name
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testRenameTables() throws Exception {
+ Connection connection = context.createConnection(ADMIN1);
+ Statement statement = context.createStatement(connection);
+
+ setupRoles(statement); // create required roles
+ setupDbObjects(statement); // create test DBs and Tables
+ setupPrivileges(statement); // setup privileges for USER1
+
+ // verify privileges on the created tables
+ statement.execute("USE " + dbName2);
+ verifyTablePrivilegeExist(statement,
+ Lists.newArrayList("select_tbl1", "insert_tbl1", "all_tbl1"),
+ tableName1);
+ verifyTablePrivilegeExist(statement, Lists.newArrayList("all_tbl2"),
+ tableName2);
+
+ renameTables(statement); // alter tables to rename
+
+ // verify privileges removed for old tables
+ verifyTablePrivilegesDropped(statement);
+
+ // verify privileges created for new tables
+ statement.execute("USE " + dbName2);
+ verifyTablePrivilegeExist(statement,
+ Lists.newArrayList("select_tbl1", "insert_tbl1", "all_tbl1"),
+ tableName1 + renameTag);
+ verifyTablePrivilegeExist(statement, Lists.newArrayList("all_tbl2"),
+ tableName2 + renameTag);
+
+ statement.close();
+ connection.close();
+ }
+
+ // Create test roles
+ private void setupRoles(Statement statement) throws Exception {
+ statement.execute("CREATE ROLE all_db1");
+ statement.execute("CREATE ROLE read_db1");
+ statement.execute("CREATE ROLE select_tbl1");
+ statement.execute("CREATE ROLE insert_tbl1");
+ statement.execute("CREATE ROLE all_tbl1");
+ statement.execute("CREATE ROLE all_tbl2");
+ statement.execute("CREATE ROLE all_prod");
+
+ statement.execute("GRANT ROLE all_db1, read_db1, select_tbl1, insert_tbl1,"
+ + " all_tbl1, all_tbl2, all_prod to GROUP " + USERGROUP1);
+
+ statement.execute("DROP DATABASE IF EXISTS " + dbName1 + " CASCADE");
+ statement.execute("DROP DATABASE IF EXISTS " + dbName2 + " CASCADE");
+ }
+
+ // create test DBs and Tables
+ private void setupDbObjects(Statement statement) throws Exception {
+ statement.execute("CREATE DATABASE " + dbName1);
+ statement.execute("CREATE DATABASE " + dbName2);
+ statement.execute("create table " + dbName2 + "." + tableName1
+ + " (under_col int comment 'the under column', value string)");
+ statement.execute("create table " + dbName2 + "." + tableName2
+ + " (under_col int comment 'the under column', value string)");
+ statement.execute("create table " + dbName1 + "." + tableName3
+ + " (under_col int comment 'the under column', value string)");
+ statement.execute("create table " + dbName1 + "." + tableName4
+ + " (under_col int comment 'the under column', value string)");
+ }
+
+ // Create privileges on DB and Tables
+ private void setupPrivileges(Statement statement) throws Exception {
+ statement.execute("GRANT ALL ON DATABASE " + dbName1 + " TO ROLE all_db1");
+ statement.execute("GRANT SELECT ON DATABASE " + dbName1
+ + " TO ROLE read_db1");
+ statement.execute("GRANT ALL ON DATABASE " + dbName2 + " TO ROLE all_prod");
+ statement.execute("USE " + dbName2);
+ statement.execute("GRANT SELECT ON TABLE " + tableName1
+ + " TO ROLE select_tbl1");
+ statement.execute("GRANT INSERT ON TABLE " + tableName1
+ + " TO ROLE insert_tbl1");
+ statement.execute("GRANT ALL ON TABLE " + tableName1 + " TO ROLE all_tbl1");
+ statement.execute("GRANT ALL ON TABLE " + tableName2 + " TO ROLE all_tbl2");
+ }
+
+ // Drop test DBs and Tables
+ private void dropDbObjects(Statement statement) throws Exception {
+ statement.execute("DROP TABLE " + dbName2 + "." + tableName1);
+ statement.execute("DROP TABLE " + dbName2 + "." + tableName2);
+ statement.execute("DROP DATABASE " + dbName2);
+ statement.execute("DROP DATABASE " + dbName1 + " CASCADE");
+ }
+
+ // rename tables
+ private void renameTables(Statement statement) throws Exception {
+ statement.execute("USE " + dbName2);
+ statement.execute("ALTER TABLE " + tableName1 + " RENAME TO " + tableName1
+ + renameTag);
+ statement.execute("ALTER TABLE " + tableName2 + " RENAME TO " + tableName2
+ + renameTag);
+ statement.execute("USE " + dbName1);
+ statement.execute("ALTER TABLE " + tableName3 + " RENAME TO " + tableName3
+ + renameTag);
+ statement.execute("ALTER TABLE " + tableName4 + " RENAME TO " + tableName4
+ + renameTag);
+ }
+
+ // verify all the test privileges are dropped as we drop the objects
+ private void verifyPrivilegesDropped(Statement statement)
+ throws Exception {
+ verifyDbPrivilegesDropped(statement);
+ verifyTablePrivilegesDropped(statement);
+ }
+
+ // verify all the test privileges are dropped as we drop the objects
+ private void verifyTablePrivilegesDropped(Statement statement)
+ throws Exception {
+ List<String> roles = getRoles(statement);
+ verifyPrivilegeDropped(statement, roles, tableName1,
+ SHOW_GRANT_TABLE_POSITION);
+ verifyPrivilegeDropped(statement, roles, tableName2,
+ SHOW_GRANT_TABLE_POSITION);
+ verifyPrivilegeDropped(statement, roles, tableName3,
+ SHOW_GRANT_TABLE_POSITION);
+ verifyPrivilegeDropped(statement, roles, tableName4,
+ SHOW_GRANT_TABLE_POSITION);
+
+ }
+
+ // verify all the test privileges are dropped as we drop the objects
+ private void verifyDbPrivilegesDropped(Statement statement) throws Exception {
+ List<String> roles = getRoles(statement);
+ verifyPrivilegeDropped(statement, roles, dbName2, SHOW_GRANT_DB_POSITION);
+ verifyPrivilegeDropped(statement, roles, dbName1, SHOW_GRANT_DB_POSITION);
+
+ }
+
+ // verify given table/DB has no longer permissions
+ private void verifyPrivilegeDropped(Statement statement, List<String> roles,
+ String objectName, int resultPos) throws Exception {
+ for (String roleName : roles) {
+ ResultSet resultSet = statement.executeQuery("SHOW GRANT ROLE "
+ + roleName);
+ while (resultSet.next()) {
+ assertFalse(objectName.equalsIgnoreCase(resultSet.getString(resultPos)));
+ }
+ resultSet.close();
+ }
+ }
+
+ // verify given table is part of the role
+ private void verifyTablePrivilegeExist(Statement statement,
+ List<String> roles, String tableName) throws Exception {
+ for (String roleName : roles) {
+ ResultSet resultSet = statement.executeQuery("SHOW GRANT ROLE "
+ + roleName + " ON TABLE " + tableName);
+ assertTrue(resultSet.next());
+ resultSet.close();
+ }
+ }
+
+ private List<String> getRoles(Statement statement) throws Exception {
+ ArrayList<String> roleList = Lists.newArrayList();
+ ResultSet resultSet = statement.executeQuery("SHOW ROLES ");
+ while (resultSet.next()) {
+ roleList.add(resultSet.getString(1));
+ }
+ return roleList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
index fd969a6..b92ca97 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
@@ -16,6 +16,10 @@
*/
package org.apache.sentry.tests.e2e.hive;
+import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER;
+import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX;
+import static org.apache.sentry.provider.common.ProviderConstants.ROLE_SPLITTER;
+
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
@@ -33,14 +37,13 @@ import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.sentry.binding.hive.SentryHiveAuthorizationTaskFactoryImpl;
+import org.apache.sentry.binding.metastore.SentryMetastorePostEventListener;
import org.apache.sentry.core.model.db.DBModelAction;
import org.apache.sentry.core.model.db.DBModelAuthorizable;
import org.apache.sentry.policy.db.DBModelAuthorizables;
-import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER;
-import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX;
-import static org.apache.sentry.provider.common.ProviderConstants.ROLE_SPLITTER;
import org.apache.sentry.provider.db.SimpleDBProviderBackend;
import org.apache.sentry.provider.file.PolicyFile;
import org.apache.sentry.service.thrift.SentryService;
@@ -103,8 +106,10 @@ public abstract class AbstractTestWithStaticConfiguration {
protected static boolean policy_on_hdfs = false;
protected static boolean useSentryService = false;
+ protected static boolean setMetastoreListener = false;
protected static String testServerType = null;
+
protected static File baseDir;
protected static File logDir;
protected static File confDir;
@@ -334,6 +339,10 @@ public abstract class AbstractTestWithStaticConfiguration {
sentryConf.set(ClientConfig.SERVER_RPC_PORT,
String.valueOf(sentryServer.getAddress().getPort()));
startSentryService();
+ if (setMetastoreListener) {
+ properties.put(HiveConf.ConfVars.METASTORE_EVENT_LISTENERS.varname,
+ SentryMetastorePostEventListener.class.getName());
+ }
}
private static void startSentryService() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
index 0165806..51acbf0 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
@@ -151,6 +151,7 @@ public class HiveServerFactory {
properties.put(METASTORE_BYPASS,
"hive,impala," + System.getProperty("user.name", ""));
}
+
properties.put(METASTORE_SETUGI, "true");
properties.put(METASTORE_CLIENT_TIMEOUT, "100");
properties.put(ConfVars.HIVE_WAREHOUSE_SUBDIR_INHERIT_PERMS.varname, "true");
[3/3] git commit: SENTRY-162: Cleanup DB store privilege metadata on
Hive DDL statements ( Prasad Mujumdar via Sravya Tirukkovalur)
Posted by sr...@apache.org.
SENTRY-162: Cleanup DB store privilege metadata on Hive DDL statements ( Prasad Mujumdar via Sravya Tirukkovalur)
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/b11f5aab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/b11f5aab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/b11f5aab
Branch: refs/heads/master
Commit: b11f5aab9970b56886c8c9a04f7598ba3b50879c
Parents: 5988495
Author: Sravya Tirukkovalur <sr...@clouera.com>
Authored: Mon Jun 23 12:21:36 2014 -0700
Committer: Sravya Tirukkovalur <sr...@clouera.com>
Committed: Mon Jun 23 12:21:36 2014 -0700
----------------------------------------------------------------------
.../sentry/binding/hive/conf/HiveAuthzConf.java | 3 +
.../SentryMetastorePostEventListener.java | 206 +++
.../db/service/thrift/SentryPolicyService.java | 1612 ++++++++++++++++++
.../service/thrift/TDropPrivilegesRequest.java | 592 +++++++
.../service/thrift/TDropPrivilegesResponse.java | 390 +++++
.../thrift/TRenamePrivilegesRequest.java | 698 ++++++++
.../thrift/TRenamePrivilegesResponse.java | 390 +++++
.../db/service/model/MSentryPrivilege.java | 4 +
.../db/service/persistent/SentryStore.java | 316 +++-
.../thrift/SentryPolicyServiceClient.java | 87 +-
.../thrift/SentryPolicyStoreProcessor.java | 42 +
.../main/resources/sentry_policy_service.thrift | 26 +
.../db/service/persistent/TestSentryStore.java | 189 ++
.../TestDbPrivilegeCleanupOnDrop.java | 292 ++++
.../AbstractTestWithStaticConfiguration.java | 15 +-
.../e2e/hive/hiveserver/HiveServerFactory.java | 1 +
16 files changed, 4757 insertions(+), 106 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/conf/HiveAuthzConf.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/conf/HiveAuthzConf.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/conf/HiveAuthzConf.java
index eb9ef00..1bb4a99 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/conf/HiveAuthzConf.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/conf/HiveAuthzConf.java
@@ -64,6 +64,9 @@ public class HiveAuthzConf extends Configuration {
AUTHZ_ALLOW_HIVE_IMPERSONATION("sentry.hive.allow.hive.impersonation", "false"),
AUTHZ_ONFAILURE_HOOKS("sentry.hive.failure.hooks", ""),
AUTHZ_METASTORE_SERVICE_USERS("sentry.metastore.service.users", ""),
+ AUTHZ_SYNC_ALTER_WITH_POLICY_STORE("sentry.hive.sync.alter", "true"),
+ AUTHZ_SYNC_CREATE_WITH_POLICY_STORE("sentry.hive.sync.create", "false"),
+ AUTHZ_SYNC_DROP_WITH_POLICY_STORE("sentry.hive.sync.drop", "true"),
AUTHZ_PROVIDER_DEPRECATED("hive.sentry.provider",
"org.apache.sentry.provider.file.ResourceAuthorizationProvider"),
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
new file mode 100644
index 0000000..5634879
--- /dev/null
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
@@ -0,0 +1,206 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sentry.binding.metastore;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.MetaStoreEventListener;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.events.AlterTableEvent;
+import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
+import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.DropTableEvent;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.sentry.SentryUserException;
+import org.apache.sentry.binding.hive.conf.HiveAuthzConf;
+import org.apache.sentry.binding.hive.conf.HiveAuthzConf.AuthzConfVars;
+import org.apache.sentry.core.common.Authorizable;
+import org.apache.sentry.core.model.db.Database;
+import org.apache.sentry.core.model.db.Server;
+import org.apache.sentry.core.model.db.Table;
+import org.apache.sentry.provider.db.service.thrift.SentryPolicyServiceClient;
+import org.apache.sentry.service.thrift.SentryServiceClientFactory;
+
+public class SentryMetastorePostEventListener extends MetaStoreEventListener {
+ private final SentryServiceClientFactory sentryClientFactory;
+ private final HiveAuthzConf authzConf;
+ private final Server server;
+
+ public SentryMetastorePostEventListener(Configuration config) {
+ super(config);
+ sentryClientFactory = new SentryServiceClientFactory();
+ authzConf = HiveAuthzConf.getAuthzConf(new HiveConf());
+ server = new Server(authzConf.get(AuthzConfVars.AUTHZ_SERVER_NAME.getVar()));
+ }
+
+ @Override
+ public void onCreateTable (CreateTableEvent tableEvent) throws MetaException {
+ // drop the privileges on the given table, in case if anything was left
+ // behind during the drop
+ if (!syncWithPolicyStore(AuthzConfVars.AUTHZ_SYNC_CREATE_WITH_POLICY_STORE)) {
+ return;
+ }
+ dropSentryTablePrivilege(tableEvent.getTable().getDbName(),
+ tableEvent.getTable().getTableName());
+ }
+
+ @Override
+ public void onDropTable(DropTableEvent tableEvent) throws MetaException {
+ // drop the privileges on the given table
+ if (!syncWithPolicyStore(AuthzConfVars.AUTHZ_SYNC_DROP_WITH_POLICY_STORE)) {
+ return;
+ }
+ dropSentryTablePrivilege(tableEvent.getTable().getDbName(),
+ tableEvent.getTable().getTableName());
+ }
+
+ @Override
+ public void onCreateDatabase(CreateDatabaseEvent dbEvent)
+ throws MetaException {
+ // drop the privileges on the database, incase anything left behind during
+ // last drop db
+ if (!syncWithPolicyStore(AuthzConfVars.AUTHZ_SYNC_CREATE_WITH_POLICY_STORE)) {
+ return;
+ }
+ dropSentryDbPrivileges(dbEvent.getDatabase().getName());
+ }
+
+ /**
+ * Drop the privileges on the database // note that child tables will be
+ * dropped individually by client, so we // just need to handle the removing
+ * the db privileges. The table drop // should cleanup the table privileges
+ */
+ @Override
+ public void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException {
+ if (!syncWithPolicyStore(AuthzConfVars.AUTHZ_SYNC_DROP_WITH_POLICY_STORE)) {
+ return;
+ }
+ dropSentryDbPrivileges(dbEvent.getDatabase().getName());
+ }
+
+ /**
+ * Adjust the privileges when table is renamed
+ */
+ @Override
+ public void onAlterTable (AlterTableEvent tableEvent) throws MetaException {
+ String oldTableName = null, newTableName = null;
+ if (!syncWithPolicyStore(AuthzConfVars.AUTHZ_SYNC_ALTER_WITH_POLICY_STORE)) {
+ return;
+ }
+ if (tableEvent.getOldTable() != null) {
+ oldTableName = tableEvent.getOldTable().getTableName();
+ }
+ if (tableEvent.getNewTable() != null) {
+ newTableName = tableEvent.getNewTable().getTableName();
+ }
+ if (!oldTableName.equalsIgnoreCase(newTableName)) {
+ renameSentryTablePrivilege(tableEvent.getOldTable().getDbName(),
+ oldTableName, tableEvent.getNewTable().getDbName(), newTableName);
+ }
+ }
+
+ private SentryPolicyServiceClient getSentryServiceClient()
+ throws MetaException {
+ try {
+ return sentryClientFactory.create(getConf());
+ } catch (Exception e) {
+ throw new MetaException("Failed to connect to Sentry service "
+ + e.getMessage());
+ }
+ }
+
+ private void dropSentryDbPrivileges(String dbName) throws MetaException {
+ List<Authorizable> authorizableTable = new ArrayList<Authorizable>();
+ authorizableTable.add(server);
+ authorizableTable.add(new Database(dbName));
+ try {
+ dropSentryPrivileges(authorizableTable);
+ } catch (SentryUserException e) {
+ throw new MetaException("Failed to remove Sentry policies for drop DB "
+ + dbName + " Error: " + e.getMessage());
+ } catch (IOException e) {
+ throw new MetaException("Failed to find local user " + e.getMessage());
+ }
+
+ }
+
+ private void dropSentryTablePrivilege(String dbName, String tabName)
+ throws MetaException {
+ List<Authorizable> authorizableTable = new ArrayList<Authorizable>();
+ authorizableTable.add(server);
+ authorizableTable.add(new Database(dbName));
+ authorizableTable.add(new Table(tabName));
+
+ try {
+ dropSentryPrivileges(authorizableTable);
+ } catch (SentryUserException e) {
+ throw new MetaException(
+ "Failed to remove Sentry policies for drop table " + dbName + "."
+ + tabName + " Error: " + e.getMessage());
+ } catch (IOException e) {
+ throw new MetaException("Failed to find local user " + e.getMessage());
+ }
+
+ }
+ private void dropSentryPrivileges(
+ List<? extends Authorizable> authorizableTable)
+ throws SentryUserException, IOException, MetaException {
+ String requestorUserName = UserGroupInformation.getCurrentUser()
+ .getShortUserName();
+ SentryPolicyServiceClient sentryClient = getSentryServiceClient();
+ sentryClient.dropPrivileges(requestorUserName, authorizableTable);
+ }
+
+ private void renameSentryTablePrivilege(String oldDbName, String oldTabName,
+ String newDbName, String newTabName)
+ throws MetaException {
+ List<Authorizable> oldAuthorizableTable = new ArrayList<Authorizable>();
+ oldAuthorizableTable.add(server);
+ oldAuthorizableTable.add(new Database(oldDbName));
+ oldAuthorizableTable.add(new Table(oldTabName));
+
+ List<Authorizable> newAuthorizableTable = new ArrayList<Authorizable>();
+ newAuthorizableTable.add(server);
+ newAuthorizableTable.add(new Database(newDbName));
+ newAuthorizableTable.add(new Table(newTabName));
+
+ try {
+ String requestorUserName = UserGroupInformation.getCurrentUser()
+ .getShortUserName();
+ SentryPolicyServiceClient sentryClient = getSentryServiceClient();
+ sentryClient.renamePrivileges(requestorUserName, oldAuthorizableTable, newAuthorizableTable);
+ } catch (SentryUserException e) {
+ throw new MetaException(
+ "Failed to remove Sentry policies for rename table " + oldDbName
+ + "." + oldTabName + "to " + newDbName + "." + newTabName
+ + " Error: " + e.getMessage());
+ } catch (IOException e) {
+ throw new MetaException("Failed to find local user " + e.getMessage());
+ }
+ }
+
+ private boolean syncWithPolicyStore(AuthzConfVars syncConfVar) {
+ return "true"
+ .equalsIgnoreCase((authzConf.get(syncConfVar.getVar(), "true")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
index ff09fdf..8a006aa 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
@@ -53,6 +53,10 @@ public class SentryPolicyService {
public TListSentryPrivilegesForProviderResponse list_sentry_privileges_for_provider(TListSentryPrivilegesForProviderRequest request) throws org.apache.thrift.TException;
+ public TDropPrivilegesResponse drop_sentry_privilege(TDropPrivilegesRequest request) throws org.apache.thrift.TException;
+
+ public TRenamePrivilegesResponse rename_sentry_privilege(TRenamePrivilegesRequest request) throws org.apache.thrift.TException;
+
}
public interface AsyncIface {
@@ -75,6 +79,10 @@ public class SentryPolicyService {
public void list_sentry_privileges_for_provider(TListSentryPrivilegesForProviderRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.list_sentry_privileges_for_provider_call> resultHandler) throws org.apache.thrift.TException;
+ public void drop_sentry_privilege(TDropPrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.drop_sentry_privilege_call> resultHandler) throws org.apache.thrift.TException;
+
+ public void rename_sentry_privilege(TRenamePrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.rename_sentry_privilege_call> resultHandler) throws org.apache.thrift.TException;
+
}
public static class Client extends org.apache.thrift.TServiceClient implements Iface {
@@ -304,6 +312,52 @@ public class SentryPolicyService {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "list_sentry_privileges_for_provider failed: unknown result");
}
+ public TDropPrivilegesResponse drop_sentry_privilege(TDropPrivilegesRequest request) throws org.apache.thrift.TException
+ {
+ send_drop_sentry_privilege(request);
+ return recv_drop_sentry_privilege();
+ }
+
+ public void send_drop_sentry_privilege(TDropPrivilegesRequest request) throws org.apache.thrift.TException
+ {
+ drop_sentry_privilege_args args = new drop_sentry_privilege_args();
+ args.setRequest(request);
+ sendBase("drop_sentry_privilege", args);
+ }
+
+ public TDropPrivilegesResponse recv_drop_sentry_privilege() throws org.apache.thrift.TException
+ {
+ drop_sentry_privilege_result result = new drop_sentry_privilege_result();
+ receiveBase(result, "drop_sentry_privilege");
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "drop_sentry_privilege failed: unknown result");
+ }
+
+ public TRenamePrivilegesResponse rename_sentry_privilege(TRenamePrivilegesRequest request) throws org.apache.thrift.TException
+ {
+ send_rename_sentry_privilege(request);
+ return recv_rename_sentry_privilege();
+ }
+
+ public void send_rename_sentry_privilege(TRenamePrivilegesRequest request) throws org.apache.thrift.TException
+ {
+ rename_sentry_privilege_args args = new rename_sentry_privilege_args();
+ args.setRequest(request);
+ sendBase("rename_sentry_privilege", args);
+ }
+
+ public TRenamePrivilegesResponse recv_rename_sentry_privilege() throws org.apache.thrift.TException
+ {
+ rename_sentry_privilege_result result = new rename_sentry_privilege_result();
+ receiveBase(result, "rename_sentry_privilege");
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "rename_sentry_privilege failed: unknown result");
+ }
+
}
public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
@@ -610,6 +664,70 @@ public class SentryPolicyService {
}
}
+ public void drop_sentry_privilege(TDropPrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<drop_sentry_privilege_call> resultHandler) throws org.apache.thrift.TException {
+ checkReady();
+ drop_sentry_privilege_call method_call = new drop_sentry_privilege_call(request, resultHandler, this, ___protocolFactory, ___transport);
+ this.___currentMethod = method_call;
+ ___manager.call(method_call);
+ }
+
+ public static class drop_sentry_privilege_call extends org.apache.thrift.async.TAsyncMethodCall {
+ private TDropPrivilegesRequest request;
+ public drop_sentry_privilege_call(TDropPrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<drop_sentry_privilege_call> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ super(client, protocolFactory, transport, resultHandler, false);
+ this.request = request;
+ }
+
+ public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+ prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("drop_sentry_privilege", org.apache.thrift.protocol.TMessageType.CALL, 0));
+ drop_sentry_privilege_args args = new drop_sentry_privilege_args();
+ args.setRequest(request);
+ args.write(prot);
+ prot.writeMessageEnd();
+ }
+
+ public TDropPrivilegesResponse getResult() throws org.apache.thrift.TException {
+ if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
+ throw new IllegalStateException("Method call not finished!");
+ }
+ org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
+ org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
+ return (new Client(prot)).recv_drop_sentry_privilege();
+ }
+ }
+
+ public void rename_sentry_privilege(TRenamePrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<rename_sentry_privilege_call> resultHandler) throws org.apache.thrift.TException {
+ checkReady();
+ rename_sentry_privilege_call method_call = new rename_sentry_privilege_call(request, resultHandler, this, ___protocolFactory, ___transport);
+ this.___currentMethod = method_call;
+ ___manager.call(method_call);
+ }
+
+ public static class rename_sentry_privilege_call extends org.apache.thrift.async.TAsyncMethodCall {
+ private TRenamePrivilegesRequest request;
+ public rename_sentry_privilege_call(TRenamePrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<rename_sentry_privilege_call> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ super(client, protocolFactory, transport, resultHandler, false);
+ this.request = request;
+ }
+
+ public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+ prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("rename_sentry_privilege", org.apache.thrift.protocol.TMessageType.CALL, 0));
+ rename_sentry_privilege_args args = new rename_sentry_privilege_args();
+ args.setRequest(request);
+ args.write(prot);
+ prot.writeMessageEnd();
+ }
+
+ public TRenamePrivilegesResponse getResult() throws org.apache.thrift.TException {
+ if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
+ throw new IllegalStateException("Method call not finished!");
+ }
+ org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
+ org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
+ return (new Client(prot)).recv_rename_sentry_privilege();
+ }
+ }
+
}
public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
@@ -632,6 +750,8 @@ public class SentryPolicyService {
processMap.put("list_sentry_roles_by_group", new list_sentry_roles_by_group());
processMap.put("list_sentry_privileges_by_role", new list_sentry_privileges_by_role());
processMap.put("list_sentry_privileges_for_provider", new list_sentry_privileges_for_provider());
+ processMap.put("drop_sentry_privilege", new drop_sentry_privilege());
+ processMap.put("rename_sentry_privilege", new rename_sentry_privilege());
return processMap;
}
@@ -815,6 +935,46 @@ public class SentryPolicyService {
}
}
+ public static class drop_sentry_privilege<I extends Iface> extends org.apache.thrift.ProcessFunction<I, drop_sentry_privilege_args> {
+ public drop_sentry_privilege() {
+ super("drop_sentry_privilege");
+ }
+
+ public drop_sentry_privilege_args getEmptyArgsInstance() {
+ return new drop_sentry_privilege_args();
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public drop_sentry_privilege_result getResult(I iface, drop_sentry_privilege_args args) throws org.apache.thrift.TException {
+ drop_sentry_privilege_result result = new drop_sentry_privilege_result();
+ result.success = iface.drop_sentry_privilege(args.request);
+ return result;
+ }
+ }
+
+ public static class rename_sentry_privilege<I extends Iface> extends org.apache.thrift.ProcessFunction<I, rename_sentry_privilege_args> {
+ public rename_sentry_privilege() {
+ super("rename_sentry_privilege");
+ }
+
+ public rename_sentry_privilege_args getEmptyArgsInstance() {
+ return new rename_sentry_privilege_args();
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public rename_sentry_privilege_result getResult(I iface, rename_sentry_privilege_args args) throws org.apache.thrift.TException {
+ rename_sentry_privilege_result result = new rename_sentry_privilege_result();
+ result.success = iface.rename_sentry_privilege(args.request);
+ return result;
+ }
+ }
+
}
public static class create_sentry_role_args implements org.apache.thrift.TBase<create_sentry_role_args, create_sentry_role_args._Fields>, java.io.Serializable, Cloneable {
@@ -7351,4 +7511,1456 @@ public class SentryPolicyService {
}
+ public static class drop_sentry_privilege_args implements org.apache.thrift.TBase<drop_sentry_privilege_args, drop_sentry_privilege_args._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("drop_sentry_privilege_args");
+
+ private static final org.apache.thrift.protocol.TField REQUEST_FIELD_DESC = new org.apache.thrift.protocol.TField("request", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new drop_sentry_privilege_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new drop_sentry_privilege_argsTupleSchemeFactory());
+ }
+
+ private TDropPrivilegesRequest request; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ REQUEST((short)1, "request");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // REQUEST
+ return REQUEST;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.REQUEST, new org.apache.thrift.meta_data.FieldMetaData("request", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TDropPrivilegesRequest.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(drop_sentry_privilege_args.class, metaDataMap);
+ }
+
+ public drop_sentry_privilege_args() {
+ }
+
+ public drop_sentry_privilege_args(
+ TDropPrivilegesRequest request)
+ {
+ this();
+ this.request = request;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public drop_sentry_privilege_args(drop_sentry_privilege_args other) {
+ if (other.isSetRequest()) {
+ this.request = new TDropPrivilegesRequest(other.request);
+ }
+ }
+
+ public drop_sentry_privilege_args deepCopy() {
+ return new drop_sentry_privilege_args(this);
+ }
+
+ @Override
+ public void clear() {
+ this.request = null;
+ }
+
+ public TDropPrivilegesRequest getRequest() {
+ return this.request;
+ }
+
+ public void setRequest(TDropPrivilegesRequest request) {
+ this.request = request;
+ }
+
+ public void unsetRequest() {
+ this.request = null;
+ }
+
+ /** Returns true if field request is set (has been assigned a value) and false otherwise */
+ public boolean isSetRequest() {
+ return this.request != null;
+ }
+
+ public void setRequestIsSet(boolean value) {
+ if (!value) {
+ this.request = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case REQUEST:
+ if (value == null) {
+ unsetRequest();
+ } else {
+ setRequest((TDropPrivilegesRequest)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case REQUEST:
+ return getRequest();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case REQUEST:
+ return isSetRequest();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof drop_sentry_privilege_args)
+ return this.equals((drop_sentry_privilege_args)that);
+ return false;
+ }
+
+ public boolean equals(drop_sentry_privilege_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_request = true && this.isSetRequest();
+ boolean that_present_request = true && that.isSetRequest();
+ if (this_present_request || that_present_request) {
+ if (!(this_present_request && that_present_request))
+ return false;
+ if (!this.request.equals(that.request))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_request = true && (isSetRequest());
+ builder.append(present_request);
+ if (present_request)
+ builder.append(request);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(drop_sentry_privilege_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ drop_sentry_privilege_args typedOther = (drop_sentry_privilege_args)other;
+
+ lastComparison = Boolean.valueOf(isSetRequest()).compareTo(typedOther.isSetRequest());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetRequest()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.request, typedOther.request);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("drop_sentry_privilege_args(");
+ boolean first = true;
+
+ sb.append("request:");
+ if (this.request == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.request);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ if (request != null) {
+ request.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class drop_sentry_privilege_argsStandardSchemeFactory implements SchemeFactory {
+ public drop_sentry_privilege_argsStandardScheme getScheme() {
+ return new drop_sentry_privilege_argsStandardScheme();
+ }
+ }
+
+ private static class drop_sentry_privilege_argsStandardScheme extends StandardScheme<drop_sentry_privilege_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, drop_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // REQUEST
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.request = new TDropPrivilegesRequest();
+ struct.request.read(iprot);
+ struct.setRequestIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, drop_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.request != null) {
+ oprot.writeFieldBegin(REQUEST_FIELD_DESC);
+ struct.request.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class drop_sentry_privilege_argsTupleSchemeFactory implements SchemeFactory {
+ public drop_sentry_privilege_argsTupleScheme getScheme() {
+ return new drop_sentry_privilege_argsTupleScheme();
+ }
+ }
+
+ private static class drop_sentry_privilege_argsTupleScheme extends TupleScheme<drop_sentry_privilege_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, drop_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetRequest()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetRequest()) {
+ struct.request.write(oprot);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, drop_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.request = new TDropPrivilegesRequest();
+ struct.request.read(iprot);
+ struct.setRequestIsSet(true);
+ }
+ }
+ }
+
+ }
+
+ public static class drop_sentry_privilege_result implements org.apache.thrift.TBase<drop_sentry_privilege_result, drop_sentry_privilege_result._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("drop_sentry_privilege_result");
+
+ private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new drop_sentry_privilege_resultStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new drop_sentry_privilege_resultTupleSchemeFactory());
+ }
+
+ private TDropPrivilegesResponse success; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 0: // SUCCESS
+ return SUCCESS;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TDropPrivilegesResponse.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(drop_sentry_privilege_result.class, metaDataMap);
+ }
+
+ public drop_sentry_privilege_result() {
+ }
+
+ public drop_sentry_privilege_result(
+ TDropPrivilegesResponse success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public drop_sentry_privilege_result(drop_sentry_privilege_result other) {
+ if (other.isSetSuccess()) {
+ this.success = new TDropPrivilegesResponse(other.success);
+ }
+ }
+
+ public drop_sentry_privilege_result deepCopy() {
+ return new drop_sentry_privilege_result(this);
+ }
+
+ @Override
+ public void clear() {
+ this.success = null;
+ }
+
+ public TDropPrivilegesResponse getSuccess() {
+ return this.success;
+ }
+
+ public void setSuccess(TDropPrivilegesResponse success) {
+ this.success = success;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been assigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((TDropPrivilegesResponse)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof drop_sentry_privilege_result)
+ return this.equals((drop_sentry_privilege_result)that);
+ return false;
+ }
+
+ public boolean equals(drop_sentry_privilege_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_success = true && (isSetSuccess());
+ builder.append(present_success);
+ if (present_success)
+ builder.append(success);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(drop_sentry_privilege_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ drop_sentry_privilege_result typedOther = (drop_sentry_privilege_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetSuccess()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("drop_sentry_privilege_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ if (success != null) {
+ success.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class drop_sentry_privilege_resultStandardSchemeFactory implements SchemeFactory {
+ public drop_sentry_privilege_resultStandardScheme getScheme() {
+ return new drop_sentry_privilege_resultStandardScheme();
+ }
+ }
+
+ private static class drop_sentry_privilege_resultStandardScheme extends StandardScheme<drop_sentry_privilege_result> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, drop_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 0: // SUCCESS
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.success = new TDropPrivilegesResponse();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, drop_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.success != null) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ struct.success.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class drop_sentry_privilege_resultTupleSchemeFactory implements SchemeFactory {
+ public drop_sentry_privilege_resultTupleScheme getScheme() {
+ return new drop_sentry_privilege_resultTupleScheme();
+ }
+ }
+
+ private static class drop_sentry_privilege_resultTupleScheme extends TupleScheme<drop_sentry_privilege_result> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, drop_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetSuccess()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetSuccess()) {
+ struct.success.write(oprot);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, drop_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.success = new TDropPrivilegesResponse();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(true);
+ }
+ }
+ }
+
+ }
+
+ public static class rename_sentry_privilege_args implements org.apache.thrift.TBase<rename_sentry_privilege_args, rename_sentry_privilege_args._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("rename_sentry_privilege_args");
+
+ private static final org.apache.thrift.protocol.TField REQUEST_FIELD_DESC = new org.apache.thrift.protocol.TField("request", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new rename_sentry_privilege_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new rename_sentry_privilege_argsTupleSchemeFactory());
+ }
+
+ private TRenamePrivilegesRequest request; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ REQUEST((short)1, "request");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // REQUEST
+ return REQUEST;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.REQUEST, new org.apache.thrift.meta_data.FieldMetaData("request", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TRenamePrivilegesRequest.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(rename_sentry_privilege_args.class, metaDataMap);
+ }
+
+ public rename_sentry_privilege_args() {
+ }
+
+ public rename_sentry_privilege_args(
+ TRenamePrivilegesRequest request)
+ {
+ this();
+ this.request = request;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public rename_sentry_privilege_args(rename_sentry_privilege_args other) {
+ if (other.isSetRequest()) {
+ this.request = new TRenamePrivilegesRequest(other.request);
+ }
+ }
+
+ public rename_sentry_privilege_args deepCopy() {
+ return new rename_sentry_privilege_args(this);
+ }
+
+ @Override
+ public void clear() {
+ this.request = null;
+ }
+
+ public TRenamePrivilegesRequest getRequest() {
+ return this.request;
+ }
+
+ public void setRequest(TRenamePrivilegesRequest request) {
+ this.request = request;
+ }
+
+ public void unsetRequest() {
+ this.request = null;
+ }
+
+ /** Returns true if field request is set (has been assigned a value) and false otherwise */
+ public boolean isSetRequest() {
+ return this.request != null;
+ }
+
+ public void setRequestIsSet(boolean value) {
+ if (!value) {
+ this.request = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case REQUEST:
+ if (value == null) {
+ unsetRequest();
+ } else {
+ setRequest((TRenamePrivilegesRequest)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case REQUEST:
+ return getRequest();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case REQUEST:
+ return isSetRequest();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof rename_sentry_privilege_args)
+ return this.equals((rename_sentry_privilege_args)that);
+ return false;
+ }
+
+ public boolean equals(rename_sentry_privilege_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_request = true && this.isSetRequest();
+ boolean that_present_request = true && that.isSetRequest();
+ if (this_present_request || that_present_request) {
+ if (!(this_present_request && that_present_request))
+ return false;
+ if (!this.request.equals(that.request))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_request = true && (isSetRequest());
+ builder.append(present_request);
+ if (present_request)
+ builder.append(request);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(rename_sentry_privilege_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ rename_sentry_privilege_args typedOther = (rename_sentry_privilege_args)other;
+
+ lastComparison = Boolean.valueOf(isSetRequest()).compareTo(typedOther.isSetRequest());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetRequest()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.request, typedOther.request);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("rename_sentry_privilege_args(");
+ boolean first = true;
+
+ sb.append("request:");
+ if (this.request == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.request);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ if (request != null) {
+ request.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class rename_sentry_privilege_argsStandardSchemeFactory implements SchemeFactory {
+ public rename_sentry_privilege_argsStandardScheme getScheme() {
+ return new rename_sentry_privilege_argsStandardScheme();
+ }
+ }
+
+ private static class rename_sentry_privilege_argsStandardScheme extends StandardScheme<rename_sentry_privilege_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, rename_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // REQUEST
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.request = new TRenamePrivilegesRequest();
+ struct.request.read(iprot);
+ struct.setRequestIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, rename_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.request != null) {
+ oprot.writeFieldBegin(REQUEST_FIELD_DESC);
+ struct.request.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class rename_sentry_privilege_argsTupleSchemeFactory implements SchemeFactory {
+ public rename_sentry_privilege_argsTupleScheme getScheme() {
+ return new rename_sentry_privilege_argsTupleScheme();
+ }
+ }
+
+ private static class rename_sentry_privilege_argsTupleScheme extends TupleScheme<rename_sentry_privilege_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, rename_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetRequest()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetRequest()) {
+ struct.request.write(oprot);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, rename_sentry_privilege_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.request = new TRenamePrivilegesRequest();
+ struct.request.read(iprot);
+ struct.setRequestIsSet(true);
+ }
+ }
+ }
+
+ }
+
+ public static class rename_sentry_privilege_result implements org.apache.thrift.TBase<rename_sentry_privilege_result, rename_sentry_privilege_result._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("rename_sentry_privilege_result");
+
+ private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new rename_sentry_privilege_resultStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new rename_sentry_privilege_resultTupleSchemeFactory());
+ }
+
+ private TRenamePrivilegesResponse success; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 0: // SUCCESS
+ return SUCCESS;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TRenamePrivilegesResponse.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(rename_sentry_privilege_result.class, metaDataMap);
+ }
+
+ public rename_sentry_privilege_result() {
+ }
+
+ public rename_sentry_privilege_result(
+ TRenamePrivilegesResponse success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public rename_sentry_privilege_result(rename_sentry_privilege_result other) {
+ if (other.isSetSuccess()) {
+ this.success = new TRenamePrivilegesResponse(other.success);
+ }
+ }
+
+ public rename_sentry_privilege_result deepCopy() {
+ return new rename_sentry_privilege_result(this);
+ }
+
+ @Override
+ public void clear() {
+ this.success = null;
+ }
+
+ public TRenamePrivilegesResponse getSuccess() {
+ return this.success;
+ }
+
+ public void setSuccess(TRenamePrivilegesResponse success) {
+ this.success = success;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been assigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((TRenamePrivilegesResponse)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof rename_sentry_privilege_result)
+ return this.equals((rename_sentry_privilege_result)that);
+ return false;
+ }
+
+ public boolean equals(rename_sentry_privilege_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_success = true && (isSetSuccess());
+ builder.append(present_success);
+ if (present_success)
+ builder.append(success);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(rename_sentry_privilege_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ rename_sentry_privilege_result typedOther = (rename_sentry_privilege_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetSuccess()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("rename_sentry_privilege_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ if (success != null) {
+ success.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class rename_sentry_privilege_resultStandardSchemeFactory implements SchemeFactory {
+ public rename_sentry_privilege_resultStandardScheme getScheme() {
+ return new rename_sentry_privilege_resultStandardScheme();
+ }
+ }
+
+ private static class rename_sentry_privilege_resultStandardScheme extends StandardScheme<rename_sentry_privilege_result> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, rename_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 0: // SUCCESS
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.success = new TRenamePrivilegesResponse();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, rename_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.success != null) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ struct.success.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class rename_sentry_privilege_resultTupleSchemeFactory implements SchemeFactory {
+ public rename_sentry_privilege_resultTupleScheme getScheme() {
+ return new rename_sentry_privilege_resultTupleScheme();
+ }
+ }
+
+ private static class rename_sentry_privilege_resultTupleScheme extends TupleScheme<rename_sentry_privilege_result> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, rename_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetSuccess()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetSuccess()) {
+ struct.success.write(oprot);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, rename_sentry_privilege_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.success = new TRenamePrivilegesResponse();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(true);
+ }
+ }
+ }
+
+ }
+
}
[2/3] SENTRY-162: Cleanup DB store privilege metadata on Hive DDL
statements ( Prasad Mujumdar via Sravya Tirukkovalur)
Posted by sr...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesRequest.java
new file mode 100644
index 0000000..3df9235
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesRequest.java
@@ -0,0 +1,592 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TDropPrivilegesRequest implements org.apache.thrift.TBase<TDropPrivilegesRequest, TDropPrivilegesRequest._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TDropPrivilegesRequest");
+
+ private static final org.apache.thrift.protocol.TField PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("protocol_version", org.apache.thrift.protocol.TType.I32, (short)1);
+ private static final org.apache.thrift.protocol.TField REQUESTOR_USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("requestorUserName", org.apache.thrift.protocol.TType.STRING, (short)2);
+ private static final org.apache.thrift.protocol.TField AUTHORIZABLE_FIELD_DESC = new org.apache.thrift.protocol.TField("authorizable", org.apache.thrift.protocol.TType.STRUCT, (short)3);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new TDropPrivilegesRequestStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new TDropPrivilegesRequestTupleSchemeFactory());
+ }
+
+ private int protocol_version; // required
+ private String requestorUserName; // required
+ private TSentryAuthorizable authorizable; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ PROTOCOL_VERSION((short)1, "protocol_version"),
+ REQUESTOR_USER_NAME((short)2, "requestorUserName"),
+ AUTHORIZABLE((short)3, "authorizable");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // PROTOCOL_VERSION
+ return PROTOCOL_VERSION;
+ case 2: // REQUESTOR_USER_NAME
+ return REQUESTOR_USER_NAME;
+ case 3: // AUTHORIZABLE
+ return AUTHORIZABLE;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ private static final int __PROTOCOL_VERSION_ISSET_ID = 0;
+ private byte __isset_bitfield = 0;
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("protocol_version", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+ tmpMap.put(_Fields.REQUESTOR_USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("requestorUserName", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.AUTHORIZABLE, new org.apache.thrift.meta_data.FieldMetaData("authorizable", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSentryAuthorizable.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TDropPrivilegesRequest.class, metaDataMap);
+ }
+
+ public TDropPrivilegesRequest() {
+ this.protocol_version = 1;
+
+ }
+
+ public TDropPrivilegesRequest(
+ int protocol_version,
+ String requestorUserName,
+ TSentryAuthorizable authorizable)
+ {
+ this();
+ this.protocol_version = protocol_version;
+ setProtocol_versionIsSet(true);
+ this.requestorUserName = requestorUserName;
+ this.authorizable = authorizable;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public TDropPrivilegesRequest(TDropPrivilegesRequest other) {
+ __isset_bitfield = other.__isset_bitfield;
+ this.protocol_version = other.protocol_version;
+ if (other.isSetRequestorUserName()) {
+ this.requestorUserName = other.requestorUserName;
+ }
+ if (other.isSetAuthorizable()) {
+ this.authorizable = new TSentryAuthorizable(other.authorizable);
+ }
+ }
+
+ public TDropPrivilegesRequest deepCopy() {
+ return new TDropPrivilegesRequest(this);
+ }
+
+ @Override
+ public void clear() {
+ this.protocol_version = 1;
+
+ this.requestorUserName = null;
+ this.authorizable = null;
+ }
+
+ public int getProtocol_version() {
+ return this.protocol_version;
+ }
+
+ public void setProtocol_version(int protocol_version) {
+ this.protocol_version = protocol_version;
+ setProtocol_versionIsSet(true);
+ }
+
+ public void unsetProtocol_version() {
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+ }
+
+ /** Returns true if field protocol_version is set (has been assigned a value) and false otherwise */
+ public boolean isSetProtocol_version() {
+ return EncodingUtils.testBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+ }
+
+ public void setProtocol_versionIsSet(boolean value) {
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID, value);
+ }
+
+ public String getRequestorUserName() {
+ return this.requestorUserName;
+ }
+
+ public void setRequestorUserName(String requestorUserName) {
+ this.requestorUserName = requestorUserName;
+ }
+
+ public void unsetRequestorUserName() {
+ this.requestorUserName = null;
+ }
+
+ /** Returns true if field requestorUserName is set (has been assigned a value) and false otherwise */
+ public boolean isSetRequestorUserName() {
+ return this.requestorUserName != null;
+ }
+
+ public void setRequestorUserNameIsSet(boolean value) {
+ if (!value) {
+ this.requestorUserName = null;
+ }
+ }
+
+ public TSentryAuthorizable getAuthorizable() {
+ return this.authorizable;
+ }
+
+ public void setAuthorizable(TSentryAuthorizable authorizable) {
+ this.authorizable = authorizable;
+ }
+
+ public void unsetAuthorizable() {
+ this.authorizable = null;
+ }
+
+ /** Returns true if field authorizable is set (has been assigned a value) and false otherwise */
+ public boolean isSetAuthorizable() {
+ return this.authorizable != null;
+ }
+
+ public void setAuthorizableIsSet(boolean value) {
+ if (!value) {
+ this.authorizable = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case PROTOCOL_VERSION:
+ if (value == null) {
+ unsetProtocol_version();
+ } else {
+ setProtocol_version((Integer)value);
+ }
+ break;
+
+ case REQUESTOR_USER_NAME:
+ if (value == null) {
+ unsetRequestorUserName();
+ } else {
+ setRequestorUserName((String)value);
+ }
+ break;
+
+ case AUTHORIZABLE:
+ if (value == null) {
+ unsetAuthorizable();
+ } else {
+ setAuthorizable((TSentryAuthorizable)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case PROTOCOL_VERSION:
+ return Integer.valueOf(getProtocol_version());
+
+ case REQUESTOR_USER_NAME:
+ return getRequestorUserName();
+
+ case AUTHORIZABLE:
+ return getAuthorizable();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case PROTOCOL_VERSION:
+ return isSetProtocol_version();
+ case REQUESTOR_USER_NAME:
+ return isSetRequestorUserName();
+ case AUTHORIZABLE:
+ return isSetAuthorizable();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof TDropPrivilegesRequest)
+ return this.equals((TDropPrivilegesRequest)that);
+ return false;
+ }
+
+ public boolean equals(TDropPrivilegesRequest that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_protocol_version = true;
+ boolean that_present_protocol_version = true;
+ if (this_present_protocol_version || that_present_protocol_version) {
+ if (!(this_present_protocol_version && that_present_protocol_version))
+ return false;
+ if (this.protocol_version != that.protocol_version)
+ return false;
+ }
+
+ boolean this_present_requestorUserName = true && this.isSetRequestorUserName();
+ boolean that_present_requestorUserName = true && that.isSetRequestorUserName();
+ if (this_present_requestorUserName || that_present_requestorUserName) {
+ if (!(this_present_requestorUserName && that_present_requestorUserName))
+ return false;
+ if (!this.requestorUserName.equals(that.requestorUserName))
+ return false;
+ }
+
+ boolean this_present_authorizable = true && this.isSetAuthorizable();
+ boolean that_present_authorizable = true && that.isSetAuthorizable();
+ if (this_present_authorizable || that_present_authorizable) {
+ if (!(this_present_authorizable && that_present_authorizable))
+ return false;
+ if (!this.authorizable.equals(that.authorizable))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_protocol_version = true;
+ builder.append(present_protocol_version);
+ if (present_protocol_version)
+ builder.append(protocol_version);
+
+ boolean present_requestorUserName = true && (isSetRequestorUserName());
+ builder.append(present_requestorUserName);
+ if (present_requestorUserName)
+ builder.append(requestorUserName);
+
+ boolean present_authorizable = true && (isSetAuthorizable());
+ builder.append(present_authorizable);
+ if (present_authorizable)
+ builder.append(authorizable);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(TDropPrivilegesRequest other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ TDropPrivilegesRequest typedOther = (TDropPrivilegesRequest)other;
+
+ lastComparison = Boolean.valueOf(isSetProtocol_version()).compareTo(typedOther.isSetProtocol_version());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetProtocol_version()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.protocol_version, typedOther.protocol_version);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetRequestorUserName()).compareTo(typedOther.isSetRequestorUserName());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetRequestorUserName()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestorUserName, typedOther.requestorUserName);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetAuthorizable()).compareTo(typedOther.isSetAuthorizable());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetAuthorizable()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.authorizable, typedOther.authorizable);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("TDropPrivilegesRequest(");
+ boolean first = true;
+
+ sb.append("protocol_version:");
+ sb.append(this.protocol_version);
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("requestorUserName:");
+ if (this.requestorUserName == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.requestorUserName);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("authorizable:");
+ if (this.authorizable == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.authorizable);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ if (!isSetProtocol_version()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'protocol_version' is unset! Struct:" + toString());
+ }
+
+ if (!isSetRequestorUserName()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'requestorUserName' is unset! Struct:" + toString());
+ }
+
+ if (!isSetAuthorizable()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'authorizable' is unset! Struct:" + toString());
+ }
+
+ // check for sub-struct validity
+ if (authorizable != null) {
+ authorizable.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+ __isset_bitfield = 0;
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class TDropPrivilegesRequestStandardSchemeFactory implements SchemeFactory {
+ public TDropPrivilegesRequestStandardScheme getScheme() {
+ return new TDropPrivilegesRequestStandardScheme();
+ }
+ }
+
+ private static class TDropPrivilegesRequestStandardScheme extends StandardScheme<TDropPrivilegesRequest> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, TDropPrivilegesRequest struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // PROTOCOL_VERSION
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.protocol_version = iprot.readI32();
+ struct.setProtocol_versionIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 2: // REQUESTOR_USER_NAME
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.requestorUserName = iprot.readString();
+ struct.setRequestorUserNameIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 3: // AUTHORIZABLE
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.authorizable = new TSentryAuthorizable();
+ struct.authorizable.read(iprot);
+ struct.setAuthorizableIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, TDropPrivilegesRequest struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldBegin(PROTOCOL_VERSION_FIELD_DESC);
+ oprot.writeI32(struct.protocol_version);
+ oprot.writeFieldEnd();
+ if (struct.requestorUserName != null) {
+ oprot.writeFieldBegin(REQUESTOR_USER_NAME_FIELD_DESC);
+ oprot.writeString(struct.requestorUserName);
+ oprot.writeFieldEnd();
+ }
+ if (struct.authorizable != null) {
+ oprot.writeFieldBegin(AUTHORIZABLE_FIELD_DESC);
+ struct.authorizable.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class TDropPrivilegesRequestTupleSchemeFactory implements SchemeFactory {
+ public TDropPrivilegesRequestTupleScheme getScheme() {
+ return new TDropPrivilegesRequestTupleScheme();
+ }
+ }
+
+ private static class TDropPrivilegesRequestTupleScheme extends TupleScheme<TDropPrivilegesRequest> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, TDropPrivilegesRequest struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ oprot.writeI32(struct.protocol_version);
+ oprot.writeString(struct.requestorUserName);
+ struct.authorizable.write(oprot);
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, TDropPrivilegesRequest struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ struct.protocol_version = iprot.readI32();
+ struct.setProtocol_versionIsSet(true);
+ struct.requestorUserName = iprot.readString();
+ struct.setRequestorUserNameIsSet(true);
+ struct.authorizable = new TSentryAuthorizable();
+ struct.authorizable.read(iprot);
+ struct.setAuthorizableIsSet(true);
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesResponse.java
new file mode 100644
index 0000000..24f7926
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TDropPrivilegesResponse.java
@@ -0,0 +1,390 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TDropPrivilegesResponse implements org.apache.thrift.TBase<TDropPrivilegesResponse, TDropPrivilegesResponse._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TDropPrivilegesResponse");
+
+ private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new TDropPrivilegesResponseStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new TDropPrivilegesResponseTupleSchemeFactory());
+ }
+
+ private org.apache.sentry.service.thrift.TSentryResponseStatus status; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ STATUS((short)1, "status");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // STATUS
+ return STATUS;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.sentry.service.thrift.TSentryResponseStatus.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TDropPrivilegesResponse.class, metaDataMap);
+ }
+
+ public TDropPrivilegesResponse() {
+ }
+
+ public TDropPrivilegesResponse(
+ org.apache.sentry.service.thrift.TSentryResponseStatus status)
+ {
+ this();
+ this.status = status;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public TDropPrivilegesResponse(TDropPrivilegesResponse other) {
+ if (other.isSetStatus()) {
+ this.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(other.status);
+ }
+ }
+
+ public TDropPrivilegesResponse deepCopy() {
+ return new TDropPrivilegesResponse(this);
+ }
+
+ @Override
+ public void clear() {
+ this.status = null;
+ }
+
+ public org.apache.sentry.service.thrift.TSentryResponseStatus getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(org.apache.sentry.service.thrift.TSentryResponseStatus status) {
+ this.status = status;
+ }
+
+ public void unsetStatus() {
+ this.status = null;
+ }
+
+ /** Returns true if field status is set (has been assigned a value) and false otherwise */
+ public boolean isSetStatus() {
+ return this.status != null;
+ }
+
+ public void setStatusIsSet(boolean value) {
+ if (!value) {
+ this.status = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case STATUS:
+ if (value == null) {
+ unsetStatus();
+ } else {
+ setStatus((org.apache.sentry.service.thrift.TSentryResponseStatus)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case STATUS:
+ return getStatus();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case STATUS:
+ return isSetStatus();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof TDropPrivilegesResponse)
+ return this.equals((TDropPrivilegesResponse)that);
+ return false;
+ }
+
+ public boolean equals(TDropPrivilegesResponse that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_status = true && this.isSetStatus();
+ boolean that_present_status = true && that.isSetStatus();
+ if (this_present_status || that_present_status) {
+ if (!(this_present_status && that_present_status))
+ return false;
+ if (!this.status.equals(that.status))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_status = true && (isSetStatus());
+ builder.append(present_status);
+ if (present_status)
+ builder.append(status);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(TDropPrivilegesResponse other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ TDropPrivilegesResponse typedOther = (TDropPrivilegesResponse)other;
+
+ lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetStatus()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("TDropPrivilegesResponse(");
+ boolean first = true;
+
+ sb.append("status:");
+ if (this.status == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.status);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ if (!isSetStatus()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString());
+ }
+
+ // check for sub-struct validity
+ if (status != null) {
+ status.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class TDropPrivilegesResponseStandardSchemeFactory implements SchemeFactory {
+ public TDropPrivilegesResponseStandardScheme getScheme() {
+ return new TDropPrivilegesResponseStandardScheme();
+ }
+ }
+
+ private static class TDropPrivilegesResponseStandardScheme extends StandardScheme<TDropPrivilegesResponse> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, TDropPrivilegesResponse struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // STATUS
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+ struct.status.read(iprot);
+ struct.setStatusIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, TDropPrivilegesResponse struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.status != null) {
+ oprot.writeFieldBegin(STATUS_FIELD_DESC);
+ struct.status.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class TDropPrivilegesResponseTupleSchemeFactory implements SchemeFactory {
+ public TDropPrivilegesResponseTupleScheme getScheme() {
+ return new TDropPrivilegesResponseTupleScheme();
+ }
+ }
+
+ private static class TDropPrivilegesResponseTupleScheme extends TupleScheme<TDropPrivilegesResponse> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, TDropPrivilegesResponse struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ struct.status.write(oprot);
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, TDropPrivilegesResponse struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+ struct.status.read(iprot);
+ struct.setStatusIsSet(true);
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesRequest.java
new file mode 100644
index 0000000..a2bc805
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesRequest.java
@@ -0,0 +1,698 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TRenamePrivilegesRequest implements org.apache.thrift.TBase<TRenamePrivilegesRequest, TRenamePrivilegesRequest._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TRenamePrivilegesRequest");
+
+ private static final org.apache.thrift.protocol.TField PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("protocol_version", org.apache.thrift.protocol.TType.I32, (short)1);
+ private static final org.apache.thrift.protocol.TField REQUESTOR_USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("requestorUserName", org.apache.thrift.protocol.TType.STRING, (short)2);
+ private static final org.apache.thrift.protocol.TField OLD_AUTHORIZABLE_FIELD_DESC = new org.apache.thrift.protocol.TField("oldAuthorizable", org.apache.thrift.protocol.TType.STRUCT, (short)3);
+ private static final org.apache.thrift.protocol.TField NEW_AUTHORIZABLE_FIELD_DESC = new org.apache.thrift.protocol.TField("newAuthorizable", org.apache.thrift.protocol.TType.STRUCT, (short)4);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new TRenamePrivilegesRequestStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new TRenamePrivilegesRequestTupleSchemeFactory());
+ }
+
+ private int protocol_version; // required
+ private String requestorUserName; // required
+ private TSentryAuthorizable oldAuthorizable; // required
+ private TSentryAuthorizable newAuthorizable; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ PROTOCOL_VERSION((short)1, "protocol_version"),
+ REQUESTOR_USER_NAME((short)2, "requestorUserName"),
+ OLD_AUTHORIZABLE((short)3, "oldAuthorizable"),
+ NEW_AUTHORIZABLE((short)4, "newAuthorizable");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // PROTOCOL_VERSION
+ return PROTOCOL_VERSION;
+ case 2: // REQUESTOR_USER_NAME
+ return REQUESTOR_USER_NAME;
+ case 3: // OLD_AUTHORIZABLE
+ return OLD_AUTHORIZABLE;
+ case 4: // NEW_AUTHORIZABLE
+ return NEW_AUTHORIZABLE;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ private static final int __PROTOCOL_VERSION_ISSET_ID = 0;
+ private byte __isset_bitfield = 0;
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("protocol_version", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+ tmpMap.put(_Fields.REQUESTOR_USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("requestorUserName", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.OLD_AUTHORIZABLE, new org.apache.thrift.meta_data.FieldMetaData("oldAuthorizable", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSentryAuthorizable.class)));
+ tmpMap.put(_Fields.NEW_AUTHORIZABLE, new org.apache.thrift.meta_data.FieldMetaData("newAuthorizable", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSentryAuthorizable.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TRenamePrivilegesRequest.class, metaDataMap);
+ }
+
+ public TRenamePrivilegesRequest() {
+ this.protocol_version = 1;
+
+ }
+
+ public TRenamePrivilegesRequest(
+ int protocol_version,
+ String requestorUserName,
+ TSentryAuthorizable oldAuthorizable,
+ TSentryAuthorizable newAuthorizable)
+ {
+ this();
+ this.protocol_version = protocol_version;
+ setProtocol_versionIsSet(true);
+ this.requestorUserName = requestorUserName;
+ this.oldAuthorizable = oldAuthorizable;
+ this.newAuthorizable = newAuthorizable;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public TRenamePrivilegesRequest(TRenamePrivilegesRequest other) {
+ __isset_bitfield = other.__isset_bitfield;
+ this.protocol_version = other.protocol_version;
+ if (other.isSetRequestorUserName()) {
+ this.requestorUserName = other.requestorUserName;
+ }
+ if (other.isSetOldAuthorizable()) {
+ this.oldAuthorizable = new TSentryAuthorizable(other.oldAuthorizable);
+ }
+ if (other.isSetNewAuthorizable()) {
+ this.newAuthorizable = new TSentryAuthorizable(other.newAuthorizable);
+ }
+ }
+
+ public TRenamePrivilegesRequest deepCopy() {
+ return new TRenamePrivilegesRequest(this);
+ }
+
+ @Override
+ public void clear() {
+ this.protocol_version = 1;
+
+ this.requestorUserName = null;
+ this.oldAuthorizable = null;
+ this.newAuthorizable = null;
+ }
+
+ public int getProtocol_version() {
+ return this.protocol_version;
+ }
+
+ public void setProtocol_version(int protocol_version) {
+ this.protocol_version = protocol_version;
+ setProtocol_versionIsSet(true);
+ }
+
+ public void unsetProtocol_version() {
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+ }
+
+ /** Returns true if field protocol_version is set (has been assigned a value) and false otherwise */
+ public boolean isSetProtocol_version() {
+ return EncodingUtils.testBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+ }
+
+ public void setProtocol_versionIsSet(boolean value) {
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID, value);
+ }
+
+ public String getRequestorUserName() {
+ return this.requestorUserName;
+ }
+
+ public void setRequestorUserName(String requestorUserName) {
+ this.requestorUserName = requestorUserName;
+ }
+
+ public void unsetRequestorUserName() {
+ this.requestorUserName = null;
+ }
+
+ /** Returns true if field requestorUserName is set (has been assigned a value) and false otherwise */
+ public boolean isSetRequestorUserName() {
+ return this.requestorUserName != null;
+ }
+
+ public void setRequestorUserNameIsSet(boolean value) {
+ if (!value) {
+ this.requestorUserName = null;
+ }
+ }
+
+ public TSentryAuthorizable getOldAuthorizable() {
+ return this.oldAuthorizable;
+ }
+
+ public void setOldAuthorizable(TSentryAuthorizable oldAuthorizable) {
+ this.oldAuthorizable = oldAuthorizable;
+ }
+
+ public void unsetOldAuthorizable() {
+ this.oldAuthorizable = null;
+ }
+
+ /** Returns true if field oldAuthorizable is set (has been assigned a value) and false otherwise */
+ public boolean isSetOldAuthorizable() {
+ return this.oldAuthorizable != null;
+ }
+
+ public void setOldAuthorizableIsSet(boolean value) {
+ if (!value) {
+ this.oldAuthorizable = null;
+ }
+ }
+
+ public TSentryAuthorizable getNewAuthorizable() {
+ return this.newAuthorizable;
+ }
+
+ public void setNewAuthorizable(TSentryAuthorizable newAuthorizable) {
+ this.newAuthorizable = newAuthorizable;
+ }
+
+ public void unsetNewAuthorizable() {
+ this.newAuthorizable = null;
+ }
+
+ /** Returns true if field newAuthorizable is set (has been assigned a value) and false otherwise */
+ public boolean isSetNewAuthorizable() {
+ return this.newAuthorizable != null;
+ }
+
+ public void setNewAuthorizableIsSet(boolean value) {
+ if (!value) {
+ this.newAuthorizable = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case PROTOCOL_VERSION:
+ if (value == null) {
+ unsetProtocol_version();
+ } else {
+ setProtocol_version((Integer)value);
+ }
+ break;
+
+ case REQUESTOR_USER_NAME:
+ if (value == null) {
+ unsetRequestorUserName();
+ } else {
+ setRequestorUserName((String)value);
+ }
+ break;
+
+ case OLD_AUTHORIZABLE:
+ if (value == null) {
+ unsetOldAuthorizable();
+ } else {
+ setOldAuthorizable((TSentryAuthorizable)value);
+ }
+ break;
+
+ case NEW_AUTHORIZABLE:
+ if (value == null) {
+ unsetNewAuthorizable();
+ } else {
+ setNewAuthorizable((TSentryAuthorizable)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case PROTOCOL_VERSION:
+ return Integer.valueOf(getProtocol_version());
+
+ case REQUESTOR_USER_NAME:
+ return getRequestorUserName();
+
+ case OLD_AUTHORIZABLE:
+ return getOldAuthorizable();
+
+ case NEW_AUTHORIZABLE:
+ return getNewAuthorizable();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case PROTOCOL_VERSION:
+ return isSetProtocol_version();
+ case REQUESTOR_USER_NAME:
+ return isSetRequestorUserName();
+ case OLD_AUTHORIZABLE:
+ return isSetOldAuthorizable();
+ case NEW_AUTHORIZABLE:
+ return isSetNewAuthorizable();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof TRenamePrivilegesRequest)
+ return this.equals((TRenamePrivilegesRequest)that);
+ return false;
+ }
+
+ public boolean equals(TRenamePrivilegesRequest that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_protocol_version = true;
+ boolean that_present_protocol_version = true;
+ if (this_present_protocol_version || that_present_protocol_version) {
+ if (!(this_present_protocol_version && that_present_protocol_version))
+ return false;
+ if (this.protocol_version != that.protocol_version)
+ return false;
+ }
+
+ boolean this_present_requestorUserName = true && this.isSetRequestorUserName();
+ boolean that_present_requestorUserName = true && that.isSetRequestorUserName();
+ if (this_present_requestorUserName || that_present_requestorUserName) {
+ if (!(this_present_requestorUserName && that_present_requestorUserName))
+ return false;
+ if (!this.requestorUserName.equals(that.requestorUserName))
+ return false;
+ }
+
+ boolean this_present_oldAuthorizable = true && this.isSetOldAuthorizable();
+ boolean that_present_oldAuthorizable = true && that.isSetOldAuthorizable();
+ if (this_present_oldAuthorizable || that_present_oldAuthorizable) {
+ if (!(this_present_oldAuthorizable && that_present_oldAuthorizable))
+ return false;
+ if (!this.oldAuthorizable.equals(that.oldAuthorizable))
+ return false;
+ }
+
+ boolean this_present_newAuthorizable = true && this.isSetNewAuthorizable();
+ boolean that_present_newAuthorizable = true && that.isSetNewAuthorizable();
+ if (this_present_newAuthorizable || that_present_newAuthorizable) {
+ if (!(this_present_newAuthorizable && that_present_newAuthorizable))
+ return false;
+ if (!this.newAuthorizable.equals(that.newAuthorizable))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_protocol_version = true;
+ builder.append(present_protocol_version);
+ if (present_protocol_version)
+ builder.append(protocol_version);
+
+ boolean present_requestorUserName = true && (isSetRequestorUserName());
+ builder.append(present_requestorUserName);
+ if (present_requestorUserName)
+ builder.append(requestorUserName);
+
+ boolean present_oldAuthorizable = true && (isSetOldAuthorizable());
+ builder.append(present_oldAuthorizable);
+ if (present_oldAuthorizable)
+ builder.append(oldAuthorizable);
+
+ boolean present_newAuthorizable = true && (isSetNewAuthorizable());
+ builder.append(present_newAuthorizable);
+ if (present_newAuthorizable)
+ builder.append(newAuthorizable);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(TRenamePrivilegesRequest other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ TRenamePrivilegesRequest typedOther = (TRenamePrivilegesRequest)other;
+
+ lastComparison = Boolean.valueOf(isSetProtocol_version()).compareTo(typedOther.isSetProtocol_version());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetProtocol_version()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.protocol_version, typedOther.protocol_version);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetRequestorUserName()).compareTo(typedOther.isSetRequestorUserName());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetRequestorUserName()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestorUserName, typedOther.requestorUserName);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetOldAuthorizable()).compareTo(typedOther.isSetOldAuthorizable());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetOldAuthorizable()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.oldAuthorizable, typedOther.oldAuthorizable);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetNewAuthorizable()).compareTo(typedOther.isSetNewAuthorizable());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetNewAuthorizable()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.newAuthorizable, typedOther.newAuthorizable);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("TRenamePrivilegesRequest(");
+ boolean first = true;
+
+ sb.append("protocol_version:");
+ sb.append(this.protocol_version);
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("requestorUserName:");
+ if (this.requestorUserName == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.requestorUserName);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("oldAuthorizable:");
+ if (this.oldAuthorizable == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.oldAuthorizable);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("newAuthorizable:");
+ if (this.newAuthorizable == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.newAuthorizable);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ if (!isSetProtocol_version()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'protocol_version' is unset! Struct:" + toString());
+ }
+
+ if (!isSetRequestorUserName()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'requestorUserName' is unset! Struct:" + toString());
+ }
+
+ if (!isSetOldAuthorizable()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'oldAuthorizable' is unset! Struct:" + toString());
+ }
+
+ if (!isSetNewAuthorizable()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'newAuthorizable' is unset! Struct:" + toString());
+ }
+
+ // check for sub-struct validity
+ if (oldAuthorizable != null) {
+ oldAuthorizable.validate();
+ }
+ if (newAuthorizable != null) {
+ newAuthorizable.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+ __isset_bitfield = 0;
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class TRenamePrivilegesRequestStandardSchemeFactory implements SchemeFactory {
+ public TRenamePrivilegesRequestStandardScheme getScheme() {
+ return new TRenamePrivilegesRequestStandardScheme();
+ }
+ }
+
+ private static class TRenamePrivilegesRequestStandardScheme extends StandardScheme<TRenamePrivilegesRequest> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, TRenamePrivilegesRequest struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // PROTOCOL_VERSION
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.protocol_version = iprot.readI32();
+ struct.setProtocol_versionIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 2: // REQUESTOR_USER_NAME
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.requestorUserName = iprot.readString();
+ struct.setRequestorUserNameIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 3: // OLD_AUTHORIZABLE
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.oldAuthorizable = new TSentryAuthorizable();
+ struct.oldAuthorizable.read(iprot);
+ struct.setOldAuthorizableIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 4: // NEW_AUTHORIZABLE
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.newAuthorizable = new TSentryAuthorizable();
+ struct.newAuthorizable.read(iprot);
+ struct.setNewAuthorizableIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, TRenamePrivilegesRequest struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldBegin(PROTOCOL_VERSION_FIELD_DESC);
+ oprot.writeI32(struct.protocol_version);
+ oprot.writeFieldEnd();
+ if (struct.requestorUserName != null) {
+ oprot.writeFieldBegin(REQUESTOR_USER_NAME_FIELD_DESC);
+ oprot.writeString(struct.requestorUserName);
+ oprot.writeFieldEnd();
+ }
+ if (struct.oldAuthorizable != null) {
+ oprot.writeFieldBegin(OLD_AUTHORIZABLE_FIELD_DESC);
+ struct.oldAuthorizable.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ if (struct.newAuthorizable != null) {
+ oprot.writeFieldBegin(NEW_AUTHORIZABLE_FIELD_DESC);
+ struct.newAuthorizable.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class TRenamePrivilegesRequestTupleSchemeFactory implements SchemeFactory {
+ public TRenamePrivilegesRequestTupleScheme getScheme() {
+ return new TRenamePrivilegesRequestTupleScheme();
+ }
+ }
+
+ private static class TRenamePrivilegesRequestTupleScheme extends TupleScheme<TRenamePrivilegesRequest> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, TRenamePrivilegesRequest struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ oprot.writeI32(struct.protocol_version);
+ oprot.writeString(struct.requestorUserName);
+ struct.oldAuthorizable.write(oprot);
+ struct.newAuthorizable.write(oprot);
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, TRenamePrivilegesRequest struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ struct.protocol_version = iprot.readI32();
+ struct.setProtocol_versionIsSet(true);
+ struct.requestorUserName = iprot.readString();
+ struct.setRequestorUserNameIsSet(true);
+ struct.oldAuthorizable = new TSentryAuthorizable();
+ struct.oldAuthorizable.read(iprot);
+ struct.setOldAuthorizableIsSet(true);
+ struct.newAuthorizable = new TSentryAuthorizable();
+ struct.newAuthorizable.read(iprot);
+ struct.setNewAuthorizableIsSet(true);
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesResponse.java
new file mode 100644
index 0000000..39e7f07
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TRenamePrivilegesResponse.java
@@ -0,0 +1,390 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TRenamePrivilegesResponse implements org.apache.thrift.TBase<TRenamePrivilegesResponse, TRenamePrivilegesResponse._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TRenamePrivilegesResponse");
+
+ private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new TRenamePrivilegesResponseStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new TRenamePrivilegesResponseTupleSchemeFactory());
+ }
+
+ private org.apache.sentry.service.thrift.TSentryResponseStatus status; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ STATUS((short)1, "status");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // STATUS
+ return STATUS;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.sentry.service.thrift.TSentryResponseStatus.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TRenamePrivilegesResponse.class, metaDataMap);
+ }
+
+ public TRenamePrivilegesResponse() {
+ }
+
+ public TRenamePrivilegesResponse(
+ org.apache.sentry.service.thrift.TSentryResponseStatus status)
+ {
+ this();
+ this.status = status;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public TRenamePrivilegesResponse(TRenamePrivilegesResponse other) {
+ if (other.isSetStatus()) {
+ this.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(other.status);
+ }
+ }
+
+ public TRenamePrivilegesResponse deepCopy() {
+ return new TRenamePrivilegesResponse(this);
+ }
+
+ @Override
+ public void clear() {
+ this.status = null;
+ }
+
+ public org.apache.sentry.service.thrift.TSentryResponseStatus getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(org.apache.sentry.service.thrift.TSentryResponseStatus status) {
+ this.status = status;
+ }
+
+ public void unsetStatus() {
+ this.status = null;
+ }
+
+ /** Returns true if field status is set (has been assigned a value) and false otherwise */
+ public boolean isSetStatus() {
+ return this.status != null;
+ }
+
+ public void setStatusIsSet(boolean value) {
+ if (!value) {
+ this.status = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case STATUS:
+ if (value == null) {
+ unsetStatus();
+ } else {
+ setStatus((org.apache.sentry.service.thrift.TSentryResponseStatus)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case STATUS:
+ return getStatus();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case STATUS:
+ return isSetStatus();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof TRenamePrivilegesResponse)
+ return this.equals((TRenamePrivilegesResponse)that);
+ return false;
+ }
+
+ public boolean equals(TRenamePrivilegesResponse that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_status = true && this.isSetStatus();
+ boolean that_present_status = true && that.isSetStatus();
+ if (this_present_status || that_present_status) {
+ if (!(this_present_status && that_present_status))
+ return false;
+ if (!this.status.equals(that.status))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_status = true && (isSetStatus());
+ builder.append(present_status);
+ if (present_status)
+ builder.append(status);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(TRenamePrivilegesResponse other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ TRenamePrivilegesResponse typedOther = (TRenamePrivilegesResponse)other;
+
+ lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetStatus()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("TRenamePrivilegesResponse(");
+ boolean first = true;
+
+ sb.append("status:");
+ if (this.status == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.status);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ if (!isSetStatus()) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString());
+ }
+
+ // check for sub-struct validity
+ if (status != null) {
+ status.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class TRenamePrivilegesResponseStandardSchemeFactory implements SchemeFactory {
+ public TRenamePrivilegesResponseStandardScheme getScheme() {
+ return new TRenamePrivilegesResponseStandardScheme();
+ }
+ }
+
+ private static class TRenamePrivilegesResponseStandardScheme extends StandardScheme<TRenamePrivilegesResponse> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, TRenamePrivilegesResponse struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // STATUS
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+ struct.status.read(iprot);
+ struct.setStatusIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, TRenamePrivilegesResponse struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.status != null) {
+ oprot.writeFieldBegin(STATUS_FIELD_DESC);
+ struct.status.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class TRenamePrivilegesResponseTupleSchemeFactory implements SchemeFactory {
+ public TRenamePrivilegesResponseTupleScheme getScheme() {
+ return new TRenamePrivilegesResponseTupleScheme();
+ }
+ }
+
+ private static class TRenamePrivilegesResponseTupleScheme extends TupleScheme<TRenamePrivilegesResponse> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, TRenamePrivilegesResponse struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ struct.status.write(oprot);
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, TRenamePrivilegesResponse struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+ struct.status.read(iprot);
+ struct.setStatusIsSet(true);
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b11f5aab/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPrivilege.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPrivilege.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPrivilege.java
index 6679193..f8491db 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPrivilege.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryPrivilege.java
@@ -138,6 +138,10 @@ public class MSentryPrivilege {
roles.add(role);
}
+ public Set<MSentryRole> getRoles() {
+ return roles;
+ }
+
public void removeRole(MSentryRole role) {
roles.remove(role);
role.removePrivilege(this);