use of org.apache.hadoop.conf.ReconfigurationTaskStatus in project hadoop by apache.
the class DFSAdmin method getReconfigurationStatus.
int getReconfigurationStatus(final String nodeType, final String address, final PrintStream out, final PrintStream err) throws IOException {
String outMsg = null;
String errMsg = null;
ReconfigurationTaskStatus status = null;
try {
status = getReconfigurationStatusDispatch(nodeType, address, out, err);
outMsg = String.format("Reconfiguring status for node [%s]: ", address);
} catch (IOException e) {
errMsg = String.format("Node [%s] reloading configuration: %s.", address, e.toString());
}
if (errMsg != null) {
err.println(errMsg);
return 1;
} else {
out.print(outMsg);
}
if (status != null) {
if (!status.hasTask()) {
out.println("no task was found.");
return 0;
}
out.print("started at " + new Date(status.getStartTime()));
if (!status.stopped()) {
out.println(" and is still running.");
return 0;
}
out.println(" and finished at " + new Date(status.getEndTime()).toString() + ".");
if (status.getStatus() == null) {
// Nothing to report.
return 0;
}
for (Map.Entry<PropertyChange, Optional<String>> result : status.getStatus().entrySet()) {
if (!result.getValue().isPresent()) {
out.printf("SUCCESS: Changed property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n", result.getKey().prop, result.getKey().oldVal, result.getKey().newVal);
} else {
final String errorMsg = result.getValue().get();
out.printf("FAILED: Change property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n", result.getKey().prop, result.getKey().oldVal, result.getKey().newVal);
out.println("\tError: " + errorMsg + ".");
}
}
} else {
return 1;
}
return 0;
}
use of org.apache.hadoop.conf.ReconfigurationTaskStatus in project hadoop by apache.
the class ReconfigurationProtocolUtils method getReconfigurationStatus.
public static ReconfigurationTaskStatus getReconfigurationStatus(GetReconfigurationStatusResponseProto response) {
Map<PropertyChange, Optional<String>> statusMap = null;
long startTime;
long endTime = 0;
startTime = response.getStartTime();
if (response.hasEndTime()) {
endTime = response.getEndTime();
}
if (response.getChangesCount() > 0) {
statusMap = Maps.newHashMap();
for (GetReconfigurationStatusConfigChangeProto change : response.getChangesList()) {
PropertyChange pc = new PropertyChange(change.getName(), change.getNewValue(), change.getOldValue());
String errorMessage = null;
if (change.hasErrorMessage()) {
errorMessage = change.getErrorMessage();
}
statusMap.put(pc, Optional.fromNullable(errorMessage));
}
}
return new ReconfigurationTaskStatus(startTime, endTime, statusMap);
}
Aggregations