This is an automated email from the ASF dual-hosted git repository.
ivandika 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 68ec901cde HDDS-10975. Recon Show SCM and OM services IDs in overview
page (#6769)
68ec901cde is described below
commit 68ec901cdee7a8f26b59b0fb21268173bdbff61f
Author: Slava Tutrinov <[email protected]>
AuthorDate: Sun Jun 9 09:14:39 2024 +0300
HDDS-10975. Recon Show SCM and OM services IDs in overview page (#6769)
---
.../ozone/recon/api/ClusterStateEndpoint.java | 13 ++++++++--
.../recon/api/types/ClusterStateResponse.java | 29 ++++++++++++++++++++++
.../webapps/recon/ozone-recon-web/api/db.json | 4 ++-
.../src/components/overviewCard/overviewCard.tsx | 5 ++++
.../src/views/overview/overview.tsx | 23 ++++++++++++++---
...teCounts.java => TestClusterStateEndpoint.java} | 28 ++++++++++++++++++---
.../hadoop/ozone/recon/api/TestEndpoints.java | 2 +-
7 files changed, 94 insertions(+), 10 deletions(-)
diff --git
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
index b074e5ba56..c3c4b3c18b 100644
---
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
+++
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.ozone.recon.api;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeStat;
@@ -46,6 +47,8 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
+import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_SERVICE_IDS_KEY;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY;
import static
org.apache.hadoop.ozone.om.OmMetadataManagerImpl.DELETED_DIR_TABLE;
import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.BUCKET_TABLE;
import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.DELETED_TABLE;
@@ -68,14 +71,17 @@ public class ClusterStateEndpoint {
private ReconPipelineManager pipelineManager;
private ReconContainerManager containerManager;
private GlobalStatsDao globalStatsDao;
-
+ private OzoneConfiguration ozoneConfiguration;
private final ContainerHealthSchemaManager containerHealthSchemaManager;
+
+
@Inject
ClusterStateEndpoint(OzoneStorageContainerManager reconSCM,
GlobalStatsDao globalStatsDao,
ContainerHealthSchemaManager
- containerHealthSchemaManager) {
+ containerHealthSchemaManager,
+ OzoneConfiguration ozoneConfiguration) {
this.nodeManager =
(ReconNodeManager) reconSCM.getScmNodeManager();
this.pipelineManager = (ReconPipelineManager)
reconSCM.getPipelineManager();
@@ -83,6 +89,7 @@ public class ClusterStateEndpoint {
(ReconContainerManager) reconSCM.getContainerManager();
this.globalStatsDao = globalStatsDao;
this.containerHealthSchemaManager = containerHealthSchemaManager;
+ this.ozoneConfiguration = ozoneConfiguration;
}
/**
@@ -182,6 +189,8 @@ public class ClusterStateEndpoint {
.setHealthyDatanodes(healthyDatanodes)
.setOpenContainers(containerStateCounts.getOpenContainersCount())
.setDeletedContainers(containerStateCounts.getDeletedContainersCount())
+ .setScmServiceId(ozoneConfiguration.get(OZONE_SCM_SERVICE_IDS_KEY))
+ .setOmServiceId(ozoneConfiguration.get(OZONE_OM_SERVICE_IDS_KEY))
.build();
return Response.ok(response).build();
}
diff --git
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ClusterStateResponse.java
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ClusterStateResponse.java
index 0560bb7ccc..6e595891c4 100644
---
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ClusterStateResponse.java
+++
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ClusterStateResponse.java
@@ -102,6 +102,12 @@ public final class ClusterStateResponse {
@JsonProperty
private long deletedDirs;
+ @JsonProperty("scmServiceId")
+ private String scmServiceId;
+
+ @JsonProperty("omServiceId")
+ private String omServiceId;
+
/**
* Returns new builder class that builds a ClusterStateResponse.
*
@@ -125,6 +131,8 @@ public final class ClusterStateResponse {
this.keysPendingDeletion = b.keysPendingDeletion;
this.deletedDirs = b.deletedDirs;
this.deletedContainers = b.deletedContainers;
+ this.scmServiceId = b.scmServiceId;
+ this.omServiceId = b.omServiceId;
}
/**
@@ -145,6 +153,8 @@ public final class ClusterStateResponse {
private long keys;
private long keysPendingDeletion;
private long deletedDirs;
+ private String scmServiceId;
+ private String omServiceId;
public Builder() {
// Default values
@@ -225,6 +235,16 @@ public final class ClusterStateResponse {
return this;
}
+ public Builder setScmServiceId(String scmServiceId) {
+ this.scmServiceId = scmServiceId;
+ return this;
+ }
+
+ public Builder setOmServiceId(String omServiceId) {
+ this.omServiceId = omServiceId;
+ return this;
+ }
+
public ClusterStateResponse build() {
Preconditions.checkNotNull(this.storageReport);
@@ -283,4 +303,13 @@ public final class ClusterStateResponse {
public long getDeletedDirs() {
return deletedDirs;
}
+
+ public String getScmServiceId() {
+ return scmServiceId;
+ }
+
+ public String getOmServiceId() {
+ return omServiceId;
+ }
+
}
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
index 79ff9f8e7c..b535746b46 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
@@ -15,7 +15,9 @@
"volumes": 5,
"buckets": 156,
"keys": 253000,
- "keysPendingDeletion": 1000
+ "keysPendingDeletion": 1000,
+ "scmServiceId": "scmservice",
+ "omServiceId": "omservice"
},
"datanodes": {
"totalCount": 12,
diff --git
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/components/overviewCard/overviewCard.tsx
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/components/overviewCard/overviewCard.tsx
index c6fdb0a257..8227fa1167 100644
---
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/components/overviewCard/overviewCard.tsx
+++
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/components/overviewCard/overviewCard.tsx
@@ -62,6 +62,11 @@ class OverviewCardWrapper extends
React.Component<IOverviewCardWrapperProps> {
active: '3'
}
}
+ else if (title === "OM Service") {
+ return {
+ active: '4'
+ }
+ }
};
render() {
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 a5faa034ec..cd097d89a2 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
@@ -44,6 +44,8 @@ interface IClusterStateResponse {
openContainers: number;
deletedContainers: number;
keysPendingDeletion: number;
+ scmServiceId: string;
+ omServiceId: string;
}
interface IOverviewState {
@@ -68,6 +70,8 @@ interface IOverviewState {
deletePendingSummarytotalUnrepSize: number,
deletePendingSummarytotalRepSize: number,
deletePendingSummarytotalDeletedKeys: number,
+ scmServiceId: string;
+ omServiceId: string;
}
let cancelOverviewSignal: AbortController;
@@ -156,7 +160,9 @@ export class Overview extends
React.Component<Record<string, object>, IOverviewS
openSummarytotalOpenKeys: openResponse.data &&
openResponse.data.totalOpenKeys,
deletePendingSummarytotalUnrepSize: deletePendingResponse.data &&
deletePendingResponse.data.totalUnreplicatedDataSize,
deletePendingSummarytotalRepSize: deletePendingResponse.data &&
deletePendingResponse.data.totalReplicatedDataSize,
- deletePendingSummarytotalDeletedKeys: deletePendingResponse.data &&
deletePendingResponse.data.totalDeletedKeys
+ deletePendingSummarytotalDeletedKeys: deletePendingResponse.data &&
deletePendingResponse.data.totalDeletedKeys,
+ scmServiceId: clusterState.scmServiceId,
+ omServiceId: clusterState.omServiceId
});
})).catch(error => {
this.setState({
@@ -209,7 +215,8 @@ export class Overview extends
React.Component<Record<string, object>, IOverviewS
render() {
const {loading, datanodes, pipelines, storageReport, containers, volumes,
buckets, openSummarytotalUnrepSize, openSummarytotalRepSize,
openSummarytotalOpenKeys,
deletePendingSummarytotalUnrepSize,deletePendingSummarytotalRepSize,deletePendingSummarytotalDeletedKeys,
- keys, missingContainersCount, lastRefreshed, lastUpdatedOMDBDelta,
lastUpdatedOMDBFull, omStatus, openContainers, deletedContainers } = this.state;
+ keys, missingContainersCount, lastRefreshed, lastUpdatedOMDBDelta,
lastUpdatedOMDBFull,
+ omStatus, openContainers, deletedContainers, scmServiceId, omServiceId }
= this.state;
const datanodesElement = (
<span>
@@ -229,7 +236,7 @@ export class Overview extends
React.Component<Record<string, object>, IOverviewS
{deletePendingSummarytotalUnrepSize!== undefined ?
byteToSize(deletePendingSummarytotalUnrepSize,1): '0'} <span
className='ant-card-meta-description meta'>Total UnReplicated Data
Size</span><br />
{deletePendingSummarytotalDeletedKeys !== undefined ?
deletePendingSummarytotalDeletedKeys: '0'} <span
className='ant-card-meta-description meta'>Total Pending Delete Keys</span>
</div>
- );
+ );
const containersTooltip = missingContainersCount === 1 ? 'container is
missing' : 'containers are missing';
const containersLink = missingContainersCount > 0 ? '/MissingContainers' :
'/Containers';
const volumesLink = '/Volumes';
@@ -302,6 +309,16 @@ export class Overview extends
React.Component<Record<string, object>, IOverviewS
<Col xs={24} sm={18} md={12} lg={12} xl={6} className='summary-font'>
<OverviewCard loading={loading} title='Pending Deleted Keys
Summary' data={deletePendingSummaryData} icon='delete' linkToUrl='/Om'/>
</Col>
+ {scmServiceId &&
+ <Col xs={24} sm={18} md={12} lg={12} xl={6}>
+ <OverviewCard title="SCM Service" loading={loading}
data={scmServiceId} icon='file-text'/>
+ </Col>
+ }
+ {omServiceId &&
+ <Col xs={24} sm={18} md={12} lg={12} xl={6}>
+ <OverviewCard title="OM Service" loading={loading}
data={omServiceId} icon='file-text' linkToUrl='/Om' />
+ </Col>
+ }
</Row>
</div>
);
diff --git
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestContainerStateCounts.java
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestClusterStateEndpoint.java
similarity index 87%
rename from
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestContainerStateCounts.java
rename to
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestClusterStateEndpoint.java
index 08d1a73dc0..1b233c02b6 100644
---
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestContainerStateCounts.java
+++
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestClusterStateEndpoint.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.ozone.recon.api;
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import
org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline;
import org.apache.hadoop.hdds.scm.container.ContainerInfo;
@@ -48,16 +49,20 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.TimeoutException;
+import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_SERVICE_IDS_KEY;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY;
import static
org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.getRandomPipeline;
import static
org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.getTestReconOmMetadataManager;
import static
org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.initializeNewOmMetadataManager;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
/**
* Unit test for ClusterStateEndpoint ContainerStateCounts.
*/
-public class TestContainerStateCounts extends AbstractReconSqlDBTest {
+public class TestClusterStateEndpoint extends AbstractReconSqlDBTest {
@TempDir
private Path temporaryFolder;
private OzoneStorageContainerManager ozoneStorageContainerManager;
@@ -68,13 +73,14 @@ public class TestContainerStateCounts extends
AbstractReconSqlDBTest {
private ReconOMMetadataManager reconOMMetadataManager;
private Pipeline pipeline;
private PipelineID pipelineID;
+ private OzoneConfiguration conf;
private long keyCount = 5L;
private int count = 0;
private static final int NUM_OPEN_CONTAINERS = 3;
private static final int NUM_DELETED_CONTAINERS = 4;
private static final int NUM_CLOSED_CONTAINERS = 3;
- public TestContainerStateCounts() {
+ public TestClusterStateEndpoint() {
super();
}
@@ -109,9 +115,10 @@ public class TestContainerStateCounts extends
AbstractReconSqlDBTest {
containerHealthSchemaManager =
reconTestInjector.getInstance(ContainerHealthSchemaManager.class);
GlobalStatsDao globalStatsDao = getDao(GlobalStatsDao.class);
+ conf = mock(OzoneConfiguration.class);
clusterStateEndpoint =
new ClusterStateEndpoint(ozoneStorageContainerManager, globalStatsDao,
- containerHealthSchemaManager);
+ containerHealthSchemaManager, conf);
pipeline = getRandomPipeline();
pipelineID = pipeline.getId();
reconPipelineManager.addPipeline(pipeline);
@@ -143,6 +150,21 @@ public class TestContainerStateCounts extends
AbstractReconSqlDBTest {
assertEquals(expectedDeletedContainers,
clusterStateResponse1.getDeletedContainers());
}
+ @Test
+ public void testScmAndOmServiceId() {
+ // given
+ when(conf.get(eq(OZONE_SCM_SERVICE_IDS_KEY))).thenReturn("scmServiceId");
+ when(conf.get(eq(OZONE_OM_SERVICE_IDS_KEY))).thenReturn("omServiceId");
+
+ // when
+ Response clusterState = clusterStateEndpoint.getClusterState();
+
+ // then
+ ClusterStateResponse clusterStateResponse = (ClusterStateResponse)
clusterState.getEntity();
+ assertEquals("scmServiceId", clusterStateResponse.getScmServiceId());
+ assertEquals("omServiceId", clusterStateResponse.getOmServiceId());
+ }
+
ContainerInfo newContainerInfo(long containerId,
HddsProtos.LifeCycleState state) {
diff --git
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
index 2c3439cd19..e549a02e98 100644
---
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
+++
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
@@ -319,7 +319,7 @@ public class TestEndpoints extends AbstractReconSqlDBTest {
reconTestInjector.getInstance(ContainerHealthSchemaManager.class);
clusterStateEndpoint =
new ClusterStateEndpoint(reconScm, globalStatsDao,
- containerHealthSchemaManager);
+ containerHealthSchemaManager, mock(OzoneConfiguration.class));
containerSizeCountTask = reconScm.getContainerSizeCountTask();
MetricsServiceProviderFactory metricsServiceProviderFactory =
reconTestInjector.getInstance(MetricsServiceProviderFactory.class);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]