当前位置: 首页>>代码示例>>Java>>正文


Java NameNode.getNameNodeAddress方法代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.server.namenode.NameNode.getNameNodeAddress方法的典型用法代码示例。如果您正苦于以下问题:Java NameNode.getNameNodeAddress方法的具体用法?Java NameNode.getNameNodeAddress怎么用?Java NameNode.getNameNodeAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hdfs.server.namenode.NameNode的用法示例。


在下文中一共展示了NameNode.getNameNodeAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIsInSafemode

import org.apache.hadoop.hdfs.server.namenode.NameNode; //导入方法依赖的package包/类
/**
 * DFS#isInSafeMode should check the ActiveNNs safemode in HA enabled cluster. HDFS-3507
 * 
 * @throws Exception
 */
@Test
public void testIsInSafemode() throws Exception {
  // Check for the standby nn without client failover.
  NameNode nn2 = cluster.getNameNode(1);
  assertTrue("nn2 should be in standby state", nn2.isStandbyState());

  InetSocketAddress nameNodeAddress = nn2.getNameNodeAddress();
  Configuration conf = new Configuration();
  DistributedFileSystem dfs = new DistributedFileSystem();
  try {
    dfs.initialize(
        URI.create("hdfs://" + nameNodeAddress.getHostName() + ":"
            + nameNodeAddress.getPort()), conf);
    dfs.isInSafeMode();
    fail("StandBy should throw exception for isInSafeMode");
  } catch (IOException e) {
    if (e instanceof RemoteException) {
      IOException sbExcpetion = ((RemoteException) e).unwrapRemoteException();
      assertTrue("StandBy nn should not support isInSafeMode",
          sbExcpetion instanceof StandbyException);
    } else {
      throw e;
    }
  } finally {
    if (null != dfs) {
      dfs.close();
    }
  }

  // Check with Client FailOver
  cluster.transitionToStandby(0);
  cluster.transitionToActive(1);
  cluster.getNameNodeRpc(1).setSafeMode(SafeModeAction.SAFEMODE_ENTER, false);
  DistributedFileSystem dfsWithFailOver = (DistributedFileSystem) fs;
  assertTrue("ANN should be in SafeMode", dfsWithFailOver.isInSafeMode());

  cluster.getNameNodeRpc(1).setSafeMode(SafeModeAction.SAFEMODE_LEAVE, false);
  assertFalse("ANN should be out of SafeMode", dfsWithFailOver.isInSafeMode());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:45,代码来源:TestHASafeMode.java

示例2: createCredentials

import org.apache.hadoop.hdfs.server.namenode.NameNode; //导入方法依赖的package包/类
/** A utility method for creating credentials. */
public static Credentials createCredentials(final NameNode namenode,
    final UserGroupInformation ugi, final String renewer) throws IOException {
  final Token<DelegationTokenIdentifier> token = namenode.getRpcServer(
      ).getDelegationToken(new Text(renewer));
  if (token == null) {
    return null;
  }

  final InetSocketAddress addr = namenode.getNameNodeAddress();
  SecurityUtil.setTokenService(token, addr);
  final Credentials c = new Credentials();
  c.addToken(new Text(ugi.getShortUserName()), token);
  return c;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:DelegationTokenSecretManager.java

示例3: getDfsClient

import org.apache.hadoop.hdfs.server.namenode.NameNode; //导入方法依赖的package包/类
private static DFSClient getDfsClient(NameNode nn,
    Configuration conf) throws IOException {
  return new DFSClient(nn.getNameNodeAddress(), conf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:TestDecommission.java


注:本文中的org.apache.hadoop.hdfs.server.namenode.NameNode.getNameNodeAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。