HDFS-15911 : Provide blocks moved count in Balancer iteration result (#2796)
Contributed by Viraj Jasani. Signed-off-by: Mingliang Liu <liuml07@apache.org> Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
parent
76c40a52d7
commit
6d3f5e844b
|
@ -596,36 +596,60 @@ public class Balancer {
|
|||
}
|
||||
|
||||
static class Result {
|
||||
final ExitStatus exitStatus;
|
||||
final long bytesLeftToMove;
|
||||
final long bytesBeingMoved;
|
||||
final long bytesAlreadyMoved;
|
||||
private final ExitStatus exitStatus;
|
||||
private final long bytesLeftToMove;
|
||||
private final long bytesBeingMoved;
|
||||
private final long bytesAlreadyMoved;
|
||||
private final long blocksMoved;
|
||||
|
||||
Result(ExitStatus exitStatus, long bytesLeftToMove, long bytesBeingMoved,
|
||||
long bytesAlreadyMoved) {
|
||||
long bytesAlreadyMoved, long blocksMoved) {
|
||||
this.exitStatus = exitStatus;
|
||||
this.bytesLeftToMove = bytesLeftToMove;
|
||||
this.bytesBeingMoved = bytesBeingMoved;
|
||||
this.bytesAlreadyMoved = bytesAlreadyMoved;
|
||||
this.blocksMoved = blocksMoved;
|
||||
}
|
||||
|
||||
public ExitStatus getExitStatus() {
|
||||
return exitStatus;
|
||||
}
|
||||
|
||||
public long getBytesLeftToMove() {
|
||||
return bytesLeftToMove;
|
||||
}
|
||||
|
||||
public long getBytesBeingMoved() {
|
||||
return bytesBeingMoved;
|
||||
}
|
||||
|
||||
public long getBytesAlreadyMoved() {
|
||||
return bytesAlreadyMoved;
|
||||
}
|
||||
|
||||
public long getBlocksMoved() {
|
||||
return blocksMoved;
|
||||
}
|
||||
|
||||
void print(int iteration, NameNodeConnector nnc, PrintStream out) {
|
||||
out.printf("%-24s %10d %19s %18s %17s %s%n",
|
||||
out.printf("%-24s %10d %19s %18s %17s %17s %s%n",
|
||||
DateFormat.getDateTimeInstance().format(new Date()), iteration,
|
||||
StringUtils.byteDesc(bytesAlreadyMoved),
|
||||
StringUtils.byteDesc(bytesLeftToMove),
|
||||
StringUtils.byteDesc(bytesBeingMoved),
|
||||
blocksMoved,
|
||||
nnc.getNameNodeUri());
|
||||
}
|
||||
}
|
||||
|
||||
Result newResult(ExitStatus exitStatus, long bytesLeftToMove, long bytesBeingMoved) {
|
||||
return new Result(exitStatus, bytesLeftToMove, bytesBeingMoved,
|
||||
dispatcher.getBytesMoved());
|
||||
dispatcher.getBytesMoved(), dispatcher.getBblocksMoved());
|
||||
}
|
||||
|
||||
Result newResult(ExitStatus exitStatus) {
|
||||
return new Result(exitStatus, -1, -1, dispatcher.getBytesMoved());
|
||||
return new Result(exitStatus, -1, -1, dispatcher.getBytesMoved(),
|
||||
dispatcher.getBblocksMoved());
|
||||
}
|
||||
|
||||
/** Run an iteration for all datanodes. */
|
||||
|
|
|
@ -1022,14 +1022,14 @@ public class TestBalancer {
|
|||
|
||||
// clean all lists
|
||||
b.resetData(conf);
|
||||
if (r.exitStatus == ExitStatus.IN_PROGRESS) {
|
||||
if (r.getExitStatus() == ExitStatus.IN_PROGRESS) {
|
||||
done = false;
|
||||
} else if (r.exitStatus != ExitStatus.SUCCESS) {
|
||||
} else if (r.getExitStatus() != ExitStatus.SUCCESS) {
|
||||
//must be an error statue, return.
|
||||
return r.exitStatus.getExitCode();
|
||||
return r.getExitStatus().getExitCode();
|
||||
} else {
|
||||
if (iteration > 0) {
|
||||
assertTrue(r.bytesAlreadyMoved > 0);
|
||||
assertTrue(r.getBytesAlreadyMoved() > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1655,7 +1655,8 @@ public class TestBalancer {
|
|||
// When a block move is not canceled in 2 seconds properly and then
|
||||
// a block is moved unexpectedly, IN_PROGRESS will be reported.
|
||||
assertEquals("We expect ExitStatus.NO_MOVE_PROGRESS to be reported.",
|
||||
ExitStatus.NO_MOVE_PROGRESS, r.exitStatus);
|
||||
ExitStatus.NO_MOVE_PROGRESS, r.getExitStatus());
|
||||
assertEquals(0, r.getBlocksMoved());
|
||||
}
|
||||
} finally {
|
||||
for (NameNodeConnector nnc : connectors) {
|
||||
|
|
Loading…
Reference in New Issue