This is an automated email from the ASF dual-hosted git repository.
zitadombi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new eb1ecbd1ae HDDS-8964. Create a separate endpoint for summary for
various SCM Insights and OM Insights. (#5023)
eb1ecbd1ae is described below
commit eb1ecbd1aee6940d0077ed730bd5cdc663437057
Author: Arafat2198 <[email protected]>
AuthorDate: Mon Aug 14 14:22:42 2023 +0530
HDDS-8964. Create a separate endpoint for summary for various SCM Insights
and OM Insights. (#5023)
---
.../ozone/recon/api/OMDBInsightEndpoint.java | 72 +++++++++++++++++-----
.../recon/api/types/KeyInsightInfoResponse.java | 15 -----
.../webapps/recon/ozone-recon-web/api/routes.json | 4 +-
.../src/views/overview/overview.tsx | 16 ++---
.../ozone/recon/api/TestOmDBInsightEndPoint.java | 40 +++++++-----
5 files changed, 89 insertions(+), 58 deletions(-)
diff --git
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java
index 2c71478662..801dbb0ff2 100644
---
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java
+++
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java
@@ -105,11 +105,6 @@ public class OMDBInsightEndpoint {
* @return the http json response wrapped in below format:
*
* {
- * "keysSummary": {
- * "totalUnreplicatedDataSize": 2147483648,
- * "totalReplicatedDataSize": 2147483648,
- * "totalOpenKeys": 8
- * },
* "lastKey": "/-4611686018427388160/-9223372036854775552/-922777620354",
* "replicatedTotal": 2147483648,
* "unreplicatedTotal": 2147483648,
@@ -174,8 +169,6 @@ public class OMDBInsightEndpoint {
List<KeyEntityInfo> nonFSOKeyInfoList =
openKeyInsightInfo.getNonFSOKeyInfoList();
- // Create a HashMap for the keysSummary
- Map<String, Long> keysSummary = new HashMap<>();
boolean skipPrevKeyDone = false;
boolean isLegacyBucketLayout = true;
boolean recordsFetchedLimitReached = false;
@@ -255,15 +248,39 @@ public class OMDBInsightEndpoint {
break;
}
}
- // Populate the keysSummary map
- createKeysSummaryForOpenKey(keysSummary);
-
- openKeyInsightInfo.setKeysSummary(keysSummary);
openKeyInsightInfo.setLastKey(lastKey);
return Response.ok(openKeyInsightInfo).build();
}
+ /**
+ * Retrieves the summary of open keys.
+ *
+ * This method calculates and returns a summary of open keys.
+ *
+ * @return The HTTP response body includes a map with the following entries:
+ * - "totalOpenKeys": the total number of open keys
+ * - "totalReplicatedDataSize": the total replicated size for open keys
+ * - "totalUnreplicatedDataSize": the total unreplicated size for open keys
+ *
+ *
+ * Example response:
+ * {
+ * "totalOpenKeys": 8,
+ * "totalReplicatedDataSize": 90000,
+ * "totalUnreplicatedDataSize": 30000
+ * }
+ */
+ @GET
+ @Path("/open/summary")
+ public Response getOpenKeySummary() {
+ // Create a HashMap for the keysSummary
+ Map<String, Long> keysSummary = new HashMap<>();
+ // Create a keys summary for open keys
+ createKeysSummaryForOpenKey(keysSummary);
+ return Response.ok(keysSummary).build();
+ }
+
/**
* Creates a keys summary for open keys and updates the provided
* keysSummary map. Calculates the total number of open keys, replicated
@@ -310,8 +327,6 @@ public class OMDBInsightEndpoint {
deletedKeyAndDirInsightInfo.getRepeatedOmKeyInfoList();
Table<String, RepeatedOmKeyInfo> deletedTable =
omMetadataManager.getDeletedTable();
- // Create a HashMap for the keysSummary
- Map<String, Long> keysSummary = new HashMap<>();
try (
TableIterator<String, ? extends Table.KeyValue<String,
RepeatedOmKeyInfo>>
@@ -348,10 +363,6 @@ public class OMDBInsightEndpoint {
break;
}
}
- // Create the keysSummary for deleted keys
- createKeysSummaryForDeletedKey(keysSummary);
- // Set the keysSummary and lastKey in the response
- deletedKeyAndDirInsightInfo.setKeysSummary(keysSummary);
deletedKeyAndDirInsightInfo.setLastKey(lastKey);
} catch (IOException ex) {
throw new WebApplicationException(ex,
@@ -364,6 +375,33 @@ public class OMDBInsightEndpoint {
}
}
+ /** Retrieves the summary of deleted keys.
+ *
+ * This method calculates and returns a summary of deleted keys.
+ *
+ * @return The HTTP response body includes a map with the following entries:
+ * - "totalDeletedKeys": the total number of deleted keys
+ * - "totalReplicatedDataSize": the total replicated size for deleted keys
+ * - "totalUnreplicatedDataSize": the total unreplicated size for deleted
keys
+ *
+ *
+ * Example response:
+ * {
+ * "totalDeletedKeys": 8,
+ * "totalReplicatedDataSize": 90000,
+ * "totalUnreplicatedDataSize": 30000
+ * }
+ */
+ @GET
+ @Path("/deletePending/summary")
+ public Response getDeletedKeySummary() {
+ // Create a HashMap for the keysSummary
+ Map<String, Long> keysSummary = new HashMap<>();
+ // Create a keys summary for deleted keys
+ createKeysSummaryForDeletedKey(keysSummary);
+ return Response.ok(keysSummary).build();
+ }
+
/**
* This method retrieves set of keys/files pending for deletion.
* <p>
diff --git
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/KeyInsightInfoResponse.java
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/KeyInsightInfoResponse.java
index 425454ffcc..2777cf53b4 100644
---
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/KeyInsightInfoResponse.java
+++
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/KeyInsightInfoResponse.java
@@ -23,19 +23,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* HTTP Response wrapped for keys insights.
*/
public class KeyInsightInfoResponse {
- /** Keys summary. Includes aggregated information about the keys. */
- @JsonProperty("keysSummary")
- private Map<String, Long> keysSummary;
-
/** last key sent. */
@JsonProperty("lastKey")
private String lastKey;
@@ -81,15 +75,6 @@ public class KeyInsightInfoResponse {
fsoKeyInfoList = new ArrayList<>();
repeatedOmKeyInfoList = new ArrayList<>();
deletedDirInfoList = new ArrayList<>();
- keysSummary = new HashMap<>();
- }
-
- public Map<String, Long> getKeysSummary() {
- return keysSummary;
- }
-
- public void setKeysSummary(Map<String, Long> keysSummary) {
- this.keysSummary = keysSummary;
}
public String getLastKey() {
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/routes.json
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/routes.json
index d7efeea053..5dc3c0d310 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/routes.json
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/routes.json
@@ -29,8 +29,8 @@
"/heatmap/readaccess?startDate=*&path=*&entityType=key": "/keyHeatmap",
"/heatmap/readaccess?startDate=*&path=*&entityType=volume": "/heatmap",
"/features/disabledFeatures": "/disabledFeatures",
- "/keys/open?limit=0": "/keysOpenSummary",
- "/keys/deletePending?limit=1": "/keysdeletePendingSummary",
+ "/keys/open/summary": "/keysOpenSummary",
+ "/keys/deletePending/summary": "/keysdeletePendingSummary",
"/containers/mismatch?limit=*&prevKey=11&missingIn=OM" : "/omMismatch1",
"/containers/mismatch?limit=*&prevKey=21&missingIn=OM" : "/omMismatch2",
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/overview/overview.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/overview/overview.tsx
index 09720fbc22..2908564bb1 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/overview/overview.tsx
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/views/overview/overview.tsx
@@ -114,8 +114,8 @@ export class Overview extends
React.Component<Record<string, object>, IOverviewS
axios.all([
axios.get('/api/v1/clusterState'),
axios.get('/api/v1/task/status'),
- axios.get('/api/v1/keys/open?limit=0'),
- axios.get('/api/v1/keys/deletePending?limit=1'),
+ axios.get('/api/v1/keys/open/summary'),
+ axios.get('/api/v1/keys/deletePending/summary'),
]).then(axios.spread((clusterStateResponse, taskstatusResponse,
openResponse, deletePendingResponse) => {
const clusterState: IClusterStateResponse = clusterStateResponse.data;
@@ -140,12 +140,12 @@ export class Overview extends
React.Component<Record<string, object>, IOverviewS
lastRefreshed: Number(moment()),
lastUpdatedOMDBDelta: omDBDeltaObject &&
omDBDeltaObject.lastUpdatedTimestamp,
lastUpdatedOMDBFull: omDBFullObject &&
omDBFullObject.lastUpdatedTimestamp,
- openSummarytotalUnrepSize: openResponse.data &&
openResponse.data.keysSummary &&
openResponse.data.keysSummary.totalUnreplicatedDataSize,
- openSummarytotalRepSize: openResponse.data &&
openResponse.data.keysSummary &&
openResponse.data.keysSummary.totalReplicatedDataSize,
- openSummarytotalOpenKeys: openResponse.data &&
openResponse.data.keysSummary && openResponse.data.keysSummary.totalOpenKeys,
- deletePendingSummarytotalUnrepSize: deletePendingResponse.data &&
deletePendingResponse.data.keysSummary &&
deletePendingResponse.data.keysSummary.totalUnreplicatedDataSize,
- deletePendingSummarytotalRepSize: deletePendingResponse.data &&
deletePendingResponse.data.keysSummary &&
deletePendingResponse.data.keysSummary.totalReplicatedDataSize,
- deletePendingSummarytotalDeletedKeys: deletePendingResponse.data &&
deletePendingResponse.data.keysSummary &&
deletePendingResponse.data.keysSummary.totalDeletedKeys
+ openSummarytotalUnrepSize: openResponse.data &&
openResponse.data.totalUnreplicatedDataSize,
+ openSummarytotalRepSize: openResponse.data &&
openResponse.data.totalReplicatedDataSize,
+ openSummarytotalOpenKeys: openResponse.data &&
openResponse.data.totalOpenKeys,
+ deletePendingSummarytotalUnrepSize: deletePendingResponse.data &&
deletePendingResponse.data.totalUnreplicatedDataSize,
+ deletePendingSummarytotalRepSize: deletePendingResponse.data &&
deletePendingResponse.data.totalReplicatedDataSize,
+ deletePendingSummarytotalDeletedKeys: deletePendingResponse.data &&
deletePendingResponse.data.totalDeletedKeys
});
})).catch(error => {
this.setState({
diff --git
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestOmDBInsightEndPoint.java
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestOmDBInsightEndPoint.java
index 8301537980..b8398b9336 100644
---
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestOmDBInsightEndPoint.java
+++
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestOmDBInsightEndPoint.java
@@ -292,25 +292,33 @@ public class TestOmDBInsightEndPoint extends
AbstractReconSqlDBTest {
// Call the API of Open keys to get the response
Response openKeyInfoResp =
- omdbInsightEndpoint.getOpenKeyInfo(-1, "", true, true);
- KeyInsightInfoResponse keyInsightInfoResp =
- (KeyInsightInfoResponse) openKeyInfoResp.getEntity();
- Assertions.assertNotNull(keyInsightInfoResp);
- Map<String, Long> summary = keyInsightInfoResp.getKeysSummary();
- Assertions.assertEquals(60L, summary.get("totalReplicatedDataSize"));
- Assertions.assertEquals(20L, summary.get("totalUnreplicatedDataSize"));
- Assertions.assertEquals(6L, summary.get("totalOpenKeys"));
+ omdbInsightEndpoint.getOpenKeySummary();
+ Assertions.assertNotNull(openKeyInfoResp);
+
+ Map<String, Long> openKeysSummary =
+ (Map<String, Long>) openKeyInfoResp.getEntity();
+
+ Assertions.assertEquals(60L,
+ openKeysSummary.get("totalReplicatedDataSize"));
+ Assertions.assertEquals(20L,
+ openKeysSummary.get("totalUnreplicatedDataSize"));
+ Assertions.assertEquals(6L,
+ openKeysSummary.get("totalOpenKeys"));
// Call the API of Deleted keys to get the response
Response deletedKeyInfoResp =
- omdbInsightEndpoint.getDeletedKeyInfo(-1, "");
- keyInsightInfoResp =
- (KeyInsightInfoResponse) deletedKeyInfoResp.getEntity();
- Assertions.assertNotNull(keyInsightInfoResp);
- summary = keyInsightInfoResp.getKeysSummary();
- Assertions.assertEquals(30L, summary.get("totalReplicatedDataSize"));
- Assertions.assertEquals(10L, summary.get("totalUnreplicatedDataSize"));
- Assertions.assertEquals(3L, summary.get("totalDeletedKeys"));
+ omdbInsightEndpoint.getDeletedKeySummary();
+ Assertions.assertNotNull(deletedKeyInfoResp);
+
+ Map<String, Long> deletedKeysSummary = (Map<String, Long>)
+ deletedKeyInfoResp.getEntity();
+
+ Assertions.assertEquals(30L,
+ deletedKeysSummary.get("totalReplicatedDataSize"));
+ Assertions.assertEquals(10L,
+ deletedKeysSummary.get("totalUnreplicatedDataSize"));
+ Assertions.assertEquals(3L,
+ deletedKeysSummary.get("totalDeletedKeys"));
}
private void insertGlobalStatsRecords(GlobalStatsDao statsDao,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]