Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ private List<DatanodeDetails> validateDatanodes(List<DatanodeDetails> dns) {
}
for (int i = 0; i < dns.size(); i++) {
DatanodeDetails node = dns.get(i);
DatanodeDetails datanodeDetails =
nodeManager.getNodeByUuid(node.getUuid());
final DatanodeDetails datanodeDetails = nodeManager.getNode(node.getID());
if (datanodeDetails != null) {
dns.set(i, datanodeDetails);
}
Expand Down Expand Up @@ -496,7 +495,7 @@ public void removePeers(DatanodeDetails dn,
public boolean isValidNode(DatanodeDetails datanodeDetails,
long metadataSizeRequired, long dataSizeRequired) {
DatanodeInfo datanodeInfo = (DatanodeInfo)getNodeManager()
.getNodeByUuid(datanodeDetails.getUuid());
.getNode(datanodeDetails.getID());
if (datanodeInfo == null) {
LOG.error("Failed to find the DatanodeInfo for datanode {}",
datanodeDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ public void onMessage(final ContainerReportFromDatanode reportFromDatanode,

final DatanodeDetails dnFromReport =
reportFromDatanode.getDatanodeDetails();
DatanodeDetails datanodeDetails =
nodeManager.getNodeByUuid(dnFromReport.getUuid());
final DatanodeDetails datanodeDetails = nodeManager.getNode(dnFromReport.getID());
if (datanodeDetails == null) {
LOG.warn("Received container report from unknown datanode {}",
dnFromReport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ public void onMessage(final IncrementalContainerReportFromDatanode report,
final EventPublisher publisher) {
final DatanodeDetails dnFromReport = report.getDatanodeDetails();
if (LOG.isDebugEnabled()) {
LOG.debug("Processing incremental container report from data node {}",
dnFromReport.getUuid());
LOG.debug("Processing incremental container report from data node {}", dnFromReport);
}
DatanodeDetails dd =
nodeManager.getNodeByUuid(dnFromReport.getUuid());
final DatanodeDetails dd = nodeManager.getNode(dnFromReport.getID());
if (dd == null) {
LOG.warn("Received container report from unknown datanode {}",
dnFromReport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void onMessage(final DatanodeDetails datanodeDetails,
//make sure after DN is removed from topology,
//DatanodeDetails instance returned from nodeStateManager has no parent.
Preconditions.checkState(
nodeManager.getNodeByUuid(datanodeDetails.getUuid())
nodeManager.getNode(datanodeDetails.getID())
.getParent() == null);
}
} catch (NodeNotFoundException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void onMessage(DatanodeDetails datanodeDetails,
// make sure after DN is added back into topology, DatanodeDetails
// instance returned from nodeStateManager has parent correctly set.
Preconditions.checkNotNull(
nodeManager.getNodeByUuid(datanodeDetails.getUuid())
nodeManager.getNode(datanodeDetails.getID())
.getParent());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.UUID;
import java.util.function.BiConsumer;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.DatanodeID;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.LayoutVersionProto;
Expand Down Expand Up @@ -360,17 +361,8 @@ Map<SCMCommandProto.Type, Integer> getTotalDatanodeCommandCounts(
// TODO: We can give better name to this method!
List<SCMCommand<?>> getCommandQueue(UUID dnID);

/**
* Given datanode uuid, returns the DatanodeDetails for the node.
*
* @param uuid datanode uuid
* @return the given datanode, or null if not found
*/
@Nullable DatanodeDetails getNodeByUuid(@Nullable String uuid);

default @Nullable DatanodeDetails getNodeByUuid(@Nullable UUID uuid) {
return uuid != null ? getNodeByUuid(uuid.toString()) : null;
};
/** @return the datanode of the given id if it exists; otherwise, return null. */
@Nullable DatanodeDetails getNode(@Nullable DatanodeID id);

/**
* Given datanode address(Ipaddress or hostname), returns a list of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1676,29 +1676,16 @@ public List<SCMCommand<?>> getCommandQueue(UUID dnID) {
}
}

/**
* Given datanode uuid, returns the DatanodeDetails for the node.
*
* @param uuid node host address
* @return the given datanode, or null if not found
*/
@Override
public DatanodeDetails getNodeByUuid(String uuid) {
return uuid != null && !uuid.isEmpty()
? getNodeByUuid(UUID.fromString(uuid))
: null;
}

@Override
public DatanodeDetails getNodeByUuid(UUID uuid) {
if (uuid == null) {
public DatanodeInfo getNode(DatanodeID id) {
if (id == null) {
return null;
}

try {
return nodeStateManager.getNode(DatanodeID.of(uuid));
return nodeStateManager.getNode(id);
} catch (NodeNotFoundException e) {
LOG.warn("Cannot find node for uuid {}", uuid);
LOG.warn("Cannot find node for uuid {}", id);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private boolean isOpenWithUnregisteredNodes(Pipeline pipeline) {
return false;
}
for (DatanodeDetails dn : pipeline.getNodes()) {
if (nodeManager.getNodeByUuid(dn.getUuid()) == null) {
if (nodeManager.getNode(dn.getID()) == null) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.DatanodeID;
import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos;
import org.apache.hadoop.hdds.scm.AddSCMRequest;
import org.apache.hadoop.hdds.scm.ScmInfo;
Expand Down Expand Up @@ -378,7 +379,7 @@ public List<DatanodeDetails> sortDatanodes(List<String> nodes,
final Node client = getClientNode(clientMachine);
List<DatanodeDetails> nodeList = new ArrayList<>();
nodes.forEach(uuid -> {
DatanodeDetails node = nodeManager.getNodeByUuid(uuid);
DatanodeDetails node = nodeManager.getNode(DatanodeID.fromUuidString(uuid));
if (node != null) {
nodeList.add(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.conf.ReconfigurationHandler;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.DatanodeID;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.DeletedBlocksTransactionInfo;
import org.apache.hadoop.hdds.protocol.proto.ReconfigureProtocolProtos.ReconfigureProtocolService;
Expand Down Expand Up @@ -616,7 +617,7 @@ public HddsProtos.Node queryNode(UUID uuid)
throws IOException {
HddsProtos.Node result = null;
try {
DatanodeDetails node = scm.getScmNodeManager().getNodeByUuid(uuid);
DatanodeDetails node = scm.getScmNodeManager().getNode(DatanodeID.of(uuid));
if (node != null) {
NodeStatus ns = scm.getScmNodeManager().getNodeStatus(node);
result = HddsProtos.Node.newBuilder()
Expand Down Expand Up @@ -1222,7 +1223,7 @@ public List<HddsProtos.DatanodeUsageInfoProto> getDatanodeUsageInfo(
// get datanodes by ip or uuid
List<DatanodeDetails> nodes = new ArrayList<>();
if (!Strings.isNullOrEmpty(uuid)) {
nodes.add(scm.getScmNodeManager().getNodeByUuid(uuid));
nodes.add(scm.getScmNodeManager().getNode(DatanodeID.fromUuidString(uuid)));
} else if (!Strings.isNullOrEmpty(address)) {
nodes = scm.getScmNodeManager().getNodesByAddress(address);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.DatanodeID;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos;
import org.apache.hadoop.hdds.scm.container.ContainerID;
import org.apache.hadoop.hdds.scm.container.ContainerReplica;
Expand Down Expand Up @@ -467,17 +468,17 @@ protected List<DatanodeDetails> chooseDatanodesInternal(
@Test
public void testDatanodeIsInvalidInCaseOfIncreasingCommittedBytes() {
NodeManager nodeMngr = mock(NodeManager.class);
UUID datanodeUuid = UUID.randomUUID();
final DatanodeID datanodeID = DatanodeID.of(UUID.randomUUID());
DummyPlacementPolicy placementPolicy =
new DummyPlacementPolicy(nodeMngr, conf, 1);
DatanodeDetails datanodeDetails = mock(DatanodeDetails.class);
when(datanodeDetails.getUuid()).thenReturn(datanodeUuid);
when(datanodeDetails.getID()).thenReturn(datanodeID);

DatanodeInfo datanodeInfo = mock(DatanodeInfo.class);
NodeStatus nodeStatus = mock(NodeStatus.class);
when(nodeStatus.isNodeWritable()).thenReturn(true);
when(datanodeInfo.getNodeStatus()).thenReturn(nodeStatus);
when(nodeMngr.getNodeByUuid(eq(datanodeUuid))).thenReturn(datanodeInfo);
when(nodeMngr.getNode(eq(datanodeID))).thenReturn(datanodeInfo);

// capacity = 200000, used = 90000, remaining = 101000, committed = 500
StorageContainerDatanodeProtocolProtos.StorageReportProto storageReport1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.stream.Collectors;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.DatanodeID;
import org.apache.hadoop.hdds.protocol.MockDatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState;
Expand Down Expand Up @@ -831,8 +832,8 @@ public List<SCMCommand<?>> getCommandQueue(UUID dnID) {
}

@Override
public DatanodeDetails getNodeByUuid(String uuid) {
Node node = clusterMap.getNode(NetConstants.DEFAULT_RACK + "/" + uuid);
public DatanodeDetails getNode(DatanodeID id) {
Node node = clusterMap.getNode(NetConstants.DEFAULT_RACK + "/" + id);
return node == null ? null : (DatanodeDetails)node;
}

Expand All @@ -844,7 +845,7 @@ public List<DatanodeDetails> getNodesByAddress(String address) {
return results;
}
for (String uuid : uuids) {
DatanodeDetails dn = getNodeByUuid(uuid);
DatanodeDetails dn = getNode(DatanodeID.fromUuidString(uuid));
if (dn != null) {
results.add(dn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public List<SCMCommand<?>> getCommandQueue(UUID dnID) {
}

@Override
public DatanodeDetails getNodeByUuid(String uuid) {
public DatanodeDetails getNode(DatanodeID id) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void testRackAwarePolicy() throws IOException {
when(nodeManager.getNodes(NodeStatus.inServiceHealthy()))
.thenReturn(new ArrayList<>(datanodes));
for (DatanodeInfo dn: dnInfos) {
when(nodeManager.getNodeByUuid(dn.getUuid()))
when(nodeManager.getNode(dn.getID()))
.thenReturn(dn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.conf.StorageUnit;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.DatanodeID;
import org.apache.hadoop.hdds.protocol.MockDatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.MetadataStorageReportProto;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.StorageReportProto;
Expand Down Expand Up @@ -112,9 +112,9 @@ public void chooseDatanodes() throws SCMException {
.thenReturn(new SCMNodeMetric(100L, 80L, 20L, 0, 19));
when(mockNodeManager.getNodeStat(datanodes.get(4)))
.thenReturn(new SCMNodeMetric(100L, 70L, 30L, 0, 20));
when(mockNodeManager.getNodeByUuid(any(UUID.class))).thenAnswer(
when(mockNodeManager.getNode(any(DatanodeID.class))).thenAnswer(
invocation -> datanodes.stream()
.filter(dn -> dn.getUuid().equals(invocation.getArgument(0)))
.filter(dn -> dn.getID().equals(invocation.getArgument(0)))
.findFirst()
.orElse(null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void setup(int datanodeCount) {
when(nodeManager.getNodes(NodeStatus.inServiceHealthy()))
.thenReturn(new ArrayList<>(datanodes));
for (DatanodeInfo dn: dnInfos) {
when(nodeManager.getNodeByUuid(dn.getUuid()))
when(nodeManager.getNode(dn.getID()))
.thenReturn(dn);
}
when(nodeManager.getClusterNetworkTopologyMap())
Expand Down Expand Up @@ -478,7 +478,7 @@ public void testDatanodeWithDefaultNetworkLocation(int datanodeCount)
assertEquals(dataList.size(), StringUtils.countMatches(
clusterMap.toString(), NetConstants.DEFAULT_RACK));
for (DatanodeInfo dn: dnInfoList) {
when(nodeManager.getNodeByUuid(dn.getUuid()))
when(nodeManager.getNode(dn.getID()))
.thenReturn(dn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private void createMocksAndUpdateStorageReports(int datanodeCount) {
when(nodeManager.getNodes(NodeStatus.inServiceHealthy()))
.thenReturn(new ArrayList<>(datanodes));
for (DatanodeInfo dn: dnInfos) {
when(nodeManager.getNodeByUuid(dn.getUuid()))
when(nodeManager.getNode(dn.getID()))
.thenReturn(dn);
}
when(nodeManager.getClusterNetworkTopologyMap())
Expand Down Expand Up @@ -511,7 +511,7 @@ public void testDatanodeWithDefaultNetworkLocation(int datanodeCount)
assertEquals(dataList.size(), StringUtils.countMatches(
clusterMap.toString(), NetConstants.DEFAULT_RACK));
for (DatanodeInfo dn: dnInfoList) {
when(nodeManager.getNodeByUuid(dn.getUuid()))
when(nodeManager.getNode(dn.getID()))
.thenReturn(dn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ public void testIsValidNode() throws SCMException {
NodeManager mockNodeManager = mock(NodeManager.class);
when(mockNodeManager.getNodes(NodeStatus.inServiceHealthy()))
.thenReturn(new ArrayList<>(datanodes));
when(mockNodeManager.getNodeByUuid(datanodes.get(0).getUuid()))
when(mockNodeManager.getNode(datanodes.get(0).getID()))
.thenReturn(datanodes.get(0));
when(mockNodeManager.getNodeByUuid(datanodes.get(1).getUuid()))
when(mockNodeManager.getNode(datanodes.get(1).getID()))
.thenReturn(datanodes.get(1));
when(mockNodeManager.getNodeByUuid(datanodes.get(2).getUuid()))
when(mockNodeManager.getNode(datanodes.get(2).getID()))
.thenReturn(datanodes.get(2));

SCMContainerPlacementRandom scmContainerPlacementRandom =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void testOnMessage(@TempDir File tempDir) throws Exception {

// First set the node to IN_MAINTENANCE and ensure the container replicas
// are not removed on the dead event
datanode1 = nodeManager.getNodeByUuid(datanode1.getUuidString());
datanode1 = nodeManager.getNode(datanode1.getID());
assertTrue(
nodeManager.getClusterNetworkTopologyMap().contains(datanode1));
nodeManager.setNodeOperationalState(datanode1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,7 @@ public void testScrubOpenWithUnregisteredNodes() throws Exception {
pipeline.getPipelineState());

// Now, "unregister" one of the nodes in the pipeline
DatanodeDetails firstDN = nodeManager.getNodeByUuid(
pipeline.getNodes().get(0).getUuidString());
DatanodeDetails firstDN = nodeManager.getNode(pipeline.getNodes().get(0).getID());
nodeManager.getClusterNetworkTopologyMap().remove(firstDN);

pipelineManager.scrubPipelines();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void setupRacks(int datanodeCount, int nodesPerRack,
false, 10);
nodeManager = spy(nodeManagerBase);
for (DatanodeInfo dn: dnInfos) {
when(nodeManager.getNodeByUuid(dn.getUuidString()))
when(nodeManager.getNode(dn.getID()))
.thenReturn(dn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ private void testScmProcessDatanodeHeartbeat(MiniOzoneCluster cluster) {
assertEquals(cluster.getHddsDatanodes().size(), allNodes.size());

for (DatanodeDetails node : allNodes) {
DatanodeInfo datanodeInfo = assertInstanceOf(DatanodeInfo.class, nodeManager.getNodeByUuid(node.getUuid()));
DatanodeInfo datanodeInfo = assertInstanceOf(DatanodeInfo.class, nodeManager.getNode(node.getID()));
assertNotNull(datanodeInfo);
assertThat(datanodeInfo.getLastHeartbeatTime()).isPositive();
assertEquals(datanodeInfo.getUuidString(), datanodeInfo.getNetworkName());
Expand Down
Loading