Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-1553: Add metric for rack aware placement policy #1242

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public final class SCMContainerPlacementRackAware extends SCMCommonPolicy {
private boolean fallback;
private static final int RACK_LEVEL = 1;
private static final int MAX_RETRY= 3;
private int numOfTotalRequests = 0;
private int numOfSuccessRequests = 0;
private int numOfSuccessRequestsWithCondition = 0;

/**
* Constructs a Container Placement with rack awareness.
Expand Down Expand Up @@ -93,6 +96,7 @@ public List<DatanodeDetails> chooseDatanodes(
List<DatanodeDetails> excludedNodes, List<DatanodeDetails> favoredNodes,
int nodesRequired, final long sizeRequired) throws SCMException {
Preconditions.checkArgument(nodesRequired > 0);
numOfTotalRequests += nodesRequired;

int datanodeCount = networkTopology.getNumOfLeafNode(NetConstants.ROOT);
int excludedNodesCount = excludedNodes == null ? 0 : excludedNodes.size();
Expand Down Expand Up @@ -125,6 +129,7 @@ public List<DatanodeDetails> chooseDatanodes(
}
chosenNodes.add(firstNode);
nodesRequired--;
numOfSuccessRequests++;
if (nodesRequired == 0) {
return Arrays.asList(chosenNodes.toArray(new DatanodeDetails[0]));
}
Expand All @@ -142,6 +147,7 @@ public List<DatanodeDetails> chooseDatanodes(
}
chosenNodes.add(secondNode);
nodesRequired--;
numOfSuccessRequests++;
if (nodesRequired == 0) {
return Arrays.asList(chosenNodes.toArray(new DatanodeDetails[0]));
}
Expand Down Expand Up @@ -170,6 +176,8 @@ public List<DatanodeDetails> chooseDatanodes(
}
chosenNodes.add(firstNode);
nodesRequired--;
numOfSuccessRequests++;
numOfSuccessRequestsWithCondition++;
if (nodesRequired == 0) {
return Arrays.asList(chosenNodes.toArray(new DatanodeDetails[0]));
}
Expand Down Expand Up @@ -206,6 +214,8 @@ public List<DatanodeDetails> chooseDatanodes(
chosenNodes.add(secondNode);
mutableExcludedNodes.add(secondNode);
nodesRequired--;
numOfSuccessRequests++;
numOfSuccessRequestsWithCondition++;
if (nodesRequired == 0) {
return Arrays.asList(chosenNodes.toArray(new DatanodeDetails[0]));
}
Expand Down Expand Up @@ -334,9 +344,45 @@ private List<DatanodeDetails> chooseNodes(List<Node> excludedNodes,
chosenNodes.add(chosenNode);
}
nodesRequired--;
numOfSuccessRequests++;
numOfSuccessRequestsWithCondition++;
if (nodesRequired == 0) {
return Arrays.asList(chosenNodes.toArray(new DatanodeDetails[0]));
}
}
}

/**
* Get the total number of total requests.
*
*
* @return the total number of requests for data node.
*/
public int getNumOfTotalRequests() {
return numOfTotalRequests;
}

/**
* Get the number of requests which return data node successfully.
*
*
* @return the number of requests which return data node successfully
*/
public int getGetNumOfSuccessRequests() {
return numOfSuccessRequests;
}

/**
* Get the number of requests with conditions and return data node
* successfully.
*
*
* @return the number of requests with conditions and return data node
* successfully
*/
public int getNumOfSuccessRequestsWithCondition() {
return numOfSuccessRequestsWithCondition;
}


}