Java Code Examples for org.apache.hadoop.hdfs.DFSTestUtil#toDatanodeDescriptor()
The following examples show how to use
org.apache.hadoop.hdfs.DFSTestUtil#toDatanodeDescriptor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestReplicationPolicyConsiderLoad.java From hadoop with Apache License 2.0 | 4 votes |
@BeforeClass public static void setupCluster() throws IOException { Configuration conf = new HdfsConfiguration(); final String[] racks = { "/rack1", "/rack1", "/rack1", "/rack2", "/rack2", "/rack2"}; storages = DFSTestUtil.createDatanodeStorageInfos(racks); dataNodes = DFSTestUtil.toDatanodeDescriptor(storages); FileSystem.setDefaultUri(conf, "hdfs://localhost:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0"); File baseDir = PathUtils.getTestDir(TestReplicationPolicy.class); conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, new File(baseDir, "name").getPath()); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_READ_KEY, true); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_WRITE_KEY, true); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_REPLICATION_CONSIDERLOAD_KEY, true); DFSTestUtil.formatNameNode(conf); namenode = new NameNode(conf); int blockSize = 1024; dnrList = new ArrayList<DatanodeRegistration>(); dnManager = namenode.getNamesystem().getBlockManager().getDatanodeManager(); // Register DNs for (int i=0; i < 6; i++) { DatanodeRegistration dnr = new DatanodeRegistration(dataNodes[i], new StorageInfo(NodeType.DATA_NODE), new ExportedBlockKeys(), VersionInfo.getVersion()); dnrList.add(dnr); dnManager.registerDatanode(dnr); dataNodes[i].getStorageInfos()[0].setUtilizationForTesting( 2*HdfsConstants.MIN_BLOCKS_FOR_WRITE*blockSize, 0L, 2*HdfsConstants.MIN_BLOCKS_FOR_WRITE*blockSize, 0L); dataNodes[i].updateHeartbeat( BlockManagerTestUtil.getStorageReportsForDatanode(dataNodes[i]), 0L, 0L, 0, 0, null); } }
Example 2
Source File: TestReplicationPolicy.java From hadoop with Apache License 2.0 | 4 votes |
@BeforeClass public static void setupCluster() throws Exception { Configuration conf = new HdfsConfiguration(); final String[] racks = { "/d1/r1", "/d1/r1", "/d1/r2", "/d1/r2", "/d2/r3", "/d2/r3"}; storages = DFSTestUtil.createDatanodeStorageInfos(racks); dataNodes = DFSTestUtil.toDatanodeDescriptor(storages); // create an extra storage for dn5. DatanodeStorage extraStorage = new DatanodeStorage( storages[5].getStorageID() + "-extra", DatanodeStorage.State.NORMAL, StorageType.DEFAULT); /* DatanodeStorageInfo si = new DatanodeStorageInfo( storages[5].getDatanodeDescriptor(), extraStorage); */ BlockManagerTestUtil.updateStorage(storages[5].getDatanodeDescriptor(), extraStorage); FileSystem.setDefaultUri(conf, "hdfs://localhost:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0"); File baseDir = PathUtils.getTestDir(TestReplicationPolicy.class); conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, new File(baseDir, "name").getPath()); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_READ_KEY, true); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_WRITE_KEY, true); DFSTestUtil.formatNameNode(conf); namenode = new NameNode(conf); final BlockManager bm = namenode.getNamesystem().getBlockManager(); replicator = bm.getBlockPlacementPolicy(); cluster = bm.getDatanodeManager().getNetworkTopology(); // construct network topology for (int i=0; i < NUM_OF_DATANODES; i++) { cluster.add(dataNodes[i]); bm.getDatanodeManager().getHeartbeatManager().addDatanode( dataNodes[i]); } resetHeartbeatForStorages(); }
Example 3
Source File: TestReplicationPolicyConsiderLoad.java From big-c with Apache License 2.0 | 4 votes |
@BeforeClass public static void setupCluster() throws IOException { Configuration conf = new HdfsConfiguration(); final String[] racks = { "/rack1", "/rack1", "/rack1", "/rack2", "/rack2", "/rack2"}; storages = DFSTestUtil.createDatanodeStorageInfos(racks); dataNodes = DFSTestUtil.toDatanodeDescriptor(storages); FileSystem.setDefaultUri(conf, "hdfs://localhost:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0"); File baseDir = PathUtils.getTestDir(TestReplicationPolicy.class); conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, new File(baseDir, "name").getPath()); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_READ_KEY, true); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_WRITE_KEY, true); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_REPLICATION_CONSIDERLOAD_KEY, true); DFSTestUtil.formatNameNode(conf); namenode = new NameNode(conf); int blockSize = 1024; dnrList = new ArrayList<DatanodeRegistration>(); dnManager = namenode.getNamesystem().getBlockManager().getDatanodeManager(); // Register DNs for (int i=0; i < 6; i++) { DatanodeRegistration dnr = new DatanodeRegistration(dataNodes[i], new StorageInfo(NodeType.DATA_NODE), new ExportedBlockKeys(), VersionInfo.getVersion()); dnrList.add(dnr); dnManager.registerDatanode(dnr); dataNodes[i].getStorageInfos()[0].setUtilizationForTesting( 2*HdfsConstants.MIN_BLOCKS_FOR_WRITE*blockSize, 0L, 2*HdfsConstants.MIN_BLOCKS_FOR_WRITE*blockSize, 0L); dataNodes[i].updateHeartbeat( BlockManagerTestUtil.getStorageReportsForDatanode(dataNodes[i]), 0L, 0L, 0, 0, null); } }
Example 4
Source File: TestReplicationPolicy.java From big-c with Apache License 2.0 | 4 votes |
@BeforeClass public static void setupCluster() throws Exception { Configuration conf = new HdfsConfiguration(); final String[] racks = { "/d1/r1", "/d1/r1", "/d1/r2", "/d1/r2", "/d2/r3", "/d2/r3"}; storages = DFSTestUtil.createDatanodeStorageInfos(racks); dataNodes = DFSTestUtil.toDatanodeDescriptor(storages); FileSystem.setDefaultUri(conf, "hdfs://localhost:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0"); File baseDir = PathUtils.getTestDir(TestReplicationPolicy.class); conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, new File(baseDir, "name").getPath()); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_READ_KEY, true); conf.setBoolean( DFSConfigKeys.DFS_NAMENODE_AVOID_STALE_DATANODE_FOR_WRITE_KEY, true); DFSTestUtil.formatNameNode(conf); namenode = new NameNode(conf); final BlockManager bm = namenode.getNamesystem().getBlockManager(); replicator = bm.getBlockPlacementPolicy(); cluster = bm.getDatanodeManager().getNetworkTopology(); // construct network topology for (int i=0; i < NUM_OF_DATANODES; i++) { cluster.add(dataNodes[i]); bm.getDatanodeManager().getHeartbeatManager().addDatanode( dataNodes[i]); } for (int i=0; i < NUM_OF_DATANODES; i++) { updateHeartbeatWithUsage(dataNodes[i], 2*HdfsConstants.MIN_BLOCKS_FOR_WRITE*BLOCK_SIZE, 0L, 2*HdfsConstants.MIN_BLOCKS_FOR_WRITE*BLOCK_SIZE, 0L, 0L, 0L, 0, 0); } }