|
@@ -2267,9 +2267,11 @@ public class MiniDFSCluster implements AutoCloseable {
|
|
info.nameNode = nn;
|
|
info.nameNode = nn;
|
|
info.setStartOpt(startOpt);
|
|
info.setStartOpt(startOpt);
|
|
if (waitActive) {
|
|
if (waitActive) {
|
|
- waitClusterUp();
|
|
|
|
|
|
+ if (numDataNodes > 0) {
|
|
|
|
+ waitNameNodeUp(nnIndex);
|
|
|
|
+ }
|
|
LOG.info("Restarted the namenode");
|
|
LOG.info("Restarted the namenode");
|
|
- waitActive();
|
|
|
|
|
|
+ waitActive(nnIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2775,11 +2777,25 @@ public class MiniDFSCluster implements AutoCloseable {
|
|
DFSClient client = new DFSClient(addr, conf);
|
|
DFSClient client = new DFSClient(addr, conf);
|
|
|
|
|
|
// ensure all datanodes have registered and sent heartbeat to the namenode
|
|
// ensure all datanodes have registered and sent heartbeat to the namenode
|
|
- while (shouldWait(client.datanodeReport(DatanodeReportType.LIVE), addr)) {
|
|
|
|
|
|
+ int failedCount = 0;
|
|
|
|
+ while (true) {
|
|
try {
|
|
try {
|
|
- LOG.info("Waiting for cluster to become active");
|
|
|
|
- Thread.sleep(100);
|
|
|
|
|
|
+ while (shouldWait(client.datanodeReport(DatanodeReportType.LIVE), addr)) {
|
|
|
|
+ LOG.info("Waiting for cluster to become active");
|
|
|
|
+ Thread.sleep(100);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ failedCount++;
|
|
|
|
+ // Cached RPC connection to namenode, if any, is expected to fail once
|
|
|
|
+ if (failedCount > 1) {
|
|
|
|
+ LOG.warn("Tried waitActive() " + failedCount
|
|
|
|
+ + " time(s) and failed, giving up. " + StringUtils
|
|
|
|
+ .stringifyException(e));
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
|
|
+ throw new IOException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2815,22 +2831,7 @@ public class MiniDFSCluster implements AutoCloseable {
|
|
*/
|
|
*/
|
|
public void waitActive() throws IOException {
|
|
public void waitActive() throws IOException {
|
|
for (int index = 0; index < namenodes.size(); index++) {
|
|
for (int index = 0; index < namenodes.size(); index++) {
|
|
- int failedCount = 0;
|
|
|
|
- while (true) {
|
|
|
|
- try {
|
|
|
|
- waitActive(index);
|
|
|
|
- break;
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- failedCount++;
|
|
|
|
- // Cached RPC connection to namenode, if any, is expected to fail once
|
|
|
|
- if (failedCount > 1) {
|
|
|
|
- LOG.warn("Tried waitActive() " + failedCount
|
|
|
|
- + " time(s) and failed, giving up. "
|
|
|
|
- + StringUtils.stringifyException(e));
|
|
|
|
- throw e;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ waitActive(index);
|
|
}
|
|
}
|
|
LOG.info("Cluster is active");
|
|
LOG.info("Cluster is active");
|
|
}
|
|
}
|