code: public static synchronized UnixUserGroupInformation getUgiForUser(
        String userName) {
      long now = System.currentTimeMillis();
      long cutoffTime = now - ugiLifetime;
      CachedUgi cachedUgi = ugiCache.get(userName);
      if (cachedUgi != null && cachedUgi.getInitTime() > cutoffTime)
        return cachedUgi.getUgi();
      UnixUserGroupInformation ugi = null;
      try {
        ugi = getUgi(userName);
      } catch (IOException e) {
        return null;
      }
      if (ugiCache.size() > CLEANUP_THRESHOLD) { // remove expired ugi's first
        for (Iterator<Map.Entry<String, CachedUgi>> it = ugiCache.entrySet()
            .iterator(); it.hasNext();) {
          Map.Entry<String, CachedUgi> e = it.next();
          if (e.getValue().getInitTime() < cutoffTime) {
            it.remove();
          }
        }
      }
      ugiCache.put(ugi.getUserName(), new CachedUgi(ugi, now));
      return ugi;
    }
docs: retrieve an ugi for a user. try the cache first, if not found, get it by
  running a shell command