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


Java NetworkTopology.getLastHalf方法代码示例

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


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

示例1: checkTargetsOnDifferentNodeGroup

import org.apache.hadoop.net.NetworkTopology; //导入方法依赖的package包/类
/**
 * Scan the targets list: all targets should be on different NodeGroups.
 * Return false if two targets are found on the same NodeGroup.
 */
private static boolean checkTargetsOnDifferentNodeGroup(
    DatanodeStorageInfo[] targets) {
  if(targets.length == 0)
    return true;
  Set<String> targetSet = new HashSet<String>();
  for(DatanodeStorageInfo storage:targets) {
    final DatanodeDescriptor node = storage.getDatanodeDescriptor();
    String nodeGroup = NetworkTopology.getLastHalf(node.getNetworkLocation());
    if(targetSet.contains(nodeGroup)) {
      return false;
    } else {
      targetSet.add(nodeGroup);
    }
  }
  return true;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestReplicationPolicyWithNodeGroup.java

示例2: checkTargetsOnDifferentNodeGroup

import org.apache.hadoop.net.NetworkTopology; //导入方法依赖的package包/类
/**
 * Scan the targets list: all targets should be on different NodeGroups.
 * Return false if two targets are found on the same NodeGroup.
 */
private static boolean checkTargetsOnDifferentNodeGroup(
    DatanodeStorageInfo[] targets) {
  if(targets.length == 0)
    return true;
  Set<String> targetSet = new HashSet<>();
  for(DatanodeStorageInfo storage:targets) {
    final DatanodeDescriptor node = storage.getDatanodeDescriptor();
    String nodeGroup = NetworkTopology.getLastHalf(node.getNetworkLocation());
    if(targetSet.contains(nodeGroup)) {
      return false;
    } else {
      targetSet.add(nodeGroup);
    }
  }
  return true;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:21,代码来源:TestReplicationPolicyWithNodeGroup.java

示例3: checkTargetsOnDifferentNodeGroup

import org.apache.hadoop.net.NetworkTopology; //导入方法依赖的package包/类
/**
 * Scan the targets list: all targets should be on different NodeGroups.
 * Return false if two targets are found on the same NodeGroup.
 */
private static boolean checkTargetsOnDifferentNodeGroup(
    DatanodeDescriptor[] targets) {
  if(targets.length == 0)
    return true;
  Set<String> targetSet = new HashSet<String>();
  for(DatanodeDescriptor node:targets) {
    String nodeGroup = NetworkTopology.getLastHalf(node.getNetworkLocation());
    if(targetSet.contains(nodeGroup)) {
      return false;
    } else {
      targetSet.add(nodeGroup);
    }
  }
  return true;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:20,代码来源:TestReplicationPolicyWithNodeGroup.java

示例4: pickupReplicaSet

import org.apache.hadoop.net.NetworkTopology; //导入方法依赖的package包/类
/**
 * Pick up replica node set for deleting replica as over-replicated. 
 * First set contains replica nodes on rack with more than one
 * replica while second set contains remaining replica nodes.
 * If first is not empty, divide first set into two subsets:
 *   moreThanOne contains nodes on nodegroup with more than one replica
 *   exactlyOne contains the remaining nodes in first set
 * then pickup priSet if not empty.
 * If first is empty, then pick second.
 */
@Override
public Collection<DatanodeStorageInfo> pickupReplicaSet(
    Collection<DatanodeStorageInfo> first,
    Collection<DatanodeStorageInfo> second) {
  // If no replica within same rack, return directly.
  if (first.isEmpty()) {
    return second;
  }
  // Split data nodes in the first set into two sets, 
  // moreThanOne contains nodes on nodegroup with more than one replica
  // exactlyOne contains the remaining nodes
  Map<String, List<DatanodeStorageInfo>> nodeGroupMap = 
      new HashMap<String, List<DatanodeStorageInfo>>();
  
  for(DatanodeStorageInfo storage : first) {
    final String nodeGroupName = NetworkTopology.getLastHalf(
        storage.getDatanodeDescriptor().getNetworkLocation());
    List<DatanodeStorageInfo> storageList = nodeGroupMap.get(nodeGroupName);
    if (storageList == null) {
      storageList = new ArrayList<DatanodeStorageInfo>();
      nodeGroupMap.put(nodeGroupName, storageList);
    }
    storageList.add(storage);
  }
  
  final List<DatanodeStorageInfo> moreThanOne = new ArrayList<DatanodeStorageInfo>();
  final List<DatanodeStorageInfo> exactlyOne = new ArrayList<DatanodeStorageInfo>();
  // split nodes into two sets
  for(List<DatanodeStorageInfo> datanodeList : nodeGroupMap.values()) {
    if (datanodeList.size() == 1 ) {
      // exactlyOne contains nodes on nodegroup with exactly one replica
      exactlyOne.add(datanodeList.get(0));
    } else {
      // moreThanOne contains nodes on nodegroup with more than one replica
      moreThanOne.addAll(datanodeList);
    }
  }
  
  return moreThanOne.isEmpty()? exactlyOne : moreThanOne;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:51,代码来源:BlockPlacementPolicyWithNodeGroup.java

示例5: pickupReplicaSet

import org.apache.hadoop.net.NetworkTopology; //导入方法依赖的package包/类
/**
 * Pick up replica node set for deleting replica as over-replicated. 
 * First set contains replica nodes on rack with more than one
 * replica while second set contains remaining replica nodes.
 * If first is not empty, divide first set into two subsets:
 *   moreThanOne contains nodes on nodegroup with more than one replica
 *   exactlyOne contains the remaining nodes in first set
 * then pickup priSet if not empty.
 * If first is empty, then pick second.
 */
@Override
public Collection<DatanodeStorageInfo> pickupReplicaSet(
    Collection<DatanodeStorageInfo> first,
    Collection<DatanodeStorageInfo> second,
    Map<String, List<DatanodeStorageInfo>> rackMap) {
  // If no replica within same rack, return directly.
  if (first.isEmpty()) {
    return second;
  }
  // Split data nodes in the first set into two sets, 
  // moreThanOne contains nodes on nodegroup with more than one replica
  // exactlyOne contains the remaining nodes
  Map<String, List<DatanodeStorageInfo>> nodeGroupMap = new HashMap<>();
  
  for(DatanodeStorageInfo storage : first) {
    final String nodeGroupName = NetworkTopology.getLastHalf(
        storage.getDatanodeDescriptor().getNetworkLocation());
    List<DatanodeStorageInfo> storageList = nodeGroupMap.get(nodeGroupName);
    if (storageList == null) {
      storageList = new ArrayList<>();
      nodeGroupMap.put(nodeGroupName, storageList);
    }
    storageList.add(storage);
  }
  
  final List<DatanodeStorageInfo> moreThanOne = new ArrayList<>();
  final List<DatanodeStorageInfo> exactlyOne = new ArrayList<>();
  // split nodes into two sets
  for(List<DatanodeStorageInfo> datanodeList : nodeGroupMap.values()) {
    if (datanodeList.size() == 1 ) {
      // exactlyOne contains nodes on nodegroup with exactly one replica
      exactlyOne.add(datanodeList.get(0));
    } else {
      // moreThanOne contains nodes on nodegroup with more than one replica
      moreThanOne.addAll(datanodeList);
    }
  }
  
  return moreThanOne.isEmpty()? exactlyOne : moreThanOne;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:51,代码来源:BlockPlacementPolicyWithNodeGroup.java


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