public void refreshLabelsCache(byte[] data) throws IOException { List<VisibilityLabel> visibilityLabels = null; try { visibilityLabels = VisibilityUtils.readLabelsFromZKData(data); } catch (DeserializationException dse) { throw new IOException(dse); } this.lock.writeLock().lock(); try { labels.clear(); ordinalVsLabels.clear(); for (VisibilityLabel visLabel : visibilityLabels) { String label = Bytes.toString(visLabel.getLabel().toByteArray()); labels.put(label, visLabel.getOrdinal()); ordinalVsLabels.put(visLabel.getOrdinal(), label); } } finally { this.lock.writeLock().unlock(); } }
public void refreshUserAuthsCache(byte[] data) throws IOException { MultiUserAuthorizations multiUserAuths = null; try { multiUserAuths = VisibilityUtils.readUserAuthsFromZKData(data); } catch (DeserializationException dse) { throw new IOException(dse); } this.lock.writeLock().lock(); try { this.userAuths.clear(); this.groupAuths.clear(); for (UserAuthorizations userAuths : multiUserAuths.getUserAuthsList()) { String user = Bytes.toString(userAuths.getUser().toByteArray()); if (AuthUtil.isGroupPrincipal(user)) { this.groupAuths.put( AuthUtil.getGroupName(user), new HashSet<Integer>(userAuths.getAuthList())); } else { this.userAuths.put(user, new HashSet<Integer>(userAuths.getAuthList())); } } } finally { this.lock.writeLock().unlock(); } }