Hey All, I'd like to discuss a design improvement of the SentryStore implementation. This class is currently used to deal with data stored in the Sentry database.
I noticed that this class is always changing and new public methods are added to deal with data in several ways. For instance, we have: - 98 public methods on master - 75 public methods in 2.0, - 36 public methods in 1.8 The class is dealing with Thrift objects as well which. Also, there are methods only to return data transformed in different ways, like return privileges in a map<String, TSentryPrivilege> or a list of Privileges or a MSentryPrivilege, etc. I think it is time to improve this class and make it more abstract. What do you think of separating the implementation of JDO and its transactions to a SentryDataStore interface and JDO implementation instead? We could keep the SentryStore implementation to deal with all these special JDO transformations, but let the SentryDataStore read and write JDO Objects instead, do filtering of those objects, do transaction retries if necessary, etc. For instance: public class SentryStore { private SentryDataStore dataStore; public SentryStore(Configuration conf) { SentryDataStore = new SentryDataStore(conf); } public Set<TSentryRole> getAllRoles() { Set<TSentryRole> roles = new HashSet<>(); for (MSentryRole : dataStore.getRoles()) { roles.add(convertToTSentryRole(role)); } } } public interface SentryDataStore { Collection<MSentryRole> getRoles(); } public class SentryDataStoreJDO extends SentryDataStore { public Collection<MSentryRole> getRoles() { tm.executeTransaction(new Transaction() { // Datanucleus Implementation here }); } } - Sergio