@Test public void getProxyUGIFromEmptyCache() throws Exception { UserGroupInformation ugi = cache.getUserGroupInformation(session, true); assertNotNull(ugi); verify(provider).createProxyUGI("the-user", UserGroupInformation.getLoginUser()); }
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") public UserGroupInformation getUserGroupInformation(SessionId session, boolean isProxyUser) throws IOException { Integer segmentId = session.getSegmentId(); String user = session.getUser(); DelayQueue<Entry> delayQueue = getExpirationQueue(segmentId); synchronized (delayQueue) { cleanup(delayQueue); Entry entry = cache.get(session); if (entry == null) { UserGroupInformation ugi; if (isProxyUser) { LOG.debug("{} Creating proxy user = {}", session, user); ugi = ugiProvider.createProxyUGI(user, session.getLoginUser()); } else { LOG.debug("{} Creating remote user = {}", session, user); ugi = ugiProvider.createRemoteUser(user, session); } entry = new Entry(ticker, ugi, session); delayQueue.offer(entry); cache.put(session, entry); } entry.incrementRefCount(); return entry.getUGI(); } }
UGICache { @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") public UserGroupInformation getUserGroupInformation(SessionId session, boolean isProxyUser) throws IOException { Integer segmentId = session.getSegmentId(); String user = session.getUser(); DelayQueue<Entry> delayQueue = getExpirationQueue(segmentId); synchronized (delayQueue) { cleanup(delayQueue); Entry entry = cache.get(session); if (entry == null) { UserGroupInformation ugi; if (isProxyUser) { LOG.debug("{} Creating proxy user = {}", session, user); ugi = ugiProvider.createProxyUGI(user, session.getLoginUser()); } else { LOG.debug("{} Creating remote user = {}", session, user); ugi = ugiProvider.createRemoteUser(user, session); } entry = new Entry(ticker, ugi, session); delayQueue.offer(entry); cache.put(session, entry); } entry.incrementRefCount(); return entry.getUGI(); } } }
UGICache { @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") public UserGroupInformation getUserGroupInformation(SessionId session, boolean isProxyUser) throws IOException { Integer segmentId = session.getSegmentId(); String user = session.getUser(); DelayQueue<Entry> delayQueue = getExpirationQueue(segmentId); synchronized (delayQueue) { cleanup(delayQueue); Entry entry = cache.get(session); if (entry == null) { UserGroupInformation ugi; if (isProxyUser) { LOG.debug("{} Creating proxy user = {}", session, user); ugi = ugiProvider.createProxyUGI(user, session.getLoginUser()); } else { LOG.debug("{} Creating remote user = {}", session, user); ugi = ugiProvider.createRemoteUser(user, session); } entry = new Entry(ticker, ugi, session); delayQueue.offer(entry); cache.put(session, entry); } entry.incrementRefCount(); return entry.getUGI(); } } UGICache(UGIProvider provider, Ticker ticker);  UGICache(); }
UGICache { @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") public UserGroupInformation getUserGroupInformation(SessionId session, boolean isProxyUser) throws IOException { Integer segmentId = session.getSegmentId(); String user = session.getUser(); DelayQueue<Entry> delayQueue = getExpirationQueue(segmentId); synchronized (delayQueue) { cleanup(delayQueue); Entry entry = cache.get(session); if (entry == null) { UserGroupInformation ugi; if (isProxyUser) { LOG.debug("{} Creating proxy user = {}", session, user); ugi = ugiProvider.createProxyUGI(user, session.getLoginUser()); } else { LOG.debug("{} Creating remote user = {}", session, user); ugi = ugiProvider.createRemoteUser(user, session); } entry = new Entry(ticker, ugi, session); delayQueue.offer(entry); cache.put(session, entry); } entry.incrementRefCount(); return entry.getUGI(); } } UGICache(UGIProvider provider, Ticker ticker);  UGICache(); @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") UserGroupInformation getUserGroupInformation(SessionId session, boolean isProxyUser); @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") void release(SessionId session, boolean cleanImmediatelyIfNoRefs); }
UGICache { @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") public UserGroupInformation getUserGroupInformation(SessionId session, boolean isProxyUser) throws IOException { Integer segmentId = session.getSegmentId(); String user = session.getUser(); DelayQueue<Entry> delayQueue = getExpirationQueue(segmentId); synchronized (delayQueue) { cleanup(delayQueue); Entry entry = cache.get(session); if (entry == null) { UserGroupInformation ugi; if (isProxyUser) { LOG.debug("{} Creating proxy user = {}", session, user); ugi = ugiProvider.createProxyUGI(user, session.getLoginUser()); } else { LOG.debug("{} Creating remote user = {}", session, user); ugi = ugiProvider.createRemoteUser(user, session); } entry = new Entry(ticker, ugi, session); delayQueue.offer(entry); cache.put(session, entry); } entry.incrementRefCount(); return entry.getUGI(); } } UGICache(UGIProvider provider, Ticker ticker);  UGICache(); @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") UserGroupInformation getUserGroupInformation(SessionId session, boolean isProxyUser); @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") void release(SessionId session, boolean cleanImmediatelyIfNoRefs);  }