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


Java Triple.getFirst方法代码示例

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


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

示例1: testSecondaryAndTertiaryPlacementWithSingleRack

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Ignore("Disabled for now until FavoredNodes gets finished as a feature") @Test
public void testSecondaryAndTertiaryPlacementWithSingleRack() {
  // Test the case where there is a single rack and we need to choose
  // Primary/Secondary/Tertiary from a single rack.
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 10);
  // have lots of regions to test with
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(60000, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  // although we created lots of regions we should have no overlap on the
  // primary/secondary/tertiary for any given region
  for (HRegionInfo region : regions) {
    ServerName[] secondaryAndTertiaryServers = secondaryAndTertiaryMap.get(region);
    assertTrue(!secondaryAndTertiaryServers[0].equals(primaryRSMap.get(region)));
    assertTrue(!secondaryAndTertiaryServers[1].equals(primaryRSMap.get(region)));
    assertTrue(!secondaryAndTertiaryServers[0].equals(secondaryAndTertiaryServers[1]));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestFavoredNodeAssignmentHelper.java

示例2: testSecondaryAndTertiaryPlacementWithSingleServer

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Ignore("Disabled for now until FavoredNodes gets finished as a feature") @Test
public void testSecondaryAndTertiaryPlacementWithSingleServer() {
  // Test the case where we have a single node in the cluster. In this case
  // the primary can be assigned but the secondary/tertiary would be null
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 1);
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(1, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();

  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  // no secondary/tertiary placement in case of a single RegionServer
  assertTrue(secondaryAndTertiaryMap.get(regions.get(0)) == null);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestFavoredNodeAssignmentHelper.java

示例3: testSecondaryAndTertiaryPlacementWithLessThanTwoServersInRacks

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Ignore("Disabled for now until FavoredNodes gets finished as a feature") @Test
public void testSecondaryAndTertiaryPlacementWithLessThanTwoServersInRacks() {
  // Test the case where we have two racks but with less than two servers in each
  // We will not have enough machines to select secondary/tertiary
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 1);
  rackToServerCount.put("rack2", 1);
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(6, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();
  assertTrue(primaryRSMap.size() == 6);
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
        helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  for (HRegionInfo region : regions) {
    // not enough secondary/tertiary room to place the regions
    assertTrue(secondaryAndTertiaryMap.get(region) == null);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestFavoredNodeAssignmentHelper.java

示例4: testSecondaryAndTertiaryPlacementWithSingleRack

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithSingleRack() {
  // Test the case where there is a single rack and we need to choose
  // Primary/Secondary/Tertiary from a single rack.
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 10);
  // have lots of regions to test with
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(60000, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  // although we created lots of regions we should have no overlap on the
  // primary/secondary/tertiary for any given region
  for (HRegionInfo region : regions) {
    ServerName[] secondaryAndTertiaryServers = secondaryAndTertiaryMap.get(region);
    assertTrue(!secondaryAndTertiaryServers[0].equals(primaryRSMap.get(region)));
    assertTrue(!secondaryAndTertiaryServers[1].equals(primaryRSMap.get(region)));
    assertTrue(!secondaryAndTertiaryServers[0].equals(secondaryAndTertiaryServers[1]));
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:24,代码来源:TestFavoredNodeAssignmentHelper.java

示例5: testSecondaryAndTertiaryPlacementWithSingleServer

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithSingleServer() {
  // Test the case where we have a single node in the cluster. In this case
  // the primary can be assigned but the secondary/tertiary would be null
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 1);
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(1, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();

  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  // no secondary/tertiary placement in case of a single RegionServer
  assertTrue(secondaryAndTertiaryMap.get(regions.get(0)) == null);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:18,代码来源:TestFavoredNodeAssignmentHelper.java

示例6: testSecondaryAndTertiaryPlacementWithLessThanTwoServersInRacks

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithLessThanTwoServersInRacks() {
  // Test the case where we have two racks but with less than two servers in each
  // We will not have enough machines to select secondary/tertiary
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 1);
  rackToServerCount.put("rack2", 1);
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(6, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();
  assertTrue(primaryRSMap.size() == 6);
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
        helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  for (HRegionInfo region : regions) {
    // not enough secondary/tertiary room to place the regions
    assertTrue(secondaryAndTertiaryMap.get(region) == null);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:21,代码来源:TestFavoredNodeAssignmentHelper.java

示例7: testSecondaryAndTertiaryPlacementWithSingleRack

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithSingleRack() {
  // Test the case where there is a single rack and we need to choose
  // Primary/Secondary/Tertiary from a single rack.
  Map<String,Integer> rackToServerCount = new HashMap<>();
  rackToServerCount.put("rack1", 10);
  // have lots of regions to test with
  Triple<Map<RegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<RegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(60000, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<RegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<RegionInfo> regions = primaryRSMapAndHelper.getThird();
  Map<RegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  // although we created lots of regions we should have no overlap on the
  // primary/secondary/tertiary for any given region
  for (RegionInfo region : regions) {
    ServerName[] secondaryAndTertiaryServers = secondaryAndTertiaryMap.get(region);
    assertNotNull(secondaryAndTertiaryServers);
    assertTrue(primaryRSMap.containsKey(region));
    assertTrue(!secondaryAndTertiaryServers[0].equals(primaryRSMap.get(region)));
    assertTrue(!secondaryAndTertiaryServers[1].equals(primaryRSMap.get(region)));
    assertTrue(!secondaryAndTertiaryServers[0].equals(secondaryAndTertiaryServers[1]));
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:TestFavoredNodeAssignmentHelper.java

示例8: testSecondaryAndTertiaryPlacementWithSingleServer

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithSingleServer() {
  // Test the case where we have a single node in the cluster. In this case
  // the primary can be assigned but the secondary/tertiary would be null
  Map<String,Integer> rackToServerCount = new HashMap<>();
  rackToServerCount.put("rack1", 1);
  Triple<Map<RegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<RegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(1, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<RegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<RegionInfo> regions = primaryRSMapAndHelper.getThird();

  Map<RegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  // no secondary/tertiary placement in case of a single RegionServer
  assertTrue(secondaryAndTertiaryMap.get(regions.get(0)) == null);
}
 
开发者ID:apache,项目名称:hbase,代码行数:18,代码来源:TestFavoredNodeAssignmentHelper.java

示例9: testSecondaryAndTertiaryPlacementWithLessThanTwoServersInRacks

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithLessThanTwoServersInRacks() {
  // Test the case where we have two racks but with less than two servers in each
  // We will not have enough machines to select secondary/tertiary
  Map<String,Integer> rackToServerCount = new HashMap<>();
  rackToServerCount.put("rack1", 1);
  rackToServerCount.put("rack2", 1);
  Triple<Map<RegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<RegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(6, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<RegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<RegionInfo> regions = primaryRSMapAndHelper.getThird();
  assertTrue(primaryRSMap.size() == 6);
  Map<RegionInfo, ServerName[]> secondaryAndTertiaryMap =
        helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  for (RegionInfo region : regions) {
    // not enough secondary/tertiary room to place the regions
    assertTrue(secondaryAndTertiaryMap.get(region) == null);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:21,代码来源:TestFavoredNodeAssignmentHelper.java

示例10: removeFirstDone

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
/**
 * Wait for one of tasks to be done, and remove it from the list.
 * @return the tasks done.
 */
private Triple<MultiAction<R>, HRegionLocation, Future<MultiResponse>>
removeFirstDone() throws InterruptedException {
  while (true) {
    synchronized (finishedTasks) {
      if (!finishedTasks.isEmpty()) {
        MultiAction<R> done = finishedTasks.remove(finishedTasks.size() - 1);

        // We now need to remove it from the inProgress part.
        Iterator<Triple<MultiAction<R>, HRegionLocation, Future<MultiResponse>>> it =
          inProgress.iterator();
        while (it.hasNext()) {
          Triple<MultiAction<R>, HRegionLocation, Future<MultiResponse>> task = it.next();
          if (task.getFirst() == done) { // We have the exact object. No java equals here.
            it.remove();
            return task;
          }
        }
        LOG.error("Development error: We didn't see a task in the list. " +
          done.getRegions());
      }
      finishedTasks.wait(10);
    }
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:29,代码来源:HConnectionManager.java

示例11: testSecondaryAndTertiaryPlacementWithMultipleRacks

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Ignore("Disabled for now until FavoredNodes gets finished as a feature") @Test
public void testSecondaryAndTertiaryPlacementWithMultipleRacks() {
  // Test the case where we have multiple racks and the region servers
  // belong to multiple racks
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 10);
  rackToServerCount.put("rack2", 10);

  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(60000, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();

  assertTrue(primaryRSMap.size() == 60000);
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  assertTrue(secondaryAndTertiaryMap.size() == 60000);
  // for every region, the primary should be on one rack and the secondary/tertiary
  // on another (we create a lot of regions just to increase probability of failure)
  for (Map.Entry<HRegionInfo, ServerName[]> entry : secondaryAndTertiaryMap.entrySet()) {
    ServerName[] allServersForRegion = entry.getValue();
    String primaryRSRack = rackManager.getRack(primaryRSMap.get(entry.getKey()));
    String secondaryRSRack = rackManager.getRack(allServersForRegion[0]);
    String tertiaryRSRack = rackManager.getRack(allServersForRegion[1]);
    assertTrue(!primaryRSRack.equals(secondaryRSRack));
    assertTrue(secondaryRSRack.equals(tertiaryRSRack));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestFavoredNodeAssignmentHelper.java

示例12: testSecondaryAndTertiaryPlacementWithMoreThanOneServerInPrimaryRack

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Ignore("Disabled for now until FavoredNodes gets finished as a feature") @Test
public void testSecondaryAndTertiaryPlacementWithMoreThanOneServerInPrimaryRack() {
  // Test the case where there is only one server in one rack and another rack
  // has more servers. We try to choose secondary/tertiary on different
  // racks than what the primary is on. But if the other rack doesn't have
  // enough nodes to have both secondary/tertiary RSs, the tertiary is placed
  // on the same rack as the primary server is on
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 2);
  rackToServerCount.put("rack2", 1);
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(6, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();
  assertTrue(primaryRSMap.size() == 6);
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
        helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  for (HRegionInfo region : regions) {
    ServerName s = primaryRSMap.get(region);
    ServerName secondaryRS = secondaryAndTertiaryMap.get(region)[0];
    ServerName tertiaryRS = secondaryAndTertiaryMap.get(region)[1];
    if (rackManager.getRack(s).equals("rack1")) {
      assertTrue(rackManager.getRack(secondaryRS).equals("rack2") &&
          rackManager.getRack(tertiaryRS).equals("rack1"));
    }
    if (rackManager.getRack(s).equals("rack2")) {
      assertTrue(rackManager.getRack(secondaryRS).equals("rack1") &&
          rackManager.getRack(tertiaryRS).equals("rack1"));
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:TestFavoredNodeAssignmentHelper.java

示例13: testSecondaryAndTertiaryPlacementWithMultipleRacks

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithMultipleRacks() {
  // Test the case where we have multiple racks and the region servers
  // belong to multiple racks
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 10);
  rackToServerCount.put("rack2", 10);

  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(60000, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();

  assertTrue(primaryRSMap.size() == 60000);
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  assertTrue(secondaryAndTertiaryMap.size() == 60000);
  // for every region, the primary should be on one rack and the secondary/tertiary
  // on another (we create a lot of regions just to increase probability of failure)
  for (Map.Entry<HRegionInfo, ServerName[]> entry : secondaryAndTertiaryMap.entrySet()) {
    ServerName[] allServersForRegion = entry.getValue();
    String primaryRSRack = rackManager.getRack(primaryRSMap.get(entry.getKey()));
    String secondaryRSRack = rackManager.getRack(allServersForRegion[0]);
    String tertiaryRSRack = rackManager.getRack(allServersForRegion[1]);
    assertTrue(!primaryRSRack.equals(secondaryRSRack));
    assertTrue(secondaryRSRack.equals(tertiaryRSRack));
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:29,代码来源:TestFavoredNodeAssignmentHelper.java

示例14: testSecondaryAndTertiaryPlacementWithMoreThanOneServerInPrimaryRack

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithMoreThanOneServerInPrimaryRack() {
  // Test the case where there is only one server in one rack and another rack
  // has more servers. We try to choose secondary/tertiary on different
  // racks than what the primary is on. But if the other rack doesn't have
  // enough nodes to have both secondary/tertiary RSs, the tertiary is placed
  // on the same rack as the primary server is on
  Map<String,Integer> rackToServerCount = new HashMap<String,Integer>();
  rackToServerCount.put("rack1", 2);
  rackToServerCount.put("rack2", 1);
  Triple<Map<HRegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<HRegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(6, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<HRegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();
  List<HRegionInfo> regions = primaryRSMapAndHelper.getThird();
  assertTrue(primaryRSMap.size() == 6);
  Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap =
        helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  for (HRegionInfo region : regions) {
    ServerName s = primaryRSMap.get(region);
    ServerName secondaryRS = secondaryAndTertiaryMap.get(region)[0];
    ServerName tertiaryRS = secondaryAndTertiaryMap.get(region)[1];
    if (rackManager.getRack(s).equals("rack1")) {
      assertTrue(rackManager.getRack(secondaryRS).equals("rack2") &&
          rackManager.getRack(tertiaryRS).equals("rack1"));
    }
    if (rackManager.getRack(s).equals("rack2")) {
      assertTrue(rackManager.getRack(secondaryRS).equals("rack1") &&
          rackManager.getRack(tertiaryRS).equals("rack1"));
    }
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:33,代码来源:TestFavoredNodeAssignmentHelper.java

示例15: testSecondaryAndTertiaryPlacementWithMultipleRacks

import org.apache.hadoop.hbase.util.Triple; //导入方法依赖的package包/类
@Test
public void testSecondaryAndTertiaryPlacementWithMultipleRacks() {
  // Test the case where we have multiple racks and the region servers
  // belong to multiple racks
  Map<String,Integer> rackToServerCount = new HashMap<>();
  rackToServerCount.put("rack1", 10);
  rackToServerCount.put("rack2", 10);

  Triple<Map<RegionInfo, ServerName>, FavoredNodeAssignmentHelper, List<RegionInfo>>
    primaryRSMapAndHelper = secondaryAndTertiaryRSPlacementHelper(60000, rackToServerCount);
  FavoredNodeAssignmentHelper helper = primaryRSMapAndHelper.getSecond();
  Map<RegionInfo, ServerName> primaryRSMap = primaryRSMapAndHelper.getFirst();

  assertTrue(primaryRSMap.size() == 60000);
  Map<RegionInfo, ServerName[]> secondaryAndTertiaryMap =
      helper.placeSecondaryAndTertiaryRS(primaryRSMap);
  assertTrue(secondaryAndTertiaryMap.size() == 60000);
  // for every region, the primary should be on one rack and the secondary/tertiary
  // on another (we create a lot of regions just to increase probability of failure)
  for (Map.Entry<RegionInfo, ServerName[]> entry : secondaryAndTertiaryMap.entrySet()) {
    ServerName[] allServersForRegion = entry.getValue();
    String primaryRSRack = rackManager.getRack(primaryRSMap.get(entry.getKey()));
    String secondaryRSRack = rackManager.getRack(allServersForRegion[0]);
    String tertiaryRSRack = rackManager.getRack(allServersForRegion[1]);
    Set<String> racks = Sets.newHashSet(primaryRSRack);
    racks.add(secondaryRSRack);
    racks.add(tertiaryRSRack);
    assertTrue(racks.size() >= 2);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:31,代码来源:TestFavoredNodeAssignmentHelper.java


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