[ https://issues.apache.org/jira/browse/GEODE-7846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17167708#comment-17167708 ]
ASF GitHub Bot commented on GEODE-7846: --------------------------------------- BenjaminPerryRoss commented on a change in pull request #5391: URL: https://github.com/apache/geode/pull/5391#discussion_r462642093 ########## File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearDUnitTest.java ########## @@ -330,6 +337,101 @@ public void normalClearFromAccessorWithoutWriterButWithWriterOnDataStore() { .isEqualTo(0); } + @Test + public void normalClearFromDataStoreUpdatesStats() { + configureServers(false, true); + client1.invoke(this::initClientCache); + client2.invoke(this::initClientCache); + + // Verify no clears have been recorded in stats + dataStore1.invoke(() -> { + PartitionedRegion region = (PartitionedRegion) getRegion(false); + + for (BucketRegion bucket : region.getDataStore().getAllLocalBucketRegions()) { + long clearCount = bucket.getCachePerfStats().getRegionClearCount(); + assertThat(clearCount).isEqualTo(0); + } + }); + + accessor.invoke(() -> feed(false)); + verifyServerRegionSize(NUM_ENTRIES); + dataStore1.invoke(() -> getRegion(false).clear()); + verifyServerRegionSize(0); + + // Verify the stats were properly updated for the bucket regions + dataStore1.invoke(() -> { + PartitionedRegion region = (PartitionedRegion) getRegion(false); + long clearCount = 0L; Review comment: Done. ########## File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearDUnitTest.java ########## @@ -330,6 +337,101 @@ public void normalClearFromAccessorWithoutWriterButWithWriterOnDataStore() { .isEqualTo(0); } + @Test + public void normalClearFromDataStoreUpdatesStats() { + configureServers(false, true); + client1.invoke(this::initClientCache); + client2.invoke(this::initClientCache); + + // Verify no clears have been recorded in stats + dataStore1.invoke(() -> { + PartitionedRegion region = (PartitionedRegion) getRegion(false); + + for (BucketRegion bucket : region.getDataStore().getAllLocalBucketRegions()) { + long clearCount = bucket.getCachePerfStats().getRegionClearCount(); + assertThat(clearCount).isEqualTo(0); + } + }); + + accessor.invoke(() -> feed(false)); + verifyServerRegionSize(NUM_ENTRIES); + dataStore1.invoke(() -> getRegion(false).clear()); + verifyServerRegionSize(0); + + // Verify the stats were properly updated for the bucket regions + dataStore1.invoke(() -> { + PartitionedRegion region = (PartitionedRegion) getRegion(false); + long clearCount = 0L; + + for (BucketRegion bucket : region.getDataStore().getAllLocalBucketRegions()) { + if (clearCount == 0) { + clearCount = bucket.getCachePerfStats().getBucketClearCount(); + } + assertThat(bucket.getCachePerfStats().getBucketClearCount()).isEqualTo(clearCount) + .isNotEqualTo(0); + } + + assertThat(region.getCachePerfStats().getRegionClearCount()).isEqualTo(1); + assertThat(region.getCachePerfStats().getPartitionedRegionClearDuration()).isGreaterThan(0); + }); + + dataStore2.invoke(() -> { + PartitionedRegion region = (PartitionedRegion) getRegion(false); + long clearCount = 0L; + + for (BucketRegion bucket : region.getDataStore().getAllLocalBucketRegions()) { + if (clearCount == 0) { + clearCount = bucket.getCachePerfStats().getBucketClearCount(); + } + assertThat(bucket.getCachePerfStats().getBucketClearCount()).isEqualTo(clearCount) + .isNotEqualTo(0); + } + + assertThat(region.getCachePerfStats().getRegionClearCount()).isEqualTo(1); + }); + + dataStore3.invoke(() -> { + PartitionedRegion region = (PartitionedRegion) getRegion(false); + long clearCount = 0L; + + for (BucketRegion bucket : region.getDataStore().getAllLocalBucketRegions()) { + if (clearCount == 0) { + clearCount = bucket.getCachePerfStats().getBucketClearCount(); + } + assertThat(bucket.getCachePerfStats().getBucketClearCount()).isEqualTo(clearCount) + .isNotEqualTo(0); + } + + assertThat(region.getCachePerfStats().getRegionClearCount()).isEqualTo(1); + }); + + + // The accessor shouldn't increment the region clear count + accessor.invoke(() -> { + PartitionedRegion region = (PartitionedRegion) getRegion(false); + assertThat(region.getCachePerfStats().getRegionClearCount()).isEqualTo(0); + }); + + // do the region destroy to compare that the same callbacks will be triggered + dataStore1.invoke(() -> { + Region region = getRegion(false); + region.destroyRegion(); + }); + + assertThat(dataStore1.invoke(getWriterDestroys)).isEqualTo(dataStore1.invoke(getWriterClears)) + .isEqualTo(0); + assertThat(dataStore2.invoke(getWriterDestroys)).isEqualTo(dataStore2.invoke(getWriterClears)) + .isEqualTo(0); + assertThat(dataStore3.invoke(getWriterDestroys)).isEqualTo(dataStore3.invoke(getWriterClears)) + .isEqualTo(0); + assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(accessor.invoke(getWriterClears)) + .isEqualTo(1); + + assertThat(accessor.invoke(getBucketRegionWriterDestroys)) + .isEqualTo(accessor.invoke(getBucketRegionWriterClears)) + .isEqualTo(0); Review comment: Done. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Clear in Partitioned Region should have its own stats > ----------------------------------------------------- > > Key: GEODE-7846 > URL: https://issues.apache.org/jira/browse/GEODE-7846 > Project: Geode > Issue Type: Improvement > Components: core > Reporter: Xiaojian Zhou > Priority: Major > Labels: GeodeCommons, GeodeOperationAPI, pull-request-available > > Clear operation in PR should have its own stats: > 1) clear operation executed. > 2) clear operation failed > 3) clear messages sends to buckets -- This message was sent by Atlassian Jira (v8.3.4#803005)