@Test public void testUpdateToken() throws IOException { Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials(); Assert.assertNull(credentials.getToken(new Text("testService"))); YarnHelixUtils.updateToken(".token1"); credentials = UserGroupInformation.getCurrentUser().getCredentials(); Assert.assertNull(credentials.getToken(new Text("testService"))); YarnHelixUtils.updateToken(GobblinYarnConfigurationKeys.TOKEN_FILE_NAME); credentials = UserGroupInformation.getCurrentUser().getCredentials(); Token<?> readToken = credentials.getToken(new Text("testService")); Assert.assertNotNull(readToken); }
public static void updateToken(String tokenFileName) throws IOException{ URL tokenFileUrl = YarnHelixUtils.class.getClassLoader().getResource(tokenFileName); if (tokenFileUrl != null) { File tokenFile = new File(tokenFileUrl.getFile()); if (tokenFile.exists()) { Credentials credentials = Credentials.readTokenStorageFile(tokenFile, new Configuration()); for (Token<? extends TokenIdentifier> token : credentials.getAllTokens()) { LOGGER.info("updating " + token.getKind() + " " + token.getService()); } UserGroupInformation.getCurrentUser().addCredentials(credentials); } } }
YarnHelixUtils { public static void updateToken(String tokenFileName) throws IOException{ URL tokenFileUrl = YarnHelixUtils.class.getClassLoader().getResource(tokenFileName); if (tokenFileUrl != null) { File tokenFile = new File(tokenFileUrl.getFile()); if (tokenFile.exists()) { Credentials credentials = Credentials.readTokenStorageFile(tokenFile, new Configuration()); for (Token<? extends TokenIdentifier> token : credentials.getAllTokens()) { LOGGER.info("updating " + token.getKind() + " " + token.getService()); } UserGroupInformation.getCurrentUser().addCredentials(credentials); } } } }
YarnHelixUtils { public static void updateToken(String tokenFileName) throws IOException{ URL tokenFileUrl = YarnHelixUtils.class.getClassLoader().getResource(tokenFileName); if (tokenFileUrl != null) { File tokenFile = new File(tokenFileUrl.getFile()); if (tokenFile.exists()) { Credentials credentials = Credentials.readTokenStorageFile(tokenFile, new Configuration()); for (Token<? extends TokenIdentifier> token : credentials.getAllTokens()) { LOGGER.info("updating " + token.getKind() + " " + token.getService()); } UserGroupInformation.getCurrentUser().addCredentials(credentials); } } }  }
YarnHelixUtils { public static void updateToken(String tokenFileName) throws IOException{ URL tokenFileUrl = YarnHelixUtils.class.getClassLoader().getResource(tokenFileName); if (tokenFileUrl != null) { File tokenFile = new File(tokenFileUrl.getFile()); if (tokenFile.exists()) { Credentials credentials = Credentials.readTokenStorageFile(tokenFile, new Configuration()); for (Token<? extends TokenIdentifier> token : credentials.getAllTokens()) { LOGGER.info("updating " + token.getKind() + " " + token.getService()); } UserGroupInformation.getCurrentUser().addCredentials(credentials); } } }  static void writeTokenToFile(Token<? extends TokenIdentifier> token, Path tokenFilePath,
      Configuration configuration); static void updateToken(String tokenFileName); static Collection<Token<? extends TokenIdentifier>> readTokensFromFile(Path tokenFilePath,
      Configuration configuration); static void addFileAsLocalResource(FileSystem fs, Path destFilePath, LocalResourceType resourceType,
      Map<String, LocalResource> resourceMap); @SuppressWarnings("deprecation") static Map<String, String> getEnvironmentVariables(Configuration yarnConfiguration); static void setAdditionalYarnClassPath(Config config, Configuration yarnConfiguration); static String getContainerNum(String containerId); }
YarnHelixUtils { public static void updateToken(String tokenFileName) throws IOException{ URL tokenFileUrl = YarnHelixUtils.class.getClassLoader().getResource(tokenFileName); if (tokenFileUrl != null) { File tokenFile = new File(tokenFileUrl.getFile()); if (tokenFile.exists()) { Credentials credentials = Credentials.readTokenStorageFile(tokenFile, new Configuration()); for (Token<? extends TokenIdentifier> token : credentials.getAllTokens()) { LOGGER.info("updating " + token.getKind() + " " + token.getService()); } UserGroupInformation.getCurrentUser().addCredentials(credentials); } } }  static void writeTokenToFile(Token<? extends TokenIdentifier> token, Path tokenFilePath,
      Configuration configuration); static void updateToken(String tokenFileName); static Collection<Token<? extends TokenIdentifier>> readTokensFromFile(Path tokenFilePath,
      Configuration configuration); static void addFileAsLocalResource(FileSystem fs, Path destFilePath, LocalResourceType resourceType,
      Map<String, LocalResource> resourceMap); @SuppressWarnings("deprecation") static Map<String, String> getEnvironmentVariables(Configuration yarnConfiguration); static void setAdditionalYarnClassPath(Config config, Configuration yarnConfiguration); static String getContainerNum(String containerId);  }