Search in sources :

Example 1 with NodeNotFoundException

use of org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException in project ozone by apache.

the class SCMNodeManager method minHealthyVolumeNum.

/**
 * Returns the min of no healthy volumes reported out of the set
 * of datanodes constituting the pipeline.
 */
@Override
public int minHealthyVolumeNum(List<DatanodeDetails> dnList) {
    List<Integer> volumeCountList = new ArrayList<>(dnList.size());
    for (DatanodeDetails dn : dnList) {
        try {
            volumeCountList.add(nodeStateManager.getNode(dn).getHealthyVolumeCount());
        } catch (NodeNotFoundException e) {
            LOG.warn("Cannot generate NodeStat, datanode {} not found.", dn.getUuid());
        }
    }
    Preconditions.checkArgument(!volumeCountList.isEmpty());
    return Collections.min(volumeCountList);
}
Also used : NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) ArrayList(java.util.ArrayList)

Example 2 with NodeNotFoundException

use of org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException in project ozone by apache.

the class SCMNodeManager method getNodesByAddress.

/**
 * Given datanode address(Ipaddress or hostname), return a list of
 * DatanodeDetails for the datanodes registered on that address.
 *
 * @param address datanode address
 * @return the given datanode, or empty list if none found
 */
@Override
public List<DatanodeDetails> getNodesByAddress(String address) {
    List<DatanodeDetails> results = new LinkedList<>();
    if (Strings.isNullOrEmpty(address)) {
        LOG.warn("address is null");
        return results;
    }
    Set<String> uuids = dnsToUuidMap.get(address);
    if (uuids == null) {
        LOG.warn("Cannot find node for address {}", address);
        return results;
    }
    for (String uuid : uuids) {
        DatanodeDetails temp = DatanodeDetails.newBuilder().setUuid(UUID.fromString(uuid)).build();
        try {
            results.add(nodeStateManager.getNode(temp));
        } catch (NodeNotFoundException e) {
            LOG.warn("Cannot find node for uuid {}", uuid);
        }
    }
    return results;
}
Also used : NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) LinkedList(java.util.LinkedList)

Example 3 with NodeNotFoundException

use of org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException in project ozone by apache.

the class SCMNodeManager method register.

/**
 * Register the node if the node finds that it is not registered with any
 * SCM.
 *
 * @param datanodeDetails - Send datanodeDetails with Node info.
 *                        This function generates and assigns new datanode ID
 *                        for the datanode. This allows SCM to be run
 *                        independent
 *                        of Namenode if required.
 * @param nodeReport      NodeReport.
 * @return SCMRegisteredResponseProto
 */
@Override
public RegisteredCommand register(DatanodeDetails datanodeDetails, NodeReportProto nodeReport, PipelineReportsProto pipelineReportsProto, LayoutVersionProto layoutInfo) {
    if (layoutInfo.getSoftwareLayoutVersion() != scmLayoutVersionManager.getSoftwareLayoutVersion()) {
        return RegisteredCommand.newBuilder().setErrorCode(ErrorCode.errorNodeNotPermitted).setDatanode(datanodeDetails).setClusterID(this.scmStorageConfig.getClusterID()).build();
    }
    if (!isNodeRegistered(datanodeDetails)) {
        InetAddress dnAddress = Server.getRemoteIp();
        if (dnAddress != null) {
            // Mostly called inside an RPC, update ip and peer hostname
            datanodeDetails.setHostName(dnAddress.getHostName());
            datanodeDetails.setIpAddress(dnAddress.getHostAddress());
        }
        try {
            String dnsName;
            String networkLocation;
            datanodeDetails.setNetworkName(datanodeDetails.getUuidString());
            if (useHostname) {
                dnsName = datanodeDetails.getHostName();
            } else {
                dnsName = datanodeDetails.getIpAddress();
            }
            networkLocation = nodeResolve(dnsName);
            if (networkLocation != null) {
                datanodeDetails.setNetworkLocation(networkLocation);
            }
            clusterMap.add(datanodeDetails);
            nodeStateManager.addNode(datanodeDetails, layoutInfo);
            // Check that datanode in nodeStateManager has topology parent set
            DatanodeDetails dn = nodeStateManager.getNode(datanodeDetails);
            Preconditions.checkState(dn.getParent() != null);
            addEntryTodnsToUuidMap(dnsName, datanodeDetails.getUuidString());
            // Updating Node Report, as registration is successful
            processNodeReport(datanodeDetails, nodeReport);
            LOG.info("Registered Data node : {}", datanodeDetails);
            scmNodeEventPublisher.fireEvent(SCMEvents.NEW_NODE, datanodeDetails);
        } catch (NodeAlreadyExistsException e) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Datanode is already registered. Datanode: {}", datanodeDetails.toString());
            }
        } catch (NodeNotFoundException e) {
            LOG.error("Cannot find datanode {} from nodeStateManager", datanodeDetails.toString());
        }
    }
    return RegisteredCommand.newBuilder().setErrorCode(ErrorCode.success).setDatanode(datanodeDetails).setClusterID(this.scmStorageConfig.getClusterID()).build();
}
Also used : NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) NodeAlreadyExistsException(org.apache.hadoop.hdds.scm.node.states.NodeAlreadyExistsException) InetAddress(java.net.InetAddress)

Example 4 with NodeNotFoundException

use of org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException in project ozone by apache.

the class SCMNodeManager method getNodeStatInternal.

private SCMNodeStat getNodeStatInternal(DatanodeDetails datanodeDetails) {
    try {
        long capacity = 0L;
        long used = 0L;
        long remaining = 0L;
        final DatanodeInfo datanodeInfo = nodeStateManager.getNode(datanodeDetails);
        final List<StorageReportProto> storageReportProtos = datanodeInfo.getStorageReports();
        for (StorageReportProto reportProto : storageReportProtos) {
            capacity += reportProto.getCapacity();
            used += reportProto.getScmUsed();
            remaining += reportProto.getRemaining();
        }
        return new SCMNodeStat(capacity, used, remaining);
    } catch (NodeNotFoundException e) {
        LOG.warn("Cannot generate NodeStat, datanode {} not found.", datanodeDetails.getUuid());
        return null;
    }
}
Also used : NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException) StorageReportProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.StorageReportProto) SCMNodeStat(org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeStat)

Example 5 with NodeNotFoundException

use of org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException in project ozone by apache.

the class NodeDecommissionManager method startMaintenanceNodes.

public synchronized List<DatanodeAdminError> startMaintenanceNodes(List<String> nodes, int endInHours) throws InvalidHostStringException {
    List<DatanodeDetails> dns = mapHostnamesToDatanodes(nodes);
    List<DatanodeAdminError> errors = new ArrayList<>();
    for (DatanodeDetails dn : dns) {
        try {
            startMaintenance(dn, endInHours);
        } catch (NodeNotFoundException e) {
            // We already validated the host strings and retrieved the DnDetails
            // object from the node manager. Therefore we should never get a
            // NodeNotFoundException here expect if the node is remove in the
            // very short window between validation and starting decom. Therefore
            // log a warning and ignore the exception
            LOG.warn("The host {} was not found in SCM. Ignoring the request to " + "start maintenance on it", dn.getHostName());
        } catch (InvalidNodeStateException e) {
            errors.add(new DatanodeAdminError(dn.getHostName(), e.getMessage()));
        }
    }
    return errors;
}
Also used : NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) ArrayList(java.util.ArrayList) DatanodeAdminError(org.apache.hadoop.hdds.scm.DatanodeAdminError)

Aggregations

NodeNotFoundException (org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException)25 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)16 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)4 NodeStatus (org.apache.hadoop.hdds.scm.node.NodeStatus)4 UUID (java.util.UUID)3 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)3 DatanodeAdminError (org.apache.hadoop.hdds.scm.DatanodeAdminError)3 InvalidStateTransitionException (org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException)3 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Collectors (java.util.stream.Collectors)2 NodeState (org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState)2 ContainerReplicaProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto)2 ContainerNotFoundException (org.apache.hadoop.hdds.scm.container.ContainerNotFoundException)2 DatanodeInfo (org.apache.hadoop.hdds.scm.node.DatanodeInfo)2 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)2 PipelineID (org.apache.hadoop.hdds.scm.pipeline.PipelineID)2 Longs (com.google.common.primitives.Longs)1