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


Java BlockPlacementPolicy类代码示例

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


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

示例1: runReplication

import org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy; //导入依赖的package包/类
/**
 * Tests replication in DFS.
 */
private void runReplication(boolean simulated,
    Class<? extends BlockPlacementPolicy> clazz) throws IOException {
  Configuration conf = new Configuration();
  conf.setClass("dfs.block.replicator.classname", clazz,
      BlockPlacementPolicy.class);
  conf.setBoolean("dfs.replication.considerLoad", false);
  if (simulated) {
    conf.setBoolean(SimulatedFSDataset.CONFIG_PROPERTY_SIMULATED, true);
  }    
  MiniDFSCluster cluster = null;
  FileSystem fileSys = null;
  DFSClient client = null;
  try {
    cluster = new MiniDFSCluster(conf, numDatanodes, racks, null,
        true, true);
    cluster.waitActive();
    cluster.getNameNode().namesystem.refreshNodes(conf);
    
    client = new DFSClient(cluster.getNameNode().getNameNodeAddress(), conf);
    DatanodeInfo[] info = client.datanodeReport(DatanodeReportType.LIVE);
    assertEquals("Number of Datanodes ", numDatanodes, info.length);
    fileSys = cluster.getFileSystem();

    Path file1 = new Path("/smallblocktest.dat");
    writeFile(fileSys, file1, 3);
    checkFile(fileSys, file1, 3);
    cleanupFile(fileSys, file1);
    writeFile(fileSys, file1, 10);
    checkFile(fileSys, file1, 10);
    cleanupFile(fileSys, file1);
    writeFile(fileSys, file1, 4);
    checkFile(fileSys, file1, 4);
    cleanupFile(fileSys, file1);
    writeFile(fileSys, file1, 1);
    checkFile(fileSys, file1, 1);
    cleanupFile(fileSys, file1);
    writeFile(fileSys, file1, 2);
    checkFile(fileSys, file1, 2);
    cleanupFile(fileSys, file1);
  } finally {
    if(client != null) {
      client.close();
    }
    if(fileSys != null)
      fileSys.close();
    if (cluster != null)
      cluster.shutdown();
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:53,代码来源:TestReplication.java

示例2: runPendingReplicationRetry

import org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy; //导入依赖的package包/类
private void runPendingReplicationRetry(
    Class<? extends BlockPlacementPolicy> clazz) throws IOException {
  pendingReplicationRetryInternal(false, clazz);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:5,代码来源:TestReplication.java

示例3: checkReplicationPolicyCompatibility

import org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy; //导入依赖的package包/类
private void checkReplicationPolicyCompatibility(Configuration conf) {
  if (!(BlockPlacementPolicy.getInstance(conf, null, null, null, null, null)
      instanceof BlockPlacementPolicyDefault)) {
    throw new IllegalArgumentException("Configuration lacks BlockPlacementPolicyDefault");
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:7,代码来源:Balancer.java

示例4: checkReplicationPolicyCompatibility

import org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy; //导入依赖的package包/类
private void checkReplicationPolicyCompatibility(Configuration conf) throws UnsupportedActionException {
  if (BlockPlacementPolicy.getInstance(conf, null, null).getClass() != 
      BlockPlacementPolicyDefault.class) {
    throw new UnsupportedActionException("Balancer without BlockPlacementPolicyDefault");
  }
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:7,代码来源:Balancer.java


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