Skip to content

Commit

Permalink
HDDS-8942. Intermittent failure in ITestOzoneContractCreate#testSynca…
Browse files Browse the repository at this point in the history
…ble (#6821)
  • Loading branch information
chungen0126 authored Jun 20, 2024
1 parent b3d191b commit 59560a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,17 @@ private XceiverClientReply sendCommandWithRetry(
}

if (blockID != null) {
if (request.getCmdType() != ContainerProtos.Type.ReadChunk) {
datanodeList = pipeline.getNodes();
int getBlockDNLeaderIndex = datanodeList.indexOf(pipeline.getLeaderNode());
if (getBlockDNLeaderIndex > 0) {
// Pull the leader DN to the top of the DN list
Collections.swap(datanodeList, 0, getBlockDNLeaderIndex);
}
}
// Check if the DN to which the GetBlock command was sent has been cached.
DatanodeDetails cachedDN = getBlockDNcache.get(blockID);
if (cachedDN != null) {
if (cachedDN != null && !topologyAwareRead) {
datanodeList = pipeline.getNodes();
int getBlockDNCacheIndex = datanodeList.indexOf(cachedDN);
if (getBlockDNCacheIndex > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,27 @@ public void testCorrectDnsReturnedFromPipeline() throws IOException {

@Test
@Timeout(5)
public void testRandomFirstNodeIsCommandTarget() throws IOException {
final ArrayList<DatanodeDetails> allDNs = new ArrayList<>(dns);
public void testLeaderNodeIsCommandTarget() throws IOException {
final Set<DatanodeDetails> seenDN = new HashSet<>();
conf.setBoolean(
OzoneConfigKeys.OZONE_NETWORK_TOPOLOGY_AWARE_READ_KEY, false);
// Using a new Xceiver Client, call it repeatedly until all DNs in the
// pipeline have been the target of the command, indicating it is shuffling
// the DNs on each call with a new client. This test will timeout if this
// is not happening.
while (allDNs.size() > 0) {
// Using a new Xceiver Client, make 100 calls and ensure leader node is used
// each time. The logic should always use the leader node, so we can check
// only a single DN is ever seen after 100 calls.
for (int i = 0; i < 100; i++) {
try (XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf) {
@Override
public XceiverClientReply sendCommandAsync(
ContainerProtos.ContainerCommandRequestProto request,
DatanodeDetails dn) {
allDNs.remove(dn);
seenDN.add(dn);
return buildValidResponse();
}
}) {
invokeXceiverClientGetBlock(client);
}
}
assertEquals(1, seenDN.size());
}

@Test
Expand Down

0 comments on commit 59560a1

Please sign in to comment.