/** * Get the authentication token of the user for the cluster specified in the configuration * @return null if the user does not have the token, otherwise the auth token for the cluster. */ private static Token<AuthenticationTokenIdentifier> getAuthToken(Configuration conf, User user) throws IOException, InterruptedException { ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "mr-init-credentials", null); try { String clusterId = ZKClusterId.readClusterIdZNode(zkw); return new AuthenticationTokenSelector().selectToken(new Text(clusterId), user.getUGI().getTokens()); } catch (KeeperException e) { throw new IOException(e); } finally { zkw.close(); } }