Skip to content

Commit

Permalink
GEODE-6334: Change cache operation stats to longs (apache#3142)
Browse files Browse the repository at this point in the history
* Change cache operation stats to longs
* Use long instead of int for CqQueryOptimized Tests
* Clean up easy parts of CqQueryOptimized Tests
* Fix usages of CachePerfStats from ints to longs
* Add CacheStatistics integration test
* Remove cachePerfStats.getPuts() testing in backwards compatibility
DUnit test because it was trying to test old versions when this is all internal
* Update sanctioned data serializables

Co-authored-by: Michael Oleske <[email protected]>
Co-authored-by: Galen O'Sullivan <[email protected]>
Co-authored-by: Kirk Lund <[email protected]>
  • Loading branch information
4 people committed Feb 11, 2019
1 parent 83fc3e2 commit 2be43b2
Show file tree
Hide file tree
Showing 22 changed files with 594 additions and 685 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ public void run() {
public void run() {
CCRegion.put(invalidationKey, "initialValue");

int invalidationCount = CCRegion.getCachePerfStats().getInvalidates();
long invalidationCount = CCRegion.getCachePerfStats().getInvalidates();
CCRegion.invalidate(invalidationKey);
CCRegion.invalidate(invalidationKey);
assertEquals(invalidationCount + 1, CCRegion.getCachePerfStats().getInvalidates());

// also test destroy() while we're at it. It should throw an exception
int destroyCount = CCRegion.getCachePerfStats().getDestroys();
long destroyCount = CCRegion.getCachePerfStats().getDestroys();
CCRegion.destroy(invalidationKey);
try {
CCRegion.destroy(invalidationKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ public void run() {
cache.getLogger().info("Delta contains: " + size + " keys");
assertEquals(expectedKeyNum, size);

int num = stats.getDeltaGetInitialImagesCompleted();
long num = stats.getDeltaGetInitialImagesCompleted();
cache.getLogger().info("Delta GII completed: " + num + " times");
assertEquals(expectedDeltaGIINum, num);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ public void testSimpleOps() throws CacheException {
cmtre.setUserAttribute("uaValue1");
assertEquals("uaValue1", cmtre.getUserAttribute());

int txRollbackChanges = stats.getTxRollbackChanges();
int txCommitChanges = stats.getTxCommitChanges();
int txFailureChanges = stats.getTxFailureChanges();
long txRollbackChanges = stats.getTxRollbackChanges();
long txCommitChanges = stats.getTxCommitChanges();
long txFailureChanges = stats.getTxFailureChanges();
this.txMgr.begin();
Region.Entry txre = this.region.getEntry("uaKey");
assertEquals(this.region, txre.getRegion());
Expand Down Expand Up @@ -299,9 +299,9 @@ public void testSimpleOps() throws CacheException {
}

{
int txRollbackChanges = stats.getTxRollbackChanges();
int txCommitChanges = stats.getTxCommitChanges();
int txFailureChanges = stats.getTxFailureChanges();
long txRollbackChanges = stats.getTxRollbackChanges();
long txCommitChanges = stats.getTxCommitChanges();
long txFailureChanges = stats.getTxFailureChanges();
this.region.create("key1", "value1");
this.txMgr.begin();
this.region.invalidate("key1");
Expand Down Expand Up @@ -432,7 +432,7 @@ public void testWriteOps() throws CacheException {
@Test
public void testTwoRegionTxs() throws CacheException {
final CachePerfStats stats = this.cache.getCachePerfStats();
int txCommitChanges;
long txCommitChanges;
TransactionId myTxId;

AttributesFactory<String, String> attributesFactory = new AttributesFactory<>();
Expand Down Expand Up @@ -2739,7 +2739,7 @@ public int getBeforeDestroyCalls(boolean fetchLocal) {
}

private void doNonTxInvalidateRegionOp(CachePerfStats stats) throws Exception {
int txRollbackChanges = stats.getTxRollbackChanges();
long txRollbackChanges = stats.getTxRollbackChanges();
this.region.create("key1", "value1");
this.region.create("key2", "value2");
this.txMgr.begin();
Expand Down Expand Up @@ -2771,7 +2771,7 @@ private void doNonTxInvalidateRegionOp(CachePerfStats stats) throws Exception {
}

private void doNonTxDestroyRegionOp(CachePerfStats stats) throws Exception {
int txRollbackChanges = stats.getTxRollbackChanges();
long txRollbackChanges = stats.getTxRollbackChanges();
this.region.put("key1", "value1");
this.region.put("key2", "value2");
this.txMgr.begin();
Expand Down Expand Up @@ -4627,15 +4627,15 @@ class statsValidator {
private long txSuccessLifeTime;
private long txFailedLifeTime;
private long txRollbackLifeTime;
private int txCommits;
private int txFailures;
private int txRollbacks;
private long txCommits;
private long txFailures;
private long txRollbacks;
private long txCommitTime;
private long txFailureTime;
private long txRollbackTime;
private int txCommitChanges;
private int txFailureChanges;
private int txRollbackChanges;
private long txCommitChanges;
private long txFailureChanges;
private long txRollbackChanges;

private CachePerfStats stats;

Expand Down Expand Up @@ -4670,15 +4670,15 @@ private void setTxRollbackLifeTime(long txRollbackLifeTime) {
this.txRollbackLifeTime = txRollbackLifeTime;
}

private void setTxCommits(int txCommits) {
private void setTxCommits(long txCommits) {
this.txCommits = txCommits;
}

private void setTxFailures(int txFailures) {
private void setTxFailures(long txFailures) {
this.txFailures = txFailures;
}

private void setTxRollbacks(int txRollbacks) {
private void setTxRollbacks(long txRollbacks) {
this.txRollbacks = txRollbacks;
}

Expand All @@ -4694,15 +4694,15 @@ private void setTxRollbackTime(long txRollbackTime) {
this.txRollbackTime = txRollbackTime;
}

private void setTxCommitChanges(int txCommitChanges) {
private void setTxCommitChanges(long txCommitChanges) {
this.txCommitChanges = txCommitChanges;
}

private void setTxFailureChanges(int txFailureChanges) {
private void setTxFailureChanges(long txFailureChanges) {
this.txFailureChanges = txFailureChanges;
}

private void setTxRollbackChanges(int txRollbackChanges) {
private void setTxRollbackChanges(long txRollbackChanges) {
this.txRollbackChanges = txRollbackChanges;
}

Expand Down Expand Up @@ -4831,10 +4831,10 @@ private void assertValid() {
public void testCacheStats() throws CacheException {
CachePerfStats cacheStats = this.cache.getCachePerfStats();
// quick sanity check to make sure perf stats work non-tx
int creates;
int destroys;
int puts;
int invalidates;
long creates;
long destroys;
long puts;
long invalidates;

creates = cacheStats.getCreates();
destroys = cacheStats.getDestroys();
Expand Down Expand Up @@ -5778,7 +5778,7 @@ public void afterRollback(TransactionEvent event) {

{ // distributed invalidate
// first make sure invalidate is counted as a change
int txRollbackChanges = stats.getTxRollbackChanges();
long txRollbackChanges = stats.getTxRollbackChanges();
this.region.create("key1", "value1");
this.txMgr.begin();
this.region.invalidate("key1");
Expand Down Expand Up @@ -5837,7 +5837,7 @@ public void afterRollback(TransactionEvent event) {

{ // local invalidate
// first make sure invalidate is counted as a change
int txRollbackChanges = stats.getTxRollbackChanges();
long txRollbackChanges = stats.getTxRollbackChanges();
this.region.create("key1", "value1");
this.txMgr.begin();
this.region.localInvalidate("key1");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.apache.geode.cache;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import org.apache.geode.internal.cache.GemFireCacheImpl;

public class CacheStatisticsTest {

@Test
public void whenRegionPuts_increasesStatisticsPutCounter() {
CacheFactory cacheFactory = new CacheFactory();
Region<String, String> region =
cacheFactory.create().<String, String>createRegionFactory(RegionShortcut.PARTITION)
.create("region");


GemFireCacheImpl regionService = (GemFireCacheImpl) region.getRegionService();
long oldPuts = regionService.getCachePerfStats().getPuts();

region.put("some", "value");

long newPuts = regionService.getCachePerfStats().getPuts();

assertEquals(oldPuts + 1, newPuts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,11 @@ public void testRegionMethods() throws Exception {
ExpectedEntryEvent expee = new ExpectedEntryEvent();
expee.r = r;
expee.key = "key";
int creates = getStats().getCreates();
// int puts = getStats().getPuts();
// int updates = getStats().getUpdates();
int destroys = getStats().getDestroys();
int invalidates = getStats().getInvalidates();
int gets = getStats().getGets();
int misses = getStats().getMisses();
long creates = getStats().getCreates();
long destroys = getStats().getDestroys();
long invalidates = getStats().getInvalidates();
long gets = getStats().getGets();
long misses = getStats().getMisses();

r.put("key", "value", cbArg);
expee.op = Operation.CREATE;
Expand Down Expand Up @@ -836,13 +834,10 @@ public void testMapMethods() throws Exception {
checkNoCW();
checkCL(expre);

int creates = getStats().getCreates();
// int puts = getStats().getPuts();
// int updates = getStats().getUpdates();
int destroys = getStats().getDestroys();
// int invalidates = getStats().getInvalidates();
int gets = getStats().getGets();
int misses = getStats().getMisses();
long creates = getStats().getCreates();
long destroys = getStats().getDestroys();
long gets = getStats().getGets();
long misses = getStats().getMisses();
ExpectedEntryEvent expee = new ExpectedEntryEvent();
expee.r = r;
expee.key = "key";
Expand Down Expand Up @@ -928,13 +923,9 @@ public void testAllMethodsWithTX() throws Exception {
checkNoTL();
checkCL(expre);

int creates = getStats().getCreates();
// int puts = getStats().getPuts();
// int updates = getStats().getUpdates();
int destroys = getStats().getDestroys();
int invalidates = getStats().getInvalidates();
// int gets = getStats().getGets();
// int misses = getStats().getMisses();
long creates = getStats().getCreates();
long destroys = getStats().getDestroys();
long invalidates = getStats().getInvalidates();
ExpectedEntryEvent expee = new ExpectedEntryEvent();
expee.r = r;
expee.key = "key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void test001Destroy() throws Exception {

for (int num = 0; num < 3; num++) {
pr.put(new Integer(num), val);
final int initialDestroyCount = getDestroyCount(pr);
final long initialDestroyCount = getDestroyCount(pr);
pr.destroy(new Integer(num));
assertEquals(initialDestroyCount + 1, getDestroyCount(pr));
}
Expand Down Expand Up @@ -228,12 +228,12 @@ public void test001Destroy() throws Exception {
}
}

private int getDestroyCount(PartitionedRegion pr) {
return ((GemFireCacheImpl) pr.getCache()).getCachePerfStats().getDestroys();
private long getDestroyCount(PartitionedRegion pr) {
return pr.getCache().getCachePerfStats().getDestroys();
}

private int getCreateCount(PartitionedRegion pr) {
return ((GemFireCacheImpl) pr.getCache()).getCachePerfStats().getCreates();
private long getCreateCount(PartitionedRegion pr) {
return pr.getCache().getCachePerfStats().getCreates();
}

/**
Expand Down Expand Up @@ -1075,7 +1075,7 @@ public void test019Create() throws EntryExistsException {
final String expectedExceptions = EntryExistsException.class.getName();
for (int num = 0; num < 3; num++) {
key++;
final int initialCreates = getCreateCount(pr);
final long initialCreates = getCreateCount(pr);
pr.create(new Integer(key), val + num);
assertEquals(initialCreates + 1, getCreateCount(pr));
final Object getObj1 = pr.get(new Integer(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private long getNetLoadsAverageLatency() {
return bridge.getNetLoadsAverageLatency();
}

private int getTotalNetSearchCompleted() {
private long getTotalNetSearchCompleted() {
return bridge.getTotalNetSearchCompleted();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,13 @@ org/apache/geode/internal/admin/remote/ChangeRefreshIntervalMessage,2
fromData,16
toData,16

org/apache/geode/internal/admin/remote/ClientHealthStats,4
org/apache/geode/internal/admin/remote/ClientHealthStats,6
fromData,73
fromDataPre_GFE_8_0_0_0,65
fromDataPre_GEODE_1_9_0_0,77
fromDataPre_GFE_8_0_0_0,69
toData,73
toDataPre_GFE_8_0_0_0,65
toDataPre_GEODE_1_9_0_0,77
toDataPre_GFE_8_0_0_0,69

org/apache/geode/internal/admin/remote/CompactRequest,2
fromData,6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ private static ClientHealthStats getClientHealthStats(InternalCache currentCache
}
ClientHealthStats stats = new ClientHealthStats();

int gets = -1;
int puts = -1;
int misses = -1;
int cacheListenerCalls = -1;
long gets = -1;
long puts = -1;
long misses = -1;
long cacheListenerCalls = -1;

if (cachePerfStats != null) {
gets = cachePerfStats.getInt("gets");
puts = cachePerfStats.getInt("puts");
misses = cachePerfStats.getInt("misses");
cacheListenerCalls = cachePerfStats.getInt("cacheListenerCallsCompleted");
gets = cachePerfStats.getLong("gets");
puts = cachePerfStats.getLong("puts");
misses = cachePerfStats.getLong("misses");
cacheListenerCalls = cachePerfStats.getLong("cacheListenerCallsCompleted");
}

long processCpuTime = -1;
Expand Down
Loading

0 comments on commit 2be43b2

Please sign in to comment.