krishnaasawa1 commented on code in PR #4509:
URL: https://github.com/apache/ozone/pull/4509#discussion_r1168432602
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -417,4 +425,78 @@ private List<ContainerBlockMetadata> getBlocks(
private BucketLayout getBucketLayout() {
return BucketLayout.DEFAULT;
}
+
+ @GET
+ @Path("insights/containermismatch")
Review Comment:
path can be /containers/mismatch which aligns with current container APIs.
In API "insights" is not required.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -417,4 +425,78 @@ private List<ContainerBlockMetadata> getBlocks(
private BucketLayout getBucketLayout() {
return BucketLayout.DEFAULT;
}
+
+ @GET
+ @Path("insights/containermismatch")
+ public Response getContainerMisMatchInsights() {
+ List<ContainerDiscrepancyInfo> containerDiscrepancyInfoList =
+ new ArrayList<>();
+ try {
+ Map<Long, ContainerMetadata> omContainers =
+ reconContainerMetadataManager.getContainers(-1, -1);
+ List<Long> scmContainers = containerManager.getContainers().stream()
+ .map(containerInfo -> containerInfo.getContainerID()).collect(
+ Collectors.toList());
+
+ // Filter list of container Ids which are present in OM but not in SCM.
+ List<Map.Entry<Long, ContainerMetadata>> notSCMContainers =
+ omContainers.entrySet().stream().filter(containerMetadataEntry ->
+ !(scmContainers.contains(containerMetadataEntry.getKey())))
+ .collect(
+ Collectors.toList());
+
+ notSCMContainers.forEach(nonSCMContainer -> {
+ ContainerDiscrepancyInfo containerDiscrepancyInfo =
+ new ContainerDiscrepancyInfo();
+ containerDiscrepancyInfo.setContainerID(nonSCMContainer.getKey());
+ containerDiscrepancyInfo.setNumberOfKeys(
+ nonSCMContainer.getValue().getNumberOfKeys());
+ containerDiscrepancyInfo.setPipelines(nonSCMContainer.getValue()
+ .getPipelines());
+ containerDiscrepancyInfo.setExistsAt("OM");
+ containerDiscrepancyInfoList.add(containerDiscrepancyInfo);
+ });
+
+ // Filter list of container Ids which are present in SCM but not in OM.
+ List<Long> nonOMContainers = scmContainers.stream()
+ .filter(containerId -> !omContainers.containsKey(containerId))
+ .collect(Collectors.toList());
+
+ List<Pipeline> pipelines = new ArrayList<>();
+ nonOMContainers.forEach(nonOMContainerId -> {
Review Comment:
Here again need a check if nonOMContainers empty
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -417,4 +425,78 @@ private List<ContainerBlockMetadata> getBlocks(
private BucketLayout getBucketLayout() {
return BucketLayout.DEFAULT;
}
+
+ @GET
+ @Path("insights/containermismatch")
+ public Response getContainerMisMatchInsights() {
+ List<ContainerDiscrepancyInfo> containerDiscrepancyInfoList =
+ new ArrayList<>();
+ try {
+ Map<Long, ContainerMetadata> omContainers =
+ reconContainerMetadataManager.getContainers(-1, -1);
+ List<Long> scmContainers = containerManager.getContainers().stream()
+ .map(containerInfo -> containerInfo.getContainerID()).collect(
+ Collectors.toList());
+
+ // Filter list of container Ids which are present in OM but not in SCM.
+ List<Map.Entry<Long, ContainerMetadata>> notSCMContainers =
+ omContainers.entrySet().stream().filter(containerMetadataEntry ->
+ !(scmContainers.contains(containerMetadataEntry.getKey())))
+ .collect(
+ Collectors.toList());
+
+ notSCMContainers.forEach(nonSCMContainer -> {
Review Comment:
notSCMContainers List will be empty in normal scenario and only if some
thing went wrong will have it populated.
Here we need to check notSCMContainers size is not zero then only do further
steps.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -417,4 +425,78 @@ private List<ContainerBlockMetadata> getBlocks(
private BucketLayout getBucketLayout() {
return BucketLayout.DEFAULT;
}
+
+ @GET
+ @Path("insights/containermismatch")
+ public Response getContainerMisMatchInsights() {
+ List<ContainerDiscrepancyInfo> containerDiscrepancyInfoList =
+ new ArrayList<>();
+ try {
+ Map<Long, ContainerMetadata> omContainers =
+ reconContainerMetadataManager.getContainers(-1, -1);
+ List<Long> scmContainers = containerManager.getContainers().stream()
Review Comment:
Assume this scmContainers are which are is not in DELETED state?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]