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); }
@Override public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException { GetReconfigurationStatusResponseProto response; Map<PropertyChange, Optional<String>> statusMap = null; long startTime; long endTime = 0; try { response = rpcProxy.getReconfigurationStatus(NULL_CONTROLLER, VOID_GET_RECONFIG_STATUS); 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)); } } } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } return new ReconfigurationTaskStatus(startTime, endTime, statusMap); }
@Override public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException { try { return ReconfigurationProtocolUtils.getReconfigurationStatus( rpcProxy .getReconfigurationStatus( NULL_CONTROLLER, VOID_GET_RECONFIG_STATUS)); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } }
public static GetReconfigurationStatusResponseProto getReconfigurationStatus( ReconfigurationTaskStatus status) { GetReconfigurationStatusResponseProto.Builder builder = GetReconfigurationStatusResponseProto.newBuilder(); builder.setStartTime(status.getStartTime()); if (status.stopped()) { builder.setEndTime(status.getEndTime()); assert status.getStatus() != null; for (Map.Entry<PropertyChange, Optional<String>> result : status .getStatus().entrySet()) { GetReconfigurationStatusConfigChangeProto.Builder changeBuilder = GetReconfigurationStatusConfigChangeProto.newBuilder(); PropertyChange change = result.getKey(); changeBuilder.setName(change.prop); changeBuilder.setOldValue(change.oldVal != null ? change.oldVal : ""); if (change.newVal != null) { changeBuilder.setNewValue(change.newVal); } if (result.getValue().isPresent()) { // Get full stack trace. changeBuilder.setErrorMessage(result.getValue().get()); } builder.addChanges(changeBuilder); } } return builder.build(); }
@Override // ClientDatanodeProtocol public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException { checkSuperuserPrivilege(); return getReconfigurationTaskStatus(); }
int getReconfigurationStatus(String nodeType, String address, PrintStream out, PrintStream err) throws IOException { if ("datanode".equals(nodeType)) { ClientDatanodeProtocol dnProxy = getDataNodeProxy(address); try { ReconfigurationTaskStatus status = dnProxy.getReconfigurationStatus(); out.print("Reconfiguring status for DataNode[" + address + "]: "); 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() + "."); for (Map.Entry<PropertyChange, Optional<String>> result : status.getStatus().entrySet()) { if (!result.getValue().isPresent()) { out.print("SUCCESS: "); } else { out.print("FAILED: "); } out.printf("Change property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n", result.getKey().prop, result.getKey().oldVal, result.getKey().newVal); if (result.getValue().isPresent()) { out.println("\tError: " + result.getValue().get() + "."); } } } catch (IOException e) { err.println("DataNode reloading configuration: " + e + "."); return 1; } } else { err.println("Node type " + nodeType + " does not support reconfiguration."); return 1; } return 0; }
@Override // ClientDatanodeProtocol & ReconfigurationProtocol public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException { checkSuperuserPrivilege(); return getReconfigurationTaskStatus(); }
int getReconfigurationStatus(String nodeType, String address, PrintStream out, PrintStream err) throws IOException { if ("datanode".equals(nodeType)) { ClientDatanodeProtocol dnProxy = getDataNodeProxy(address); try { ReconfigurationTaskStatus status = dnProxy.getReconfigurationStatus(); out.print("Reconfiguring status for DataNode[" + address + "]: "); 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 + "."); } } } catch (IOException e) { err.println("DataNode reloading configuration: " + e + "."); return 1; } } else { err.println("Node type " + nodeType + " does not support reconfiguration."); return 1; } return 0; }
int getReconfigurationStatus(String nodeType, String address, PrintStream out, PrintStream err) throws IOException { if ("datanode".equals(nodeType)) { ClientDatanodeProtocol dnProxy = getDataNodeProxy(address); try { ReconfigurationTaskStatus status = dnProxy.getReconfigurationStatus(); out.print("Reconfiguring status for DataNode[" + address + "]: "); 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() + "."); for (Map.Entry<PropertyChange, Optional<String>> result : status.getStatus().entrySet()) { if (!result.getValue().isPresent()) { out.print("SUCCESS: "); } else { out.print("FAILED: "); } out.printf("Change property %s\n\tFrom: \"%s\"\n\tTo: \"%s\"\n", result.getKey().prop, result.getKey().oldVal, result.getKey().newVal); if (result.getValue().isPresent()) { out.println("\tError: " + result.getValue().get() + "."); } } } catch (IOException e) { err.println("DataNode reloading configuration: " + e + "."); return 1; } } else { err.println("Node type " + nodeType + " does not support reconfiguration."); return 1; } return 0; }
/** * Get the status of the previously issued reconfig task. * @see {@link org.apache.hadoop.conf.ReconfigurationTaskStatus}. */ ReconfigurationTaskStatus getReconfigurationStatus() throws IOException;