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


Java ReplaceDatanodeOnFailure.DEFAULT属性代码示例

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


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

示例1: testDefaultPolicy

/** Test DEFAULT ReplaceDatanodeOnFailure policy. */
@Test
public void testDefaultPolicy() throws Exception {
  final ReplaceDatanodeOnFailure p = ReplaceDatanodeOnFailure.DEFAULT;

  final DatanodeInfo[] infos = new DatanodeInfo[5];
  final DatanodeInfo[][] datanodes = new DatanodeInfo[infos.length + 1][];
  datanodes[0] = new DatanodeInfo[0];
  for(int i = 0; i < infos.length; ) {
    infos[i] = DFSTestUtil.getLocalDatanodeInfo(50020 + i);
    i++;
    datanodes[i] = new DatanodeInfo[i];
    System.arraycopy(infos, 0, datanodes[i], 0, datanodes[i].length);
  }

  final boolean[] isAppend   = {true, true, false, false};
  final boolean[] isHflushed = {true, false, true, false};

  for(short replication = 1; replication <= infos.length; replication++) {
    for(int nExistings = 0; nExistings < datanodes.length; nExistings++) {
      final DatanodeInfo[] existings = datanodes[nExistings];
      Assert.assertEquals(nExistings, existings.length);

      for(int i = 0; i < isAppend.length; i++) {
        for(int j = 0; j < isHflushed.length; j++) {
          final int half = replication/2;
          final boolean enoughReplica = replication <= nExistings;
          final boolean noReplica = nExistings == 0;
          final boolean replicationL3 = replication < 3;
          final boolean existingsLEhalf = nExistings <= half;
          final boolean isAH = isAppend[i] || isHflushed[j];

          final boolean expected;
          if (enoughReplica || noReplica || replicationL3) {
            expected = false;
          } else {
            expected = isAH || existingsLEhalf;
          }
          
          final boolean computed = p.satisfy(
              replication, existings, isAppend[i], isHflushed[j]);
          try {
            Assert.assertEquals(expected, computed);
          } catch(AssertionError e) {
            final String s = "replication=" + replication
                         + "\nnExistings =" + nExistings
                         + "\nisAppend   =" + isAppend[i]
                         + "\nisHflushed =" + isHflushed[j];
            throw new RuntimeException(s, e);
          }
        }
      }
    }
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:55,代码来源:TestReplaceDatanodeOnFailure.java

示例2: testDefaultPolicy

/**
 * Test DEFAULT ReplaceDatanodeOnFailure policy.
 */
@Test
public void testDefaultPolicy() throws Exception {
  final ReplaceDatanodeOnFailure p = ReplaceDatanodeOnFailure.DEFAULT;

  final DatanodeInfo[] infos = new DatanodeInfo[5];
  final DatanodeInfo[][] datanodes = new DatanodeInfo[infos.length + 1][];
  datanodes[0] = new DatanodeInfo[0];
  for (int i = 0; i < infos.length; ) {
    infos[i] = DFSTestUtil.getLocalDatanodeInfo(50020 + i);
    i++;
    datanodes[i] = new DatanodeInfo[i];
    System.arraycopy(infos, 0, datanodes[i], 0, datanodes[i].length);
  }

  final boolean[] isAppend = {true, true, false, false};
  final boolean[] isHflushed = {true, false, true, false};

  for (short replication = 1; replication <= infos.length; replication++) {
    for (int nExistings = 0; nExistings < datanodes.length; nExistings++) {
      final DatanodeInfo[] existings = datanodes[nExistings];
      Assert.assertEquals(nExistings, existings.length);

      for (boolean anIsAppend : isAppend) {
        for (boolean anIsHflushed : isHflushed) {
          final int half = replication / 2;
          final boolean enoughReplica = replication <= nExistings;
          final boolean noReplica = nExistings == 0;
          final boolean replicationL3 = replication < 3;
          final boolean existingsLEhalf = nExistings <= half;
          final boolean isAH = anIsAppend || anIsHflushed;
    
          final boolean expected;
          if (enoughReplica || noReplica || replicationL3) {
            expected = false;
          } else {
            expected = isAH || existingsLEhalf;
          }
    
          final boolean computed =
              p.satisfy(replication, existings, anIsAppend, anIsHflushed);
          try {
            Assert.assertEquals(expected, computed);
          } catch (AssertionError e) {
            final String s =
                "replication=" + replication + "\nnExistings =" + nExistings +
                    "\nisAppend   =" + anIsAppend + "\nisHflushed =" +
                    anIsHflushed;
            throw new RuntimeException(s, e);
          }
        }
      }
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:57,代码来源:TestReplaceDatanodeOnFailure.java


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