Search in sources :

Example 11 with NodeOperationalState

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);
    }
}
Also used : NodeOperationalState(org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState)

Aggregations

NodeOperationalState (org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState)11 NodeState (org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState)5 IOException (java.io.IOException)3 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)3 NodeStatus (org.apache.hadoop.hdds.scm.node.NodeStatus)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)2 DatanodeMetadata (org.apache.hadoop.ozone.recon.api.types.DatanodeMetadata)2 DatanodesResponse (org.apache.hadoop.ozone.recon.api.types.DatanodesResponse)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 GET (javax.ws.rs.GET)1 Response (javax.ws.rs.core.Response)1