Search in sources :

Example 1 with ReconfigurationTaskStatus

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;
}
Also used : ReconfigurationTaskStatus(org.apache.hadoop.conf.ReconfigurationTaskStatus) PropertyChange(org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange) Optional(com.google.common.base.Optional) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) Date(java.util.Date)

Example 2 with ReconfigurationTaskStatus

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);
}
Also used : ReconfigurationTaskStatus(org.apache.hadoop.conf.ReconfigurationTaskStatus) PropertyChange(org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange) Optional(com.google.common.base.Optional) GetReconfigurationStatusConfigChangeProto(org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusConfigChangeProto)

Aggregations

Optional (com.google.common.base.Optional)2 ReconfigurationTaskStatus (org.apache.hadoop.conf.ReconfigurationTaskStatus)2 PropertyChange (org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange)2 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GetReconfigurationStatusConfigChangeProto (org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.GetReconfigurationStatusConfigChangeProto)1