use of org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState in project ozone by apache.
the class NodeDecommissionManager method startMaintenance.
// TODO - If startMaintenance is called on a host already in maintenance,
// then we should update the end time?
public synchronized void startMaintenance(DatanodeDetails dn, int endInHours) throws NodeNotFoundException, InvalidNodeStateException {
NodeStatus nodeStatus = getNodeStatus(dn);
NodeOperationalState opState = nodeStatus.getOperationalState();
long maintenanceEnd = 0;
if (endInHours != 0) {
maintenanceEnd = (System.currentTimeMillis() / 1000L) + (endInHours * 60L * 60L);
}
if (opState == NodeOperationalState.IN_SERVICE) {
nodeManager.setNodeOperationalState(dn, NodeOperationalState.ENTERING_MAINTENANCE, maintenanceEnd);
monitor.startMonitoring(dn);
LOG.info("Starting Maintenance for node {}", dn);
} else if (nodeStatus.isMaintenance()) {
LOG.info("Starting Maintenance called on node {} with state {}. " + "Nothing to do.", dn, opState);
} else {
LOG.error("Cannot start maintenance on node {} in state {}", dn, opState);
throw new InvalidNodeStateException("Cannot start maintenance on node " + dn + " in state " + opState);
}
}
Aggregations