From c681cc51e63b420a8d90952708dc8003df538f55 Mon Sep 17 00:00:00 2001 From: Artem Ananev Date: Tue, 19 Sep 2023 18:33:55 -0700 Subject: [PATCH] 8751: No data source metrics for accounts, NFTs, or token rels Signed-off-by: Artem Ananev --- .../app/service/mono/state/StateModule.java | 2 ++ .../mono/stats/ServicesStatsManager.java | 34 ++++++++++++++++++- .../mono/stats/ServicesStatsManagerTest.java | 23 ++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/state/StateModule.java b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/state/StateModule.java index 29cb4ef7edf3..691ae0bbb93a 100644 --- a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/state/StateModule.java +++ b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/state/StateModule.java @@ -63,10 +63,12 @@ import com.hedera.node.app.service.mono.state.validation.BasedLedgerValidator; import com.hedera.node.app.service.mono.state.validation.LedgerValidator; import com.hedera.node.app.service.mono.state.virtual.ContractKey; +import com.hedera.node.app.service.mono.state.virtual.EntityNumVirtualKey; import com.hedera.node.app.service.mono.state.virtual.IterableContractValue; import com.hedera.node.app.service.mono.state.virtual.VirtualBlobKey; import com.hedera.node.app.service.mono.state.virtual.VirtualBlobValue; import com.hedera.node.app.service.mono.state.virtual.VirtualMapFactory; +import com.hedera.node.app.service.mono.state.virtual.entities.OnDiskAccount; import com.hedera.node.app.service.mono.store.schedule.ScheduleStore; import com.hedera.node.app.service.mono.stream.RecordStreamManager; import com.hedera.node.app.service.mono.stream.RecordsRunningHashLeaf; diff --git a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/stats/ServicesStatsManager.java b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/stats/ServicesStatsManager.java index 390e5fa0c107..e63ceddc1a61 100644 --- a/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/stats/ServicesStatsManager.java +++ b/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/stats/ServicesStatsManager.java @@ -20,10 +20,18 @@ import com.hedera.node.app.service.mono.context.properties.NodeLocalProperties; import com.hedera.node.app.service.mono.state.adapters.VirtualMapLike; +import com.hedera.node.app.service.mono.state.migration.AccountStorageAdapter; +import com.hedera.node.app.service.mono.state.migration.TokenRelStorageAdapter; +import com.hedera.node.app.service.mono.state.migration.UniqueTokenMapAdapter; import com.hedera.node.app.service.mono.state.virtual.ContractKey; +import com.hedera.node.app.service.mono.state.virtual.EntityNumVirtualKey; import com.hedera.node.app.service.mono.state.virtual.IterableContractValue; +import com.hedera.node.app.service.mono.state.virtual.UniqueTokenKey; +import com.hedera.node.app.service.mono.state.virtual.UniqueTokenValue; import com.hedera.node.app.service.mono.state.virtual.VirtualBlobKey; import com.hedera.node.app.service.mono.state.virtual.VirtualBlobValue; +import com.hedera.node.app.service.mono.state.virtual.entities.OnDiskAccount; +import com.hedera.node.app.service.mono.state.virtual.entities.OnDiskTokenRel; import com.hedera.node.app.service.mono.utils.Pause; import com.swirlds.common.system.Platform; import java.util.concurrent.atomic.AtomicLong; @@ -58,6 +66,9 @@ public class ServicesStatsManager { private final EntityUtilGauges entityUtilGauges; private final Supplier> storage; private final Supplier> bytecode; + private final Supplier accounts; + private final Supplier tokenRels; + private final Supplier uniqueTokens; @Inject public ServicesStatsManager( @@ -70,9 +81,15 @@ public ServicesStatsManager( final HapiOpSpeedometers opSpeedometers, final NodeLocalProperties localProperties, final Supplier> storage, - final Supplier> bytecode) { + final Supplier> bytecode, + final Supplier accounts, + final Supplier tokenRels, + final Supplier uniqueTokens) { this.storage = storage; this.bytecode = bytecode; + this.accounts = accounts; + this.tokenRels = tokenRels; + this.uniqueTokens = uniqueTokens; this.localProperties = localProperties; this.expiryStats = expiryStats; this.opCounters = opCounters; @@ -93,6 +110,21 @@ public void initializeFor(final Platform platform) { entityUtilGauges.registerWith(platform); storage.get().registerMetrics(platform.getContext().getMetrics()); bytecode.get().registerMetrics(platform.getContext().getMetrics()); + final VirtualMapLike accountsOnDisk = + accounts.get().getOnDiskAccounts(); + if (accountsOnDisk != null) { + accountsOnDisk.registerMetrics(platform.getContext().getMetrics()); + } + final VirtualMapLike tokenRelsOnDisk = + tokenRels.get().getOnDiskRels(); + if (tokenRelsOnDisk != null) { + tokenRelsOnDisk.registerMetrics(platform.getContext().getMetrics()); + } + final VirtualMapLike uniqueTokensOnDisk = + uniqueTokens.get().getOnDiskNfts(); + if (uniqueTokensOnDisk != null) { + uniqueTokensOnDisk.registerMetrics(platform.getContext().getMetrics()); + } final var hapiOpsUpdateIntervalMs = Math.max(MIN_STAT_INTERVAL_UPDATE_MS, localProperties.hapiOpsStatsUpdateIntervalMs()); diff --git a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/stats/ServicesStatsManagerTest.java b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/stats/ServicesStatsManagerTest.java index a992de1aafc2..543597187a35 100644 --- a/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/stats/ServicesStatsManagerTest.java +++ b/hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/stats/ServicesStatsManagerTest.java @@ -25,10 +25,19 @@ import com.hedera.node.app.service.mono.context.properties.NodeLocalProperties; import com.hedera.node.app.service.mono.state.adapters.VirtualMapLike; +import com.hedera.node.app.service.mono.state.migration.AccountStorageAdapter; +import com.hedera.node.app.service.mono.state.migration.TokenRelStorageAdapter; +import com.hedera.node.app.service.mono.state.migration.UniqueTokenAdapter; +import com.hedera.node.app.service.mono.state.migration.UniqueTokenMapAdapter; import com.hedera.node.app.service.mono.state.virtual.ContractKey; +import com.hedera.node.app.service.mono.state.virtual.EntityNumVirtualKey; import com.hedera.node.app.service.mono.state.virtual.IterableContractValue; +import com.hedera.node.app.service.mono.state.virtual.UniqueTokenKey; +import com.hedera.node.app.service.mono.state.virtual.UniqueTokenValue; import com.hedera.node.app.service.mono.state.virtual.VirtualBlobKey; import com.hedera.node.app.service.mono.state.virtual.VirtualBlobValue; +import com.hedera.node.app.service.mono.state.virtual.entities.OnDiskAccount; +import com.hedera.node.app.service.mono.state.virtual.entities.OnDiskTokenRel; import com.hedera.node.app.service.mono.utils.Pause; import com.hedera.node.app.service.mono.utils.SleepingPause; import com.swirlds.common.context.PlatformContext; @@ -81,6 +90,15 @@ class ServicesStatsManagerTest { @Mock private VirtualMap bytecode; + @Mock + private VirtualMap accounts; + + @Mock + private VirtualMap tokenRels; + + @Mock + private VirtualMap uniqueTokens; + @Mock private ThrottleGauges throttleGauges; @@ -112,7 +130,10 @@ void setup() { speedometers, properties, () -> VirtualMapLike.from(storage), - () -> VirtualMapLike.from(bytecode)); + () -> VirtualMapLike.from(bytecode), + () -> AccountStorageAdapter.fromOnDisk(VirtualMapLike.from(accounts)), + () -> TokenRelStorageAdapter.fromOnDisk(VirtualMapLike.from(tokenRels)), + () -> UniqueTokenMapAdapter.wrap(VirtualMapLike.from(uniqueTokens))); } @AfterEach