本文整理汇总了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();
}
}
示例2: runPendingReplicationRetry
import org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicy; //导入依赖的package包/类
private void runPendingReplicationRetry(
Class<? extends BlockPlacementPolicy> clazz) throws IOException {
pendingReplicationRetryInternal(false, clazz);
}
示例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");
}
}
示例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");
}
}