Skip to content

Commit

Permalink
8751: No data source metrics for accounts, NFTs, or token rels
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Ananev <[email protected]>
  • Loading branch information
artemananiev committed Sep 20, 2023
1 parent e698740 commit c681cc5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,6 +66,9 @@ public class ServicesStatsManager {
private final EntityUtilGauges entityUtilGauges;
private final Supplier<VirtualMapLike<ContractKey, IterableContractValue>> storage;
private final Supplier<VirtualMapLike<VirtualBlobKey, VirtualBlobValue>> bytecode;
private final Supplier<AccountStorageAdapter> accounts;
private final Supplier<TokenRelStorageAdapter> tokenRels;
private final Supplier<UniqueTokenMapAdapter> uniqueTokens;

@Inject
public ServicesStatsManager(
Expand All @@ -70,9 +81,15 @@ public ServicesStatsManager(
final HapiOpSpeedometers opSpeedometers,
final NodeLocalProperties localProperties,
final Supplier<VirtualMapLike<ContractKey, IterableContractValue>> storage,
final Supplier<VirtualMapLike<VirtualBlobKey, VirtualBlobValue>> bytecode) {
final Supplier<VirtualMapLike<VirtualBlobKey, VirtualBlobValue>> bytecode,
final Supplier<AccountStorageAdapter> accounts,
final Supplier<TokenRelStorageAdapter> tokenRels,
final Supplier<UniqueTokenMapAdapter> 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;
Expand All @@ -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<EntityNumVirtualKey, OnDiskAccount> accountsOnDisk =
accounts.get().getOnDiskAccounts();
if (accountsOnDisk != null) {
accountsOnDisk.registerMetrics(platform.getContext().getMetrics());
}
final VirtualMapLike<EntityNumVirtualKey, OnDiskTokenRel> tokenRelsOnDisk =
tokenRels.get().getOnDiskRels();
if (tokenRelsOnDisk != null) {
tokenRelsOnDisk.registerMetrics(platform.getContext().getMetrics());
}
final VirtualMapLike<UniqueTokenKey, UniqueTokenValue> uniqueTokensOnDisk =
uniqueTokens.get().getOnDiskNfts();
if (uniqueTokensOnDisk != null) {
uniqueTokensOnDisk.registerMetrics(platform.getContext().getMetrics());
}

final var hapiOpsUpdateIntervalMs =
Math.max(MIN_STAT_INTERVAL_UPDATE_MS, localProperties.hapiOpsStatsUpdateIntervalMs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,6 +90,15 @@ class ServicesStatsManagerTest {
@Mock
private VirtualMap<VirtualBlobKey, VirtualBlobValue> bytecode;

@Mock
private VirtualMap<EntityNumVirtualKey, OnDiskAccount> accounts;

@Mock
private VirtualMap<EntityNumVirtualKey, OnDiskTokenRel> tokenRels;

@Mock
private VirtualMap<UniqueTokenKey, UniqueTokenValue> uniqueTokens;

@Mock
private ThrottleGauges throttleGauges;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c681cc5

Please sign in to comment.