|
@@ -27,6 +27,9 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Random;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.concurrent.TimeoutException;
|
|
|
+
|
|
|
+import junit.framework.Assert;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -65,7 +68,7 @@ import org.mockito.invocation.InvocationOnMock;
|
|
|
|
|
|
/**
|
|
|
* This test simulates a variety of situations when blocks are being
|
|
|
- * intentionally orrupted, unexpectedly modified, and so on before a block
|
|
|
+ * intentionally corrupted, unexpectedly modified, and so on before a block
|
|
|
* report is happening
|
|
|
*/
|
|
|
public class TestBlockReport {
|
|
@@ -316,7 +319,7 @@ public class TestBlockReport {
|
|
|
* @throws IOException in case of an error
|
|
|
*/
|
|
|
@Test
|
|
|
- public void blockReport_06() throws IOException {
|
|
|
+ public void blockReport_06() throws Exception {
|
|
|
final String METHOD_NAME = GenericTestUtils.getMethodName();
|
|
|
Path filePath = new Path("/" + METHOD_NAME + ".dat");
|
|
|
final int DN_N1 = DN_N0 + 1;
|
|
@@ -353,7 +356,7 @@ public class TestBlockReport {
|
|
|
@Test
|
|
|
// Currently this test is failing as expected 'cause the correct behavior is
|
|
|
// not yet implemented (9/15/09)
|
|
|
- public void blockReport_07() throws IOException {
|
|
|
+ public void blockReport_07() throws Exception {
|
|
|
final String METHOD_NAME = GenericTestUtils.getMethodName();
|
|
|
Path filePath = new Path("/" + METHOD_NAME + ".dat");
|
|
|
final int DN_N1 = DN_N0 + 1;
|
|
@@ -670,21 +673,24 @@ public class TestBlockReport {
|
|
|
}
|
|
|
|
|
|
private void startDNandWait(Path filePath, boolean waitReplicas)
|
|
|
- throws IOException {
|
|
|
- if(LOG.isDebugEnabled()) {
|
|
|
+ throws IOException, InterruptedException, TimeoutException {
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug("Before next DN start: " + cluster.getDataNodes().size());
|
|
|
}
|
|
|
cluster.startDataNodes(conf, 1, true, null, null);
|
|
|
+ cluster.waitClusterUp();
|
|
|
ArrayList<DataNode> datanodes = cluster.getDataNodes();
|
|
|
assertEquals(datanodes.size(), 2);
|
|
|
|
|
|
- if(LOG.isDebugEnabled()) {
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
int lastDn = datanodes.size() - 1;
|
|
|
LOG.debug("New datanode "
|
|
|
+ cluster.getDataNodes().get(lastDn).getDisplayName()
|
|
|
+ " has been started");
|
|
|
}
|
|
|
- if (waitReplicas) DFSTestUtil.waitReplication(fs, filePath, REPL_FACTOR);
|
|
|
+ if (waitReplicas) {
|
|
|
+ DFSTestUtil.waitReplication(fs, filePath, REPL_FACTOR);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private ArrayList<Block> prepareForRide(final Path filePath,
|
|
@@ -836,8 +842,9 @@ public class TestBlockReport {
|
|
|
public void run() {
|
|
|
try {
|
|
|
startDNandWait(filePath, true);
|
|
|
- } catch (IOException e) {
|
|
|
- LOG.warn("Shouldn't happen", e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ Assert.fail("Failed to start BlockChecker: " + e);
|
|
|
}
|
|
|
}
|
|
|
}
|