Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ private void getReconfigurationStatus(String nodeType, String address,
private void reconfigurationOutErrFormatter(String methodName,
String nodeType, String address, final List<String> outs,
final List<String> errs) throws IOException, InterruptedException {
// Start reconfiguration once and capture output directly to avoid
// triggering "Another reconfiguration task is running" error.
ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
PrintStream outStream = new PrintStream(bufOut);
ByteArrayOutputStream bufErr = new ByteArrayOutputStream();
Expand Down Expand Up @@ -1251,22 +1253,27 @@ public void testAllDatanodesReconfig()
when(reconfigurationUtil.parseChangedProperties(any(Configuration.class),
any(Configuration.class))).thenReturn(changes);

int result = admin.startReconfiguration("datanode", "livenodes");
ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
PrintStream outStream = new PrintStream(bufOut);
ByteArrayOutputStream bufErr = new ByteArrayOutputStream();
PrintStream errStream = new PrintStream(bufErr);
int result = admin.startReconfigurationUtil("datanode", "livenodes",
outStream, errStream);
assertThat(result).isEqualTo(0);
final List<String> outsForStartReconf = new ArrayList<>();
final List<String> errsForStartReconf = new ArrayList<>();
reconfigurationOutErrFormatter("startReconfiguration", "datanode",
"livenodes", outsForStartReconf, errsForStartReconf);
scanIntoList(bufOut, outsForStartReconf);
scanIntoList(bufErr, errsForStartReconf);
String started = "Started reconfiguration task on node";
String starting =
"Starting of reconfiguration task successful on 2 nodes, failed on 0 nodes.";
assertThat(outsForStartReconf).hasSize(3);
assertThat(errsForStartReconf).hasSize(0);
assertThat(outsForStartReconf.get(0)).startsWith(started);
assertThat(outsForStartReconf.get(1)).startsWith(started);
assertThat(outsForStartReconf.get(2)).startsWith(starting);

Thread.sleep(1000);
"Starting of reconfiguration task successful on " + NUM_DATANODES
+ " nodes, failed on 0 nodes.";
assertThat(errsForStartReconf).isEmpty();
assertThat(outsForStartReconf).hasSize(NUM_DATANODES + 1);
assertThat(outsForStartReconf.stream()
.filter(s -> s.startsWith(started))
.count()).isEqualTo(NUM_DATANODES);
assertThat(outsForStartReconf).contains(starting);
final List<String> outs = new ArrayList<>();
final List<String> errs = new ArrayList<>();
awaitReconfigurationFinished("datanode", "livenodes", outs, errs);
Expand Down