當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。