类org.apache.hadoop.mapred.Master源码实例Demo

下面列出了怎么用org.apache.hadoop.mapred.Master的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hadoop   文件: TokenCache.java
/**
 * get delegation token for a specific FS
 * @param fs
 * @param credentials
 * @param p
 * @param conf
 * @throws IOException
 */
static void obtainTokensForNamenodesInternal(FileSystem fs, 
    Credentials credentials, Configuration conf) throws IOException {
  String delegTokenRenewer = Master.getMasterPrincipal(conf);
  if (delegTokenRenewer == null || delegTokenRenewer.length() == 0) {
    throw new IOException(
        "Can't get Master Kerberos principal for use as renewer");
  }
  mergeBinaryTokens(credentials, conf);

  final Token<?> tokens[] = fs.addDelegationTokens(delegTokenRenewer,
                                                   credentials);
  if (tokens != null) {
    for (Token<?> token : tokens) {
      LOG.info("Got dt for " + fs.getUri() + "; "+token);
    }
  }
}
 
源代码2 项目: hadoop   文件: TestTokenCache.java
@Test
public void testSingleTokenFetch() throws Exception {
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/[email protected]");
  String renewer = Master.getMasterPrincipal(conf);
  Credentials credentials = new Credentials();
  
  final MockFileSystem fs = new MockFileSystem();
  final MockFileSystem mockFs = (MockFileSystem) fs.getRawFileSystem();
  when(mockFs.getCanonicalServiceName()).thenReturn("host:0");
  when(mockFs.getUri()).thenReturn(new URI("mockfs://host:0"));
  
  Path mockPath = mock(Path.class);
  when(mockPath.getFileSystem(conf)).thenReturn(mockFs);
  
  Path[] paths = new Path[]{ mockPath, mockPath };
  when(mockFs.addDelegationTokens("me", credentials)).thenReturn(null);
  TokenCache.obtainTokensForNamenodesInternal(credentials, paths, conf);
  verify(mockFs, times(1)).addDelegationTokens(renewer, credentials);
}
 
源代码3 项目: big-c   文件: TokenCache.java
/**
 * get delegation token for a specific FS
 * @param fs
 * @param credentials
 * @param p
 * @param conf
 * @throws IOException
 */
static void obtainTokensForNamenodesInternal(FileSystem fs, 
    Credentials credentials, Configuration conf) throws IOException {
  String delegTokenRenewer = Master.getMasterPrincipal(conf);
  if (delegTokenRenewer == null || delegTokenRenewer.length() == 0) {
    throw new IOException(
        "Can't get Master Kerberos principal for use as renewer");
  }
  mergeBinaryTokens(credentials, conf);

  final Token<?> tokens[] = fs.addDelegationTokens(delegTokenRenewer,
                                                   credentials);
  if (tokens != null) {
    for (Token<?> token : tokens) {
      LOG.info("Got dt for " + fs.getUri() + "; "+token);
    }
  }
}
 
源代码4 项目: big-c   文件: TestTokenCache.java
@Test
public void testSingleTokenFetch() throws Exception {
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/[email protected]");
  String renewer = Master.getMasterPrincipal(conf);
  Credentials credentials = new Credentials();
  
  final MockFileSystem fs = new MockFileSystem();
  final MockFileSystem mockFs = (MockFileSystem) fs.getRawFileSystem();
  when(mockFs.getCanonicalServiceName()).thenReturn("host:0");
  when(mockFs.getUri()).thenReturn(new URI("mockfs://host:0"));
  
  Path mockPath = mock(Path.class);
  when(mockPath.getFileSystem(conf)).thenReturn(mockFs);
  
  Path[] paths = new Path[]{ mockPath, mockPath };
  when(mockFs.addDelegationTokens("me", credentials)).thenReturn(null);
  TokenCache.obtainTokensForNamenodesInternal(credentials, paths, conf);
  verify(mockFs, times(1)).addDelegationTokens(renewer, credentials);
}
 
源代码5 项目: incubator-gobblin   文件: TokenUtils.java
private static Token<?> getDelegationTokenFromHS(HSClientProtocol hsProxy, Configuration conf) throws IOException {
  GetDelegationTokenRequest request =
      RecordFactoryProvider.getRecordFactory(null).newRecordInstance(GetDelegationTokenRequest.class);
  request.setRenewer(Master.getMasterPrincipal(conf));
  org.apache.hadoop.yarn.api.records.Token mrDelegationToken;
  mrDelegationToken = hsProxy.getDelegationToken(request).getDelegationToken();
  return ConverterUtils.convertFromYarn(mrDelegationToken, hsProxy.getConnectAddress());
}
 
private Token<?> getDelegationTokenFromHS(HSClientProtocol hsProxy)
    throws IOException, InterruptedException {
  GetDelegationTokenRequest request =
      recordFactory.newRecordInstance(GetDelegationTokenRequest.class);
  request.setRenewer(Master.getMasterPrincipal(conf));
  org.apache.hadoop.yarn.api.records.Token mrDelegationToken;
  mrDelegationToken =
      hsProxy.getDelegationToken(request).getDelegationToken();
  return ConverterUtils.convertFromYarn(mrDelegationToken,
      hsProxy.getConnectAddress());
}
 
源代码7 项目: hadoop   文件: TestTokenCache.java
@BeforeClass
public static void setup() throws Exception {
  conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/[email protected]");
  renewer = Master.getMasterPrincipal(conf);
}
 
源代码8 项目: big-c   文件: TestTokenCache.java
@BeforeClass
public static void setup() throws Exception {
  conf = new Configuration();
  conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/[email protected]");
  renewer = Master.getMasterPrincipal(conf);
}
 
 类所在包
 同包方法