Java Code Examples for org.apache.hadoop.hdfs.DFSUtil#getNameServiceIds()

The following examples show how to use org.apache.hadoop.hdfs.DFSUtil#getNameServiceIds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AvatarDataNode.java    From RDFS with Apache License 2.0 6 votes vote down vote up
@Override
void startDataNode(Configuration conf, 
                   AbstractList<File> dataDirs
                   ) throws IOException {
  initGlobalSetting(conf, dataDirs);
  
  Collection<String> serviceIds = DFSUtil.getNameServiceIds(conf);
  List<InetSocketAddress> defaultNameAddrs =
    AvatarDataNode.getDatanodeProtocolAddresses(conf, serviceIds);
  List<InetSocketAddress> nameAddrs0 = 
      DFSUtil.getRPCAddresses("0", conf, serviceIds,
         NameNode.DATANODE_PROTOCOL_ADDRESS, FSConstants.DFS_NAMENODE_RPC_ADDRESS_KEY);
  List<InetSocketAddress> nameAddrs1 = 
      DFSUtil.getRPCAddresses("1", conf, serviceIds,
         NameNode.DATANODE_PROTOCOL_ADDRESS, FSConstants.DFS_NAMENODE_RPC_ADDRESS_KEY);
  List<InetSocketAddress> avatarAddrs0 =
    AvatarDataNode.getAvatarNodeAddresses("0", conf, serviceIds);
  List<InetSocketAddress> avatarAddrs1 =
    AvatarDataNode.getAvatarNodeAddresses("1", conf, serviceIds);

  namespaceManager = new AvatarNamespaceManager(nameAddrs0, nameAddrs1,
      avatarAddrs0, avatarAddrs1, defaultNameAddrs, 
      DFSUtil.getNameServiceIds(conf));

  initDataSetAndScanner(conf, dataDirs, nameAddrs0.size());
}
 
Example 2
Source File: NameNode.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Valide if the input service name is valid
 * @param conf configuration
 * @param nameServiceId name service id
 * @return true if valid; false otherwise
 */
public static boolean validateServiceName(Configuration conf,
    String nameServiceId) {
  Collection<String> nameserviceIds = DFSUtil.getNameServiceIds(conf);
  if (nameserviceIds != null && !nameserviceIds.isEmpty()) {
    if (nameServiceId == null) {
      System.err.println("Need to input a nameservice id");
      return false;
    } else if (!nameserviceIds.contains(nameServiceId)) {
      System.err.println("An invalid nameservice id: " + nameServiceId);
      return false;
    }
  } else if (nameServiceId != null) {
    System.err.println("An invalid nameservice id: " + nameServiceId);
    return false;
  }
  return true;
}
 
Example 3
Source File: AvatarDataNode.java    From RDFS with Apache License 2.0 5 votes vote down vote up
@Override
public void refreshNamenodes(Configuration conf) throws IOException {
  LOG.info("refresh namenodes");
  try {
    Collection<String> serviceIds = DFSUtil.getNameServiceIds(conf);
    List<InetSocketAddress> defaultNameAddrs = 
        AvatarDataNode.getDatanodeProtocolAddresses(conf, serviceIds);
    List<InetSocketAddress> nameAddrs0 = 
        DFSUtil.getRPCAddresses("0", conf, serviceIds,
            NameNode.DATANODE_PROTOCOL_ADDRESS,
            FSConstants.DFS_NAMENODE_RPC_ADDRESS_KEY);
    List<InetSocketAddress> nameAddrs1 =
        DFSUtil.getRPCAddresses("1", conf, serviceIds,
            NameNode.DATANODE_PROTOCOL_ADDRESS, 
            FSConstants.DFS_NAMENODE_RPC_ADDRESS_KEY);
    List<InetSocketAddress> avatarAddrs0 =
        AvatarDataNode.getAvatarNodeAddresses("0", conf, serviceIds);
    List<InetSocketAddress> avatarAddrs1 =
        AvatarDataNode.getAvatarNodeAddresses("1", conf, serviceIds);
    ((AvatarNamespaceManager)namespaceManager).refreshNamenodes(
        nameAddrs0, nameAddrs1,
        avatarAddrs0, avatarAddrs1, 
        defaultNameAddrs, serviceIds);
  } catch (InterruptedException e) {
    throw new IOException(e.getCause());
  }
}
 
Example 4
Source File: DataNode.java    From RDFS with Apache License 2.0 5 votes vote down vote up
NamespaceManager(Configuration conf, List<InetSocketAddress> nameNodeAddrs)
    throws IOException {
  Collection<String> nameserviceIds = DFSUtil.getNameServiceIds(conf);
  Iterator<String> it = nameserviceIds.iterator();
  for(InetSocketAddress nnAddr : nameNodeAddrs){
    String nameserivceId = it.hasNext()? it.next(): null;
    NSOfferService nsos = new NSOfferService(nnAddr, nameserivceId);
    nameNodeThreads.put(nsos.getNNSocketAddress(), nsos);
  }
}