public MSentryGroup(String groupName, long createTime, Set<MSentryRole> roles) { this.groupName = MSentryUtil.safeIntern(groupName); this.createTime = createTime; this.roles = roles; }
if (!MSentryUtil.isConsecutive(changes)) { String pathChangesIds = MSentryUtil.collapseChangeIDsToString(changes); LOGGER.error(String.format("Certain delta is missing in %s! The table may get corrupted. " + "Start changeID %s, Current size of elements = %s. path changeID list: %s",
/** * Given a collection of MSentryChange instances sorted by ID, return the string that prints in the collapsed format. * <p> * e.g: * <li> Input: [MSentryChange(1), MSentryChange(2), MSentryChange(3), MSentryChange(5), MSentryChange(7)] </li> * <li> Output: "[1-3, 5, 7]" </li> * </p> * @param changes List of {@link MSentryChange} * @return Collapsed string representation of the changeIDs */ public static String collapseChangeIDsToString(Collection<? extends MSentryChange> changes) { return SentryUtils.collapseNumsToString(getChangeIds(changes)); } }
@Test public void testMSentryUtilWithPathChanges() throws Exception { List<MSentryPathChange> changes = new ArrayList<>(); PathsUpdate update = new PathsUpdate(1, false); changes.add(new MSentryPathChange(1, "u1", update)); assertEquals("Collapsed string should match", "[1]", MSentryUtil.collapseChangeIDsToString(changes)); assertTrue("List of changes should be consecutive", MSentryUtil.isConsecutive(changes)); changes.add(new MSentryPathChange(2, "u2",update)); assertEquals("Collapsed string should match", "[1, 2]", MSentryUtil.collapseChangeIDsToString(changes)); assertTrue("List of changes should be consecutive", MSentryUtil.isConsecutive(changes)); changes.add(new MSentryPathChange(4, "u4",update)); assertEquals("Collapsed string should match", "[1, 2, 4]", MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes)); changes.add(new MSentryPathChange(5, "u5",update)); assertEquals("Collapsed string should match", "[1, 2, 4, 5]", MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes)); changes.add(new MSentryPathChange(6, "u6",update)); assertEquals("Collapsed string should match", "[1, 2, 4-6]", MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes)); changes.add(new MSentryPathChange(8, "u8",update)); assertEquals("Collapsed string should match", "[1, 2, 4-6, 8]", MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes)); }
MSentryUtil.collapseChangeIDsToString(changes)); assertTrue("List of changes should be consecutive", MSentryUtil.isConsecutive(changes)); MSentryUtil.collapseChangeIDsToString(changes)); assertTrue("List of changes should be consecutive", MSentryUtil.isConsecutive(changes)); MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes)); MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes)); MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes)); MSentryUtil.collapseChangeIDsToString(changes)); assertFalse("List of changes should not be consecutive", MSentryUtil.isConsecutive(changes));
public MPathToPersist(long authzObjectId, String path) { this.authzObjectId = authzObjectId; this.path = MSentryUtil.safeIntern(path); }
public MPath(String path) { this.path = MSentryUtil.safeIntern(path); }
public MSentryUser(String userName, long createTime, Set<MSentryRole> roles) { this.userName = MSentryUtil.safeIntern(userName); this.createTime = createTime; this.roles = roles; this.privileges = new HashSet<>(); }
public MSentryGMPrivilege(String componentName, String serviceName, List<? extends Authorizable> authorizables, String action, Boolean grantOption) { this.componentName = MSentryUtil.safeIntern(componentName); this.serviceName = MSentryUtil.safeIntern(serviceName); this.action = MSentryUtil.safeIntern(action); this.grantOption = grantOption; this.roles = new HashSet<>(); this.createTime = System.currentTimeMillis(); setAuthorizables(authorizables); }
public MAuthzPathsMapping(long authzSnapshotID, long authzObjectId, String authzObjName, Collection<String> paths) { this.authzSnapshotID = authzSnapshotID; this.authzObjectId = authzObjectId; this.authzObjName = MSentryUtil.safeIntern(authzObjName); this.pathsPersisted = Collections.EMPTY_SET; this.pathsToPersist = new HashSet<>(paths.size()); for(String path : paths) { this.pathsToPersist.add(path); } this.createTimeMs = System.currentTimeMillis(); }
public MSentryRole(String roleName, long createTime) { this.roleName = MSentryUtil.safeIntern(roleName); this.createTime = createTime; privileges = new HashSet<>(); gmPrivileges = new HashSet<>(); groups = new HashSet<>(); users = new HashSet<>(); }
public MSentryPrivilege(String privilegeScope, String serverName, String dbName, String tableName, String columnName, String URI, String action, Boolean grantOption) { this.privilegeScope = MSentryUtil.safeIntern(privilegeScope); this.serverName = MSentryUtil.safeIntern(serverName); this.dbName = SentryStore.toNULLCol(dbName).intern(); this.tableName = SentryStore.toNULLCol(tableName).intern(); this.columnName = SentryStore.toNULLCol(columnName).intern(); this.URI = SentryStore.toNULLCol(URI).intern(); this.action = SentryStore.toNULLCol(action).intern(); this.grantOption = grantOption; this.roles = new HashSet<>(); this.users = new HashSet<>(); }