devmadhuu commented on code in PR #4509:
URL: https://github.com/apache/ozone/pull/4509#discussion_r1174764344
##########
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:
Changes done and pushed
##########
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:
Yes, this is SCM container list irrespective of their state.
##########
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:
foreach will not execute if list is empty, so no check 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:
foreach will not execute if list is empty, so no check required.
--
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]