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);
}
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;
}
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();
}
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;
}
}
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;
}
Aggregations