You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by br...@apache.org on 2014/03/11 23:29:54 UTC

[2/4] SENTRY-126 - Implement alter role grant/revoke privilege in sentry service and sentry store (Shreepadma via Brock)

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeRequest.java
deleted file mode 100644
index 34689fc..0000000
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeRequest.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/**
- * 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 TCreateSentryPrivilegeRequest implements org.apache.thrift.TBase<TCreateSentryPrivilegeRequest, TCreateSentryPrivilegeRequest._Fields>, java.io.Serializable, Cloneable {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TCreateSentryPrivilegeRequest");
-
-  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 USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("userName", org.apache.thrift.protocol.TType.STRING, (short)2);
-  private static final org.apache.thrift.protocol.TField PRIVILEGE_FIELD_DESC = new org.apache.thrift.protocol.TField("privilege", 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 TCreateSentryPrivilegeRequestStandardSchemeFactory());
-    schemes.put(TupleScheme.class, new TCreateSentryPrivilegeRequestTupleSchemeFactory());
-  }
-
-  private int protocol_version; // required
-  private String userName; // required
-  private TSentryPrivilege privilege; // 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"),
-    USER_NAME((short)2, "userName"),
-    PRIVILEGE((short)3, "privilege");
-
-    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: // USER_NAME
-          return USER_NAME;
-        case 3: // PRIVILEGE
-          return PRIVILEGE;
-        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.USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("userName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.PRIVILEGE, new org.apache.thrift.meta_data.FieldMetaData("privilege", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSentryPrivilege.class)));
-    metaDataMap = Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TCreateSentryPrivilegeRequest.class, metaDataMap);
-  }
-
-  public TCreateSentryPrivilegeRequest() {
-    this.protocol_version = 1;
-
-  }
-
-  public TCreateSentryPrivilegeRequest(
-    int protocol_version,
-    String userName,
-    TSentryPrivilege privilege)
-  {
-    this();
-    this.protocol_version = protocol_version;
-    setProtocol_versionIsSet(true);
-    this.userName = userName;
-    this.privilege = privilege;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public TCreateSentryPrivilegeRequest(TCreateSentryPrivilegeRequest other) {
-    __isset_bitfield = other.__isset_bitfield;
-    this.protocol_version = other.protocol_version;
-    if (other.isSetUserName()) {
-      this.userName = other.userName;
-    }
-    if (other.isSetPrivilege()) {
-      this.privilege = new TSentryPrivilege(other.privilege);
-    }
-  }
-
-  public TCreateSentryPrivilegeRequest deepCopy() {
-    return new TCreateSentryPrivilegeRequest(this);
-  }
-
-  @Override
-  public void clear() {
-    this.protocol_version = 1;
-
-    this.userName = null;
-    this.privilege = 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 getUserName() {
-    return this.userName;
-  }
-
-  public void setUserName(String userName) {
-    this.userName = userName;
-  }
-
-  public void unsetUserName() {
-    this.userName = null;
-  }
-
-  /** Returns true if field userName is set (has been assigned a value) and false otherwise */
-  public boolean isSetUserName() {
-    return this.userName != null;
-  }
-
-  public void setUserNameIsSet(boolean value) {
-    if (!value) {
-      this.userName = null;
-    }
-  }
-
-  public TSentryPrivilege getPrivilege() {
-    return this.privilege;
-  }
-
-  public void setPrivilege(TSentryPrivilege privilege) {
-    this.privilege = privilege;
-  }
-
-  public void unsetPrivilege() {
-    this.privilege = null;
-  }
-
-  /** Returns true if field privilege is set (has been assigned a value) and false otherwise */
-  public boolean isSetPrivilege() {
-    return this.privilege != null;
-  }
-
-  public void setPrivilegeIsSet(boolean value) {
-    if (!value) {
-      this.privilege = 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 USER_NAME:
-      if (value == null) {
-        unsetUserName();
-      } else {
-        setUserName((String)value);
-      }
-      break;
-
-    case PRIVILEGE:
-      if (value == null) {
-        unsetPrivilege();
-      } else {
-        setPrivilege((TSentryPrivilege)value);
-      }
-      break;
-
-    }
-  }
-
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case PROTOCOL_VERSION:
-      return Integer.valueOf(getProtocol_version());
-
-    case USER_NAME:
-      return getUserName();
-
-    case PRIVILEGE:
-      return getPrivilege();
-
-    }
-    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 USER_NAME:
-      return isSetUserName();
-    case PRIVILEGE:
-      return isSetPrivilege();
-    }
-    throw new IllegalStateException();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof TCreateSentryPrivilegeRequest)
-      return this.equals((TCreateSentryPrivilegeRequest)that);
-    return false;
-  }
-
-  public boolean equals(TCreateSentryPrivilegeRequest 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_userName = true && this.isSetUserName();
-    boolean that_present_userName = true && that.isSetUserName();
-    if (this_present_userName || that_present_userName) {
-      if (!(this_present_userName && that_present_userName))
-        return false;
-      if (!this.userName.equals(that.userName))
-        return false;
-    }
-
-    boolean this_present_privilege = true && this.isSetPrivilege();
-    boolean that_present_privilege = true && that.isSetPrivilege();
-    if (this_present_privilege || that_present_privilege) {
-      if (!(this_present_privilege && that_present_privilege))
-        return false;
-      if (!this.privilege.equals(that.privilege))
-        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_userName = true && (isSetUserName());
-    builder.append(present_userName);
-    if (present_userName)
-      builder.append(userName);
-
-    boolean present_privilege = true && (isSetPrivilege());
-    builder.append(present_privilege);
-    if (present_privilege)
-      builder.append(privilege);
-
-    return builder.toHashCode();
-  }
-
-  public int compareTo(TCreateSentryPrivilegeRequest other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-    TCreateSentryPrivilegeRequest typedOther = (TCreateSentryPrivilegeRequest)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(isSetUserName()).compareTo(typedOther.isSetUserName());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetUserName()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.userName, typedOther.userName);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetPrivilege()).compareTo(typedOther.isSetPrivilege());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetPrivilege()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.privilege, typedOther.privilege);
-      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("TCreateSentryPrivilegeRequest(");
-    boolean first = true;
-
-    sb.append("protocol_version:");
-    sb.append(this.protocol_version);
-    first = false;
-    if (!first) sb.append(", ");
-    sb.append("userName:");
-    if (this.userName == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.userName);
-    }
-    first = false;
-    if (!first) sb.append(", ");
-    sb.append("privilege:");
-    if (this.privilege == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.privilege);
-    }
-    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 (!isSetUserName()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'userName' is unset! Struct:" + toString());
-    }
-
-    if (!isSetPrivilege()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'privilege' is unset! Struct:" + toString());
-    }
-
-    // check for sub-struct validity
-    if (privilege != null) {
-      privilege.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 TCreateSentryPrivilegeRequestStandardSchemeFactory implements SchemeFactory {
-    public TCreateSentryPrivilegeRequestStandardScheme getScheme() {
-      return new TCreateSentryPrivilegeRequestStandardScheme();
-    }
-  }
-
-  private static class TCreateSentryPrivilegeRequestStandardScheme extends StandardScheme<TCreateSentryPrivilegeRequest> {
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot, TCreateSentryPrivilegeRequest 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: // USER_NAME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.userName = iprot.readString();
-              struct.setUserNameIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 3: // PRIVILEGE
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-              struct.privilege = new TSentryPrivilege();
-              struct.privilege.read(iprot);
-              struct.setPrivilegeIsSet(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, TCreateSentryPrivilegeRequest 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.userName != null) {
-        oprot.writeFieldBegin(USER_NAME_FIELD_DESC);
-        oprot.writeString(struct.userName);
-        oprot.writeFieldEnd();
-      }
-      if (struct.privilege != null) {
-        oprot.writeFieldBegin(PRIVILEGE_FIELD_DESC);
-        struct.privilege.write(oprot);
-        oprot.writeFieldEnd();
-      }
-      oprot.writeFieldStop();
-      oprot.writeStructEnd();
-    }
-
-  }
-
-  private static class TCreateSentryPrivilegeRequestTupleSchemeFactory implements SchemeFactory {
-    public TCreateSentryPrivilegeRequestTupleScheme getScheme() {
-      return new TCreateSentryPrivilegeRequestTupleScheme();
-    }
-  }
-
-  private static class TCreateSentryPrivilegeRequestTupleScheme extends TupleScheme<TCreateSentryPrivilegeRequest> {
-
-    @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, TCreateSentryPrivilegeRequest struct) throws org.apache.thrift.TException {
-      TTupleProtocol oprot = (TTupleProtocol) prot;
-      oprot.writeI32(struct.protocol_version);
-      oprot.writeString(struct.userName);
-      struct.privilege.write(oprot);
-    }
-
-    @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, TCreateSentryPrivilegeRequest struct) throws org.apache.thrift.TException {
-      TTupleProtocol iprot = (TTupleProtocol) prot;
-      struct.protocol_version = iprot.readI32();
-      struct.setProtocol_versionIsSet(true);
-      struct.userName = iprot.readString();
-      struct.setUserNameIsSet(true);
-      struct.privilege = new TSentryPrivilege();
-      struct.privilege.read(iprot);
-      struct.setPrivilegeIsSet(true);
-    }
-  }
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeResponse.java
deleted file mode 100644
index a92698e..0000000
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TCreateSentryPrivilegeResponse.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/**
- * 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 TCreateSentryPrivilegeResponse implements org.apache.thrift.TBase<TCreateSentryPrivilegeResponse, TCreateSentryPrivilegeResponse._Fields>, java.io.Serializable, Cloneable {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TCreateSentryPrivilegeResponse");
-
-  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 TCreateSentryPrivilegeResponseStandardSchemeFactory());
-    schemes.put(TupleScheme.class, new TCreateSentryPrivilegeResponseTupleSchemeFactory());
-  }
-
-  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(TCreateSentryPrivilegeResponse.class, metaDataMap);
-  }
-
-  public TCreateSentryPrivilegeResponse() {
-  }
-
-  public TCreateSentryPrivilegeResponse(
-    org.apache.sentry.service.thrift.TSentryResponseStatus status)
-  {
-    this();
-    this.status = status;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public TCreateSentryPrivilegeResponse(TCreateSentryPrivilegeResponse other) {
-    if (other.isSetStatus()) {
-      this.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(other.status);
-    }
-  }
-
-  public TCreateSentryPrivilegeResponse deepCopy() {
-    return new TCreateSentryPrivilegeResponse(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 TCreateSentryPrivilegeResponse)
-      return this.equals((TCreateSentryPrivilegeResponse)that);
-    return false;
-  }
-
-  public boolean equals(TCreateSentryPrivilegeResponse 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(TCreateSentryPrivilegeResponse other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-    TCreateSentryPrivilegeResponse typedOther = (TCreateSentryPrivilegeResponse)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("TCreateSentryPrivilegeResponse(");
-    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 TCreateSentryPrivilegeResponseStandardSchemeFactory implements SchemeFactory {
-    public TCreateSentryPrivilegeResponseStandardScheme getScheme() {
-      return new TCreateSentryPrivilegeResponseStandardScheme();
-    }
-  }
-
-  private static class TCreateSentryPrivilegeResponseStandardScheme extends StandardScheme<TCreateSentryPrivilegeResponse> {
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot, TCreateSentryPrivilegeResponse 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, TCreateSentryPrivilegeResponse 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 TCreateSentryPrivilegeResponseTupleSchemeFactory implements SchemeFactory {
-    public TCreateSentryPrivilegeResponseTupleScheme getScheme() {
-      return new TCreateSentryPrivilegeResponseTupleScheme();
-    }
-  }
-
-  private static class TCreateSentryPrivilegeResponseTupleScheme extends TupleScheme<TCreateSentryPrivilegeResponse> {
-
-    @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, TCreateSentryPrivilegeResponse struct) throws org.apache.thrift.TException {
-      TTupleProtocol oprot = (TTupleProtocol) prot;
-      struct.status.write(oprot);
-    }
-
-    @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, TCreateSentryPrivilegeResponse 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/a7df761d/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
index 32370ba..b035b12 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
@@ -447,14 +447,14 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
           case 2: // ROLES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set16 = iprot.readSetBegin();
-                struct.roles = new HashSet<TSentryRole>(2*_set16.size);
-                for (int _i17 = 0; _i17 < _set16.size; ++_i17)
+                org.apache.thrift.protocol.TSet _set8 = iprot.readSetBegin();
+                struct.roles = new HashSet<TSentryRole>(2*_set8.size);
+                for (int _i9 = 0; _i9 < _set8.size; ++_i9)
                 {
-                  TSentryRole _elem18; // required
-                  _elem18 = new TSentryRole();
-                  _elem18.read(iprot);
-                  struct.roles.add(_elem18);
+                  TSentryRole _elem10; // required
+                  _elem10 = new TSentryRole();
+                  _elem10.read(iprot);
+                  struct.roles.add(_elem10);
                 }
                 iprot.readSetEnd();
               }
@@ -485,9 +485,9 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
         oprot.writeFieldBegin(ROLES_FIELD_DESC);
         {
           oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.roles.size()));
-          for (TSentryRole _iter19 : struct.roles)
+          for (TSentryRole _iter11 : struct.roles)
           {
-            _iter19.write(oprot);
+            _iter11.write(oprot);
           }
           oprot.writeSetEnd();
         }
@@ -513,9 +513,9 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
       struct.status.write(oprot);
       {
         oprot.writeI32(struct.roles.size());
-        for (TSentryRole _iter20 : struct.roles)
+        for (TSentryRole _iter12 : struct.roles)
         {
-          _iter20.write(oprot);
+          _iter12.write(oprot);
         }
       }
     }
@@ -527,14 +527,14 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
       struct.status.read(iprot);
       struct.setStatusIsSet(true);
       {
-        org.apache.thrift.protocol.TSet _set21 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-        struct.roles = new HashSet<TSentryRole>(2*_set21.size);
-        for (int _i22 = 0; _i22 < _set21.size; ++_i22)
+        org.apache.thrift.protocol.TSet _set13 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+        struct.roles = new HashSet<TSentryRole>(2*_set13.size);
+        for (int _i14 = 0; _i14 < _set13.size; ++_i14)
         {
-          TSentryRole _elem23; // required
-          _elem23 = new TSentryRole();
-          _elem23.read(iprot);
-          struct.roles.add(_elem23);
+          TSentryRole _elem15; // required
+          _elem15 = new TSentryRole();
+          _elem15.read(iprot);
+          struct.roles.add(_elem15);
         }
       }
       struct.setRolesIsSet(true);

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilege.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilege.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilege.java
index 37f9fb7..9796562 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilege.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilege.java
@@ -51,14 +51,14 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
   }
 
   private String privilegeScope; // required
-  private String privilegeName; // required
+  private String privilegeName; // optional
   private String serverName; // required
   private String dbName; // optional
   private String tableName; // optional
   private String URI; // optional
   private String action; // required
   private long createTime; // required
-  private String grantorPrincipal; // required
+  private String grantorPrincipal; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -145,13 +145,13 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
   // isset id assignments
   private static final int __CREATETIME_ISSET_ID = 0;
   private byte __isset_bitfield = 0;
-  private _Fields optionals[] = {_Fields.DB_NAME,_Fields.TABLE_NAME,_Fields.URI};
+  private _Fields optionals[] = {_Fields.PRIVILEGE_NAME,_Fields.DB_NAME,_Fields.TABLE_NAME,_Fields.URI,_Fields.GRANTOR_PRINCIPAL};
   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.PRIVILEGE_SCOPE, new org.apache.thrift.meta_data.FieldMetaData("privilegeScope", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.PRIVILEGE_NAME, new org.apache.thrift.meta_data.FieldMetaData("privilegeName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+    tmpMap.put(_Fields.PRIVILEGE_NAME, new org.apache.thrift.meta_data.FieldMetaData("privilegeName", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     tmpMap.put(_Fields.SERVER_NAME, new org.apache.thrift.meta_data.FieldMetaData("serverName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
@@ -165,7 +165,7 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     tmpMap.put(_Fields.CREATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("createTime", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.GRANTOR_PRINCIPAL, new org.apache.thrift.meta_data.FieldMetaData("grantorPrincipal", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+    tmpMap.put(_Fields.GRANTOR_PRINCIPAL, new org.apache.thrift.meta_data.FieldMetaData("grantorPrincipal", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSentryPrivilege.class, metaDataMap);
@@ -176,20 +176,16 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
 
   public TSentryPrivilege(
     String privilegeScope,
-    String privilegeName,
     String serverName,
     String action,
-    long createTime,
-    String grantorPrincipal)
+    long createTime)
   {
     this();
     this.privilegeScope = privilegeScope;
-    this.privilegeName = privilegeName;
     this.serverName = serverName;
     this.action = action;
     this.createTime = createTime;
     setCreateTimeIsSet(true);
-    this.grantorPrincipal = grantorPrincipal;
   }
 
   /**
@@ -861,14 +857,16 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
       sb.append(this.privilegeScope);
     }
     first = false;
-    if (!first) sb.append(", ");
-    sb.append("privilegeName:");
-    if (this.privilegeName == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.privilegeName);
+    if (isSetPrivilegeName()) {
+      if (!first) sb.append(", ");
+      sb.append("privilegeName:");
+      if (this.privilegeName == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.privilegeName);
+      }
+      first = false;
     }
-    first = false;
     if (!first) sb.append(", ");
     sb.append("serverName:");
     if (this.serverName == null) {
@@ -919,14 +917,16 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
     sb.append("createTime:");
     sb.append(this.createTime);
     first = false;
-    if (!first) sb.append(", ");
-    sb.append("grantorPrincipal:");
-    if (this.grantorPrincipal == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.grantorPrincipal);
+    if (isSetGrantorPrincipal()) {
+      if (!first) sb.append(", ");
+      sb.append("grantorPrincipal:");
+      if (this.grantorPrincipal == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.grantorPrincipal);
+      }
+      first = false;
     }
-    first = false;
     sb.append(")");
     return sb.toString();
   }
@@ -937,10 +937,6 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
       throw new org.apache.thrift.protocol.TProtocolException("Required field 'privilegeScope' is unset! Struct:" + toString());
     }
 
-    if (!isSetPrivilegeName()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'privilegeName' is unset! Struct:" + toString());
-    }
-
     if (!isSetServerName()) {
       throw new org.apache.thrift.protocol.TProtocolException("Required field 'serverName' is unset! Struct:" + toString());
     }
@@ -953,10 +949,6 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
       throw new org.apache.thrift.protocol.TProtocolException("Required field 'createTime' is unset! Struct:" + toString());
     }
 
-    if (!isSetGrantorPrincipal()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'grantorPrincipal' is unset! Struct:" + toString());
-    }
-
     // check for sub-struct validity
   }
 
@@ -1087,9 +1079,11 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
         oprot.writeFieldEnd();
       }
       if (struct.privilegeName != null) {
-        oprot.writeFieldBegin(PRIVILEGE_NAME_FIELD_DESC);
-        oprot.writeString(struct.privilegeName);
-        oprot.writeFieldEnd();
+        if (struct.isSetPrivilegeName()) {
+          oprot.writeFieldBegin(PRIVILEGE_NAME_FIELD_DESC);
+          oprot.writeString(struct.privilegeName);
+          oprot.writeFieldEnd();
+        }
       }
       if (struct.serverName != null) {
         oprot.writeFieldBegin(SERVER_NAME_FIELD_DESC);
@@ -1126,9 +1120,11 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
       oprot.writeI64(struct.createTime);
       oprot.writeFieldEnd();
       if (struct.grantorPrincipal != null) {
-        oprot.writeFieldBegin(GRANTOR_PRINCIPAL_FIELD_DESC);
-        oprot.writeString(struct.grantorPrincipal);
-        oprot.writeFieldEnd();
+        if (struct.isSetGrantorPrincipal()) {
+          oprot.writeFieldBegin(GRANTOR_PRINCIPAL_FIELD_DESC);
+          oprot.writeString(struct.grantorPrincipal);
+          oprot.writeFieldEnd();
+        }
       }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
@@ -1148,22 +1144,29 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
     public void write(org.apache.thrift.protocol.TProtocol prot, TSentryPrivilege struct) throws org.apache.thrift.TException {
       TTupleProtocol oprot = (TTupleProtocol) prot;
       oprot.writeString(struct.privilegeScope);
-      oprot.writeString(struct.privilegeName);
       oprot.writeString(struct.serverName);
       oprot.writeString(struct.action);
       oprot.writeI64(struct.createTime);
-      oprot.writeString(struct.grantorPrincipal);
       BitSet optionals = new BitSet();
-      if (struct.isSetDbName()) {
+      if (struct.isSetPrivilegeName()) {
         optionals.set(0);
       }
-      if (struct.isSetTableName()) {
+      if (struct.isSetDbName()) {
         optionals.set(1);
       }
-      if (struct.isSetURI()) {
+      if (struct.isSetTableName()) {
         optionals.set(2);
       }
-      oprot.writeBitSet(optionals, 3);
+      if (struct.isSetURI()) {
+        optionals.set(3);
+      }
+      if (struct.isSetGrantorPrincipal()) {
+        optionals.set(4);
+      }
+      oprot.writeBitSet(optionals, 5);
+      if (struct.isSetPrivilegeName()) {
+        oprot.writeString(struct.privilegeName);
+      }
       if (struct.isSetDbName()) {
         oprot.writeString(struct.dbName);
       }
@@ -1173,6 +1176,9 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
       if (struct.isSetURI()) {
         oprot.writeString(struct.URI);
       }
+      if (struct.isSetGrantorPrincipal()) {
+        oprot.writeString(struct.grantorPrincipal);
+      }
     }
 
     @Override
@@ -1180,29 +1186,33 @@ public class TSentryPrivilege implements org.apache.thrift.TBase<TSentryPrivileg
       TTupleProtocol iprot = (TTupleProtocol) prot;
       struct.privilegeScope = iprot.readString();
       struct.setPrivilegeScopeIsSet(true);
-      struct.privilegeName = iprot.readString();
-      struct.setPrivilegeNameIsSet(true);
       struct.serverName = iprot.readString();
       struct.setServerNameIsSet(true);
       struct.action = iprot.readString();
       struct.setActionIsSet(true);
       struct.createTime = iprot.readI64();
       struct.setCreateTimeIsSet(true);
-      struct.grantorPrincipal = iprot.readString();
-      struct.setGrantorPrincipalIsSet(true);
-      BitSet incoming = iprot.readBitSet(3);
+      BitSet incoming = iprot.readBitSet(5);
       if (incoming.get(0)) {
+        struct.privilegeName = iprot.readString();
+        struct.setPrivilegeNameIsSet(true);
+      }
+      if (incoming.get(1)) {
         struct.dbName = iprot.readString();
         struct.setDbNameIsSet(true);
       }
-      if (incoming.get(1)) {
+      if (incoming.get(2)) {
         struct.tableName = iprot.readString();
         struct.setTableNameIsSet(true);
       }
-      if (incoming.get(2)) {
+      if (incoming.get(3)) {
         struct.URI = iprot.readString();
         struct.setURIIsSet(true);
       }
+      if (incoming.get(4)) {
+        struct.grantorPrincipal = iprot.readString();
+        struct.setGrantorPrincipalIsSet(true);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/service/thrift/sentry_common_serviceConstants.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/service/thrift/sentry_common_serviceConstants.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/service/thrift/sentry_common_serviceConstants.java
index 8174fe2..c465737 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/service/thrift/sentry_common_serviceConstants.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/service/thrift/sentry_common_serviceConstants.java
@@ -43,4 +43,6 @@ public class sentry_common_serviceConstants {
 
   public static final int TSENTRY_STATUS_RUNTIME_ERROR = 3;
 
+  public static final int TSENTRY_STATUS_INVALID_INPUT = 4;
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/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 4c3e6ea..9642689 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
@@ -19,6 +19,7 @@
 package org.apache.sentry.provider.db.service.model;
 
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import javax.jdo.annotations.PersistenceCapable;
@@ -132,6 +133,19 @@ public class MSentryPrivilege {
   }
 
   public void appendRole(MSentryRole role) {
-    this.roles.add(role);
+    if (!roles.contains(role)) {
+      roles.add(role);
+      role.appendPrivilege(this);
+    }
+  }
+
+  public void removeRole(MSentryRole role) {
+    for (Iterator<MSentryRole> iter = roles.iterator(); iter.hasNext();) {
+      if (iter.next().getRoleName().equalsIgnoreCase(role.getRoleName())) {
+        iter.remove();
+        role.removePrivilege(this);
+        return;
+      }
+    }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
index 28416e0..9559c57 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
@@ -19,20 +19,23 @@
 package org.apache.sentry.provider.db.service.model;
 
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import javax.jdo.annotations.PersistenceCapable;
 
+import org.apache.sentry.provider.db.service.persistent.SentryNoSuchObjectException;
+
 @PersistenceCapable
 public class MSentryRole {
 
-  String roleName;
+  private String roleName;
   // set of privileges granted to this role
-  Set<MSentryPrivilege> privileges;
+  private Set<MSentryPrivilege> privileges;
   // set of groups this role belongs to
-  Set<MSentryGroup> groups;
-  long createTime;
-  String grantorPrincipal;
+  private Set<MSentryGroup> groups;
+  private long createTime;
+  private String grantorPrincipal;
 
   public MSentryRole() {
     privileges = new HashSet<MSentryPrivilege>();
@@ -87,12 +90,25 @@ public class MSentryRole {
     return groups;
   }
 
+  public void removePrivilege(MSentryPrivilege privilege) {
+    for (Iterator<MSentryPrivilege> iter = privileges.iterator(); iter.hasNext();) {
+      if (iter.next().getPrivilegeName().equalsIgnoreCase(privilege.getPrivilegeName())) {
+        iter.remove();
+        privilege.removeRole(this);
+        return;
+      }
+    }
+  }
+
   public void appendPrivileges(Set<MSentryPrivilege> privileges) {
     this.privileges.addAll(privileges);
   }
 
   public void appendPrivilege(MSentryPrivilege privilege) {
-    this.privileges.add(privilege);
+    if (!privileges.contains(privilege)) {
+      privileges.add(privilege);
+      privilege.appendRole(this);
+    }
   }
 
   public void appendGroups(Set<MSentryGroup> groups) {

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryInvalidInputException.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryInvalidInputException.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryInvalidInputException.java
new file mode 100644
index 0000000..6ac9942
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryInvalidInputException.java
@@ -0,0 +1,27 @@
+/**
+ * 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.provider.db.service.persistent;
+
+import org.apache.sentry.SentryUserException;
+
+public class SentryInvalidInputException extends SentryUserException {
+  private static final long serialVersionUID = 2962080655835L;
+  public SentryInvalidInputException(String msg) {
+    super(msg);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/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 7419a0d..5df6657 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
@@ -61,108 +61,6 @@ public class SentryStore {
     }
   }
 
-  public CommitContext createSentryRole(TSentryRole role)
-      throws SentryAlreadyExistsException {
-    boolean rollbackTransaction = true;
-    PersistenceManager pm = null;
-    try {
-      pm = openTransaction();
-      Query query = pm.newQuery(MSentryRole.class);
-      query.setFilter("roleName == t");
-      query.declareParameters("java.lang.String t");
-      query.setUnique(true);
-      MSentryRole sentryRole = (MSentryRole) query.execute(role.getRoleName());
-      if (sentryRole == null) {
-        MSentryRole mRole = convertToMSentryRole(role);
-        pm.makePersistent(mRole);
-        CommitContext commit = commitUpdateTransaction(pm);
-        rollbackTransaction = false;
-        return commit;
-      } else {
-        throw new SentryAlreadyExistsException("Role: " + role.getRoleName());
-      }
-    } finally {
-      if (rollbackTransaction) {
-        rollbackTransaction(pm);
-      }
-    }
-  }
-
-  public CommitContext createSentryPrivilege(TSentryPrivilege privilege)
-      throws SentryAlreadyExistsException {
-    // TODO implement
-    throw new RuntimeException("TODO");
-  }
-
-  public CommitContext alterSentryRoleAddGroups()
-      throws SentryNoSuchObjectException {
-    // TODO implement
-    throw new RuntimeException("TODO");
-  }
-
-  public CommitContext alterSentryRoleDeleteGroups()
-      throws SentryNoSuchObjectException {
-    // TODO implement
-    throw new RuntimeException("TODO");
-  }
-
-
-  public CommitContext dropSentryRole(String roleName)
-      throws SentryNoSuchObjectException {
-    boolean rollbackTransaction = true;
-    PersistenceManager pm = null;
-    roleName = roleName.trim();
-    try {
-      pm = openTransaction();
-      Query query = pm.newQuery(MSentryRole.class);
-      query.setFilter("roleName == t");
-      query.declareParameters("java.lang.String t");
-      query.setUnique(true);
-      MSentryRole sentryRole = (MSentryRole) query.execute(roleName);
-      if (sentryRole == null) {
-        throw new SentryNoSuchObjectException("Role " + roleName);
-      } else {
-        pm.retrieve(sentryRole);
-        sentryRole.removePrivileges();
-        pm.deletePersistent(sentryRole);
-      }
-      CommitContext commit = commitUpdateTransaction(pm);
-      rollbackTransaction = false;
-      return commit;
-    } finally {
-      if (rollbackTransaction) {
-        rollbackTransaction(pm);
-      }
-    }
-  }
-
-  public TSentryRole getSentryRoleByName(String roleName)
-      throws SentryNoSuchObjectException {
-    boolean rollbackTransaction = true;
-    PersistenceManager pm = null;
-    roleName = roleName.trim();
-    try {
-      pm = openTransaction();
-      Query query = pm.newQuery(MSentryRole.class);
-      query.setFilter("roleName == t");
-      query.declareParameters("java.lang.String t");
-      query.setUnique(true);
-      MSentryRole sentryRole = (MSentryRole) query.execute(roleName);
-      if (sentryRole == null) {
-        throw new SentryNoSuchObjectException("Role " + roleName);
-      } else {
-        pm.retrieve(sentryRole);
-      }
-      rollbackTransaction = false;
-      commitTransaction(pm);
-      return convertToSentryRole(sentryRole);
-    } finally {
-      if (rollbackTransaction) {
-        rollbackTransaction(pm);
-      }
-    }
-  }
-
   private Properties getDataSourceProperties() {
     Properties prop = new Properties();
     // FIXME: Read from configuration, override the default
@@ -181,9 +79,9 @@ public class SentryStore {
     prop.setProperty("datanucleus.rdbms.useLegacyNativeValueStrategy", "true");
     prop.setProperty("datanucleus.plugin.pluginRegistryBundleCheck", "LOG");
     prop.setProperty("javax.jdo.option.ConnectionDriverName",
-        "org.apache.derby.jdbc.EmbeddedDriver");
+                     "org.apache.derby.jdbc.EmbeddedDriver");
     prop.setProperty("javax.jdo.PersistenceManagerFactoryClass",
-        "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
+                     "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
     prop.setProperty("javax.jdo.option.DetachAllOnCommit", "true");
     prop.setProperty("javax.jdo.option.NonTransactionalRead", "false");
     prop.setProperty("javax.jdo.option.NonTransactionalWrite", "false");
@@ -191,7 +89,7 @@ public class SentryStore {
     prop.setProperty("javax.jdo.option.ConnectionPassword", "Sentry");
     prop.setProperty("javax.jdo.option.Multithreaded", "true");
     prop.setProperty("javax.jdo.option.ConnectionURL",
-        "jdbc:derby:;databaseName=sentry_policy_db;create=true");
+                     "jdbc:derby:;databaseName=sentry_policy_db;create=true");
     return prop;
   }
 
@@ -205,6 +103,8 @@ public class SentryStore {
    *
    * Note that there's only one instance of PersistenceManagerFactory object
    * for the service.
+   *
+   * Synchronized because we obtain persistence manager
    */
   private synchronized PersistenceManager openTransaction() {
     PersistenceManager pm = pmf.getPersistenceManager();
@@ -230,7 +130,7 @@ public class SentryStore {
   private synchronized long incrementGetSequenceId() {
     return ++commitSequenceId;
   }
-  
+
   private void commitTransaction(PersistenceManager pm) {
     Transaction currentTransaction = pm.currentTransaction();
     try {
@@ -255,6 +155,170 @@ public class SentryStore {
     }
   }
 
+  public CommitContext createSentryRole(TSentryRole role)
+  throws SentryAlreadyExistsException {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    try {
+      pm = openTransaction();
+      Query query = pm.newQuery(MSentryRole.class);
+      query.setFilter("this.roleName == t");
+      query.declareParameters("java.lang.String t");
+      query.setUnique(true);
+      MSentryRole sentryRole = (MSentryRole) query.execute(role.getRoleName());
+      if (sentryRole == null) {
+        MSentryRole mRole = convertToMSentryRole(role);
+        pm.makePersistent(mRole);
+        CommitContext commit = commitUpdateTransaction(pm);
+        rollbackTransaction = false;
+        return commit;
+      } else {
+        throw new SentryAlreadyExistsException("Role: " + role.getRoleName());
+      }
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
+  //TODO: handle case where a) privilege already exists, b) role to privilege mapping already exists
+  public CommitContext alterSentryRoleGrantPrivilege(String roleName,
+      TSentryPrivilege privilege) throws SentryNoSuchObjectException {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    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 {
+        MSentryPrivilege mPrivilege = convertToMSentryPrivilege(privilege);
+        // add privilege and role objects to each other. needed by datanucleus to model
+        // m:n relationships correctly through a join table.
+        mRole.appendPrivilege(mPrivilege);
+        pm.makePersistent(mRole);
+        pm.makePersistent(mPrivilege);
+        CommitContext commit = commitUpdateTransaction(pm);
+        rollbackTransaction = false;
+        return commit;
+      }
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
+  public CommitContext alterSentryRoleRevokePrivilege(String roleName,
+      String privilegeName) throws SentryNoSuchObjectException {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    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);
+        query.setFilter("this.privilegeName == t");
+        query.declareParameters("java.lang.String t");
+        query.setUnique(true);
+        MSentryPrivilege mPrivilege = (MSentryPrivilege) query.execute(privilegeName);
+        if (mPrivilege == null) {
+          throw new SentryNoSuchObjectException("Privilege: " + privilegeName);
+        } else {
+          // remove privilege and role objects from each other's set. needed by datanucleus to model
+          // m:n relationships correctly through a join table.
+          mRole.removePrivilege(mPrivilege);
+          CommitContext commit = commitUpdateTransaction(pm);
+          rollbackTransaction = false;
+          return commit;
+        }
+      }
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
+  public CommitContext dropSentryRole(String roleName)
+  throws SentryNoSuchObjectException {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    roleName = roleName.trim();
+    try {
+      pm = openTransaction();
+      Query query = pm.newQuery(MSentryRole.class);
+      query.setFilter("this.roleName == t");
+      query.declareParameters("java.lang.String t");
+      query.setUnique(true);
+      MSentryRole sentryRole = (MSentryRole) query.execute(roleName);
+      if (sentryRole == null) {
+        throw new SentryNoSuchObjectException("Role " + roleName);
+      } else {
+        pm.retrieve(sentryRole);
+        sentryRole.removePrivileges();
+        pm.deletePersistent(sentryRole);
+      }
+      CommitContext commit = commitUpdateTransaction(pm);
+      rollbackTransaction = false;
+      return commit;
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
+  public CommitContext alterSentryRoleAddGroups()
+  throws SentryNoSuchObjectException {
+    // TODO implement
+    throw new RuntimeException("TODO");
+  }
+
+  public CommitContext alterSentryRoleDeleteGroups()
+  throws SentryNoSuchObjectException {
+    // TODO implement
+    throw new RuntimeException("TODO");
+  }
+
+  public TSentryRole getSentryRoleByName(String roleName)
+  throws SentryNoSuchObjectException {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    roleName = roleName.trim();
+    try {
+      pm = openTransaction();
+      Query query = pm.newQuery(MSentryRole.class);
+      query.setFilter("this.roleName == t");
+      query.declareParameters("java.lang.String t");
+      query.setUnique(true);
+      MSentryRole sentryRole = (MSentryRole) query.execute(roleName);
+      if (sentryRole == null) {
+        throw new SentryNoSuchObjectException("Role " + roleName);
+      } else {
+        pm.retrieve(sentryRole);
+      }
+      rollbackTransaction = false;
+      commitTransaction(pm);
+      return convertToSentryRole(sentryRole);
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
   private MSentryRole convertToMSentryRole(TSentryRole role) {
     MSentryRole mRole = new MSentryRole();
     mRole.setCreateTime(role.getCreateTime());
@@ -290,11 +354,9 @@ public class SentryStore {
     privilege.setTableName(mSentryPrivilege.getTableName());
     privilege.setURI(mSentryPrivilege.getURI());
     privilege.setGrantorPrincipal(mSentryPrivilege.getGrantorPrincipal());
-
     return privilege;
   }
 
-  @SuppressWarnings("unused")
   private MSentryPrivilege convertToMSentryPrivilege(TSentryPrivilege privilege) {
     MSentryPrivilege mSentryPrivilege = new MSentryPrivilege();
     mSentryPrivilege.setServerName(privilege.getServerName());
@@ -306,7 +368,6 @@ public class SentryStore {
     mSentryPrivilege.setGrantorPrincipal(privilege.getGrantorPrincipal());
     mSentryPrivilege.setURI(privilege.getURI());
     mSentryPrivilege.setPrivilegeName(privilege.getPrivilegeName());
-    //MSentryRole mSentryRole = convertToMSentryRole(role);
     return mSentryPrivilege;
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
index dbd8dae..506d433 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
@@ -44,16 +44,19 @@ public abstract class NotificationHandler {
   }
 
   public void create_sentry_role(CommitContext context,
-      TCreateSentryRoleRequest request, TCreateSentryRoleResponse response) {
+                                 TCreateSentryRoleRequest request, TCreateSentryRoleResponse response) {
   }
 
   public void drop_sentry_role(CommitContext context, TDropSentryRoleRequest request,
-      TDropSentryRoleResponse response) {
+                               TDropSentryRoleResponse response) {
   }
 
-  public void create_sentry_privilege(CommitContext context,
-      TCreateSentryPrivilegeRequest request,
-      TCreateSentryPrivilegeResponse response) {
+  public void alter_sentry_role_grant_privilege(CommitContext context, TAlterSentryRoleGrantPrivilegeRequest request,
+      TAlterSentryRoleGrantPrivilegeResponse response) {
+  }
+
+  public void alter_sentry_role_revoke_privilege(CommitContext context, TAlterSentryRoleRevokePrivilegeRequest request,
+      TAlterSentryRoleRevokePrivilegeResponse response) {
   }
 
   public void alter_sentry_role_add_groups(CommitContext context,
@@ -62,7 +65,7 @@ public abstract class NotificationHandler {
   }
 
   public void alter_sentry_role_delete_groups(
-      CommitContext context, TAlterSentryRoleDeleteGroupsRequest request,
-      TAlterSentryRoleDeleteGroupsResponse response) {
+    CommitContext context, TAlterSentryRoleDeleteGroupsRequest request,
+    TAlterSentryRoleDeleteGroupsResponse response) {
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
index 2425ac3..9d9e867 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
@@ -38,58 +38,76 @@ public class NotificationHandlerInvoker extends NotificationHandler {
   private final ImmutableList<NotificationHandler> handlers;
 
   public NotificationHandlerInvoker(Configuration conf, NotificationHandler handler)
-      throws Exception {
+  throws Exception {
     this(conf, ImmutableList.of(handler));
   }
 
   public NotificationHandlerInvoker(Configuration conf, List<NotificationHandler> handlers)
-      throws Exception {
+  throws Exception {
     super(conf);
     this.handlers = ImmutableList.copyOf(handlers);
   }
 
   @Override
   public void create_sentry_role(CommitContext context,
-      TCreateSentryRoleRequest request, TCreateSentryRoleResponse response) {
+                                 TCreateSentryRoleRequest request, TCreateSentryRoleResponse response) {
     for (NotificationHandler handler : handlers) {
       try {
         LOGGER.debug("Calling " + handler);
         handler.create_sentry_role(context,  new TCreateSentryRoleRequest(request),
-            new TCreateSentryRoleResponse(response));
+                                   new TCreateSentryRoleResponse(response));
       } catch (Exception ex) {
         LOGGER.error("Unexpected error in " + handler + ". Request: "
-            + request + ", Response: " + response, ex);
+                     + request + ", Response: " + response, ex);
       }
     }
   }
 
   @Override
   public void drop_sentry_role(CommitContext context, TDropSentryRoleRequest request,
-      TDropSentryRoleResponse response) {
+                               TDropSentryRoleResponse response) {
     for (NotificationHandler handler : handlers) {
       try {
         LOGGER.debug("Calling " + handler);
         handler.drop_sentry_role(context,  new TDropSentryRoleRequest(request),
-            new TDropSentryRoleResponse(response));
+                                 new TDropSentryRoleResponse(response));
       } catch (Exception ex) {
         LOGGER.error("Unexpected error in " + handler + ". Request: "
-            + request + ", Response: " + response, ex);
+                     + request + ", Response: " + response, ex);
       }
     }
   }
 
   @Override
-  public void create_sentry_privilege(CommitContext context,
-      TCreateSentryPrivilegeRequest request,
-      TCreateSentryPrivilegeResponse response) {
+  public void alter_sentry_role_grant_privilege(CommitContext context,
+      TAlterSentryRoleGrantPrivilegeRequest request,
+      TAlterSentryRoleGrantPrivilegeResponse response) {
     for (NotificationHandler handler : handlers) {
       try {
         LOGGER.debug("Calling " + handler);
-        handler.create_sentry_privilege(context, new TCreateSentryPrivilegeRequest(request),
-            new TCreateSentryPrivilegeResponse(response));
+        handler.alter_sentry_role_grant_privilege(context,
+            new TAlterSentryRoleGrantPrivilegeRequest(request),
+            new TAlterSentryRoleGrantPrivilegeResponse(response));
       } catch (Exception ex) {
         LOGGER.error("Unexpected error in " + handler + ". Request: "
-            + request + ", Response: " + response, ex);
+                     + request + ", Response: " + response, ex);
+      }
+    }
+  }
+
+  @Override
+  public void alter_sentry_role_revoke_privilege(CommitContext context,
+      TAlterSentryRoleRevokePrivilegeRequest request,
+      TAlterSentryRoleRevokePrivilegeResponse response) {
+    for (NotificationHandler handler : handlers) {
+      try {
+        LOGGER.debug("Calling " + handler);
+        handler.alter_sentry_role_revoke_privilege(context,
+            new TAlterSentryRoleRevokePrivilegeRequest(request),
+            new TAlterSentryRoleRevokePrivilegeResponse(response));
+      } catch (Exception ex) {
+        LOGGER.error("Unexpected error in " + handler + ". Request: "
+                     + request + ", Response: " + response, ex);
       }
     }
   }
@@ -102,26 +120,26 @@ public class NotificationHandlerInvoker extends NotificationHandler {
       try {
         LOGGER.debug("Calling " + handler);
         handler.alter_sentry_role_add_groups(context, new TAlterSentryRoleAddGroupsRequest(request),
-            new TAlterSentryRoleAddGroupsResponse(response));
+                                             new TAlterSentryRoleAddGroupsResponse(response));
       } catch (Exception ex) {
         LOGGER.error("Unexpected error in " + handler + ". Request: "
-            + request + ", Response: " + response, ex);
+                     + request + ", Response: " + response, ex);
       }
     }
   }
 
   @Override
   public void alter_sentry_role_delete_groups(
-      CommitContext context, TAlterSentryRoleDeleteGroupsRequest request,
-      TAlterSentryRoleDeleteGroupsResponse response) {
+    CommitContext context, TAlterSentryRoleDeleteGroupsRequest request,
+    TAlterSentryRoleDeleteGroupsResponse response) {
     for (NotificationHandler handler : handlers) {
       try {
         LOGGER.debug("Calling " + handler);
         handler.alter_sentry_role_delete_groups(context, new TAlterSentryRoleDeleteGroupsRequest(request),
-            new TAlterSentryRoleDeleteGroupsResponse(response));
+                                                new TAlterSentryRoleDeleteGroupsResponse(response));
       } catch (Exception ex) {
         LOGGER.error("Unexpected error in " + handler + ". Request: "
-            + request + ", Response: " + response, ex);
+                     + request + ", Response: " + response, ex);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a7df761d/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 aa83ffd..a4487ee 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
@@ -47,51 +47,61 @@ public class SentryPolicyServiceClient {
   private TTransport transport;
   private int connectionTimeout;
   private static final Logger LOGGER = LoggerFactory
-      .getLogger(SentryPolicyServiceClient.class);
+                                       .getLogger(SentryPolicyServiceClient.class);
 
   public SentryPolicyServiceClient(Configuration conf) throws Exception {
     this.conf = conf;
     this.serverAddress = NetUtils.createSocketAddr(Preconditions.checkNotNull(
-        conf.get(ClientConfig.SERVER_RPC_ADDRESS), "Config key "
-            + ClientConfig.SERVER_RPC_ADDRESS + " is required"), conf.getInt(
-        ClientConfig.SERVER_RPC_PORT, ClientConfig.SERVER_RPC_PORT_DEFAULT));
+                           conf.get(ClientConfig.SERVER_RPC_ADDRESS), "Config key "
+                           + ClientConfig.SERVER_RPC_ADDRESS + " is required"), conf.getInt(
+                           ClientConfig.SERVER_RPC_PORT, ClientConfig.SERVER_RPC_PORT_DEFAULT));
     this.connectionTimeout = conf.getInt(ClientConfig.SERVER_RPC_CONN_TIMEOUT,
-        ClientConfig.SERVER_RPC_CONN_TIMEOUT_DEFAULT);
+                                         ClientConfig.SERVER_RPC_CONN_TIMEOUT_DEFAULT);
     String serverPrincipal = Preconditions.checkNotNull(
-        conf.get(ServerConfig.PRINCIPAL), ServerConfig.PRINCIPAL
-            + " is required");
+                               conf.get(ServerConfig.PRINCIPAL), ServerConfig.PRINCIPAL
+                               + " is required");
     serverPrincipalParts = SaslRpcServer.splitKerberosName(serverPrincipal);
     Preconditions.checkArgument(serverPrincipalParts.length == 3,
-        "Kerberos principal should have 3 parts: " + serverPrincipal);
+                                "Kerberos principal should have 3 parts: " + serverPrincipal);
     transport = new TSocket(serverAddress.getHostString(),
-        serverAddress.getPort(), connectionTimeout);
+                            serverAddress.getPort(), connectionTimeout);
     TTransport saslTransport = new TSaslClientTransport(
-        AuthMethod.KERBEROS.getMechanismName(), null, serverPrincipalParts[0],
-        serverPrincipalParts[1], ClientConfig.SASL_PROPERTIES, null, transport);
+      AuthMethod.KERBEROS.getMechanismName(), null, serverPrincipalParts[0],
+      serverPrincipalParts[1], ClientConfig.SASL_PROPERTIES, null, transport);
     saslTransport.open();
     LOGGER.info("Successfully opened transport");
     TMultiplexedProtocol protocol = new TMultiplexedProtocol(
-        new TBinaryProtocol(saslTransport),
-        SentryPolicyStoreProcessor.SENTRY_POLICY_SERVICE_NAME);
+      new TBinaryProtocol(saslTransport),
+      SentryPolicyStoreProcessor.SENTRY_POLICY_SERVICE_NAME);
     client = new SentryPolicyService.Client(protocol);
     LOGGER.info("Successfully created client");
   }
 
   public TCreateSentryRoleResponse createRole(TCreateSentryRoleRequest req)
-      throws TException {
+  throws TException {
     return client.create_sentry_role(req);
   }
 
   public TListSentryRolesResponse listRoleByName(TListSentryRolesRequest req)
-      throws TException {
+  throws TException {
     return client.list_sentry_roles_by_role_name(req);
   }
 
   public TDropSentryRoleResponse dropRole(TDropSentryRoleRequest req)
-      throws TException {
+  throws TException {
     return client.drop_sentry_role(req);
   }
 
+  public TAlterSentryRoleGrantPrivilegeResponse grantPrivilege(TAlterSentryRoleGrantPrivilegeRequest req)
+  throws TException {
+    return client.alter_sentry_role_grant_privilege(req);
+  }
+
+  public TAlterSentryRoleRevokePrivilegeResponse revokePrivilege(TAlterSentryRoleRevokePrivilegeRequest req)
+  throws TException {
+    return client.alter_sentry_role_revoke_privilege(req);
+  }
+
   public void close() {
     if (transport != null) {
       transport.close();