Skip to content
Merged
Show file tree
Hide file tree
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 @@ -596,36 +596,60 @@ void resetData(Configuration conf) {
}

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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,14 +1022,14 @@ private static int runBalancer(Collection<URI> namenodes,

// 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);
}
}
}
Expand Down Expand Up @@ -1655,7 +1655,8 @@ public void testMaxIterationTime() throws Exception {
// 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) {
Expand Down