/** * This method is valid only if the data nodes have simulated data * @param blocksToInject - blocksToInject[] is indexed in the same order as the list * of datanodes returned by getDataNodes() * @throws IOException * if not simulatedFSDataset * if any of blocks already exist in the data nodes * Note the rest of the blocks are not injected. */ public void injectBlocks(Iterable<Block>[] blocksToInject) throws IOException { if (blocksToInject.length > dataNodes.size()) { throw new IndexOutOfBoundsException(); } for (int i = 0; i < blocksToInject.length; ++i) { injectBlocks(i, blocksToInject[i]); } }
mc.injectBlocks((i_dn + i- 1)% numDataNodes, Arrays.asList(blocks)); System.out.println("Injecting blocks of dn " + i_dn + " into dn" + ((i_dn + i- 1)% numDataNodes));
mc.injectBlocks(dnIndex, blockList, bpid); } catch (IOException ioe) { System.out.printf("Error injecting blocks into DataNode %d for block pool %s: %s%n", dnIndex, bpid,
cluster.injectBlocks(0, uniqueBlocks);
cluster.injectBlocks(i, Arrays.asList(blocksDN[i]));
mc.injectBlocks((i_dn + i- 1)% numDataNodes, Arrays.asList(blocks), bpid); System.out.println("Injecting blocks of dn " + i_dn + " into dn" + ((i_dn + i- 1)% numDataNodes));
cluster.injectBlocks(n, d, Arrays.asList(blocksDN[d]));
cluster.injectBlocks(0, uniqueBlocks, null);
private void testUnevenDistribution(Configuration conf, long distribution[], long capacities[], String[] racks) throws Exception { int numDatanodes = distribution.length; if (capacities.length != numDatanodes || racks.length != numDatanodes) { throw new IllegalArgumentException("Array length is not the same"); } // calculate total space that need to be filled final long totalUsedSpace = sum(distribution); // fill the cluster ExtendedBlock[] blocks = generateBlocks(conf, totalUsedSpace, (short) numDatanodes); // redistribute blocks Block[][] blocksDN = distributeBlocks( blocks, (short)(numDatanodes-1), distribution); // restart the cluster: do NOT format the cluster conf.set(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_THRESHOLD_PCT_KEY, "0.0f"); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDatanodes) .format(false) .racks(racks) .simulatedCapacities(capacities) .build(); cluster.waitActive(); client = NameNodeProxies.createProxy(conf, cluster.getFileSystem(0).getUri(), ClientProtocol.class).getProxy(); for(int i = 0; i < blocksDN.length; i++) cluster.injectBlocks(i, Arrays.asList(blocksDN[i]), null); final long totalCapacity = sum(capacities); runBalancer(conf, totalUsedSpace, totalCapacity); cluster.shutdown(); }
cluster.injectBlocks(i, Arrays.asList(blocksDN[i]), null);
cluster.injectBlocks(0, RO_NODE_INDEX, Collections.singleton(block));