@Override // ClientProtocol public boolean setReplication(String src, short replication) throws IOException { checkNNStartup(); return namesystem.setReplication(src, replication); }
/** {@inheritDoc} */ public boolean setReplication(String src, short replication ) throws IOException { return namesystem.setReplication(src, replication); }
/** {@inheritDoc} */ public boolean setReplication(String src, short replication ) throws IOException { boolean value = namesystem.setReplication(src, replication); if (value) { myMetrics.numSetReplication.inc(); } return value; }
@Override // ClientProtocol public boolean setReplication(String src, short replication) throws IOException { checkNNStartup(); return namesystem.setReplication(src, replication); }
@Override // ClientProtocol public boolean setReplication(String src, short replication) throws IOException { checkNNStartup(); return namesystem.setReplication(src, replication); }
public static boolean setReplication(final FSNamesystem ns, final String src, final short replication) throws IOException { return ns.setReplication(src, replication); }
namesystem.setReplication("/filestatus0", (short) 4);
/** Create excess blocks by reducing the replication factor for * for a file and ensure metrics reflects it */ public void testExcessBlocks() throws Exception { Path file = getTestPath("testExcessBlocks"); createFile(file, 100, (short)2); int totalBlocks = 1; namesystem.setReplication(file.toString(), (short)1); updateMetrics(); assertEquals(totalBlocks, metrics.excessBlocks.get()); fs.delete(file, true); }
namesystem.setReplication(fileName.toString(), (short)1);
.corruptReplicas()); namesystem.setReplication(fileName.toString(), (short) 1);
.corruptReplicas()); namesystem.setReplication(fileName.toString(), (short) 1);
.corruptReplicas()); namesystem.setReplication(fileName.toString(), (short) 2);
@Test public void testSufficientlySingleReplBlockUsesNewRack() throws Exception { Configuration conf = getConf(); short REPLICATION_FACTOR = 1; final Path filePath = new Path("/testFile"); String racks[] = {"/rack1", "/rack1", "/rack1", "/rack2"}; MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(racks.length).racks(racks).build(); final FSNamesystem ns = cluster.getNameNode().getNamesystem(); try { // Create a file with one block with a replication factor of 1 final FileSystem fs = cluster.getFileSystem(); DFSTestUtil.createFile(fs, filePath, 1L, REPLICATION_FACTOR, 1L); Block b = DFSTestUtil.getFirstBlock(fs, filePath); DFSTestUtil.waitForReplication(cluster, b, 1, REPLICATION_FACTOR, 0); REPLICATION_FACTOR = 2; ns.setReplication("/testFile", REPLICATION_FACTOR); DFSTestUtil.waitForReplication(cluster, b, 2, REPLICATION_FACTOR, 0); } finally { cluster.shutdown(); } }
@Test public void testReduceReplFactorRespectsRackPolicy() throws Exception { Configuration conf = getConf(); short REPLICATION_FACTOR = 3; final Path filePath = new Path("/testFile"); String racks[] = {"/rack1", "/rack1", "/rack2", "/rack2"}; MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(racks.length).racks(racks).build(); final FSNamesystem ns = cluster.getNameNode().getNamesystem(); try { // Create a file with one block final FileSystem fs = cluster.getFileSystem(); DFSTestUtil.createFile(fs, filePath, 1L, REPLICATION_FACTOR, 1L); Block b = DFSTestUtil.getFirstBlock(fs, filePath); DFSTestUtil.waitForReplication(cluster, b, 2, REPLICATION_FACTOR, 0); // Decrease the replication factor, make sure the deleted replica // was not the one that lived on the rack with only one replica, // ie we should still have 2 racks after reducing the repl factor. REPLICATION_FACTOR = 2; ns.setReplication("/testFile", REPLICATION_FACTOR); DFSTestUtil.waitForReplication(cluster, b, 2, REPLICATION_FACTOR, 0); } finally { cluster.shutdown(); } }
@Test public void testUnderReplicatedUsesNewRacks() throws Exception { Configuration conf = getConf(); short REPLICATION_FACTOR = 3; final Path filePath = new Path("/testFile"); // All datanodes are on the same rack String racks[] = {"/rack1", "/rack1", "/rack1", "/rack1", "/rack1"}; MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(racks.length).racks(racks).build(); final FSNamesystem ns = cluster.getNameNode().getNamesystem(); try { // Create a file with one block final FileSystem fs = cluster.getFileSystem(); DFSTestUtil.createFile(fs, filePath, 1L, REPLICATION_FACTOR, 1L); Block b = DFSTestUtil.getFirstBlock(fs, filePath); DFSTestUtil.waitForReplication(cluster, b, 1, REPLICATION_FACTOR, 1); // Add new datanodes on a different rack and increase the // replication factor so the block is underreplicated and make // sure at least one of the hosts on the new rack is used. String newRacks[] = {"/rack2", "/rack2"}; cluster.startDataNodes(conf, 2, true, null, newRacks); REPLICATION_FACTOR = 5; ns.setReplication("/testFile", REPLICATION_FACTOR); DFSTestUtil.waitForReplication(cluster, b, 2, REPLICATION_FACTOR, 0); } finally { cluster.shutdown(); } }
assertEquals(3, countReplicas(namesystem, block).corruptReplicas()); namesystem.setReplication(fileName.toString(), (short) 1);
assertEquals(1, countReplicas(namesystem, block).corruptReplicas()); namesystem.setReplication(fileName.toString(), (short) 2);
assertEquals(1, countReplicas(namesystem, block).corruptReplicas()); namesystem.setReplication(fileName.toString(), (short) 1);